constantcontact 1.0.0 → 1.0.1

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.
Files changed (60) hide show
  1. checksums.yaml +7 -7
  2. data/README.md +7 -0
  3. data/constantcontact.gemspec +1 -1
  4. data/lib/constantcontact.rb +54 -54
  5. data/lib/constantcontact/api.rb +5 -3
  6. data/lib/constantcontact/auth/oauth2.rb +7 -4
  7. data/lib/constantcontact/auth/session_data_store.rb +52 -52
  8. data/lib/constantcontact/components/account/verified_email_address.rb +17 -17
  9. data/lib/constantcontact/components/activities/activity.rb +34 -34
  10. data/lib/constantcontact/components/activities/activity_error.rb +17 -17
  11. data/lib/constantcontact/components/activities/add_contacts.rb +109 -109
  12. data/lib/constantcontact/components/activities/add_contacts_import_data.rb +37 -37
  13. data/lib/constantcontact/components/activities/export_contacts.rb +19 -19
  14. data/lib/constantcontact/components/component.rb +13 -13
  15. data/lib/constantcontact/components/contacts/address.rb +18 -18
  16. data/lib/constantcontact/components/contacts/contact.rb +69 -69
  17. data/lib/constantcontact/components/contacts/contact_list.rb +17 -17
  18. data/lib/constantcontact/components/contacts/custom_field.rb +17 -17
  19. data/lib/constantcontact/components/contacts/email_address.rb +23 -23
  20. data/lib/constantcontact/components/contacts/note.rb +16 -16
  21. data/lib/constantcontact/components/email_marketing/campaign.rb +67 -67
  22. data/lib/constantcontact/components/email_marketing/click_through_details.rb +17 -17
  23. data/lib/constantcontact/components/email_marketing/message_footer.rb +20 -20
  24. data/lib/constantcontact/components/email_marketing/schedule.rb +18 -18
  25. data/lib/constantcontact/components/email_marketing/test_send.rb +32 -32
  26. data/lib/constantcontact/components/result_set.rb +15 -15
  27. data/lib/constantcontact/components/tracking/bounce_activity.rb +18 -18
  28. data/lib/constantcontact/components/tracking/click_activity.rb +17 -17
  29. data/lib/constantcontact/components/tracking/forward_activity.rb +17 -17
  30. data/lib/constantcontact/components/tracking/open_activity.rb +17 -17
  31. data/lib/constantcontact/components/tracking/send_activity.rb +17 -17
  32. data/lib/constantcontact/components/tracking/tracking_activity.rb +15 -15
  33. data/lib/constantcontact/components/tracking/tracking_summary.rb +17 -17
  34. data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +18 -18
  35. data/lib/constantcontact/exceptions/ctct_exception.rb +15 -15
  36. data/lib/constantcontact/exceptions/illegal_argument_exception.rb +3 -3
  37. data/lib/constantcontact/exceptions/oauth2_exception.rb +3 -3
  38. data/lib/constantcontact/services/account_service.rb +19 -19
  39. data/lib/constantcontact/services/activity_service.rb +99 -99
  40. data/lib/constantcontact/services/base_service.rb +24 -24
  41. data/lib/constantcontact/services/campaign_schedule_service.rb +85 -85
  42. data/lib/constantcontact/services/campaign_tracking_service.rb +151 -151
  43. data/lib/constantcontact/services/contact_service.rb +106 -106
  44. data/lib/constantcontact/services/contact_tracking_service.rb +151 -151
  45. data/lib/constantcontact/services/email_marketing_service.rb +66 -66
  46. data/lib/constantcontact/services/list_service.rb +67 -67
  47. data/lib/constantcontact/util/config.rb +102 -96
  48. data/lib/constantcontact/util/helpers.rb +18 -18
  49. data/lib/constantcontact/version.rb +4 -4
  50. data/spec/constantcontact/api_spec.rb +223 -173
  51. data/spec/constantcontact/auth/oauth2_spec.rb +68 -4
  52. data/spec/constantcontact/components/contacts/address_spec.rb +7 -7
  53. data/spec/constantcontact/components/contacts/contact_list_spec.rb +7 -7
  54. data/spec/constantcontact/components/contacts/contact_spec.rb +7 -7
  55. data/spec/constantcontact/components/contacts/custom_field_spec.rb +7 -7
  56. data/spec/constantcontact/components/contacts/email_address_spec.rb +7 -7
  57. data/spec/constantcontact/services/contact_service_spec.rb +95 -95
  58. data/spec/constantcontact/services/list_service_spec.rb +48 -48
  59. data/spec/spec_helper.rb +1 -1
  60. metadata +55 -44
