constantcontact 1.0.2 → 1.1.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/README.md +127 -136
- data/constantcontact.gemspec +4 -3
- data/lib/constantcontact.rb +63 -44
- data/lib/constantcontact/api.rb +932 -535
- data/lib/constantcontact/auth/oauth2.rb +86 -66
- data/lib/constantcontact/components/account/verified_email_address.rb +14 -14
- data/lib/constantcontact/components/activities/activity.rb +30 -30
- data/lib/constantcontact/components/activities/activity_error.rb +14 -14
- data/lib/constantcontact/components/activities/add_contacts.rb +1 -1
- data/lib/constantcontact/components/activities/add_contacts_import_data.rb +37 -36
- data/lib/constantcontact/components/component.rb +25 -0
- data/lib/constantcontact/components/contacts/address.rb +12 -12
- data/lib/constantcontact/components/contacts/contact.rb +50 -44
- data/lib/constantcontact/components/contacts/contact_list.rb +12 -12
- data/lib/constantcontact/components/contacts/custom_field.rb +14 -14
- data/lib/constantcontact/components/contacts/email_address.rb +14 -14
- data/lib/constantcontact/components/contacts/note.rb +13 -13
- data/lib/constantcontact/components/email_marketing/campaign.rb +41 -41
- data/lib/constantcontact/components/email_marketing/click_through_details.rb +14 -14
- data/lib/constantcontact/components/email_marketing/message_footer.rb +14 -14
- data/lib/constantcontact/components/email_marketing/schedule.rb +14 -15
- data/lib/constantcontact/components/email_marketing/test_send.rb +21 -21
- data/lib/constantcontact/components/event_spot/contact.rb +27 -0
- data/lib/constantcontact/components/event_spot/event.rb +63 -0
- data/lib/constantcontact/components/event_spot/event_track.rb +28 -0
- data/lib/constantcontact/components/event_spot/fee.rb +27 -0
- data/lib/constantcontact/components/event_spot/guest.rb +31 -0
- data/lib/constantcontact/components/event_spot/notification_option.rb +27 -0
- data/lib/constantcontact/components/event_spot/promo_code.rb +26 -0
- data/lib/constantcontact/components/event_spot/registrant.rb +54 -0
- data/lib/constantcontact/components/event_spot/registrant_field.rb +27 -0
- data/lib/constantcontact/components/event_spot/registrant_section.rb +34 -0
- data/lib/constantcontact/components/event_spot/sale_item.rb +27 -0
- data/lib/constantcontact/components/library/file/library_file.rb +27 -0
- data/lib/constantcontact/components/library/folder/library_folder.rb +26 -0
- data/lib/constantcontact/components/library/info/library_summary.rb +26 -0
- data/lib/constantcontact/components/library/info/move_results.rb +26 -0
- data/lib/constantcontact/components/library/info/upload_status.rb +26 -0
- data/lib/constantcontact/components/tracking/bounce_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/click_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/forward_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/open_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/send_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/tracking_summary.rb +17 -17
- data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +14 -14
- data/lib/constantcontact/services/account_service.rb +4 -3
- data/lib/constantcontact/services/activity_service.rb +40 -3
- data/lib/constantcontact/services/base_service.rb +34 -6
- data/lib/constantcontact/services/campaign_tracking_service.rb +20 -20
- data/lib/constantcontact/services/contact_service.rb +10 -12
- data/lib/constantcontact/services/contact_tracking_service.rb +20 -20
- data/lib/constantcontact/services/email_marketing_service.rb +8 -10
- data/lib/constantcontact/services/event_spot_service.rb +254 -0
- data/lib/constantcontact/services/library_service.rb +297 -0
- data/lib/constantcontact/services/list_service.rb +6 -5
- data/lib/constantcontact/util/config.rb +135 -117
- data/lib/constantcontact/version.rb +1 -1
- data/spec/constantcontact/api_spec.rb +1223 -173
- data/spec/constantcontact/auth/oauth2_spec.rb +60 -47
- data/spec/constantcontact/components/contacts/address_spec.rb +1 -1
- data/spec/constantcontact/components/contacts/contact_list_spec.rb +1 -1
- data/spec/constantcontact/components/contacts/contact_spec.rb +1 -1
- data/spec/constantcontact/components/contacts/email_address_spec.rb +1 -1
- data/spec/constantcontact/services/activity_service_spec.rb +201 -0
- data/spec/constantcontact/services/base_service_spec.rb +27 -0
- data/spec/constantcontact/services/campaign_schedule_service_spec.rb +111 -0
- data/spec/constantcontact/services/campaign_tracking_service_spec.rb +127 -0
- data/spec/constantcontact/services/contact_service_spec.rb +24 -22
- data/spec/constantcontact/services/contact_tracking_service_spec.rb +127 -0
- data/spec/constantcontact/services/email_marketing_spec.rb +72 -66
- data/spec/constantcontact/services/event_spot_spec.rb +217 -0
- data/spec/constantcontact/services/library_service_spec.rb +248 -0
- data/spec/constantcontact/services/list_service_spec.rb +33 -17
- data/spec/spec_helper.rb +3 -1
- metadata +63 -7
@@ -9,15 +9,15 @@ module ConstantContact
|
|
9
9
|
class CampaignTrackingService < BaseService
|
10
10
|
class << self
|
11
11
|
|
12
|
-
# Get
|
12
|
+
# Get bounces for a given campaign
|
13
13
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
14
14
|
# @param [String] campaign_id - Campaign id
|
15
|
-
# @param [Hash]
|
15
|
+
# @param [Hash] params - query parameters to be appended to request
|
16
16
|
# @return [ResultSet<BounceActivity>] - Containing a results array of BounceActivity
|
17
|
-
def get_bounces(access_token, campaign_id,
|
17
|
+
def get_bounces(access_token, campaign_id, params = {})
|
18
18
|
url = Util::Config.get('endpoints.base_url') +
|
19
19
|
sprintf(Util::Config.get('endpoints.campaign_tracking_bounces'), campaign_id)
|
20
|
-
url = build_url(url,
|
20
|
+
url = build_url(url, params)
|
21
21
|
|
22
22
|
response = RestClient.get(url, get_headers(access_token))
|
23
23
|
body = JSON.parse(response.body)
|
@@ -34,12 +34,12 @@ module ConstantContact
|
|
34
34
|
# Get clicks for a given campaign
|
35
35
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
36
36
|
# @param [String] campaign_id - Campaign id
|
37
|
-
# @param [Hash]
|
37
|
+
# @param [Hash] params - query parameters to be appended to request
|
38
38
|
# @return [ResultSet<ClickActivity>] - Containing a results array of ClickActivity
|
39
|
-
def get_clicks(access_token, campaign_id,
|
39
|
+
def get_clicks(access_token, campaign_id, params = {})
|
40
40
|
url = Util::Config.get('endpoints.base_url') +
|
41
41
|
sprintf(Util::Config.get('endpoints.campaign_tracking_clicks'), campaign_id)
|
42
|
-
url = build_url(url,
|
42
|
+
url = build_url(url, params)
|
43
43
|
|
44
44
|
response = RestClient.get(url, get_headers(access_token))
|
45
45
|
body = JSON.parse(response.body)
|
@@ -56,12 +56,12 @@ module ConstantContact
|
|
56
56
|
# Get forwards for a given campaign
|
57
57
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
58
58
|
# @param [String] campaign_id - Campaign id
|
59
|
-
# @param [Hash]
|
59
|
+
# @param [Hash] params - query parameters to be appended to request
|
60
60
|
# @return [ResultSet<ForwardActivity>] - Containing a results array of ForwardActivity
|
61
|
-
def get_forwards(access_token, campaign_id,
|
61
|
+
def get_forwards(access_token, campaign_id, params = {})
|
62
62
|
url = Util::Config.get('endpoints.base_url') +
|
63
63
|
sprintf(Util::Config.get('endpoints.campaign_tracking_forwards'), campaign_id)
|
64
|
-
url = build_url(url,
|
64
|
+
url = build_url(url, params)
|
65
65
|
|
66
66
|
response = RestClient.get(url, get_headers(access_token))
|
67
67
|
body = JSON.parse(response.body)
|
@@ -78,12 +78,12 @@ module ConstantContact
|
|
78
78
|
# Get opens for a given campaign
|
79
79
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
80
80
|
# @param [String] campaign_id - Campaign id
|
81
|
-
# @param [Hash]
|
81
|
+
# @param [Hash] params - query parameters to be appended to request
|
82
82
|
# @return [ResultSet<OpenActivity>] - Containing a results array of OpenActivity
|
83
|
-
def get_opens(access_token, campaign_id,
|
83
|
+
def get_opens(access_token, campaign_id, params = {})
|
84
84
|
url = Util::Config.get('endpoints.base_url') +
|
85
85
|
sprintf(Util::Config.get('endpoints.campaign_tracking_opens'), campaign_id)
|
86
|
-
url = build_url(url,
|
86
|
+
url = build_url(url, params)
|
87
87
|
|
88
88
|
response = RestClient.get(url, get_headers(access_token))
|
89
89
|
body = JSON.parse(response.body)
|
@@ -100,12 +100,12 @@ module ConstantContact
|
|
100
100
|
# Get sends for a given campaign
|
101
101
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
102
102
|
# @param [String] campaign_id - Campaign id
|
103
|
-
# @param [Hash]
|
103
|
+
# @param [Hash] params - query parameters to be appended to request
|
104
104
|
# @return [ResultSet<SendActivity>] - Containing a results array of SendActivity
|
105
|
-
def get_sends(access_token, campaign_id,
|
105
|
+
def get_sends(access_token, campaign_id, params = {})
|
106
106
|
url = Util::Config.get('endpoints.base_url') +
|
107
107
|
sprintf(Util::Config.get('endpoints.campaign_tracking_sends'), campaign_id)
|
108
|
-
url = build_url(url,
|
108
|
+
url = build_url(url, params)
|
109
109
|
|
110
110
|
response = RestClient.get(url, get_headers(access_token))
|
111
111
|
body = JSON.parse(response.body)
|
@@ -122,19 +122,19 @@ module ConstantContact
|
|
122
122
|
# Get unsubscribes for a given campaign
|
123
123
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
124
124
|
# @param [String] campaign_id - Campaign id
|
125
|
-
# @param [Hash]
|
125
|
+
# @param [Hash] params - query params to be appended to request
|
126
126
|
# @return [ResultSet<UnsubscribeActivity>] - Containing a results array of UnsubscribeActivity
|
127
|
-
def get_unsubscribes(access_token, campaign_id,
|
127
|
+
def get_unsubscribes(access_token, campaign_id, params = {})
|
128
128
|
url = Util::Config.get('endpoints.base_url') +
|
129
129
|
sprintf(Util::Config.get('endpoints.campaign_tracking_unsubscribes'), campaign_id)
|
130
|
-
url = build_url(url,
|
130
|
+
url = build_url(url, params)
|
131
131
|
|
132
132
|
response = RestClient.get(url, get_headers(access_token))
|
133
133
|
body = JSON.parse(response.body)
|
134
134
|
|
135
135
|
unsubscribes = []
|
136
136
|
body['results'].each do |unsubscribe_activity|
|
137
|
-
unsubscribes
|
137
|
+
unsubscribes << Components::UnsubscribeActivity.create(unsubscribe_activity)
|
138
138
|
end
|
139
139
|
|
140
140
|
Components::ResultSet.new(unsubscribes, body['meta'])
|
@@ -11,11 +11,11 @@ module ConstantContact
|
|
11
11
|
|
12
12
|
# Get an array of contacts
|
13
13
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
14
|
-
# @param [Hash]
|
14
|
+
# @param [Hash] params - query parameters to be appended to the request
|
15
15
|
# @return [ResultSet<Contact>]
|
16
|
-
def get_contacts(access_token,
|
16
|
+
def get_contacts(access_token, params = {})
|
17
17
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.contacts')
|
18
|
-
url = build_url(url,
|
18
|
+
url = build_url(url, params)
|
19
19
|
|
20
20
|
response = RestClient.get(url, get_headers(access_token))
|
21
21
|
body = JSON.parse(response.body)
|
@@ -45,12 +45,11 @@ module ConstantContact
|
|
45
45
|
# Add a new contact to the Constant Contact account
|
46
46
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
47
47
|
# @param [Contact] contact - Contact to add
|
48
|
-
# @param [Boolean]
|
48
|
+
# @param [Boolean] params - query params to be appended to the request
|
49
49
|
# @return [Contact]
|
50
|
-
def add_contact(access_token, contact,
|
50
|
+
def add_contact(access_token, contact, params = {})
|
51
51
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.contacts')
|
52
|
-
|
53
|
-
url = build_url(url, param)
|
52
|
+
url = build_url(url, params)
|
54
53
|
payload = contact.to_json
|
55
54
|
response = RestClient.post(url, payload, get_headers(access_token))
|
56
55
|
Components::Contact.create(JSON.parse(response.body))
|
@@ -84,7 +83,7 @@ module ConstantContact
|
|
84
83
|
# Delete a contact from a specific contact list
|
85
84
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
86
85
|
# @param [Integer] contact_id - Contact id to be removed
|
87
|
-
# @param [Integer] list_id - ContactList to remove the contact from
|
86
|
+
# @param [Integer] list_id - ContactList id to remove the contact from
|
88
87
|
# @return [Boolean]
|
89
88
|
def delete_contact_from_list(access_token, contact_id, list_id)
|
90
89
|
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.contact_list'), contact_id, list_id)
|
@@ -97,12 +96,11 @@ module ConstantContact
|
|
97
96
|
# Update contact details for a specific contact
|
98
97
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
99
98
|
# @param [Contact] contact - Contact to be updated
|
100
|
-
# @param [
|
99
|
+
# @param [Hash] params - query params to be appended to the request
|
101
100
|
# @return [Contact]
|
102
|
-
def update_contact(access_token, contact,
|
101
|
+
def update_contact(access_token, contact, params = {})
|
103
102
|
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.contact'), contact.id)
|
104
|
-
|
105
|
-
url = build_url(url, param)
|
103
|
+
url = build_url(url, params)
|
106
104
|
payload = contact.to_json
|
107
105
|
response = RestClient.put(url, payload, get_headers(access_token))
|
108
106
|
Components::Contact.create(JSON.parse(response.body))
|
@@ -9,15 +9,15 @@ module ConstantContact
|
|
9
9
|
class ContactTrackingService < BaseService
|
10
10
|
class << self
|
11
11
|
|
12
|
-
# Get
|
12
|
+
# Get bounces for a given contact
|
13
13
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
14
14
|
# @param [String] contact_id - Contact id
|
15
|
-
# @param [Hash]
|
15
|
+
# @param [Hash] params - query parameters to be appended to request
|
16
16
|
# @return [ResultSet<BounceActivity>] - Containing a results array of BounceActivity
|
17
|
-
def get_bounces(access_token, contact_id,
|
17
|
+
def get_bounces(access_token, contact_id, params = {})
|
18
18
|
url = Util::Config.get('endpoints.base_url') +
|
19
19
|
sprintf(Util::Config.get('endpoints.contact_tracking_bounces'), contact_id)
|
20
|
-
url = build_url(url,
|
20
|
+
url = build_url(url, params)
|
21
21
|
|
22
22
|
response = RestClient.get(url, get_headers(access_token))
|
23
23
|
body = JSON.parse(response.body)
|
@@ -34,12 +34,12 @@ module ConstantContact
|
|
34
34
|
# Get clicks for a given contact
|
35
35
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
36
36
|
# @param [String] contact_id - Contact id
|
37
|
-
# @param [Hash]
|
37
|
+
# @param [Hash] params - query parameters to be appended to request
|
38
38
|
# @return [ResultSet<ClickActivity>] - Containing a results array of ClickActivity
|
39
|
-
def get_clicks(access_token, contact_id,
|
39
|
+
def get_clicks(access_token, contact_id, params = {})
|
40
40
|
url = Util::Config.get('endpoints.base_url') +
|
41
41
|
sprintf(Util::Config.get('endpoints.contact_tracking_clicks'), contact_id)
|
42
|
-
url = build_url(url,
|
42
|
+
url = build_url(url, params)
|
43
43
|
|
44
44
|
response = RestClient.get(url, get_headers(access_token))
|
45
45
|
body = JSON.parse(response.body)
|
@@ -56,12 +56,12 @@ module ConstantContact
|
|
56
56
|
# Get forwards for a given contact
|
57
57
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
58
58
|
# @param [String] contact_id - Contact id
|
59
|
-
# @param [Hash]
|
59
|
+
# @param [Hash] params - query parameters to be appended to request
|
60
60
|
# @return [ResultSet<ForwardActivity>] - Containing a results array of ForwardActivity
|
61
|
-
def get_forwards(access_token, contact_id,
|
61
|
+
def get_forwards(access_token, contact_id, params = {})
|
62
62
|
url = Util::Config.get('endpoints.base_url') +
|
63
63
|
sprintf(Util::Config.get('endpoints.contact_tracking_forwards'), contact_id)
|
64
|
-
url = build_url(url,
|
64
|
+
url = build_url(url, params)
|
65
65
|
|
66
66
|
response = RestClient.get(url, get_headers(access_token))
|
67
67
|
body = JSON.parse(response.body)
|
@@ -78,12 +78,12 @@ module ConstantContact
|
|
78
78
|
# Get opens for a given contact
|
79
79
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
80
80
|
# @param [String] contact_id - Contact id
|
81
|
-
# @param [Hash]
|
81
|
+
# @param [Hash] params - query parameters to be appended to request
|
82
82
|
# @return [ResultSet<OpenActivity>] - Containing a results array of OpenActivity
|
83
|
-
def get_opens(access_token, contact_id,
|
83
|
+
def get_opens(access_token, contact_id, params = {})
|
84
84
|
url = Util::Config.get('endpoints.base_url') +
|
85
85
|
sprintf(Util::Config.get('endpoints.contact_tracking_opens'), contact_id)
|
86
|
-
url = build_url(url,
|
86
|
+
url = build_url(url, params)
|
87
87
|
|
88
88
|
response = RestClient.get(url, get_headers(access_token))
|
89
89
|
body = JSON.parse(response.body)
|
@@ -100,12 +100,12 @@ module ConstantContact
|
|
100
100
|
# Get sends for a given contact
|
101
101
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
102
102
|
# @param [String] contact_id - Contact id
|
103
|
-
# @param [Hash]
|
103
|
+
# @param [Hash] params - query parameters to be appended to request
|
104
104
|
# @return [ResultSet<SendActivity>] - Containing a results array of SendActivity
|
105
|
-
def get_sends(access_token, contact_id,
|
105
|
+
def get_sends(access_token, contact_id, params = {})
|
106
106
|
url = Util::Config.get('endpoints.base_url') +
|
107
107
|
sprintf(Util::Config.get('endpoints.contact_tracking_sends'), contact_id)
|
108
|
-
url = build_url(url,
|
108
|
+
url = build_url(url, params)
|
109
109
|
|
110
110
|
response = RestClient.get(url, get_headers(access_token))
|
111
111
|
body = JSON.parse(response.body)
|
@@ -122,19 +122,19 @@ module ConstantContact
|
|
122
122
|
# Get unsubscribes for a given contact
|
123
123
|
# @param [String] access_token - Constant Contact OAuth2 access token
|
124
124
|
# @param [String] contact_id - Contact id
|
125
|
-
# @param [Hash]
|
125
|
+
# @param [Hash] params - query parameters to be appended to request
|
126
126
|
# @return [ResultSet<UnsubscribeActivity>] - Containing a results array of UnsubscribeActivity
|
127
|
-
def get_unsubscribes(access_token, contact_id,
|
127
|
+
def get_unsubscribes(access_token, contact_id, params = {})
|
128
128
|
url = Util::Config.get('endpoints.base_url') +
|
129
129
|
sprintf(Util::Config.get('endpoints.contact_tracking_unsubscribes'), contact_id)
|
130
|
-
url = build_url(url,
|
130
|
+
url = build_url(url, params)
|
131
131
|
|
132
132
|
response = RestClient.get(url, get_headers(access_token))
|
133
133
|
body = JSON.parse(response.body)
|
134
134
|
|
135
135
|
unsubscribes = []
|
136
136
|
body['results'].each do |unsubscribe_activity|
|
137
|
-
unsubscribes
|
137
|
+
unsubscribes << Components::UnsubscribeActivity.create(unsubscribe_activity)
|
138
138
|
end
|
139
139
|
|
140
140
|
Components::ResultSet.new(unsubscribes, body['meta'])
|
@@ -21,16 +21,14 @@ module ConstantContact
|
|
21
21
|
Components::Campaign.create(JSON.parse(response.body))
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.campaigns')
|
33
|
-
url = build_url(url, opts)
|
24
|
+
|
25
|
+
# Get a set of campaigns
|
26
|
+
# @param [String] access_token Constant Contact OAuth2 access token
|
27
|
+
# @param [Hash] params - query parameters to be appended to the request
|
28
|
+
# @return [ResultSet<Campaign>]
|
29
|
+
def get_campaigns(access_token, params = {})
|
30
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.campaigns')
|
31
|
+
url = build_url(url, params)
|
34
32
|
|
35
33
|
response = RestClient.get(url, get_headers(access_token))
|
36
34
|
body = JSON.parse(response.body)
|
@@ -0,0 +1,254 @@
|
|
1
|
+
#
|
2
|
+
# event_spot_service.rb
|
3
|
+
# ConstantContact
|
4
|
+
#
|
5
|
+
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
|
+
|
7
|
+
module ConstantContact
|
8
|
+
module Services
|
9
|
+
class EventSpotService < BaseService
|
10
|
+
class << self
|
11
|
+
|
12
|
+
# Create a new event
|
13
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
14
|
+
# @param [Event] event - Event to be created
|
15
|
+
# @return [Event]
|
16
|
+
def add_event(access_token, event)
|
17
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.events')
|
18
|
+
url = build_url(url)
|
19
|
+
payload = event.to_json
|
20
|
+
response = RestClient.post(url, payload, get_headers(access_token))
|
21
|
+
Components::Event.create(JSON.parse(response.body))
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# Get a set of events
|
26
|
+
# @param [String] access_token Constant Contact OAuth2 access token
|
27
|
+
# @param [Hash] opts query parameters to be appended to the request
|
28
|
+
# @option opts [String] status email campaigns status of DRAFT, RUNNING, SENT, SCHEDULED.
|
29
|
+
# @option opts [String] modified_since ISO-8601 date string to return campaigns modified since then.
|
30
|
+
# @option opts [Integer] limit number of campaigns to return, 1 to 50.
|
31
|
+
# @return [ResultSet<Event>]
|
32
|
+
def get_events(access_token, opts = {})
|
33
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.events')
|
34
|
+
url = build_url(url, opts)
|
35
|
+
|
36
|
+
response = RestClient.get(url, get_headers(access_token))
|
37
|
+
body = JSON.parse(response.body)
|
38
|
+
|
39
|
+
events = body['results'].collect do |event|
|
40
|
+
Components::Event.create_summary(event)
|
41
|
+
end
|
42
|
+
|
43
|
+
Components::ResultSet.new(events, body['meta'])
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
# Get event details for a specific event
|
48
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
49
|
+
# @param [Integer] event - Valid event id
|
50
|
+
# @return [Event]
|
51
|
+
def get_event(access_token, event)
|
52
|
+
event_id = get_id_for(event)
|
53
|
+
url = Util::Config.get('endpoints.base_url') +
|
54
|
+
sprintf(Util::Config.get('endpoints.event'), event_id)
|
55
|
+
url = build_url(url)
|
56
|
+
response = RestClient.get(url, get_headers(access_token))
|
57
|
+
Components::Event.create(JSON.parse(response.body))
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# Delete an EventSpot event
|
62
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
63
|
+
# @param [Integer] event - Valid event id
|
64
|
+
# @return [Boolean]
|
65
|
+
def delete_event(access_token, event)
|
66
|
+
event_id = get_id_for(event)
|
67
|
+
url = Util::Config.get('endpoints.base_url') +
|
68
|
+
sprintf(Util::Config.get('endpoints.event'), event_id)
|
69
|
+
url = build_url(url)
|
70
|
+
response = RestClient.delete(url, get_headers(access_token))
|
71
|
+
response.code == 204
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
# Update a specific EventSpot event
|
76
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
77
|
+
# @param [Event] event - Event to be updated
|
78
|
+
# @return [Event]
|
79
|
+
def update_event(access_token, event)
|
80
|
+
event_id = get_id_for(event)
|
81
|
+
url = Util::Config.get('endpoints.base_url') +
|
82
|
+
sprintf(Util::Config.get('endpoints.event'), event_id)
|
83
|
+
url = build_url(url)
|
84
|
+
payload = event.to_json
|
85
|
+
response = RestClient.put(url, payload, get_headers(access_token))
|
86
|
+
Components::Event.create(JSON.parse(response.body))
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
# Publish a specific EventSpot event
|
91
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
92
|
+
# @param [Event] event - Event to be updated
|
93
|
+
# @return [Event]
|
94
|
+
def publish_event(access_token, event)
|
95
|
+
event_id = get_id_for(event)
|
96
|
+
url = Util::Config.get('endpoints.base_url') +
|
97
|
+
sprintf(Util::Config.get('endpoints.event'), event_id)
|
98
|
+
url = build_url(url)
|
99
|
+
payload = [{:op => "REPLACE", :path => "#/status", :value => "ACTIVE"}].to_json
|
100
|
+
response = RestClient.patch(url, payload, get_headers(access_token))
|
101
|
+
Components::Event.create(JSON.parse(response.body))
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
# Cancel a specific EventSpot event
|
106
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
107
|
+
# @param [Event] event - Event to be updated
|
108
|
+
# @return [Event]
|
109
|
+
def cancel_event(access_token, event)
|
110
|
+
event_id = get_id_for(event)
|
111
|
+
url = Util::Config.get('endpoints.base_url') +
|
112
|
+
sprintf(Util::Config.get('endpoints.event'), event_id)
|
113
|
+
url = build_url(url)
|
114
|
+
payload = [{ :op => "REPLACE", :path => "#/status", :value => "CANCELLED" }].to_json
|
115
|
+
response = RestClient.patch(url, payload, get_headers(access_token))
|
116
|
+
Components::Event.create(JSON.parse(response.body))
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
# Create a new event fee
|
121
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
122
|
+
# @param [Integer] event - Valid event id
|
123
|
+
# @param [Fee] fee - Event fee to be created
|
124
|
+
# @return [Fee]
|
125
|
+
def add_fee(access_token, event, fee)
|
126
|
+
event_id = get_id_for(event)
|
127
|
+
url = Util::Config.get('endpoints.base_url') +
|
128
|
+
sprintf(Util::Config.get('endpoints.event_fees'), event_id)
|
129
|
+
url = build_url(url)
|
130
|
+
payload = fee.to_json
|
131
|
+
response = RestClient.post(url, payload, get_headers(access_token))
|
132
|
+
Components::Fee.create(JSON.parse(response.body))
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
# Get a set of event fees
|
137
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
138
|
+
# @param [Integer] event - Valid event id
|
139
|
+
# @return [ResultSet<Fee>]
|
140
|
+
def get_fees(access_token, event)
|
141
|
+
event_id = get_id_for(event)
|
142
|
+
url = Util::Config.get('endpoints.base_url') +
|
143
|
+
sprintf(Util::Config.get('endpoints.event_fees'), event_id)
|
144
|
+
url = build_url(url)
|
145
|
+
|
146
|
+
response = RestClient.get(url, get_headers(access_token))
|
147
|
+
body = JSON.parse(response.body)
|
148
|
+
|
149
|
+
fees = body.collect do |fee|
|
150
|
+
Components::Fee.create(fee)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
# Get an individual event fee
|
156
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
157
|
+
# @param [Integer] event - Valid event id
|
158
|
+
# @param [Integer] fee - Valid fee id
|
159
|
+
# @return [Fee]
|
160
|
+
def get_fee(access_token, event, fee)
|
161
|
+
event_id = get_id_for(event)
|
162
|
+
fee_id = get_id_for(fee)
|
163
|
+
url = Util::Config.get('endpoints.base_url') +
|
164
|
+
sprintf(Util::Config.get('endpoints.event_fee'), event_id, fee_id)
|
165
|
+
url = build_url(url)
|
166
|
+
|
167
|
+
response = RestClient.get(url, get_headers(access_token))
|
168
|
+
fee = Components::Fee.create(JSON.parse(response.body))
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
# Update an individual event fee
|
173
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
174
|
+
# @param [Integer] event - Valid event id
|
175
|
+
# @param [Integer] fee - Valid fee id
|
176
|
+
# @return [Fee]
|
177
|
+
def update_fee(access_token, event, fee)
|
178
|
+
event_id = get_id_for(event)
|
179
|
+
if fee.kind_of?(ConstantContact::Components::Fee)
|
180
|
+
fee_id = fee.id
|
181
|
+
elsif fee.kind_of?(Hash)
|
182
|
+
fee_id = fee['id']
|
183
|
+
else
|
184
|
+
raise ArgumentError.new "Fee must be a Hash or ConstantContact::Components::Fee"
|
185
|
+
end
|
186
|
+
|
187
|
+
url = Util::Config.get('endpoints.base_url') +
|
188
|
+
sprintf(Util::Config.get('endpoints.event_fee'), event_id, fee_id)
|
189
|
+
url = build_url(url)
|
190
|
+
payload = fee.to_json
|
191
|
+
|
192
|
+
response = RestClient.put(url, payload, get_headers(access_token))
|
193
|
+
fee = Components::Fee.create(JSON.parse(response.body))
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
# Delete an individual event fee
|
198
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
199
|
+
# @param [Integer] event - Valid event id
|
200
|
+
# @param [Integer] fee - Valid fee id
|
201
|
+
# @return [Fee]
|
202
|
+
def delete_fee(access_token, event, fee)
|
203
|
+
event_id = get_id_for(event)
|
204
|
+
fee_id = get_id_for(fee)
|
205
|
+
url = Util::Config.get('endpoints.base_url') +
|
206
|
+
sprintf(Util::Config.get('endpoints.event_fee'), event_id, fee_id)
|
207
|
+
url = build_url(url)
|
208
|
+
|
209
|
+
response = RestClient.delete(url, get_headers(access_token))
|
210
|
+
response.code == 204
|
211
|
+
end
|
212
|
+
|
213
|
+
|
214
|
+
# Get a set of event registrants
|
215
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
216
|
+
# @param [Integer] event - Valid event id
|
217
|
+
# @return [ResultSet<Registrant>]
|
218
|
+
def get_registrants(access_token, event)
|
219
|
+
event_id = event.kind_of?(ConstantContact::Components::Event) ? event.id : event
|
220
|
+
url = Util::Config.get('endpoints.base_url') +
|
221
|
+
sprintf(Util::Config.get('endpoints.event_registrants'), event_id)
|
222
|
+
url = build_url(url)
|
223
|
+
|
224
|
+
response = RestClient.get(url, get_headers(access_token))
|
225
|
+
body = JSON.parse(response.body)
|
226
|
+
|
227
|
+
registrants = body['results'].collect do |registrant|
|
228
|
+
Components::Registrant.create(registrant)
|
229
|
+
end
|
230
|
+
|
231
|
+
Components::ResultSet.new(registrants, body['meta'])
|
232
|
+
end
|
233
|
+
|
234
|
+
|
235
|
+
# Get an individual event registant
|
236
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
237
|
+
# @param [Integer] event - Valid event id
|
238
|
+
# @param [Integer] registrant - Valid fee id
|
239
|
+
# @return [Fee]
|
240
|
+
def get_registrant(access_token, event, registrant)
|
241
|
+
event_id = get_id_for(event)
|
242
|
+
registrant_id = get_id_for(registrant)
|
243
|
+
url = Util::Config.get('endpoints.base_url') +
|
244
|
+
sprintf(Util::Config.get('endpoints.event_fee'), event_id, registrant_id)
|
245
|
+
url = build_url(url)
|
246
|
+
|
247
|
+
response = RestClient.get(url, get_headers(access_token))
|
248
|
+
registrant = Components::Registrant.create(JSON.parse(response.body))
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|