Skip to content

Commit

Permalink
rename settings
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jun 21, 2024
1 parent 1f19565 commit c0f4a70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions codeforlife/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def add_contact(
consent_fields: The consent fields that apply to the contact.
preferences: The marketing preferences to be applied.
region: The Dotdigital region id your account belongs to e.g. r1, r2 or r3.
auth: The authorization header used to enable API access. If None, the value will be retrieved from the DOTDIGITAL_AUTH environment variable.
auth: The authorization header used to enable API access. If None, the value will be retrieved from the MAIL_AUTH environment variable.
timeout: Send timeout to avoid hanging.
Raises:
Expand All @@ -74,7 +74,7 @@ def add_contact(
# pylint: enable=line-too-long

if auth is None:
auth = settings.DOTDIGITAL_AUTH
auth = settings.MAIL_AUTH

Check warning on line 77 in codeforlife/mail.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/mail.py#L76-L77

Added lines #L76 - L77 were not covered by tests

contact: JsonDict = {"email": email.lower()}
if opt_in_type is not None:
Expand Down Expand Up @@ -125,7 +125,7 @@ def add_contact(
for preference in preferences
]

if not settings.DOTDIGITAL_ENABLED:
if not settings.MAIL_ENABLED:
logging.info(

Check warning on line 129 in codeforlife/mail.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/mail.py#L128-L129

Added lines #L128 - L129 were not covered by tests
"Added contact to DotDigital:\n%s", json.dumps(body, indent=2)
)
Expand Down Expand Up @@ -165,7 +165,7 @@ def remove_contact(
Args:
contact_identifier: Either the contact id or email address of the contact.
region: The Dotdigital region id your account belongs to e.g. r1, r2 or r3.
auth: The authorization header used to enable API access. If None, the value will be retrieved from the DOTDIGITAL_AUTH environment variable.
auth: The authorization header used to enable API access. If None, the value will be retrieved from the MAIL_AUTH environment variable.
timeout: Send timeout to avoid hanging.
Raises:
Expand All @@ -174,12 +174,12 @@ def remove_contact(
"""
# pylint: enable=line-too-long

if not settings.DOTDIGITAL_ENABLED:
if not settings.MAIL_ENABLED:
logging.info("Removed contact from DotDigital: %s", contact_identifier)
return

Check warning on line 179 in codeforlife/mail.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/mail.py#L177-L179

Added lines #L177 - L179 were not covered by tests

if auth is None:
auth = settings.DOTDIGITAL_AUTH
auth = settings.MAIL_AUTH

Check warning on line 182 in codeforlife/mail.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/mail.py#L181-L182

Added lines #L181 - L182 were not covered by tests

response = requests.get(

Check warning on line 184 in codeforlife/mail.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/mail.py#L184

Added line #L184 was not covered by tests
# pylint: disable-next=line-too-long
Expand Down Expand Up @@ -253,7 +253,7 @@ def send_mail(
metadata: The metadata for your email. It can be either a single value or a series of values in a JSON object.
attachments: A Base64 encoded string. All attachment types are supported. Maximum file size: 15 MB.
region: The Dotdigital region id your account belongs to e.g. r1, r2 or r3.
auth: The authorization header used to enable API access. If None, the value will be retrieved from the DOTDIGITAL_AUTH environment variable.
auth: The authorization header used to enable API access. If None, the value will be retrieved from the MAIL_AUTH environment variable.
timeout: Send timeout to avoid hanging.
Raises:
Expand All @@ -262,7 +262,7 @@ def send_mail(
# pylint: enable=line-too-long

if auth is None:
auth = settings.DOTDIGITAL_AUTH
auth = settings.MAIL_AUTH

Check warning on line 265 in codeforlife/mail.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/mail.py#L265

Added line #L265 was not covered by tests

body = {
"campaignId": campaign_id,
Expand Down Expand Up @@ -294,7 +294,7 @@ def send_mail(
for attachment in attachments
]

if not settings.DOTDIGITAL_ENABLED:
if not settings.MAIL_ENABLED:
logging.info(

Check warning on line 298 in codeforlife/mail.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/mail.py#L297-L298

Added lines #L297 - L298 were not covered by tests
"Sent a triggered email with DotDigital:\n%s",
json.dumps(body, indent=2),
Expand Down
8 changes: 4 additions & 4 deletions codeforlife/settings/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
)

# The authorization bearer token used to authenticate with Dotdigital.
DOTDIGITAL_AUTH = os.getenv("DOTDIGITAL_AUTH", "REPLACE_ME")
MAIL_AUTH = os.getenv("MAIL_AUTH", "REPLACE_ME")

# A global flag used to enabled/disable calls to Dotdigital's API.
# If disabled, API calls will be logged to the console instead.
DOTDIGITAL_ENABLED = bool(int(os.getenv("DOTDIGITAL_ENABLED", "0")))
# A global flag to enable/disable sending emails.
# If disabled, emails will be logged to the console instead.
MAIL_ENABLED = bool(int(os.getenv("MAIL_ENABLED", "0")))

0 comments on commit c0f4a70

Please sign in to comment.