@@ -5,21 +5,21 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Exceptions
9
- class CtctException < Exception
10
- attr_accessor :errors
8
+ module Exceptions
9
+ class CtctException < Exception
10
+ attr_accessor :errors
11
11
 
12
- # Setter
13
- # @param [Array<String>] errors
14
- def set_errors(errors)
15
- @errors = errors
16
- end
12
+ # Setter
13
+ # @param [Array<String>] errors
14
+ def set_errors(errors)
15
+ @errors = errors
16
+ end
17
17
 
18
- # Getter
19
- # @return [Array<String>]
20
- def get_errors
21
- @errors
22
- end
23
- end
24
- end
18
+ # Getter
19
+ # @return [Array<String>]
20
+ def get_errors
21
+ @errors
22
+ end
23
+ end
24
+ end
25
25
  end
@@ -5,7 +5,7 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Exceptions
9
- class IllegalArgumentException < Exception; end
10
- end
8
+ module Exceptions
9
+ class IllegalArgumentException < Exception; end
10
+ end
11
11
  end
@@ -5,7 +5,7 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Exceptions
9
- class OAuth2Exception < Exception; end
10
- end
8
+ module Exceptions
9
+ class OAuth2Exception < Exception; end
10
+ end
11
11
  end
@@ -5,25 +5,25 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Services
9
- class AccountService < BaseService
10
- class << self
8
+ module Services
9
+ class AccountService < BaseService
10
+ class << self
11
11
 
12
- # Get the verified emails from account
13
- # @param [String] access_token - Constant Contact OAuth2 access token
14
- # @return [Array<VerifiedEmailAddress>]
15
- def get_verified_email_addresses(access_token)
16
- url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.account_verified_addresses')
17
- url = build_url(url)
18
- response = RestClient.get(url, get_headers(access_token))
19
- email_addresses = []
20
- JSON.parse(response.body).each do |email_address|
21
- email_addresses << Components::VerifiedEmailAddress.create(email_address)
22
- end
23
- email_addresses
24
- end
12
+ # Get the verified emails from account
13
+ # @param [String] access_token - Constant Contact OAuth2 access token
14
+ # @return [Array<VerifiedEmailAddress>]
15
+ def get_verified_email_addresses(access_token)
16
+ url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.account_verified_addresses')
17
+ url = build_url(url)
18
+ response = RestClient.get(url, get_headers(access_token))
19
+ email_addresses = []
20
+ JSON.parse(response.body).each do |email_address|
21
+ email_addresses << Components::VerifiedEmailAddress.create(email_address)
22
+ end
23
+ email_addresses
24
+ end
25
25
 
26
- end
27
- end
28
- end
26
+ end
27
+ end
28
+ end
29
29
  end
