-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaddCampaign.py
48 lines (43 loc) · 1.66 KB
/
addCampaign.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import ElasticEmail
from ElasticEmail.apis.tags import campaigns_api
from ElasticEmail.model.campaign import Campaign
from ElasticEmail.model.campaign_recipient import CampaignRecipient
from ElasticEmail.model.campaign_status import CampaignStatus
from ElasticEmail.model.campaign_template import CampaignTemplate
from pprint import pprint
# Defining the host is optional and defaults to https://api.elasticemail.com/v4
configuration = ElasticEmail.Configuration()
# Configure API key authorization: apikey
configuration.api_key['apikey'] = 'YOUR_API_KEY'
"""
Add Campaign
Example api call that creates a new campaign.
Send will be triggered immediately or postponed, depending on given options.
"""
with ElasticEmail.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = campaigns_api.CampaignsApi(api_client)
campaign = Campaign(
Content=[
CampaignTemplate(
From="[email protected]",
ReplyTo="[email protected]",
Subject="Hello",
TemplateName="hello_template",
),
],
Name="hello campaign",
Status=CampaignStatus("Draft"),
Recipients=CampaignRecipient(
list_names=[
"my list name",
],
),
) # Campaign | JSON representation of a campaign
# example passing only required values which don't have defaults set
try:
# Add Campaign
api_response = api_instance.campaigns_post(body = campaign)
pprint(api_response)
except ElasticEmail.ApiException as e:
print("Exception when calling CampaignsApi->campaigns_post: %s\n" % e)