constantcontact 2.2.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +2 -2
- data/README.md +56 -1
- data/constantcontact.gemspec +1 -1
- data/lib/constantcontact/api.rb +111 -97
- data/lib/constantcontact/services/account_service.rb +20 -22
- data/lib/constantcontact/services/activity_service.rb +98 -100
- data/lib/constantcontact/services/base_service.rb +46 -44
- data/lib/constantcontact/services/campaign_schedule_service.rb +72 -74
- data/lib/constantcontact/services/campaign_tracking_service.rb +103 -105
- data/lib/constantcontact/services/contact_service.rb +73 -75
- data/lib/constantcontact/services/contact_tracking_service.rb +103 -105
- data/lib/constantcontact/services/email_marketing_service.rb +64 -66
- data/lib/constantcontact/services/event_spot_service.rb +356 -358
- data/lib/constantcontact/services/library_service.rb +228 -230
- data/lib/constantcontact/services/list_service.rb +55 -57
- data/lib/constantcontact/version.rb +1 -1
- data/spec/constantcontact/api_spec.rb +2 -4
- data/spec/constantcontact/services/account_service_spec.rb +3 -2
- data/spec/constantcontact/services/activity_service_spec.rb +10 -9
- data/spec/constantcontact/services/base_service_spec.rb +7 -5
- data/spec/constantcontact/services/campaign_schedule_service_spec.rb +7 -6
- data/spec/constantcontact/services/campaign_tracking_service_spec.rb +8 -7
- data/spec/constantcontact/services/contact_service_spec.rb +8 -7
- data/spec/constantcontact/services/contact_tracking_service_spec.rb +8 -7
- data/spec/constantcontact/services/email_marketing_spec.rb +7 -6
- data/spec/constantcontact/services/event_spot_spec.rb +28 -27
- data/spec/constantcontact/services/library_service_spec.rb +17 -16
- data/spec/constantcontact/services/list_service_spec.rb +6 -5
- metadata +20 -20
@@ -7,33 +7,31 @@
|
|
7
7
|
module ConstantContact
|
8
8
|
module Services
|
9
9
|
class AccountService < BaseService
|
10
|
-
class << self
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
# Get a summary of account information
|
12
|
+
# @return [AccountInfo]
|
13
|
+
def get_account_info()
|
14
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.account_info')
|
15
|
+
url = build_url(url)
|
16
|
+
response = RestClient.get(url, get_headers())
|
17
|
+
Components::AccountInfo.create(JSON.parse(response.body))
|
18
|
+
end
|
20
19
|
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
email_addresses
|
21
|
+
# Get all verified email addresses associated with an account
|
22
|
+
# @param [Hash] params - hash of query parameters/values to append to the request
|
23
|
+
# @return [Array<VerifiedEmailAddress>]
|
24
|
+
def get_verified_email_addresses(params)
|
25
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.account_verified_addresses')
|
26
|
+
url = build_url(url, params)
|
27
|
+
response = RestClient.get(url, get_headers())
|
28
|
+
email_addresses = []
|
29
|
+
JSON.parse(response.body).each do |email_address|
|
30
|
+
email_addresses << Components::VerifiedEmailAddress.create(email_address)
|
34
31
|
end
|
35
|
-
|
32
|
+
email_addresses
|
36
33
|
end
|
34
|
+
|
37
35
|
end
|
38
36
|
end
|
39
37
|
end
|
@@ -7,130 +7,128 @@
|
|
7
7
|
module ConstantContact
|
8
8
|
module Services
|
9
9
|
class ActivityService < BaseService
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
activities << Components::Activity.create(activity)
|
23
|
-
end
|
24
|
-
|
25
|
-
activities
|
10
|
+
|
11
|
+
# Get a set of activities
|
12
|
+
# @param [Hash] params - query parameters to be appended to the url
|
13
|
+
# @return [Array<Activity>]
|
14
|
+
def get_activities(params = {})
|
15
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.activities')
|
16
|
+
url = build_url(url, params)
|
17
|
+
response = RestClient.get(url, get_headers())
|
18
|
+
|
19
|
+
activities = []
|
20
|
+
JSON.parse(response.body).each do |activity|
|
21
|
+
activities << Components::Activity.create(activity)
|
26
22
|
end
|
27
23
|
|
24
|
+
activities
|
25
|
+
end
|
28
26
|
|
29
|
-
# Get an array of activities
|
30
|
-
# @param [String] activity_id - Activity id
|
31
|
-
# @return [Activity]
|
32
|
-
def get_activity(activity_id)
|
33
|
-
url = Util::Config.get('endpoints.base_url') +
|
34
|
-
sprintf(Util::Config.get('endpoints.activity'), activity_id)
|
35
|
-
url = build_url(url)
|
36
|
-
response = RestClient.get(url, get_headers())
|
37
|
-
Components::Activity.create(JSON.parse(response.body))
|
38
|
-
end
|
39
27
|
|
28
|
+
# Get an array of activities
|
29
|
+
# @param [String] activity_id - Activity id
|
30
|
+
# @return [Activity]
|
31
|
+
def get_activity(activity_id)
|
32
|
+
url = Util::Config.get('endpoints.base_url') +
|
33
|
+
sprintf(Util::Config.get('endpoints.activity'), activity_id)
|
34
|
+
url = build_url(url)
|
35
|
+
response = RestClient.get(url, get_headers())
|
36
|
+
Components::Activity.create(JSON.parse(response.body))
|
37
|
+
end
|
40
38
|
|
41
|
-
# Create an Add Contacts Activity
|
42
|
-
# @param [AddContacts] add_contacts
|
43
|
-
# @return [Activity]
|
44
|
-
def create_add_contacts_activity(add_contacts)
|
45
|
-
url = Util::Config.get('endpoints.base_url') +
|
46
|
-
Util::Config.get('endpoints.add_contacts_activity')
|
47
|
-
url = build_url(url)
|
48
|
-
payload = add_contacts.to_json
|
49
|
-
response = RestClient.post(url, payload, get_headers())
|
50
|
-
Components::Activity.create(JSON.parse(response.body))
|
51
|
-
end
|
52
39
|
|
40
|
+
# Create an Add Contacts Activity
|
41
|
+
# @param [AddContacts] add_contacts
|
42
|
+
# @return [Activity]
|
43
|
+
def create_add_contacts_activity(add_contacts)
|
44
|
+
url = Util::Config.get('endpoints.base_url') +
|
45
|
+
Util::Config.get('endpoints.add_contacts_activity')
|
46
|
+
url = build_url(url)
|
47
|
+
payload = add_contacts.to_json
|
48
|
+
response = RestClient.post(url, payload, get_headers())
|
49
|
+
Components::Activity.create(JSON.parse(response.body))
|
50
|
+
end
|
53
51
|
|
54
|
-
# Create an Add Contacts Activity from a file. Valid file types are txt, csv, xls, xlsx
|
55
|
-
# @param [String] file_name - The name of the file (ie: contacts.csv)
|
56
|
-
# @param [String] contents - The content of the file
|
57
|
-
# @param [String] lists - Comma separated list of ContactList id's to add the contacts to
|
58
|
-
# @return [Activity]
|
59
|
-
def create_add_contacts_activity_from_file(file_name, contents, lists)
|
60
|
-
url = Util::Config.get('endpoints.base_url') +
|
61
|
-
Util::Config.get('endpoints.add_contacts_activity')
|
62
|
-
url = build_url(url)
|
63
52
|
|
64
|
-
|
53
|
+
# Create an Add Contacts Activity from a file. Valid file types are txt, csv, xls, xlsx
|
54
|
+
# @param [String] file_name - The name of the file (ie: contacts.csv)
|
55
|
+
# @param [String] contents - The content of the file
|
56
|
+
# @param [String] lists - Comma separated list of ContactList id's to add the contacts to
|
57
|
+
# @return [Activity]
|
58
|
+
def create_add_contacts_activity_from_file(file_name, contents, lists)
|
59
|
+
url = Util::Config.get('endpoints.base_url') +
|
60
|
+
Util::Config.get('endpoints.add_contacts_activity')
|
61
|
+
url = build_url(url)
|
65
62
|
|
66
|
-
|
67
|
-
Components::Activity.create(JSON.parse(response.body))
|
68
|
-
end
|
63
|
+
payload = { :file_name => file_name, :lists => lists, :data => contents, :multipart => true }
|
69
64
|
|
65
|
+
response = RestClient.post(url, payload, get_headers())
|
66
|
+
Components::Activity.create(JSON.parse(response.body))
|
67
|
+
end
|
70
68
|
|
71
|
-
# Create a Clear Lists Activity
|
72
|
-
# @param [Array<lists>] lists - array of list id's to be cleared
|
73
|
-
# @return [Activity]
|
74
|
-
def add_clear_lists_activity(lists)
|
75
|
-
url = Util::Config.get('endpoints.base_url') +
|
76
|
-
Util::Config.get('endpoints.clear_lists_activity')
|
77
|
-
url = build_url(url)
|
78
|
-
payload = {'lists' => lists}.to_json
|
79
|
-
response = RestClient.post(url, payload, get_headers())
|
80
|
-
Components::Activity.create(JSON.parse(response.body))
|
81
|
-
end
|
82
69
|
|
70
|
+
# Create a Clear Lists Activity
|
71
|
+
# @param [Array<lists>] lists - array of list id's to be cleared
|
72
|
+
# @return [Activity]
|
73
|
+
def add_clear_lists_activity(lists)
|
74
|
+
url = Util::Config.get('endpoints.base_url') +
|
75
|
+
Util::Config.get('endpoints.clear_lists_activity')
|
76
|
+
url = build_url(url)
|
77
|
+
payload = {'lists' => lists}.to_json
|
78
|
+
response = RestClient.post(url, payload, get_headers())
|
79
|
+
Components::Activity.create(JSON.parse(response.body))
|
80
|
+
end
|
83
81
|
|
84
|
-
# Create an Export Contacts Activity
|
85
|
-
# @param [ExportContacts] export_contacts
|
86
|
-
# @return [Activity]
|
87
|
-
def add_export_contacts_activity(export_contacts)
|
88
|
-
url = Util::Config.get('endpoints.base_url') +
|
89
|
-
Util::Config.get('endpoints.export_contacts_activity')
|
90
|
-
url = build_url(url)
|
91
|
-
payload = export_contacts.to_json
|
92
|
-
response = RestClient.post(url, payload, get_headers())
|
93
|
-
Components::Activity.create(JSON.parse(response.body))
|
94
|
-
end
|
95
82
|
|
83
|
+
# Create an Export Contacts Activity
|
84
|
+
# @param [ExportContacts] export_contacts
|
85
|
+
# @return [Activity]
|
86
|
+
def add_export_contacts_activity(export_contacts)
|
87
|
+
url = Util::Config.get('endpoints.base_url') +
|
88
|
+
Util::Config.get('endpoints.export_contacts_activity')
|
89
|
+
url = build_url(url)
|
90
|
+
payload = export_contacts.to_json
|
91
|
+
response = RestClient.post(url, payload, get_headers())
|
92
|
+
Components::Activity.create(JSON.parse(response.body))
|
93
|
+
end
|
96
94
|
|
97
|
-
# Create a Remove Contacts From Lists Activity
|
98
|
-
# @param [<Array>EmailAddress] email_addresses
|
99
|
-
# @param [<Array>RemoveFromLists] lists
|
100
|
-
# @return [Activity]
|
101
|
-
def add_remove_contacts_from_lists_activity(email_addresses, lists)
|
102
|
-
url = Util::Config.get('endpoints.base_url') +
|
103
|
-
Util::Config.get('endpoints.remove_from_lists_activity')
|
104
|
-
url = build_url(url)
|
105
95
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
96
|
+
# Create a Remove Contacts From Lists Activity
|
97
|
+
# @param [<Array>EmailAddress] email_addresses
|
98
|
+
# @param [<Array>RemoveFromLists] lists
|
99
|
+
# @return [Activity]
|
100
|
+
def add_remove_contacts_from_lists_activity(email_addresses, lists)
|
101
|
+
url = Util::Config.get('endpoints.base_url') +
|
102
|
+
Util::Config.get('endpoints.remove_from_lists_activity')
|
103
|
+
url = build_url(url)
|
111
104
|
|
112
|
-
|
113
|
-
|
105
|
+
payload = { 'import_data' => [], 'lists' => lists }
|
106
|
+
email_addresses.each do |email_address|
|
107
|
+
payload['import_data'] << { 'email_addresses' => [email_address] }
|
114
108
|
end
|
109
|
+
payload = payload.to_json
|
115
110
|
|
111
|
+
response = RestClient.post(url, payload, get_headers())
|
112
|
+
Components::Activity.create(JSON.parse(response.body))
|
113
|
+
end
|
116
114
|
|
117
|
-
# Create an Remove Contacts Activity from a file. Valid file types are txt, csv, xls, xlsx
|
118
|
-
# @param [String] file_name - The name of the file (ie: contacts.csv)
|
119
|
-
# @param [String] contents - The content of the file
|
120
|
-
# @param [String] lists - Comma separated list of ContactList id' to add the contacts too
|
121
|
-
# @return [Activity]
|
122
|
-
def add_remove_contacts_from_lists_activity_from_file(file_name, contents, lists)
|
123
|
-
url = Util::Config.get('endpoints.base_url') +
|
124
|
-
Util::Config.get('endpoints.remove_from_lists_activity')
|
125
|
-
url = build_url(url)
|
126
115
|
|
127
|
-
|
116
|
+
# Create an Remove Contacts Activity from a file. Valid file types are txt, csv, xls, xlsx
|
117
|
+
# @param [String] file_name - The name of the file (ie: contacts.csv)
|
118
|
+
# @param [String] contents - The content of the file
|
119
|
+
# @param [String] lists - Comma separated list of ContactList id' to add the contacts too
|
120
|
+
# @return [Activity]
|
121
|
+
def add_remove_contacts_from_lists_activity_from_file(file_name, contents, lists)
|
122
|
+
url = Util::Config.get('endpoints.base_url') +
|
123
|
+
Util::Config.get('endpoints.remove_from_lists_activity')
|
124
|
+
url = build_url(url)
|
128
125
|
|
129
|
-
|
130
|
-
Components::Activity.create(JSON.parse(response.body))
|
131
|
-
end
|
126
|
+
payload = { :file_name => file_name, :lists => lists, :data => contents, :multipart => true }
|
132
127
|
|
128
|
+
response = RestClient.post(url, payload, get_headers())
|
129
|
+
Components::Activity.create(JSON.parse(response.body))
|
133
130
|
end
|
131
|
+
|
134
132
|
end
|
135
133
|
end
|
136
134
|
end
|
@@ -7,63 +7,65 @@
|
|
7
7
|
module ConstantContact
|
8
8
|
module Services
|
9
9
|
class BaseService
|
10
|
-
|
11
|
-
|
10
|
+
attr_accessor :api_client
|
11
|
+
|
12
|
+
def initialize(api_client = nil)
|
13
|
+
@api_client = api_client
|
14
|
+
end
|
12
15
|
|
13
|
-
|
16
|
+
protected
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
18
|
+
# Return required headers for making an http request with Constant Contact
|
19
|
+
# @param [String] content_type - The MIME type of the body of the request, default is 'application/json'
|
20
|
+
# @return [Hash] - authorization headers
|
21
|
+
def get_headers(content_type = 'application/json')
|
22
|
+
{
|
23
|
+
:content_type => content_type,
|
24
|
+
:accept => 'application/json',
|
25
|
+
:authorization => "Bearer #{api_client.access_token}",
|
26
|
+
:user_agent => "AppConnect Ruby SDK v#{ConstantContact::SDK::VERSION} (#{RUBY_DESCRIPTION})",
|
27
|
+
:x_ctct_request_source => "sdk.ruby.#{ConstantContact::SDK::VERSION}"
|
28
|
+
}
|
29
|
+
end
|
27
30
|
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
32
|
+
# returns the id of a ConstantContact component
|
33
|
+
def get_id_for(obj)
|
34
|
+
if obj.kind_of? ConstantContact::Components::Component
|
35
|
+
obj.id
|
36
|
+
elsif obj.kind_of? Hash
|
37
|
+
obj["id"]
|
38
|
+
else
|
39
|
+
obj
|
38
40
|
end
|
41
|
+
end
|
39
42
|
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
44
|
+
# Build a url from the base url and query parameters hash. Query parameters
|
45
|
+
# should not be URL encoded because this method will handle that
|
46
|
+
# @param [String] url - The base url
|
47
|
+
# @param [Hash] params - A hash with query parameters
|
48
|
+
# @return [String] - the url with query parameters hash
|
49
|
+
def build_url(url, params = nil)
|
50
|
+
if params.respond_to? :each
|
51
|
+
params.each do |key, value|
|
52
|
+
# Convert dates to CC date format
|
53
|
+
if value.respond_to? :iso8601
|
54
|
+
params[key] = value.iso8601
|
55
|
+
end
|
53
56
|
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
+
if key.to_s == 'next' && value.match(/^.*?next=(.*)$/)
|
58
|
+
params[key] = $1
|
57
59
|
end
|
58
|
-
else
|
59
|
-
params ||= {}
|
60
60
|
end
|
61
|
-
|
62
|
-
params
|
63
|
-
url += '?' + Util::Helpers.http_build_query(params)
|
61
|
+
else
|
62
|
+
params ||= {}
|
64
63
|
end
|
65
64
|
|
65
|
+
params['api_key'] = api_client.api_key
|
66
|
+
url += '?' + Util::Helpers.http_build_query(params)
|
66
67
|
end
|
68
|
+
|
67
69
|
end
|
68
70
|
end
|
69
71
|
end
|
@@ -7,95 +7,93 @@
|
|
7
7
|
module ConstantContact
|
8
8
|
module Services
|
9
9
|
class CampaignScheduleService < BaseService
|
10
|
-
class << self
|
11
|
-
|
12
|
-
# Create a new schedule for a campaign
|
13
|
-
# @param [Integer] campaign_id - Campaign id to be scheduled
|
14
|
-
# @param [Schedule] schedule - Schedule to be created
|
15
|
-
# @return [Schedule]
|
16
|
-
def add_schedule(campaign_id, schedule)
|
17
|
-
url = Util::Config.get('endpoints.base_url') +
|
18
|
-
sprintf(Util::Config.get('endpoints.campaign_schedules'), campaign_id)
|
19
|
-
url = build_url(url)
|
20
|
-
payload = schedule.to_json
|
21
|
-
response = RestClient.post(url, payload, get_headers())
|
22
|
-
Components::Schedule.create(JSON.parse(response.body))
|
23
|
-
end
|
24
10
|
|
11
|
+
# Create a new schedule for a campaign
|
12
|
+
# @param [Integer] campaign_id - Campaign id to be scheduled
|
13
|
+
# @param [Schedule] schedule - Schedule to be created
|
14
|
+
# @return [Schedule]
|
15
|
+
def add_schedule(campaign_id, schedule)
|
16
|
+
url = Util::Config.get('endpoints.base_url') +
|
17
|
+
sprintf(Util::Config.get('endpoints.campaign_schedules'), campaign_id)
|
18
|
+
url = build_url(url)
|
19
|
+
payload = schedule.to_json
|
20
|
+
response = RestClient.post(url, payload, get_headers())
|
21
|
+
Components::Schedule.create(JSON.parse(response.body))
|
22
|
+
end
|
25
23
|
|
26
|
-
# Get a list of schedules for a campaign
|
27
|
-
# @param [Integer] campaign_id - Campaign id to be scheduled
|
28
|
-
# @return [Array<Schedule>]
|
29
|
-
def get_schedules(campaign_id)
|
30
|
-
url = Util::Config.get('endpoints.base_url') +
|
31
|
-
sprintf(Util::Config.get('endpoints.campaign_schedules'), campaign_id)
|
32
|
-
url = build_url(url)
|
33
|
-
response = RestClient.get(url, get_headers())
|
34
|
-
body = JSON.parse(response.body)
|
35
24
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
25
|
+
# Get a list of schedules for a campaign
|
26
|
+
# @param [Integer] campaign_id - Campaign id to be scheduled
|
27
|
+
# @return [Array<Schedule>]
|
28
|
+
def get_schedules(campaign_id)
|
29
|
+
url = Util::Config.get('endpoints.base_url') +
|
30
|
+
sprintf(Util::Config.get('endpoints.campaign_schedules'), campaign_id)
|
31
|
+
url = build_url(url)
|
32
|
+
response = RestClient.get(url, get_headers())
|
33
|
+
body = JSON.parse(response.body)
|
40
34
|
|
41
|
-
|
35
|
+
schedules = []
|
36
|
+
body.each do |schedule|
|
37
|
+
schedules << Components::Schedule.create(schedule)
|
42
38
|
end
|
43
39
|
|
40
|
+
schedules
|
41
|
+
end
|
44
42
|
|
45
|
-
# Get a specific schedule for a campaign
|
46
|
-
# @param [Integer] campaign_id - Campaign id to get a schedule for
|
47
|
-
# @param [Integer] schedule_id - Schedule id to retrieve
|
48
|
-
# @return [Schedule]
|
49
|
-
def get_schedule(campaign_id, schedule_id)
|
50
|
-
url = Util::Config.get('endpoints.base_url') +
|
51
|
-
sprintf(Util::Config.get('endpoints.campaign_schedule'), campaign_id, schedule_id)
|
52
|
-
url = build_url(url)
|
53
|
-
response = RestClient.get(url, get_headers())
|
54
|
-
Components::Schedule.create(JSON.parse(response.body))
|
55
|
-
end
|
56
43
|
|
44
|
+
# Get a specific schedule for a campaign
|
45
|
+
# @param [Integer] campaign_id - Campaign id to get a schedule for
|
46
|
+
# @param [Integer] schedule_id - Schedule id to retrieve
|
47
|
+
# @return [Schedule]
|
48
|
+
def get_schedule(campaign_id, schedule_id)
|
49
|
+
url = Util::Config.get('endpoints.base_url') +
|
50
|
+
sprintf(Util::Config.get('endpoints.campaign_schedule'), campaign_id, schedule_id)
|
51
|
+
url = build_url(url)
|
52
|
+
response = RestClient.get(url, get_headers())
|
53
|
+
Components::Schedule.create(JSON.parse(response.body))
|
54
|
+
end
|
57
55
|
|
58
|
-
# Delete a specific schedule for a campaign
|
59
|
-
# @param [Integer] campaign_id - Campaign id to delete a schedule for
|
60
|
-
# @param [Integer] schedule_id - Schedule id to delete
|
61
|
-
# @return [Boolean]
|
62
|
-
def delete_schedule(campaign_id, schedule_id)
|
63
|
-
url = Util::Config.get('endpoints.base_url') +
|
64
|
-
sprintf(Util::Config.get('endpoints.campaign_schedule'), campaign_id, schedule_id)
|
65
|
-
url = build_url(url)
|
66
|
-
response = RestClient.delete(url, get_headers())
|
67
|
-
response.code == 204
|
68
|
-
end
|
69
56
|
|
57
|
+
# Delete a specific schedule for a campaign
|
58
|
+
# @param [Integer] campaign_id - Campaign id to delete a schedule for
|
59
|
+
# @param [Integer] schedule_id - Schedule id to delete
|
60
|
+
# @return [Boolean]
|
61
|
+
def delete_schedule(campaign_id, schedule_id)
|
62
|
+
url = Util::Config.get('endpoints.base_url') +
|
63
|
+
sprintf(Util::Config.get('endpoints.campaign_schedule'), campaign_id, schedule_id)
|
64
|
+
url = build_url(url)
|
65
|
+
response = RestClient.delete(url, get_headers())
|
66
|
+
response.code == 204
|
67
|
+
end
|
70
68
|
|
71
|
-
# Update a specific schedule for a campaign
|
72
|
-
# @param [Integer] campaign_id - Campaign id to be scheduled
|
73
|
-
# @param [Schedule] schedule - Schedule to retrieve
|
74
|
-
# @return [Schedule]
|
75
|
-
def update_schedule(campaign_id, schedule)
|
76
|
-
url = Util::Config.get('endpoints.base_url') +
|
77
|
-
sprintf(Util::Config.get('endpoints.campaign_schedule'), campaign_id, schedule.id)
|
78
|
-
url = build_url(url)
|
79
|
-
payload = schedule.to_json
|
80
|
-
response = RestClient.put(url, payload, get_headers())
|
81
|
-
Components::Schedule.create(JSON.parse(response.body))
|
82
|
-
end
|
83
69
|
|
70
|
+
# Update a specific schedule for a campaign
|
71
|
+
# @param [Integer] campaign_id - Campaign id to be scheduled
|
72
|
+
# @param [Schedule] schedule - Schedule to retrieve
|
73
|
+
# @return [Schedule]
|
74
|
+
def update_schedule(campaign_id, schedule)
|
75
|
+
url = Util::Config.get('endpoints.base_url') +
|
76
|
+
sprintf(Util::Config.get('endpoints.campaign_schedule'), campaign_id, schedule.id)
|
77
|
+
url = build_url(url)
|
78
|
+
payload = schedule.to_json
|
79
|
+
response = RestClient.put(url, payload, get_headers())
|
80
|
+
Components::Schedule.create(JSON.parse(response.body))
|
81
|
+
end
|
84
82
|
|
85
|
-
# Send a test send of a campaign
|
86
|
-
# @param [Integer] campaign_id - Id of campaign to send test of
|
87
|
-
# @param [TestSend] test_send - Test send details
|
88
|
-
# @return [TestSend]
|
89
|
-
def send_test(campaign_id, test_send)
|
90
|
-
url = Util::Config.get('endpoints.base_url') +
|
91
|
-
sprintf(Util::Config.get('endpoints.campaign_test_sends'), campaign_id)
|
92
|
-
url = build_url(url)
|
93
|
-
payload = test_send.to_json
|
94
|
-
response = RestClient.post(url, payload, get_headers())
|
95
|
-
Components::TestSend.create(JSON.parse(response.body))
|
96
|
-
end
|
97
83
|
|
84
|
+
# Send a test send of a campaign
|
85
|
+
# @param [Integer] campaign_id - Id of campaign to send test of
|
86
|
+
# @param [TestSend] test_send - Test send details
|
87
|
+
# @return [TestSend]
|
88
|
+
def send_test(campaign_id, test_send)
|
89
|
+
url = Util::Config.get('endpoints.base_url') +
|
90
|
+
sprintf(Util::Config.get('endpoints.campaign_test_sends'), campaign_id)
|
91
|
+
url = build_url(url)
|
92
|
+
payload = test_send.to_json
|
93
|
+
response = RestClient.post(url, payload, get_headers())
|
94
|
+
Components::TestSend.create(JSON.parse(response.body))
|
98
95
|
end
|
96
|
+
|
99
97
|
end
|
100
98
|
end
|
101
99
|
end
|