@@ -5,103 +5,103 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Services
9
- class ActivityService < BaseService
10
- class << self
11
-
12
- # Get a set of activities
13
- # @param [String] access_token
14
- # @return [Array<Activity>]
15
- def get_activities(access_token)
16
- url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.activities')
17
- url = build_url(url)
18
- response = RestClient.get(url, get_headers(access_token))
19
-
20
- activities = []
21
- JSON.parse(response.body).each do |activity|
22
- activities << Components::Activity.create(activity)
23
- end
24
-
25
- activities
26
- end
27
-
28
-
29
- # Get an array of activities
30
- # @param [String] access_token - Constant Contact OAuth2 access token
31
- # @param [String] activity_id - Activity id
32
- # @return [Activity]
33
- def get_activity(access_token, activity_id)
34
- url = Util::Config.get('endpoints.base_url') +
35
- sprintf(Util::Config.get('endpoints.activity'), activity_id)
36
- url = build_url(url)
37
- response = RestClient.get(url, get_headers(access_token))
38
- Components::Activity.create(JSON.parse(response.body))
39
- end
40
-
41
-
42
- # Create an Add Contacts Activity
43
- # @param [String] access_token - Constant Contact OAuth2 access token
44
- # @param [AddContacts] add_contacts
45
- # @return [Activity]
46
- def create_add_contacts_activity(access_token, add_contacts)
47
- url = Util::Config.get('endpoints.base_url') +
48
- Util::Config.get('endpoints.add_contacts_activity')
49
- url = build_url(url)
50
- payload = add_contacts.to_json
51
- response = RestClient.post(url, payload, get_headers(access_token))
52
- Components::Activity.create(JSON.parse(response.body))
53
- end
54
-
55
-
56
- # Create a Clear Lists Activity
57
- # @param [String] access_token - Constant Contact OAuth2 access token
58
- # @param [Array<lists>] lists - array of list id's to be cleared
59
- # @return [Activity]
60
- def add_clear_lists_activity(access_token, lists)
61
- url = Util::Config.get('endpoints.base_url') +
62
- Util::Config.get('endpoints.clear_lists_activity')
63
- url = build_url(url)
64
- payload = {'lists' => lists}.to_json
65
- response = RestClient.post(url, payload, get_headers(access_token))
66
- Components::Activity.create(JSON.parse(response.body))
67
- end
68
-
69
-
70
- # Create an Export Contacts Activity
71
- # @param [String] access_token - Constant Contact OAuth2 access token
72
- # @param [ExportContacts] export_contacts
73
- # @return [Activity]
74
- def add_export_contacts_activity(access_token, export_contacts)
75
- url = Util::Config.get('endpoints.base_url') +
76
- Util::Config.get('endpoints.export_contacts_activity')
77
- url = build_url(url)
78
- payload = export_contacts.to_json
79
- response = RestClient.post(url, payload, get_headers(access_token))
80
- Components::Activity.create(JSON.parse(response.body))
81
- end
82
-
83
-
84
- # Create a Remove Contacts From Lists Activity
85
- # @param [String] access_token - Constant Contact OAuth2 access token
86
- # @param [<Array>EmailAddress] email_addresses
87
- # @param [<Array>RemoveFromLists] lists
88
- # @return [Activity]
89
- def add_remove_contacts_from_lists_activity(access_token, email_addresses, lists)
90
- url = Util::Config.get('endpoints.base_url') +
91
- Util::Config.get('endpoints.remove_from_lists_activity')
92
- url = build_url(url)
93
-
94
- payload = { 'import_data' => [], 'lists' => lists }
95
- email_addresses.each do |email_address|
96
- payload['import_data'] << { 'email_addresses' => [email_address] }
97
- end
98
- payload = payload.to_json
99
-
100
- response = RestClient.post(url, payload, get_headers(access_token))
101
- Components::Activity.create(JSON.parse(response.body))
102
- end
103
-
104
- end
105
- end
106
- end
8
+ module Services
9
+ class ActivityService < BaseService
10
+ class << self
11
+
12
+ # Get a set of activities
13
+ # @param [String] access_token
14
+ # @return [Array<Activity>]
15
+ def get_activities(access_token)
16
+ url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.activities')
17
+ url = build_url(url)
18
+ response = RestClient.get(url, get_headers(access_token))
19
+
20
+ activities = []
21
+ JSON.parse(response.body).each do |activity|
22
+ activities << Components::Activity.create(activity)
23
+ end
24
+
25
+ activities
26
+ end
27
+
28
+
29
+ # Get an array of activities
30
+ # @param [String] access_token - Constant Contact OAuth2 access token
31
+ # @param [String] activity_id - Activity id
32
+ # @return [Activity]
33
+ def get_activity(access_token, activity_id)
34
+ url = Util::Config.get('endpoints.base_url') +
35
+ sprintf(Util::Config.get('endpoints.activity'), activity_id)
36
+ url = build_url(url)
37
+ response = RestClient.get(url, get_headers(access_token))
38
+ Components::Activity.create(JSON.parse(response.body))
39
+ end
40
+
41
+
42
+ # Create an Add Contacts Activity
43
+ # @param [String] access_token - Constant Contact OAuth2 access token
44
+ # @param [AddContacts] add_contacts
45
+ # @return [Activity]
46
+ def create_add_contacts_activity(access_token, add_contacts)
47
+ url = Util::Config.get('endpoints.base_url') +
48
+ Util::Config.get('endpoints.add_contacts_activity')
49
+ url = build_url(url)
50
+ payload = add_contacts.to_json
51
+ response = RestClient.post(url, payload, get_headers(access_token))
52
+ Components::Activity.create(JSON.parse(response.body))
53
+ end
54
+
55
+
56
+ # Create a Clear Lists Activity
57
+ # @param [String] access_token - Constant Contact OAuth2 access token
58
+ # @param [Array<lists>] lists - array of list id's to be cleared
59
+ # @return [Activity]
60
+ def add_clear_lists_activity(access_token, lists)
61
+ url = Util::Config.get('endpoints.base_url') +
62
+ Util::Config.get('endpoints.clear_lists_activity')
63
+ url = build_url(url)
64
+ payload = {'lists' => lists}.to_json
65
+ response = RestClient.post(url, payload, get_headers(access_token))
66
+ Components::Activity.create(JSON.parse(response.body))
67
+ end
68
+
69
+
70
+ # Create an Export Contacts Activity
71
+ # @param [String] access_token - Constant Contact OAuth2 access token
72
+ # @param [ExportContacts] export_contacts
73
+ # @return [Activity]
74
+ def add_export_contacts_activity(access_token, export_contacts)
75
+ url = Util::Config.get('endpoints.base_url') +
76
+ Util::Config.get('endpoints.export_contacts_activity')
77
+ url = build_url(url)
78
+ payload = export_contacts.to_json
79
+ response = RestClient.post(url, payload, get_headers(access_token))
80
+ Components::Activity.create(JSON.parse(response.body))
81
+ end
82
+
83
+
84
+ # Create a Remove Contacts From Lists Activity
85
+ # @param [String] access_token - Constant Contact OAuth2 access token
86
+ # @param [<Array>EmailAddress] email_addresses
87
+ # @param [<Array>RemoveFromLists] lists
88
+ # @return [Activity]
89
+ def add_remove_contacts_from_lists_activity(access_token, email_addresses, lists)
90
+ url = Util::Config.get('endpoints.base_url') +
91
+ Util::Config.get('endpoints.remove_from_lists_activity')
92
+ url = build_url(url)
93
+
94
+ payload = { 'import_data' => [], 'lists' => lists }
95
+ email_addresses.each do |email_address|
96
+ payload['import_data'] << { 'email_addresses' => [email_address] }
97
+ end
98
+ payload = payload.to_json
99
+
100
+ response = RestClient.post(url, payload, get_headers(access_token))
101
+ Components::Activity.create(JSON.parse(response.body))
102
+ end
103
+
104
+ end
105
+ end
106
+ end
107
107
  end
