-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathaddCampaign.py
More file actions
47 lines (42 loc) · 1.62 KB
/
Copy pathaddCampaign.py
File metadata and controls
47 lines (42 loc) · 1.62 KB
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
import ElasticEmail
from ElasticEmail.models.campaign import Campaign
from ElasticEmail.models.campaign_recipient import CampaignRecipient
from ElasticEmail.models.campaign_status import CampaignStatus
from ElasticEmail.models.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 = ElasticEmail.CampaignsApi(api_client)
campaign = Campaign(
Content=[
CampaignTemplate(
From="example@email.test",
ReplyTo="example@email.test",
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(campaign=campaign)
pprint(api_response)
except ElasticEmail.ApiException as e:
print("Exception when calling CampaignsApi->campaigns_post: %s\n" % e)