constantcontact 1.3.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/constantcontact.gemspec +2 -2
- data/lib/constantcontact/api.rb +223 -307
- data/lib/constantcontact/services/account_service.rb +5 -7
- data/lib/constantcontact/services/activity_service.rb +16 -24
- data/lib/constantcontact/services/base_service.rb +3 -4
- data/lib/constantcontact/services/campaign_schedule_service.rb +12 -18
- data/lib/constantcontact/services/campaign_tracking_service.rb +14 -21
- data/lib/constantcontact/services/contact_service.rb +14 -21
- data/lib/constantcontact/services/contact_tracking_service.rb +14 -21
- data/lib/constantcontact/services/email_marketing_service.rb +10 -15
- data/lib/constantcontact/services/event_spot_service.rb +56 -85
- data/lib/constantcontact/services/library_service.rb +32 -48
- data/lib/constantcontact/services/list_service.rb +10 -15
- data/lib/constantcontact/util/config.rb +5 -3
- data/lib/constantcontact/version.rb +3 -3
- data/spec/constantcontact/api_spec.rb +121 -103
- data/spec/constantcontact/services/account_service_spec.rb +15 -1
- data/spec/constantcontact/services/activity_service_spec.rb +9 -14
- data/spec/constantcontact/services/base_service_spec.rb +2 -1
- data/spec/constantcontact/services/campaign_schedule_service_spec.rb +6 -6
- data/spec/constantcontact/services/campaign_tracking_service_spec.rb +7 -7
- data/spec/constantcontact/services/contact_service_spec.rb +7 -7
- data/spec/constantcontact/services/contact_tracking_service_spec.rb +7 -7
- data/spec/constantcontact/services/email_marketing_spec.rb +5 -5
- data/spec/constantcontact/services/event_spot_spec.rb +27 -27
- data/spec/constantcontact/services/library_service_spec.rb +16 -16
- data/spec/constantcontact/services/list_service_spec.rb +5 -5
- metadata +2 -2
@@ -10,16 +10,15 @@ module ConstantContact
|
|
10
10
|
class << self
|
11
11
|
|
12
12
|
# Get bounces for a given contact
|
13
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
14
13
|
# @param [String] contact_id - Contact id
|
15
14
|
# @param [Hash] params - query parameters to be appended to request
|
16
15
|
# @return [ResultSet<BounceActivity>] - Containing a results array of BounceActivity
|
17
|
-
def get_bounces(
|
16
|
+
def get_bounces(contact_id, params = {})
|
18
17
|
url = Util::Config.get('endpoints.base_url') +
|
19
18
|
sprintf(Util::Config.get('endpoints.contact_tracking_bounces'), contact_id)
|
20
19
|
url = build_url(url, params)
|
21
20
|
|
22
|
-
response = RestClient.get(url, get_headers(
|
21
|
+
response = RestClient.get(url, get_headers())
|
23
22
|
body = JSON.parse(response.body)
|
24
23
|
|
25
24
|
bounces = []
|
@@ -32,16 +31,15 @@ module ConstantContact
|
|
32
31
|
|
33
32
|
|
34
33
|
# Get clicks for a given contact
|
35
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
36
34
|
# @param [String] contact_id - Contact id
|
37
35
|
# @param [Hash] params - query parameters to be appended to request
|
38
36
|
# @return [ResultSet<ClickActivity>] - Containing a results array of ClickActivity
|
39
|
-
def get_clicks(
|
37
|
+
def get_clicks(contact_id, params = {})
|
40
38
|
url = Util::Config.get('endpoints.base_url') +
|
41
39
|
sprintf(Util::Config.get('endpoints.contact_tracking_clicks'), contact_id)
|
42
40
|
url = build_url(url, params)
|
43
41
|
|
44
|
-
response = RestClient.get(url, get_headers(
|
42
|
+
response = RestClient.get(url, get_headers())
|
45
43
|
body = JSON.parse(response.body)
|
46
44
|
|
47
45
|
clicks = []
|
@@ -54,16 +52,15 @@ module ConstantContact
|
|
54
52
|
|
55
53
|
|
56
54
|
# Get forwards for a given contact
|
57
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
58
55
|
# @param [String] contact_id - Contact id
|
59
56
|
# @param [Hash] params - query parameters to be appended to request
|
60
57
|
# @return [ResultSet<ForwardActivity>] - Containing a results array of ForwardActivity
|
61
|
-
def get_forwards(
|
58
|
+
def get_forwards(contact_id, params = {})
|
62
59
|
url = Util::Config.get('endpoints.base_url') +
|
63
60
|
sprintf(Util::Config.get('endpoints.contact_tracking_forwards'), contact_id)
|
64
61
|
url = build_url(url, params)
|
65
62
|
|
66
|
-
response = RestClient.get(url, get_headers(
|
63
|
+
response = RestClient.get(url, get_headers())
|
67
64
|
body = JSON.parse(response.body)
|
68
65
|
|
69
66
|
forwards = []
|
@@ -76,16 +73,15 @@ module ConstantContact
|
|
76
73
|
|
77
74
|
|
78
75
|
# Get opens for a given contact
|
79
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
80
76
|
# @param [String] contact_id - Contact id
|
81
77
|
# @param [Hash] params - query parameters to be appended to request
|
82
78
|
# @return [ResultSet<OpenActivity>] - Containing a results array of OpenActivity
|
83
|
-
def get_opens(
|
79
|
+
def get_opens(contact_id, params = {})
|
84
80
|
url = Util::Config.get('endpoints.base_url') +
|
85
81
|
sprintf(Util::Config.get('endpoints.contact_tracking_opens'), contact_id)
|
86
82
|
url = build_url(url, params)
|
87
83
|
|
88
|
-
response = RestClient.get(url, get_headers(
|
84
|
+
response = RestClient.get(url, get_headers())
|
89
85
|
body = JSON.parse(response.body)
|
90
86
|
|
91
87
|
opens = []
|
@@ -98,16 +94,15 @@ module ConstantContact
|
|
98
94
|
|
99
95
|
|
100
96
|
# Get sends for a given contact
|
101
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
102
97
|
# @param [String] contact_id - Contact id
|
103
98
|
# @param [Hash] params - query parameters to be appended to request
|
104
99
|
# @return [ResultSet<SendActivity>] - Containing a results array of SendActivity
|
105
|
-
def get_sends(
|
100
|
+
def get_sends(contact_id, params = {})
|
106
101
|
url = Util::Config.get('endpoints.base_url') +
|
107
102
|
sprintf(Util::Config.get('endpoints.contact_tracking_sends'), contact_id)
|
108
103
|
url = build_url(url, params)
|
109
104
|
|
110
|
-
response = RestClient.get(url, get_headers(
|
105
|
+
response = RestClient.get(url, get_headers())
|
111
106
|
body = JSON.parse(response.body)
|
112
107
|
|
113
108
|
sends = []
|
@@ -120,16 +115,15 @@ module ConstantContact
|
|
120
115
|
|
121
116
|
|
122
117
|
# Get unsubscribes for a given contact
|
123
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
124
118
|
# @param [String] contact_id - Contact id
|
125
119
|
# @param [Hash] params - query parameters to be appended to request
|
126
120
|
# @return [ResultSet<UnsubscribeActivity>] - Containing a results array of UnsubscribeActivity
|
127
|
-
def get_unsubscribes(
|
121
|
+
def get_unsubscribes(contact_id, params = {})
|
128
122
|
url = Util::Config.get('endpoints.base_url') +
|
129
123
|
sprintf(Util::Config.get('endpoints.contact_tracking_unsubscribes'), contact_id)
|
130
124
|
url = build_url(url, params)
|
131
125
|
|
132
|
-
response = RestClient.get(url, get_headers(
|
126
|
+
response = RestClient.get(url, get_headers())
|
133
127
|
body = JSON.parse(response.body)
|
134
128
|
|
135
129
|
unsubscribes = []
|
@@ -142,14 +136,13 @@ module ConstantContact
|
|
142
136
|
|
143
137
|
|
144
138
|
# Get a summary of reporting data for a given contact
|
145
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
146
139
|
# @param [String] contact_id - Contact id
|
147
140
|
# @return [TrackingSummary]
|
148
|
-
def get_summary(
|
141
|
+
def get_summary(contact_id)
|
149
142
|
url = Util::Config.get('endpoints.base_url') +
|
150
143
|
sprintf(Util::Config.get('endpoints.contact_tracking_summary'), contact_id)
|
151
144
|
url = build_url(url)
|
152
|
-
response = RestClient.get(url, get_headers(
|
145
|
+
response = RestClient.get(url, get_headers())
|
153
146
|
Components::TrackingSummary.create(JSON.parse(response.body))
|
154
147
|
end
|
155
148
|
|
@@ -10,27 +10,25 @@ module ConstantContact
|
|
10
10
|
class << self
|
11
11
|
|
12
12
|
# Create a new campaign
|
13
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
14
13
|
# @param [Campaign] campaign - Campaign to be created
|
15
14
|
# @return [Campaign]
|
16
|
-
def add_campaign(
|
15
|
+
def add_campaign(campaign)
|
17
16
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.campaigns')
|
18
17
|
url = build_url(url)
|
19
18
|
payload = campaign.to_json
|
20
|
-
response = RestClient.post(url, payload, get_headers(
|
19
|
+
response = RestClient.post(url, payload, get_headers())
|
21
20
|
Components::Campaign.create(JSON.parse(response.body))
|
22
21
|
end
|
23
22
|
|
24
23
|
|
25
24
|
# Get a set of campaigns
|
26
|
-
# @param [String] access_token Constant Contact OAuth2 access token
|
27
25
|
# @param [Hash] params - query parameters to be appended to the request
|
28
26
|
# @return [ResultSet<Campaign>]
|
29
|
-
def get_campaigns(
|
27
|
+
def get_campaigns(params = {})
|
30
28
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.campaigns')
|
31
29
|
url = build_url(url, params)
|
32
30
|
|
33
|
-
response = RestClient.get(url, get_headers(
|
31
|
+
response = RestClient.get(url, get_headers())
|
34
32
|
body = JSON.parse(response.body)
|
35
33
|
|
36
34
|
campaigns = []
|
@@ -43,41 +41,38 @@ module ConstantContact
|
|
43
41
|
|
44
42
|
|
45
43
|
# Get campaign details for a specific campaign
|
46
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
47
44
|
# @param [Integer] campaign_id - Valid campaign id
|
48
45
|
# @return [Campaign]
|
49
|
-
def get_campaign(
|
46
|
+
def get_campaign(campaign_id)
|
50
47
|
url = Util::Config.get('endpoints.base_url') +
|
51
48
|
sprintf(Util::Config.get('endpoints.campaign'), campaign_id)
|
52
49
|
url = build_url(url)
|
53
|
-
response = RestClient.get(url, get_headers(
|
50
|
+
response = RestClient.get(url, get_headers())
|
54
51
|
Components::Campaign.create(JSON.parse(response.body))
|
55
52
|
end
|
56
53
|
|
57
54
|
|
58
55
|
# Delete an email campaign
|
59
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
60
56
|
# @param [Integer] campaign_id - Valid campaign id
|
61
57
|
# @return [Boolean]
|
62
|
-
def delete_campaign(
|
58
|
+
def delete_campaign(campaign_id)
|
63
59
|
url = Util::Config.get('endpoints.base_url') +
|
64
60
|
sprintf(Util::Config.get('endpoints.campaign'), campaign_id)
|
65
61
|
url = build_url(url)
|
66
|
-
response = RestClient.delete(url, get_headers(
|
62
|
+
response = RestClient.delete(url, get_headers())
|
67
63
|
response.code == 204
|
68
64
|
end
|
69
65
|
|
70
66
|
|
71
67
|
# Update a specific email campaign
|
72
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
73
68
|
# @param [Campaign] campaign - Campaign to be updated
|
74
69
|
# @return [Campaign]
|
75
|
-
def update_campaign(
|
70
|
+
def update_campaign(campaign)
|
76
71
|
url = Util::Config.get('endpoints.base_url') +
|
77
72
|
sprintf(Util::Config.get('endpoints.campaign'), campaign.id)
|
78
73
|
url = build_url(url)
|
79
74
|
payload = campaign.to_json
|
80
|
-
response = RestClient.put(url, payload, get_headers(
|
75
|
+
response = RestClient.put(url, payload, get_headers())
|
81
76
|
Components::Campaign.create(JSON.parse(response.body))
|
82
77
|
end
|
83
78
|
|
@@ -10,30 +10,28 @@ module ConstantContact
|
|
10
10
|
class << self
|
11
11
|
|
12
12
|
# Create a new event
|
13
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
14
13
|
# @param [Event] event - Event to be created
|
15
14
|
# @return [Event]
|
16
|
-
def add_event(
|
15
|
+
def add_event(event)
|
17
16
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.events')
|
18
17
|
url = build_url(url)
|
19
18
|
payload = event.to_json
|
20
|
-
response = RestClient.post(url, payload, get_headers(
|
19
|
+
response = RestClient.post(url, payload, get_headers())
|
21
20
|
Components::Event.create(JSON.parse(response.body))
|
22
21
|
end
|
23
22
|
|
24
23
|
|
25
24
|
# Get a set of events
|
26
|
-
# @param [String] access_token Constant Contact OAuth2 access token
|
27
25
|
# @param [Hash] opts query parameters to be appended to the request
|
28
26
|
# @option opts [String] status email campaigns status of DRAFT, RUNNING, SENT, SCHEDULED.
|
29
27
|
# @option opts [String] modified_since ISO-8601 date string to return campaigns modified since then.
|
30
28
|
# @option opts [Integer] limit number of campaigns to return, 1 to 50.
|
31
29
|
# @return [ResultSet<Event>]
|
32
|
-
def get_events(
|
30
|
+
def get_events(opts = {})
|
33
31
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.events')
|
34
32
|
url = build_url(url, opts)
|
35
33
|
|
36
|
-
response = RestClient.get(url, get_headers(
|
34
|
+
response = RestClient.get(url, get_headers())
|
37
35
|
body = JSON.parse(response.body)
|
38
36
|
|
39
37
|
events = body['results'].collect do |event|
|
@@ -45,91 +43,85 @@ module ConstantContact
|
|
45
43
|
|
46
44
|
|
47
45
|
# Get event details for a specific event
|
48
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
49
46
|
# @param [Integer] event - Valid event id
|
50
47
|
# @return [Event]
|
51
|
-
def get_event(
|
48
|
+
def get_event(event)
|
52
49
|
event_id = get_id_for(event)
|
53
50
|
url = Util::Config.get('endpoints.base_url') +
|
54
51
|
sprintf(Util::Config.get('endpoints.event'), event_id)
|
55
52
|
url = build_url(url)
|
56
|
-
response = RestClient.get(url, get_headers(
|
53
|
+
response = RestClient.get(url, get_headers())
|
57
54
|
Components::Event.create(JSON.parse(response.body))
|
58
55
|
end
|
59
56
|
|
60
57
|
|
61
58
|
# Update a specific EventSpot event
|
62
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
63
59
|
# @param [Event] event - Event to be updated
|
64
60
|
# @return [Event]
|
65
|
-
def update_event(
|
61
|
+
def update_event(event)
|
66
62
|
event_id = get_id_for(event)
|
67
63
|
url = Util::Config.get('endpoints.base_url') +
|
68
64
|
sprintf(Util::Config.get('endpoints.event'), event_id)
|
69
65
|
url = build_url(url)
|
70
66
|
payload = event.to_json
|
71
|
-
response = RestClient.put(url, payload, get_headers(
|
67
|
+
response = RestClient.put(url, payload, get_headers())
|
72
68
|
Components::Event.create(JSON.parse(response.body))
|
73
69
|
end
|
74
70
|
|
75
71
|
|
76
72
|
# Publish a specific EventSpot event
|
77
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
78
73
|
# @param [Event] event - Event to be updated
|
79
74
|
# @return [Event]
|
80
|
-
def publish_event(
|
75
|
+
def publish_event(event)
|
81
76
|
event_id = get_id_for(event)
|
82
77
|
url = Util::Config.get('endpoints.base_url') +
|
83
78
|
sprintf(Util::Config.get('endpoints.event'), event_id)
|
84
79
|
url = build_url(url)
|
85
80
|
payload = [{:op => "REPLACE", :path => "#/status", :value => "ACTIVE"}].to_json
|
86
|
-
response = RestClient.patch(url, payload, get_headers(
|
81
|
+
response = RestClient.patch(url, payload, get_headers())
|
87
82
|
Components::Event.create(JSON.parse(response.body))
|
88
83
|
end
|
89
84
|
|
90
85
|
|
91
86
|
# Cancel a specific EventSpot event
|
92
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
93
87
|
# @param [Event] event - Event to be updated
|
94
88
|
# @return [Event]
|
95
|
-
def cancel_event(
|
89
|
+
def cancel_event(event)
|
96
90
|
event_id = get_id_for(event)
|
97
91
|
url = Util::Config.get('endpoints.base_url') +
|
98
92
|
sprintf(Util::Config.get('endpoints.event'), event_id)
|
99
93
|
url = build_url(url)
|
100
94
|
payload = [{ :op => "REPLACE", :path => "#/status", :value => "CANCELLED" }].to_json
|
101
|
-
response = RestClient.patch(url, payload, get_headers(
|
95
|
+
response = RestClient.patch(url, payload, get_headers())
|
102
96
|
Components::Event.create(JSON.parse(response.body))
|
103
97
|
end
|
104
98
|
|
105
99
|
|
106
100
|
# Create a new event fee
|
107
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
108
101
|
# @param [Integer] event - Valid event id
|
109
102
|
# @param [EventFee] fee - Event fee to be created
|
110
103
|
# @return [EventFee]
|
111
|
-
def add_fee(
|
104
|
+
def add_fee(event, fee)
|
112
105
|
event_id = get_id_for(event)
|
113
106
|
url = Util::Config.get('endpoints.base_url') +
|
114
107
|
sprintf(Util::Config.get('endpoints.event_fees'), event_id)
|
115
108
|
url = build_url(url)
|
116
109
|
payload = fee.to_json
|
117
|
-
response = RestClient.post(url, payload, get_headers(
|
110
|
+
response = RestClient.post(url, payload, get_headers())
|
118
111
|
Components::EventFee.create(JSON.parse(response.body))
|
119
112
|
end
|
120
113
|
|
121
114
|
|
122
115
|
# Get an array of event fees
|
123
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
124
116
|
# @param [Integer] event - Valid event id
|
125
117
|
# @return [Array<EventFee>]
|
126
|
-
def get_fees(
|
118
|
+
def get_fees(event)
|
127
119
|
event_id = get_id_for(event)
|
128
120
|
url = Util::Config.get('endpoints.base_url') +
|
129
121
|
sprintf(Util::Config.get('endpoints.event_fees'), event_id)
|
130
122
|
url = build_url(url)
|
131
123
|
|
132
|
-
response = RestClient.get(url, get_headers(
|
124
|
+
response = RestClient.get(url, get_headers())
|
133
125
|
body = JSON.parse(response.body)
|
134
126
|
|
135
127
|
fees = body.collect do |fee|
|
@@ -139,28 +131,26 @@ module ConstantContact
|
|
139
131
|
|
140
132
|
|
141
133
|
# Get an individual event fee
|
142
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
143
134
|
# @param [Integer] event - Valid event id
|
144
135
|
# @param [Integer] fee - Valid fee id
|
145
136
|
# @return [EventFee]
|
146
|
-
def get_fee(
|
137
|
+
def get_fee(event, fee)
|
147
138
|
event_id = get_id_for(event)
|
148
139
|
fee_id = get_id_for(fee)
|
149
140
|
url = Util::Config.get('endpoints.base_url') +
|
150
141
|
sprintf(Util::Config.get('endpoints.event_fee'), event_id, fee_id)
|
151
142
|
url = build_url(url)
|
152
143
|
|
153
|
-
response = RestClient.get(url, get_headers(
|
144
|
+
response = RestClient.get(url, get_headers())
|
154
145
|
fee = Components::EventFee.create(JSON.parse(response.body))
|
155
146
|
end
|
156
147
|
|
157
148
|
|
158
149
|
# Update an individual event fee
|
159
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
160
150
|
# @param [Integer] event - Valid event id
|
161
151
|
# @param [Integer] fee - Valid fee id
|
162
152
|
# @return [EventFee]
|
163
|
-
def update_fee(
|
153
|
+
def update_fee(event, fee)
|
164
154
|
event_id = get_id_for(event)
|
165
155
|
if fee.kind_of?(ConstantContact::Components::EventFee)
|
166
156
|
fee_id = fee.id
|
@@ -175,39 +165,37 @@ module ConstantContact
|
|
175
165
|
url = build_url(url)
|
176
166
|
payload = fee.to_json
|
177
167
|
|
178
|
-
response = RestClient.put(url, payload, get_headers(
|
168
|
+
response = RestClient.put(url, payload, get_headers())
|
179
169
|
fee = Components::EventFee.create(JSON.parse(response.body))
|
180
170
|
end
|
181
171
|
|
182
172
|
|
183
173
|
# Delete an individual event fee
|
184
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
185
174
|
# @param [Integer] event - Valid event id
|
186
175
|
# @param [Integer] fee - Valid fee id
|
187
176
|
# @return [Boolean]
|
188
|
-
def delete_fee(
|
177
|
+
def delete_fee(event, fee)
|
189
178
|
event_id = get_id_for(event)
|
190
179
|
fee_id = get_id_for(fee)
|
191
180
|
url = Util::Config.get('endpoints.base_url') +
|
192
181
|
sprintf(Util::Config.get('endpoints.event_fee'), event_id, fee_id)
|
193
182
|
url = build_url(url)
|
194
183
|
|
195
|
-
response = RestClient.delete(url, get_headers(
|
184
|
+
response = RestClient.delete(url, get_headers())
|
196
185
|
response.code == 204
|
197
186
|
end
|
198
187
|
|
199
188
|
|
200
189
|
# Get a set of event registrants
|
201
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
202
190
|
# @param [Integer] event - Valid event id
|
203
191
|
# @return [ResultSet<Registrant>]
|
204
|
-
def get_registrants(
|
192
|
+
def get_registrants(event)
|
205
193
|
event_id = event.kind_of?(ConstantContact::Components::Event) ? event.id : event
|
206
194
|
url = Util::Config.get('endpoints.base_url') +
|
207
195
|
sprintf(Util::Config.get('endpoints.event_registrants'), event_id)
|
208
196
|
url = build_url(url)
|
209
197
|
|
210
|
-
response = RestClient.get(url, get_headers(
|
198
|
+
response = RestClient.get(url, get_headers())
|
211
199
|
body = JSON.parse(response.body)
|
212
200
|
|
213
201
|
registrants = body['results'].collect do |registrant|
|
@@ -219,31 +207,29 @@ module ConstantContact
|
|
219
207
|
|
220
208
|
|
221
209
|
# Get an individual event registant
|
222
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
223
210
|
# @param [Integer] event - Valid event id
|
224
211
|
# @param [Integer] registrant - Valid fee id
|
225
212
|
# @return [Registrant]
|
226
|
-
def get_registrant(
|
213
|
+
def get_registrant(event, registrant)
|
227
214
|
event_id = get_id_for(event)
|
228
215
|
registrant_id = get_id_for(registrant)
|
229
216
|
url = Util::Config.get('endpoints.base_url') +
|
230
217
|
sprintf(Util::Config.get('endpoints.event_registrant'), event_id, registrant_id)
|
231
218
|
url = build_url(url)
|
232
219
|
|
233
|
-
response = RestClient.get(url, get_headers(
|
220
|
+
response = RestClient.get(url, get_headers())
|
234
221
|
Components::Registrant.create(JSON.parse(response.body))
|
235
222
|
end
|
236
223
|
|
237
224
|
|
238
225
|
# Get an array of event items for an individual event
|
239
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
240
226
|
# @param [Integer] event_id - event id to retrieve items for
|
241
227
|
# @return [Array<EventItem>]
|
242
|
-
def get_event_items(
|
228
|
+
def get_event_items(event_id)
|
243
229
|
url = Util::Config.get('endpoints.base_url') +
|
244
230
|
sprintf(Util::Config.get('endpoints.event_items'), event_id)
|
245
231
|
url = build_url(url)
|
246
|
-
response = RestClient.get(url, get_headers(
|
232
|
+
response = RestClient.get(url, get_headers())
|
247
233
|
|
248
234
|
event_items = []
|
249
235
|
JSON.parse(response.body).each do |event_item|
|
@@ -255,73 +241,68 @@ module ConstantContact
|
|
255
241
|
|
256
242
|
|
257
243
|
# Get an individual event item
|
258
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
259
244
|
# @param [Integer] event_id - id of event to retrieve item for
|
260
245
|
# @param [Integer] item_id - id of item to be retrieved
|
261
246
|
# @return [EventItem]
|
262
|
-
def get_event_item(
|
247
|
+
def get_event_item(event_id, item_id)
|
263
248
|
url = Util::Config.get('endpoints.base_url') +
|
264
249
|
sprintf(Util::Config.get('endpoints.event_item'), event_id, item_id)
|
265
250
|
url = build_url(url)
|
266
|
-
response = RestClient.get(url, get_headers(
|
251
|
+
response = RestClient.get(url, get_headers())
|
267
252
|
Components::EventItem.create(JSON.parse(response.body))
|
268
253
|
end
|
269
254
|
|
270
255
|
|
271
256
|
# Create a new event item for an event
|
272
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
273
257
|
# @param [Integer] event_id - id of event to be associated with the event item
|
274
258
|
# @param [EventItem] event_item - event item to be created
|
275
259
|
# @return [EventItem]
|
276
|
-
def add_event_item(
|
260
|
+
def add_event_item(event_id, event_item)
|
277
261
|
url = Util::Config.get('endpoints.base_url') +
|
278
262
|
sprintf(Util::Config.get('endpoints.event_items'), event_id)
|
279
263
|
url = build_url(url)
|
280
264
|
payload = event_item.to_json
|
281
|
-
response = RestClient.post(url, payload, get_headers(
|
265
|
+
response = RestClient.post(url, payload, get_headers())
|
282
266
|
Components::EventItem.create(JSON.parse(response.body))
|
283
267
|
end
|
284
268
|
|
285
269
|
|
286
270
|
# Delete a specific event item for an event
|
287
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
288
271
|
# @param [Integer] event_id - id of event to delete an event item for
|
289
272
|
# @param [Integer] item_id - id of event item to be deleted
|
290
273
|
# @return [Boolean]
|
291
|
-
def delete_event_item(
|
274
|
+
def delete_event_item(event_id, item_id)
|
292
275
|
url = Util::Config.get('endpoints.base_url') +
|
293
276
|
sprintf(Util::Config.get('endpoints.event_item'), event_id, item_id)
|
294
277
|
url = build_url(url)
|
295
|
-
response = RestClient.delete(url, get_headers(
|
278
|
+
response = RestClient.delete(url, get_headers())
|
296
279
|
response.code == 204
|
297
280
|
end
|
298
281
|
|
299
282
|
|
300
283
|
# Update a specific event item for an event
|
301
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
302
284
|
# @param [Integer] event_id - id of event associated with the event item
|
303
285
|
# @param [EventItem] event_item - event item to be updated
|
304
286
|
# @return [EventItem]
|
305
|
-
def update_event_item(
|
287
|
+
def update_event_item(event_id, event_item)
|
306
288
|
url = Util::Config.get('endpoints.base_url') +
|
307
289
|
sprintf(Util::Config.get('endpoints.event_item'), event_id, event_item.id)
|
308
290
|
url = build_url(url)
|
309
291
|
payload = event_item.to_json
|
310
|
-
response = RestClient.put(url, payload, get_headers(
|
292
|
+
response = RestClient.put(url, payload, get_headers())
|
311
293
|
Components::EventItem.create(JSON.parse(response.body))
|
312
294
|
end
|
313
295
|
|
314
296
|
|
315
297
|
# Get an array of attributes for an individual event item
|
316
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
317
298
|
# @param [Integer] event_id - event id to retrieve item for
|
318
299
|
# @param [Integer] item_id - event item id to retrieve attributes for
|
319
300
|
# @return [Array<EventItemAttribute>]
|
320
|
-
def get_event_item_attributes(
|
301
|
+
def get_event_item_attributes(event_id, item_id)
|
321
302
|
url = Util::Config.get('endpoints.base_url') +
|
322
303
|
sprintf(Util::Config.get('endpoints.event_item_attributes'), event_id, item_id)
|
323
304
|
url = build_url(url)
|
324
|
-
response = RestClient.get(url, get_headers(
|
305
|
+
response = RestClient.get(url, get_headers())
|
325
306
|
|
326
307
|
event_item_attributes = []
|
327
308
|
JSON.parse(response.body).each do |event_item_attribute|
|
@@ -333,76 +314,71 @@ module ConstantContact
|
|
333
314
|
|
334
315
|
|
335
316
|
# Get an individual event item attribute
|
336
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
337
317
|
# @param [Integer] event_id - id of event to retrieve item for
|
338
318
|
# @param [Integer] item_id - id of item to retrieve attribute for
|
339
319
|
# @param [Integer] attribute_id - id of attribute to be retrieved
|
340
320
|
# @return [EventItemAttribute]
|
341
|
-
def get_event_item_attribute(
|
321
|
+
def get_event_item_attribute(event_id, item_id, attribute_id)
|
342
322
|
url = Util::Config.get('endpoints.base_url') +
|
343
323
|
sprintf(Util::Config.get('endpoints.event_item_attribute'), event_id, item_id, attribute_id)
|
344
324
|
url = build_url(url)
|
345
|
-
response = RestClient.get(url, get_headers(
|
325
|
+
response = RestClient.get(url, get_headers())
|
346
326
|
Components::EventItemAttribute.create(JSON.parse(response.body))
|
347
327
|
end
|
348
328
|
|
349
329
|
|
350
330
|
# Create a new event item attribute for an event item
|
351
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
352
331
|
# @param [Integer] event_id - id of event to be associated with the event item attribute
|
353
332
|
# @param [Integer] item_id - id of event item to be associated with the event item attribute
|
354
333
|
# @param [EventItemAttribute] event_item_attribute - event item attribute to be created
|
355
334
|
# @return [EventItemAttribute]
|
356
|
-
def add_event_item_attribute(
|
335
|
+
def add_event_item_attribute(event_id, item_id, event_item_attribute)
|
357
336
|
url = Util::Config.get('endpoints.base_url') +
|
358
337
|
sprintf(Util::Config.get('endpoints.event_item_attributes'), event_id, item_id)
|
359
338
|
url = build_url(url)
|
360
339
|
payload = event_item_attribute.to_json
|
361
|
-
response = RestClient.post(url, payload, get_headers(
|
340
|
+
response = RestClient.post(url, payload, get_headers())
|
362
341
|
Components::EventItemAttribute.create(JSON.parse(response.body))
|
363
342
|
end
|
364
343
|
|
365
344
|
|
366
345
|
# Delete a specific event item for an event
|
367
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
368
346
|
# @param [Integer] event_id - id of event to delete an event item attribute for
|
369
347
|
# @param [Integer] item_id - id of event item to delete an event item attribute for
|
370
348
|
# @param [Integer] attribute_id - id of attribute to be deleted
|
371
349
|
# @return [Boolean]
|
372
|
-
def delete_event_item_attribute(
|
350
|
+
def delete_event_item_attribute(event_id, item_id, attribute_id)
|
373
351
|
url = Util::Config.get('endpoints.base_url') +
|
374
352
|
sprintf(Util::Config.get('endpoints.event_item_attribute'), event_id, item_id, attribute_id)
|
375
353
|
url = build_url(url)
|
376
|
-
response = RestClient.delete(url, get_headers(
|
354
|
+
response = RestClient.delete(url, get_headers())
|
377
355
|
response.code == 204
|
378
356
|
end
|
379
357
|
|
380
358
|
|
381
359
|
# Update a specific event item attribute for an event item
|
382
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
383
360
|
# @param [Integer] event_id - id of event associated with the event item
|
384
361
|
# @param [Integer] item_id - id of event item associated with the event item attribute
|
385
362
|
# @param [EventItemAttribute] event_item_attribute - event item to be updated
|
386
363
|
# @return [EventItemAttribute]
|
387
|
-
def update_event_item_attribute(
|
364
|
+
def update_event_item_attribute(event_id, item_id, event_item_attribute)
|
388
365
|
url = Util::Config.get('endpoints.base_url') +
|
389
366
|
sprintf(Util::Config.get('endpoints.event_item'), event_id, item_id, event_item_attribute.id)
|
390
367
|
url = build_url(url)
|
391
368
|
payload = event_item_attribute.to_json
|
392
|
-
response = RestClient.put(url, payload, get_headers(
|
369
|
+
response = RestClient.put(url, payload, get_headers())
|
393
370
|
Components::EventItemAttribute.create(JSON.parse(response.body))
|
394
371
|
end
|
395
372
|
|
396
373
|
|
397
374
|
# Get an array of promocodes for an individual event
|
398
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
399
375
|
# @param [Integer] event_id - event id to retrieve promocodes for
|
400
376
|
# @return [Array<Promocode>]
|
401
|
-
def get_promocodes(
|
377
|
+
def get_promocodes(event_id)
|
402
378
|
url = Util::Config.get('endpoints.base_url') +
|
403
379
|
sprintf(Util::Config.get('endpoints.event_promocodes'), event_id)
|
404
380
|
url = build_url(url)
|
405
|
-
response = RestClient.get(url, get_headers(
|
381
|
+
response = RestClient.get(url, get_headers())
|
406
382
|
|
407
383
|
promocodes = []
|
408
384
|
JSON.parse(response.body).each do |promocode|
|
@@ -414,63 +390,58 @@ module ConstantContact
|
|
414
390
|
|
415
391
|
|
416
392
|
# Get an individual promocode
|
417
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
418
393
|
# @param [Integer] event_id - id of event to retrieve item for
|
419
394
|
# @param [Integer] promocode_id - id of item to be retrieved
|
420
395
|
# @return [Promocode]
|
421
|
-
def get_promocode(
|
396
|
+
def get_promocode(event_id, promocode_id)
|
422
397
|
url = Util::Config.get('endpoints.base_url') +
|
423
398
|
sprintf(Util::Config.get('endpoints.event_promocode'), event_id, promocode_id)
|
424
399
|
url = build_url(url)
|
425
|
-
response = RestClient.get(url, get_headers(
|
400
|
+
response = RestClient.get(url, get_headers())
|
426
401
|
Components::Promocode.create(JSON.parse(response.body))
|
427
402
|
end
|
428
403
|
|
429
404
|
|
430
405
|
# Create a new promocode for an event
|
431
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
432
406
|
# @param [Integer] event_id - id of event to be associated with the promocode
|
433
407
|
# @param [Promocode] promocode - promocode to be created
|
434
408
|
# @return [Promocode]
|
435
|
-
def add_promocode(
|
409
|
+
def add_promocode(event_id, promocode)
|
436
410
|
url = Util::Config.get('endpoints.base_url') +
|
437
411
|
sprintf(Util::Config.get('endpoints.event_promocodes'), event_id)
|
438
412
|
url = build_url(url)
|
439
413
|
payload = promocode.to_json
|
440
|
-
response = RestClient.post(url, payload, get_headers(
|
414
|
+
response = RestClient.post(url, payload, get_headers())
|
441
415
|
Components::Promocode.create(JSON.parse(response.body))
|
442
416
|
end
|
443
417
|
|
444
418
|
|
445
419
|
# Delete a specific promocode for an event
|
446
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
447
420
|
# @param [Integer] event_id - id of event to delete a promocode for
|
448
421
|
# @param [Integer] promocode_id - id of promocode to be deleted
|
449
422
|
# @return [Boolean]
|
450
|
-
def delete_promocode(
|
423
|
+
def delete_promocode(event_id, promocode_id)
|
451
424
|
url = Util::Config.get('endpoints.base_url') +
|
452
425
|
sprintf(Util::Config.get('endpoints.event_promocode'), event_id, promocode_id)
|
453
426
|
url = build_url(url)
|
454
|
-
response = RestClient.delete(url, get_headers(
|
427
|
+
response = RestClient.delete(url, get_headers())
|
455
428
|
response.code == 204
|
456
429
|
end
|
457
430
|
|
458
431
|
|
459
432
|
# Update a specific promocode for an event
|
460
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
461
433
|
# @param [Integer] event_id - id of event associated with the promocode
|
462
434
|
# @param [Promocode] promocode - promocode to be updated
|
463
435
|
# @return [Promocode]
|
464
|
-
def update_promocode(
|
436
|
+
def update_promocode(event_id, promocode)
|
465
437
|
url = Util::Config.get('endpoints.base_url') +
|
466
438
|
sprintf(Util::Config.get('endpoints.event_promocode'), event_id, promocode.id)
|
467
439
|
url = build_url(url)
|
468
440
|
payload = promocode.to_json
|
469
|
-
response = RestClient.put(url, payload, get_headers(
|
441
|
+
response = RestClient.put(url, payload, get_headers())
|
470
442
|
Components::Promocode.create(JSON.parse(response.body))
|
471
443
|
end
|
472
444
|
|
473
|
-
|
474
445
|
end
|
475
446
|
end
|
476
447
|
end
|