@@ -5,33 +5,33 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Services
9
- class BaseService
10
- class << self
11
- attr_accessor :api_key
8
+ module Services
9
+ class BaseService
10
+ class << self
11
+ attr_accessor :api_key
12
12
 
13
- protected
13
+ protected
14
14
 
15
- # Helper function to return required headers for making an http request with constant contact
16
- # @param [String] access_token - OAuth2 access token to be placed into the Authorization header
17
- # @return [Hash] - authorization headers
18
- def get_headers(access_token)
19
- {
20
- :content_type => 'application/json',
21
- :accept => 'application/json',
22
- :authorization => "Bearer #{access_token}"
23
- }
24
- end
15
+ # Helper function to return required headers for making an http request with constant contact
16
+ # @param [String] access_token - OAuth2 access token to be placed into the Authorization header
17
+ # @return [Hash] - authorization headers
18
+ def get_headers(access_token)
19
+ {
20
+ :content_type => 'application/json',
21
+ :accept => 'application/json',
22
+ :authorization => "Bearer #{access_token}"
23
+ }
24
+ end
25
25
 
26
26
 
27
- # Build a url from the base url and query parameters hash
28
- def build_url(url, params = nil)
29
- params = {} if !params
30
- params['api_key'] = BaseService.api_key
31
- url += '?' + Util::Helpers.http_build_query(params)
32
- end
27
+ # Build a url from the base url and query parameters hash
28
+ def build_url(url, params = nil)
29
+ params = {} if !params
30
+ params['api_key'] = BaseService.api_key
31
+ url += '?' + Util::Helpers.http_build_query(params)
32
+ end
33
33
 
34
- end
35
- end
36
- end
34
+ end
35
+ end
36
+ end
37
37
  end
@@ -5,103 +5,103 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Services
9
- class CampaignScheduleService < BaseService
10
- class << self
8
+ module Services
9
+ class CampaignScheduleService < BaseService
10
+ class << self
11
11
 
