Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
which the campaign will be sent.
:returns String representing the ID of the newly created campaign.
"""
body = {
"Subject": subject,
"Name": name,
"FromName": from_name,
"FromEmail": from_email,
"ReplyTo": reply_to,
"HtmlUrl": html_url,
"TextUrl": text_url,
"ListIDs": list_ids,
"SegmentIDs": segment_ids}
response = self._post("/campaigns/%s.json" %
client_id, json.dumps(body))
self.campaign_id = json_to_py(response)
return self.campaign_id
"""Refresh an OAuth token given a refresh token."""
if (not self.auth_details or
not 'refresh_token' in self.auth_details or
not self.auth_details['refresh_token']):
raise Exception(
"auth_details['refresh_token'] does not contain a refresh token.")
refresh_token = self.auth_details['refresh_token']
params = [
('grant_type', 'refresh_token'),
('refresh_token', refresh_token)
]
response = self._post('', urlencode(params),
CreateSend.oauth_token_uri, "application/x-www-form-urlencoded")
new_access_token, new_expires_in, new_refresh_token = None, None, None
r = json_to_py(response)
new_access_token, new_expires_in, new_refresh_token = r.access_token, r.expires_in, r.refresh_token
self.auth({
'access_token': new_access_token,
'refresh_token': new_refresh_token})
return [new_access_token, new_expires_in, new_refresh_token]
def lists_and_segments(self):
"""Retrieves the lists and segments to which this campaaign will be (or was) sent."""
response = self._get(self.uri_for("listsandsegments"))
return json_to_py(response)
def unconfirmed(self, date="", page=1, page_size=1000, order_field="email", order_direction="asc", include_tracking_preference=False):
"""Gets the unconfirmed subscribers for this list."""
params = {
"date": date,
"page": page,
"pagesize": page_size,
"orderfield": order_field,
"orderdirection": order_direction,
"includetrackingpreference": include_tracking_preference,
}
response = self._get(self.uri_for("unconfirmed"), params=params)
return json_to_py(response)
for full details of template content format.
:returns String representing the ID of the newly created campaign.
"""
body = {
"Subject": subject,
"Name": name,
"FromName": from_name,
"FromEmail": from_email,
"ReplyTo": reply_to,
"ListIDs": list_ids,
"SegmentIDs": segment_ids,
"TemplateID": template_id,
"TemplateContent": template_content}
response = self._post("/campaigns/%s/fromtemplate.json" %
client_id, json.dumps(body))
self.campaign_id = json_to_py(response)
return self.campaign_id
def segments(self):
"""Gets the segments belonging to this client."""
response = self._get(self.uri_for("segments"))
return json_to_py(response)
def get_journey_email_response(self, date, page, page_size, order_direction, uri):
"""Retrieves information for the journey email - based on theuri"""
params = {}
if date is not None:
params["date"] = date
if page is not None:
params["page"] = page
if page_size is not None:
params["pagesize"] = page_size
if order_direction is not None:
params["orderdirection"] = order_direction
response = self._get(self.uri_for(uri), params=params)
return json_to_py(response)
def systemdate(self):
"""Gets the current date in your account's timezone."""
response = self._get('/systemdate.json')
return json_to_py(response).SystemDate
:param integrator_id: String representing the Integrator ID. You need to
contact Campaign Monitor support to get an Integrator ID.
:param client_id: String representing the Client ID of the client which
should be active once logged in to the Campaign Monitor account.
:returns Object containing a single field SessionUrl which represents
the URL to initiate the external Campaign Monitor session.
"""
body = {
"Email": email,
"Chrome": chrome,
"Url": url,
"IntegratorID": integrator_id,
"ClientID": client_id}
response = self._put('/externalsession.json', json.dumps(body))
return json_to_py(response)