12
- # Create a new schedule for a campaign
13
- # @param [String] access_token - Constant Contact OAuth2 access token
14
- # @param [Integer] campaign_id - Campaign id to be scheduled
15
- # @param [Schedule] schedule - Schedule to be created
16
- # @return [Schedule]
17
- def add_schedule(access_token, campaign_id, schedule)
18
- url = Util::Config.get('endpoints.base_url') +
19
- sprintf(Util::Config.get('endpoints.campaign_schedules'), campaign_id)
20
- url = build_url(url)
21
- payload = schedule.to_json
22
- response = RestClient.post(url, payload, get_headers(access_token))
23
- Components::Schedule.create(JSON.parse(response.body))
24
- end
12
+ # Create a new schedule for a campaign
13
+ # @param [String] access_token - Constant Contact OAuth2 access token
14
+ # @param [Integer] campaign_id - Campaign id to be scheduled
15
+ # @param [Schedule] schedule - Schedule to be created
16
+ # @return [Schedule]
17
+ def add_schedule(access_token, campaign_id, schedule)
18
+ url = Util::Config.get('endpoints.base_url') +
19
+ sprintf(Util::Config.get('endpoints.campaign_schedules'), campaign_id)
20
+ url = build_url(url)
21
+ payload = schedule.to_json
22
+ response = RestClient.post(url, payload, get_headers(access_token))
23
+ Components::Schedule.create(JSON.parse(response.body))
24
+ end
25
25
 
26
26
 
27
- # Get a list of schedules for a campaign
28
- # @param [String] access_token - Constant Contact OAuth2 access token
29
- # @param [Integer] campaign_id - Campaign id to be scheduled
30
- # @return [Array<Schedule>]
31
- def get_schedules(access_token, campaign_id)
32
- url = Util::Config.get('endpoints.base_url') +
33
- sprintf(Util::Config.get('endpoints.campaign_schedules'), campaign_id)
34
- url = build_url(url)
35
- response = RestClient.get(url, get_headers(access_token))
36
- body = JSON.parse(response.body)
27
+ # Get a list of schedules for a campaign
28
+ # @param [String] access_token - Constant Contact OAuth2 access token
29
+ # @param [Integer] campaign_id - Campaign id to be scheduled
30
+ # @return [Array<Schedule>]
31
+ def get_schedules(access_token, campaign_id)
32
+ url = Util::Config.get('endpoints.base_url') +
33
+ sprintf(Util::Config.get('endpoints.campaign_schedules'), campaign_id)
34
+ url = build_url(url)
35
+ response = RestClient.get(url, get_headers(access_token))
36
+ body = JSON.parse(response.body)
37
37
 
38
- schedules = []
39
- body.each do |schedule|
40
- schedules << Components::Schedule.create(schedule)
41
- end
38
+ schedules = []
39
+ body.each do |schedule|
40
+ schedules << Components::Schedule.create(schedule)
41
+ end
42
42
 
43
- schedules
44
- end
43
+ schedules
44
+ end
45
45
 
46
46
 
47
- # Get a specific schedule for a campaign
48
- # @param [String] access_token - Constant Contact OAuth2 access token
49
- # @param [Integer] campaign_id - Campaign id to get a schedule for
50
- # @param [Integer] schedule_id - Schedule id to retrieve
51
- # @return [Schedule]
52
- def get_schedule(access_token, campaign_id, schedule_id)
53
- url = Util::Config.get('endpoints.base_url') +
54
- sprintf(Util::Config.get('endpoints.campaign_schedule'), campaign_id, schedule_id)
55
- url = build_url(url)
56
- response = RestClient.get(url, get_headers(access_token))
57
- Components::Schedule.create(JSON.parse(response.body))
58
- end
47
+ # Get a specific schedule for a campaign
48
+ # @param [String] access_token - Constant Contact OAuth2 access token
49
+ # @param [Integer] campaign_id - Campaign id to get a schedule for
50
+ # @param [Integer] schedule_id - Schedule id to retrieve
51
+ # @return [Schedule]
52
+ def get_schedule(access_token, campaign_id, schedule_id)
53
+ url = Util::Config.get('endpoints.base_url') +
54
+ sprintf(Util::Config.get('endpoints.campaign_schedule'), campaign_id, schedule_id)
55
+ url = build_url(url)
56
+ response = RestClient.get(url, get_headers(access_token))
57
+ Components::Schedule.create(JSON.parse(response.body))
58
+ end
59
59
 
60
60
 
61
- # Delete a specific schedule for a campaign
62
- # @param [String] access_token - Constant Contact OAuth2 access token
63
- # @param [Integer] campaign_id - Campaign id to delete a schedule for
64
- # @param [Integer] schedule_id - Schedule id to delete
65
- # @return [Boolean]
66
- def delete_schedule(access_token, campaign_id, schedule_id)
67
- url = Util::Config.get('endpoints.base_url') +
68
- sprintf(Util::Config.get('endpoints.campaign_schedule'), campaign_id, schedule_id)
69
- url = build_url(url)
70
- response = RestClient.delete(url, get_headers(access_token))
71
- response.code == 204
72
- end
61
+ # Delete a specific schedule for a campaign
62
+ # @param [String] access_token - Constant Contact OAuth2 access token
63
+ # @param [Integer] campaign_id - Campaign id to delete a schedule for
64
+ # @param [Integer] schedule_id - Schedule id to delete
65
+ # @return [Boolean]
66
+ def delete_schedule(access_token, campaign_id, schedule_id)
67
+ url = Util::Config.get('endpoints.base_url') +
68
+ sprintf(Util::Config.get('endpoints.campaign_schedule'), campaign_id, schedule_id)
69
+ url = build_url(url)
70
+ response = RestClient.delete(url, get_headers(access_token))
71
+ response.code == 204
72
+ end
73
73
 
74
74
 
75
- # Update a specific schedule for a campaign
76
- # @param [String] access_token - Constant Contact OAuth2 access token
77
- # @param [Integer] campaign_id - Campaign id to be scheduled
78
- # @param [Schedule] schedule - Schedule to retrieve
79
- # @return [Schedule]
80
- def update_schedule(access_token, campaign_id, schedule)
81
- url = Util::Config.get('endpoints.base_url') +
82
- sprintf(Util::Config.get('endpoints.campaign_schedule'), campaign_id, schedule.id)
83
- url = build_url(url)
84
- payload = schedule.to_json
85
- response = RestClient.put(url, payload, get_headers(access_token))
86
- Components::Schedule.create(JSON.parse(response.body))
87
- end
75
+ # Update a specific schedule for a campaign
76
+ # @param [String] access_token - Constant Contact OAuth2 access token
77
+ # @param [Integer] campaign_id - Campaign id to be scheduled
78
+ # @param [Schedule] schedule - Schedule to retrieve
79
+ # @return [Schedule]
80
+ def update_schedule(access_token, campaign_id, schedule)
81
+ url = Util::Config.get('endpoints.base_url') +
82
+ sprintf(Util::Config.get('endpoints.campaign_schedule'), campaign_id, schedule.id)
83
+ url = build_url(url)
84
+ payload = schedule.to_json
85
+ response = RestClient.put(url, payload, get_headers(access_token))
86
+ Components::Schedule.create(JSON.parse(response.body))
87
+ end
88
88
 
89
89
 
90
- # Send a test send of a campaign
91
- # @param [String] access_token - Constant Contact OAuth2 access token
92
- # @param [Integer] campaign_id - Id of campaign to send test of
93
- # @param [TestSend] test_send - Test send details
94
- # @return [TestSend]
95
- def send_test(access_token, campaign_id, test_send)
96
- url = Util::Config.get('endpoints.base_url') +
97
- sprintf(Util::Config.get('endpoints.campaign_test_sends'), campaign_id)
98
- url = build_url(url)
99
- payload = test_send.to_json
100
- response = RestClient.post(url, payload, get_headers(access_token))
101
- Components::TestSend.create(JSON.parse(response.body))
102
- end
90
+ # Send a test send of a campaign
91
+ # @param [String] access_token - Constant Contact OAuth2 access token
92
+ # @param [Integer] campaign_id - Id of campaign to send test of
93
+ # @param [TestSend] test_send - Test send details
94
+ # @return [TestSend]
95
+ def send_test(access_token, campaign_id, test_send)
96
+ url = Util::Config.get('endpoints.base_url') +
97
+ sprintf(Util::Config.get('endpoints.campaign_test_sends'), campaign_id)
98
+ url = build_url(url)
99
+ payload = test_send.to_json
100
+ response = RestClient.post(url, payload, get_headers(access_token))
101
+ Components::TestSend.create(JSON.parse(response.body))
102
+ end
103
103
 
104
- end
105
- end
106
- end
104
+ end
105
+ end
106
+ end
107
107
  end