sendgrid4r 1.11.0 → 1.12.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/.rubocop.yml +6 -1
- data/exe/sg +5 -0
- data/lib/sendgrid4r/cli/api_keys/api_key.rb +53 -0
- data/lib/sendgrid4r/cli/api_keys/permission.rb +15 -0
- data/lib/sendgrid4r/cli/campaign/campaign.rb +134 -0
- data/lib/sendgrid4r/cli/campaign/contact/contact.rb +25 -0
- data/lib/sendgrid4r/cli/campaign/contact/custom_field.rb +42 -0
- data/lib/sendgrid4r/cli/campaign/contact/list.rb +71 -0
- data/lib/sendgrid4r/cli/campaign/contact/recipient.rb +78 -0
- data/lib/sendgrid4r/cli/campaign/contact/reserved_field.rb +17 -0
- data/lib/sendgrid4r/cli/campaign/contact/segment.rb +96 -0
- data/lib/sendgrid4r/cli/campaign/sender.rb +83 -0
- data/lib/sendgrid4r/cli/cancel_schedules/batch_id.rb +23 -0
- data/lib/sendgrid4r/cli/cancel_schedules/cancel_schedule.rb +55 -0
- data/lib/sendgrid4r/cli/category.rb +16 -0
- data/lib/sendgrid4r/cli/ipam/activity.rb +16 -0
- data/lib/sendgrid4r/cli/ipam/ipam.rb +14 -0
- data/lib/sendgrid4r/cli/ipam/whitelist.rb +39 -0
- data/lib/sendgrid4r/cli/ips/address.rb +48 -0
- data/lib/sendgrid4r/cli/ips/ip.rb +17 -0
- data/lib/sendgrid4r/cli/ips/pool.rb +48 -0
- data/lib/sendgrid4r/cli/ips/warmup.rb +39 -0
- data/lib/sendgrid4r/cli/mail.rb +34 -0
- data/lib/sendgrid4r/cli/settings/enforced_tls.rb +24 -0
- data/lib/sendgrid4r/cli/settings/mail.rb +171 -0
- data/lib/sendgrid4r/cli/settings/partner.rb +34 -0
- data/lib/sendgrid4r/cli/settings/settings.rb +20 -0
- data/lib/sendgrid4r/cli/settings/tracking.rb +92 -0
- data/lib/sendgrid4r/cli/sg.rb +55 -0
- data/lib/sendgrid4r/cli/sg_thor.rb +34 -0
- data/lib/sendgrid4r/cli/stats/advanced.rb +72 -0
- data/lib/sendgrid4r/cli/stats/category.rb +35 -0
- data/lib/sendgrid4r/cli/stats/global.rb +18 -0
- data/lib/sendgrid4r/cli/stats/parse.rb +18 -0
- data/lib/sendgrid4r/cli/stats/stats.rb +23 -0
- data/lib/sendgrid4r/cli/stats/subuser.rb +67 -0
- data/lib/sendgrid4r/cli/subusers/monitor.rb +44 -0
- data/lib/sendgrid4r/cli/subusers/subuser.rb +77 -0
- data/lib/sendgrid4r/cli/suppressions/block.rb +43 -0
- data/lib/sendgrid4r/cli/suppressions/bounce.rb +41 -0
- data/lib/sendgrid4r/cli/suppressions/global_unsubscribe.rb +43 -0
- data/lib/sendgrid4r/cli/suppressions/group.rb +56 -0
- data/lib/sendgrid4r/cli/suppressions/group_unsubscribe.rb +34 -0
- data/lib/sendgrid4r/cli/suppressions/invalid_email.rb +43 -0
- data/lib/sendgrid4r/cli/suppressions/spam_report.rb +43 -0
- data/lib/sendgrid4r/cli/suppressions/suppression.rb +36 -0
- data/lib/sendgrid4r/cli/templates/template.rb +51 -0
- data/lib/sendgrid4r/cli/templates/version.rb +78 -0
- data/lib/sendgrid4r/cli/user.rb +86 -0
- data/lib/sendgrid4r/cli/webhooks/event.rb +53 -0
- data/lib/sendgrid4r/cli/webhooks/parse.rb +15 -0
- data/lib/sendgrid4r/cli/webhooks/webhook.rb +14 -0
- data/lib/sendgrid4r/cli/whitelabel/domain.rb +117 -0
- data/lib/sendgrid4r/cli/whitelabel/ip.rb +52 -0
- data/lib/sendgrid4r/cli/whitelabel/link.rb +96 -0
- data/lib/sendgrid4r/cli/whitelabel/whitelabel.rb +17 -0
- data/lib/sendgrid4r/client.rb +4 -1
- data/lib/sendgrid4r/factory/campaign_factory.rb +1 -1
- data/lib/sendgrid4r/factory/condition_factory.rb +2 -2
- data/lib/sendgrid4r/factory/event_factory.rb +21 -0
- data/lib/sendgrid4r/rest/api_keys_management/api_keys.rb +5 -5
- data/lib/sendgrid4r/rest/api_keys_management/permissions.rb +3 -1
- data/lib/sendgrid4r/rest/blocks.rb +2 -2
- data/lib/sendgrid4r/rest/bounces.rb +2 -2
- data/lib/sendgrid4r/rest/cancel_scheduled_sends.rb +12 -4
- data/lib/sendgrid4r/rest/categories.rb +1 -1
- data/lib/sendgrid4r/rest/email_activity.rb +1 -1
- data/lib/sendgrid4r/rest/invalid_emails.rb +2 -2
- data/lib/sendgrid4r/rest/ip_access_management.rb +12 -4
- data/lib/sendgrid4r/rest/ips/addresses.rb +4 -4
- data/lib/sendgrid4r/rest/ips/pools.rb +4 -4
- data/lib/sendgrid4r/rest/ips/warmup.rb +3 -3
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/custom_fields.rb +9 -3
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb +7 -5
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/recipients.rb +22 -7
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/reserved_fields.rb +3 -1
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/segments.rb +7 -5
- data/lib/sendgrid4r/rest/marketing_campaigns/marketing_campaigns.rb +8 -8
- data/lib/sendgrid4r/rest/marketing_campaigns/senders.rb +4 -4
- data/lib/sendgrid4r/rest/request.rb +6 -4
- data/lib/sendgrid4r/rest/settings/enforced_tls.rb +6 -2
- data/lib/sendgrid4r/rest/settings/mail.rb +71 -17
- data/lib/sendgrid4r/rest/settings/partner.rb +3 -3
- data/lib/sendgrid4r/rest/settings/tracking.rb +17 -9
- data/lib/sendgrid4r/rest/sm/global_unsubscribes.rb +5 -3
- data/lib/sendgrid4r/rest/sm/groups.rb +4 -4
- data/lib/sendgrid4r/rest/sm/suppressions.rb +6 -3
- data/lib/sendgrid4r/rest/spam_reports.rb +2 -2
- data/lib/sendgrid4r/rest/stats/advanced.rb +8 -8
- data/lib/sendgrid4r/rest/stats/category.rb +2 -2
- data/lib/sendgrid4r/rest/stats/global.rb +1 -1
- data/lib/sendgrid4r/rest/stats/parse.rb +1 -1
- data/lib/sendgrid4r/rest/stats/subuser.rb +4 -4
- data/lib/sendgrid4r/rest/subusers.rb +15 -10
- data/lib/sendgrid4r/rest/transactional_templates/templates.rb +12 -4
- data/lib/sendgrid4r/rest/transactional_templates/versions.rb +4 -4
- data/lib/sendgrid4r/rest/users.rb +9 -9
- data/lib/sendgrid4r/rest/webhooks/event.rb +2 -2
- data/lib/sendgrid4r/rest/webhooks/parse.rb +1 -1
- data/lib/sendgrid4r/rest/whitelabel/domains.rb +10 -11
- data/lib/sendgrid4r/rest/whitelabel/ips.rb +4 -4
- data/lib/sendgrid4r/rest/whitelabel/links.rb +8 -8
- data/lib/sendgrid4r/version.rb +1 -1
- data/lib/sendgrid4r.rb +57 -0
- data/sendgrid4r.gemspec +3 -1
- data/spec/cli/api_keys/api_key_spec.rb +77 -0
- data/spec/cli/api_keys/permission_spec.rb +29 -0
- data/spec/cli/campaign/campaign_spec.rb +136 -0
- data/spec/cli/campaign/contact/custom_field_spec.rb +48 -0
- data/spec/cli/campaign/contact/list_spec.rb +88 -0
- data/spec/cli/campaign/contact/recipient_spec.rb +93 -0
- data/spec/cli/campaign/contact/reserved_field_spec.rb +20 -0
- data/spec/cli/campaign/contact/segment_spec.rb +93 -0
- data/spec/cli/campaign/sender_spec.rb +83 -0
- data/spec/cli/cancel_schedules/batch_id_spec.rb +33 -0
- data/spec/cli/cancel_schedules/cancel_schedule_spec.rb +69 -0
- data/spec/cli/category_spec.rb +23 -0
- data/spec/cli/ipam/activity_spec.rb +21 -0
- data/spec/cli/ipam/ipam_spec.rb +26 -0
- data/spec/cli/ipam/whitelist_spec.rb +47 -0
- data/spec/cli/ips/address_spec.rb +57 -0
- data/spec/cli/ips/ip_spec.rb +33 -0
- data/spec/cli/ips/pool_spec.rb +57 -0
- data/spec/cli/ips/warmup_spec.rb +47 -0
- data/spec/cli/mail_spec.rb +37 -0
- data/spec/cli/settings/enforced_tls_spec.rb +30 -0
- data/spec/cli/settings/mail_spec.rb +255 -0
- data/spec/cli/settings/partner_spec.rb +47 -0
- data/spec/cli/settings/settings_spec.rb +40 -0
- data/spec/cli/settings/tracking_spec.rb +128 -0
- data/spec/cli/sg_spec.rb +82 -0
- data/spec/cli/stats/advanced_spec.rb +137 -0
- data/spec/cli/stats/category_spec.rb +57 -0
- data/spec/cli/stats/global_spec.rb +32 -0
- data/spec/cli/stats/parse_spec.rb +32 -0
- data/spec/cli/stats/stats_spec.rb +40 -0
- data/spec/cli/stats/subuser_spec.rb +104 -0
- data/spec/cli/subusers/monitor_spec.rb +52 -0
- data/spec/cli/subusers/subuser_spec.rb +88 -0
- data/spec/cli/suppressions/block_spec.rb +60 -0
- data/spec/cli/suppressions/bounce_spec.rb +58 -0
- data/spec/cli/suppressions/global_unsubscribe_spec.rb +59 -0
- data/spec/cli/suppressions/group_spec.rb +69 -0
- data/spec/cli/suppressions/group_unsubscribe_spec.rb +41 -0
- data/spec/cli/suppressions/invalid_email_spec.rb +60 -0
- data/spec/cli/suppressions/spam_report_spec.rb +60 -0
- data/spec/cli/suppressions/suppression_spec.rb +68 -0
- data/spec/cli/templates/template_spec.rb +65 -0
- data/spec/cli/templates/version_spec.rb +71 -0
- data/spec/cli/user_spec.rb +82 -0
- data/spec/cli/webhooks/event_spec.rb +67 -0
- data/spec/cli/webhooks/parse_spec.rb +20 -0
- data/spec/cli/webhooks/webhook_spec.rb +28 -0
- data/spec/cli/whitelabel/domain_spec.rb +112 -0
- data/spec/cli/whitelabel/ip_spec.rb +61 -0
- data/spec/cli/whitelabel/link_spec.rb +110 -0
- data/spec/cli/whitelabel/whitelabel_spec.rb +27 -0
- data/spec/client_spec.rb +1 -1
- data/spec/factory/campaign_factory_spec.rb +2 -2
- data/spec/factory/event_factory_spec.rb +36 -0
- data/spec/rest/api_keys_management/api_keys_spec.rb +24 -24
- data/spec/rest/api_keys_management/permissions_spec.rb +8 -10
- data/spec/rest/blocks_spec.rb +14 -18
- data/spec/rest/bounces_spec.rb +28 -32
- data/spec/rest/cancel_scheduled_sends_spec.rb +15 -19
- data/spec/rest/categories_spec.rb +8 -10
- data/spec/rest/email_activity_spec.rb +18 -22
- data/spec/rest/invalid_emails_spec.rb +19 -23
- data/spec/rest/ip_access_management_spec.rb +46 -52
- data/spec/rest/ips/addresses_spec.rb +21 -25
- data/spec/rest/ips/pools_spec.rb +20 -24
- data/spec/rest/ips/warmup_spec.rb +11 -15
- data/spec/rest/marketing_campaigns/contacts/custom_fields_spec.rb +26 -30
- data/spec/rest/marketing_campaigns/contacts/lists_spec.rb +58 -66
- data/spec/rest/marketing_campaigns/contacts/recipients_spec.rb +77 -87
- data/spec/rest/marketing_campaigns/contacts/reserved_fields_spec.rb +46 -50
- data/spec/rest/marketing_campaigns/contacts/segments_spec.rb +75 -78
- data/spec/rest/marketing_campaigns/marketing_campaigns_spec.rb +92 -94
- data/spec/rest/marketing_campaigns/senders_spec.rb +51 -51
- data/spec/rest/settings/enforced_tls_spec.rb +5 -7
- data/spec/rest/settings/mail_spec.rb +89 -60
- data/spec/rest/settings/partner_spec.rb +5 -7
- data/spec/rest/settings/settings_spec.rb +18 -22
- data/spec/rest/settings/tracking_spec.rb +26 -34
- data/spec/rest/sm/global_unsubscribes_spec.rb +9 -13
- data/spec/rest/sm/groups_spec.rb +24 -28
- data/spec/rest/sm/sm_spec.rb +15 -15
- data/spec/rest/sm/suppressions_spec.rb +34 -44
- data/spec/rest/spam_reports_spec.rb +19 -23
- data/spec/rest/stats/advanced_spec.rb +4 -4
- data/spec/rest/stats/global_spec.rb +0 -21
- data/spec/rest/subusers_spec.rb +38 -47
- data/spec/rest/transactional_templates/templates_spec.rb +29 -33
- data/spec/rest/transactional_templates/versions_spec.rb +11 -93
- data/spec/rest/users_spec.rb +42 -54
- data/spec/rest/webhooks/event_spec.rb +16 -18
- data/spec/rest/webhooks/parse_spec.rb +16 -20
- data/spec/rest/whitelabel/domains_spec.rb +93 -100
- data/spec/rest/whitelabel/ips_spec.rb +28 -32
- data/spec/rest/whitelabel/links_spec.rb +41 -45
- metadata +181 -4
|
@@ -37,11 +37,15 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
|
|
|
37
37
|
end
|
|
38
38
|
# post a custom field and a segment
|
|
39
39
|
@client.post_custom_field(name: @field, type: 'text')
|
|
40
|
-
@
|
|
41
|
-
field: @field, value: @value, operator: @operator
|
|
40
|
+
@condition1 = @condition_factory.create(
|
|
41
|
+
field: @field, value: @value, operator: @operator
|
|
42
|
+
)
|
|
43
|
+
@condition2 = @condition_factory.create(
|
|
44
|
+
field: @field, value: @value, operator: @operator, and_or: 'and'
|
|
42
45
|
)
|
|
43
46
|
params1 = @segment_factory.create(
|
|
44
|
-
name: @name1, list_id: nil,
|
|
47
|
+
name: @name1, list_id: nil,
|
|
48
|
+
conditions: [@condition1, @condition2]
|
|
45
49
|
)
|
|
46
50
|
@segment1 = @client.post_segment(params: params1)
|
|
47
51
|
end
|
|
@@ -50,13 +54,14 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
|
|
|
50
54
|
it '#post_segment' do
|
|
51
55
|
lists = @client.get_lists
|
|
52
56
|
params2 = @segment_factory.create(
|
|
53
|
-
name: @name2, list_id: lists.lists[0].id,
|
|
57
|
+
name: @name2, list_id: lists.lists[0].id,
|
|
58
|
+
conditions: [@condition1, @condition2]
|
|
54
59
|
)
|
|
55
60
|
segment = @client.post_segment(params: params2)
|
|
56
61
|
expect(segment.id).to be_a(Fixnum)
|
|
57
62
|
expect(segment.name).to eq(@name2)
|
|
58
63
|
expect(segment.list_id).to eq(lists.lists[0].id)
|
|
59
|
-
expect(segment.conditions.length).to eq(
|
|
64
|
+
expect(segment.conditions.length).to eq(2)
|
|
60
65
|
expect(segment.recipient_count).to eq(0)
|
|
61
66
|
condition = segment.conditions[0]
|
|
62
67
|
expect(condition.field).to eq(@field)
|
|
@@ -88,7 +93,7 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
|
|
|
88
93
|
|
|
89
94
|
it '#patch_segment' do
|
|
90
95
|
edit_params = @segment_factory.create(
|
|
91
|
-
name: @edit_name1, conditions: [@
|
|
96
|
+
name: @edit_name1, conditions: [@condition1, @condition2]
|
|
92
97
|
)
|
|
93
98
|
edit_segment = @client.patch_segment(
|
|
94
99
|
segment_id: @segment1.id, params: edit_params
|
|
@@ -117,84 +122,76 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
|
|
|
117
122
|
end
|
|
118
123
|
|
|
119
124
|
let(:condition) do
|
|
120
|
-
|
|
121
|
-
'
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
'}'
|
|
127
|
-
)
|
|
125
|
+
'{'\
|
|
126
|
+
'"field": "last_name",'\
|
|
127
|
+
'"value": "Miller",'\
|
|
128
|
+
'"operator": "eq",'\
|
|
129
|
+
'"and_or": ""'\
|
|
130
|
+
'}'
|
|
128
131
|
end
|
|
129
132
|
|
|
130
133
|
let(:segment) do
|
|
131
|
-
|
|
132
|
-
'
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
'
|
|
137
|
-
'
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
'}'
|
|
146
|
-
)
|
|
134
|
+
'{'\
|
|
135
|
+
'"id": 1,'\
|
|
136
|
+
'"name": "Last Name Miller",'\
|
|
137
|
+
'"list_id": 4,'\
|
|
138
|
+
'"conditions": ['\
|
|
139
|
+
'{'\
|
|
140
|
+
'"field": "last_name",'\
|
|
141
|
+
'"value": "Miller",'\
|
|
142
|
+
'"operator": "eq",'\
|
|
143
|
+
'"and_or": ""'\
|
|
144
|
+
'}'\
|
|
145
|
+
'],'\
|
|
146
|
+
'"recipient_count": 1'\
|
|
147
|
+
'}'
|
|
147
148
|
end
|
|
148
149
|
|
|
149
150
|
let(:segments) do
|
|
150
|
-
|
|
151
|
-
'
|
|
152
|
-
'
|
|
153
|
-
'
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
'
|
|
158
|
-
'
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
'}'
|
|
169
|
-
)
|
|
151
|
+
'{'\
|
|
152
|
+
'"segments": ['\
|
|
153
|
+
'{'\
|
|
154
|
+
'"id": 1,'\
|
|
155
|
+
'"name": "Last Name Miller",'\
|
|
156
|
+
'"list_id": 4,'\
|
|
157
|
+
'"conditions": ['\
|
|
158
|
+
'{'\
|
|
159
|
+
'"field": "last_name",'\
|
|
160
|
+
'"value": "Miller",'\
|
|
161
|
+
'"operator": "eq",'\
|
|
162
|
+
'"and_or": ""'\
|
|
163
|
+
'}'\
|
|
164
|
+
'],'\
|
|
165
|
+
'"recipient_count": 1'\
|
|
166
|
+
'}'\
|
|
167
|
+
']'\
|
|
168
|
+
'}'
|
|
170
169
|
end
|
|
171
170
|
|
|
172
171
|
let(:recipients) do
|
|
173
|
-
|
|
174
|
-
'
|
|
175
|
-
'
|
|
176
|
-
'
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
'
|
|
187
|
-
'
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
'}'
|
|
197
|
-
)
|
|
172
|
+
'{'\
|
|
173
|
+
'"recipients": ['\
|
|
174
|
+
'{'\
|
|
175
|
+
'"created_at": 1422313607,'\
|
|
176
|
+
'"email": "jones@example.com",'\
|
|
177
|
+
'"first_name": null,'\
|
|
178
|
+
'"id": "jones@example.com",'\
|
|
179
|
+
'"last_clicked": null,'\
|
|
180
|
+
'"last_emailed": null,'\
|
|
181
|
+
'"last_name": "Jones",'\
|
|
182
|
+
'"last_opened": null,'\
|
|
183
|
+
'"updated_at": 1422313790,'\
|
|
184
|
+
'"custom_fields": ['\
|
|
185
|
+
'{'\
|
|
186
|
+
'"id": 23,'\
|
|
187
|
+
'"name": "pet",'\
|
|
188
|
+
'"value": "Fluffy",'\
|
|
189
|
+
'"type": "text"'\
|
|
190
|
+
'}'\
|
|
191
|
+
']'\
|
|
192
|
+
'}'\
|
|
193
|
+
']'\
|
|
194
|
+
'}'
|
|
198
195
|
end
|
|
199
196
|
|
|
200
197
|
it '#post_segment' do
|
|
@@ -234,7 +231,7 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
|
|
|
234
231
|
end
|
|
235
232
|
|
|
236
233
|
it 'creates condition instance' do
|
|
237
|
-
actual = Segments.create_condition(condition)
|
|
234
|
+
actual = Segments.create_condition(JSON.parse(condition))
|
|
238
235
|
expect(actual).to be_a(Segments::Condition)
|
|
239
236
|
expect(actual.field).to eq('last_name')
|
|
240
237
|
expect(actual.value).to eq('Miller')
|
|
@@ -243,7 +240,7 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
|
|
|
243
240
|
end
|
|
244
241
|
|
|
245
242
|
it 'creates segment instance' do
|
|
246
|
-
actual = Segments.create_segment(segment)
|
|
243
|
+
actual = Segments.create_segment(JSON.parse(segment))
|
|
247
244
|
expect(actual).to be_a(Segments::Segment)
|
|
248
245
|
expect(actual.id).to eq(1)
|
|
249
246
|
expect(actual.name).to eq('Last Name Miller')
|
|
@@ -256,7 +253,7 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
|
|
|
256
253
|
end
|
|
257
254
|
|
|
258
255
|
it 'creates segments instance' do
|
|
259
|
-
actual = Segments.create_segments(segments)
|
|
256
|
+
actual = Segments.create_segments(JSON.parse(segments))
|
|
260
257
|
expect(actual).to be_a(Segments::Segments)
|
|
261
258
|
expect(actual.segments).to be_a(Array)
|
|
262
259
|
actual.segments.each do |segment|
|
|
@@ -210,105 +210,97 @@ module SendGrid4r::REST::MarketingCampaigns
|
|
|
210
210
|
end
|
|
211
211
|
|
|
212
212
|
let(:campaign) do
|
|
213
|
-
|
|
214
|
-
'
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
'
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
'
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
'"
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
'
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
'}'
|
|
237
|
-
)
|
|
213
|
+
'{'\
|
|
214
|
+
'"id": 986724,'\
|
|
215
|
+
'"title": "March Newsletter",'\
|
|
216
|
+
'"subject": "New Products for Spring!",'\
|
|
217
|
+
'"sender_id": 124451,'\
|
|
218
|
+
'"list_ids": ['\
|
|
219
|
+
'110,'\
|
|
220
|
+
'124'\
|
|
221
|
+
'],'\
|
|
222
|
+
'"segment_ids": ['\
|
|
223
|
+
'110'\
|
|
224
|
+
'],'\
|
|
225
|
+
'"categories": ['\
|
|
226
|
+
'"spring line"'\
|
|
227
|
+
'],'\
|
|
228
|
+
'"suppression_group_id": 42,'\
|
|
229
|
+
'"custom_unsubscribe_url": "",'\
|
|
230
|
+
'"ip_pool": "marketing",'\
|
|
231
|
+
'"html_content": "<html><head><title></title></head><body>'\
|
|
232
|
+
'<p>Check out our spring line!</p></body></html>",'\
|
|
233
|
+
'"plain_content": "Check out our spring line!",'\
|
|
234
|
+
'"status": "Draft"'\
|
|
235
|
+
'}'
|
|
238
236
|
end
|
|
239
237
|
|
|
240
238
|
let(:campaigns) do
|
|
241
|
-
|
|
242
|
-
'
|
|
243
|
-
'
|
|
244
|
-
'
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
'
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
'
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
'"
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
'
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
'
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
'
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
'
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
'"
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
'
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
'}'
|
|
292
|
-
)
|
|
239
|
+
'{'\
|
|
240
|
+
'"result": ['\
|
|
241
|
+
'{'\
|
|
242
|
+
'"id": 986724,'\
|
|
243
|
+
'"title": "March Newsletter",'\
|
|
244
|
+
'"subject": "New Products for Spring!",'\
|
|
245
|
+
'"sender_id": 124451,'\
|
|
246
|
+
'"list_ids": ['\
|
|
247
|
+
'110,'\
|
|
248
|
+
'124'\
|
|
249
|
+
'],'\
|
|
250
|
+
'"segment_ids": ['\
|
|
251
|
+
'110'\
|
|
252
|
+
'],'\
|
|
253
|
+
'"categories": ['\
|
|
254
|
+
'"spring line"'\
|
|
255
|
+
'],'\
|
|
256
|
+
'"suppression_group_id": 42,'\
|
|
257
|
+
'"custom_unsubscribe_url": "",'\
|
|
258
|
+
'"ip_pool": "marketing",'\
|
|
259
|
+
'"html_content": "<html><head><title></title></head><body>'\
|
|
260
|
+
'<p>Check out our spring line!</p></body></html>",'\
|
|
261
|
+
'"plain_content": "Check out our spring line!",'\
|
|
262
|
+
'"status": "Draft"'\
|
|
263
|
+
'},'\
|
|
264
|
+
'{'\
|
|
265
|
+
'"id": 986723,'\
|
|
266
|
+
'"title": "February Newsletter",'\
|
|
267
|
+
'"subject": "Final Winter Product Sale!",'\
|
|
268
|
+
'"sender_id": 124451,'\
|
|
269
|
+
'"list_ids": ['\
|
|
270
|
+
'110,'\
|
|
271
|
+
'124'\
|
|
272
|
+
'],'\
|
|
273
|
+
'"segment_ids": ['\
|
|
274
|
+
'110'\
|
|
275
|
+
'],'\
|
|
276
|
+
'"categories": ['\
|
|
277
|
+
'"winter line"'\
|
|
278
|
+
'],'\
|
|
279
|
+
'"suppression_group_id": 42,'\
|
|
280
|
+
'"custom_unsubscribe_url": "",'\
|
|
281
|
+
'"ip_pool": "marketing",'\
|
|
282
|
+
'"html_content": "<html><head><title></title></head><body>'\
|
|
283
|
+
'<p>Last call for winter clothes!</p></body></html>",'\
|
|
284
|
+
'"plain_content": "Last call for winter clothes!",'\
|
|
285
|
+
'"status": "Sent"'\
|
|
286
|
+
'}'\
|
|
287
|
+
']'\
|
|
288
|
+
'}'
|
|
293
289
|
end
|
|
294
290
|
|
|
295
291
|
let(:sent) do
|
|
296
|
-
|
|
297
|
-
'
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
'}'
|
|
301
|
-
)
|
|
292
|
+
'{'\
|
|
293
|
+
'"id": 986724,'\
|
|
294
|
+
'"status": "Scheduled"'\
|
|
295
|
+
'}'
|
|
302
296
|
end
|
|
303
297
|
|
|
304
298
|
let(:schedule) do
|
|
305
|
-
|
|
306
|
-
'
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
'}'
|
|
311
|
-
)
|
|
299
|
+
'{'\
|
|
300
|
+
'"id": 986724,'\
|
|
301
|
+
'"send_at": 1489771528,'\
|
|
302
|
+
'"status": "Scheduled"'\
|
|
303
|
+
'}'
|
|
312
304
|
end
|
|
313
305
|
|
|
314
306
|
it '#post_campaign' do
|
|
@@ -379,7 +371,9 @@ module SendGrid4r::REST::MarketingCampaigns
|
|
|
379
371
|
end
|
|
380
372
|
|
|
381
373
|
it 'creates campaign instance' do
|
|
382
|
-
actual = SendGrid4r::REST::MarketingCampaigns.create_campaign(
|
|
374
|
+
actual = SendGrid4r::REST::MarketingCampaigns.create_campaign(
|
|
375
|
+
JSON.parse(campaign)
|
|
376
|
+
)
|
|
383
377
|
expect(actual).to be_a(Campaign)
|
|
384
378
|
expect(actual.id).to eq(986724)
|
|
385
379
|
expect(actual.title).to eq('March Newsletter')
|
|
@@ -400,7 +394,7 @@ module SendGrid4r::REST::MarketingCampaigns
|
|
|
400
394
|
|
|
401
395
|
it 'creates campaigns instance' do
|
|
402
396
|
actual = SendGrid4r::REST::MarketingCampaigns.create_campaigns(
|
|
403
|
-
campaigns
|
|
397
|
+
JSON.parse(campaigns)
|
|
404
398
|
)
|
|
405
399
|
expect(actual).to be_a(Campaigns)
|
|
406
400
|
actual.result.each do |campaign|
|
|
@@ -409,14 +403,18 @@ module SendGrid4r::REST::MarketingCampaigns
|
|
|
409
403
|
end
|
|
410
404
|
|
|
411
405
|
it 'creates sent instance' do
|
|
412
|
-
actual = SendGrid4r::REST::MarketingCampaigns.create_campaign(
|
|
406
|
+
actual = SendGrid4r::REST::MarketingCampaigns.create_campaign(
|
|
407
|
+
JSON.parse(sent)
|
|
408
|
+
)
|
|
413
409
|
expect(actual).to be_a(Campaign)
|
|
414
410
|
expect(actual.id).to eq(986724)
|
|
415
411
|
expect(actual.status).to eq('Scheduled')
|
|
416
412
|
end
|
|
417
413
|
|
|
418
414
|
it 'creates schedule instance' do
|
|
419
|
-
actual = SendGrid4r::REST::MarketingCampaigns.create_campaign(
|
|
415
|
+
actual = SendGrid4r::REST::MarketingCampaigns.create_campaign(
|
|
416
|
+
JSON.parse(schedule)
|
|
417
|
+
)
|
|
420
418
|
expect(actual).to be_a(Campaign)
|
|
421
419
|
expect(actual.id).to eq(986724)
|
|
422
420
|
expect(actual.send_at).to eq(Time.at(1489771528))
|
|
@@ -87,61 +87,57 @@ module SendGrid4r::REST::MarketingCampaigns
|
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
let(:sender) do
|
|
90
|
-
|
|
90
|
+
'{'\
|
|
91
|
+
'"id": 1,'\
|
|
92
|
+
'"nickname": "My Sender ID",'\
|
|
93
|
+
'"from": {'\
|
|
94
|
+
'"email": "from@example.com",'\
|
|
95
|
+
'"name": "Example INC"'\
|
|
96
|
+
'},'\
|
|
97
|
+
'"reply_to": {'\
|
|
98
|
+
'"email": "replyto@example.com",'\
|
|
99
|
+
'"name": "Example INC"'\
|
|
100
|
+
'},'\
|
|
101
|
+
'"address": "123 Elm St.",'\
|
|
102
|
+
'"address_2": "Apt. 456",'\
|
|
103
|
+
'"city": "Denver",'\
|
|
104
|
+
'"state": "Colorado",'\
|
|
105
|
+
'"zip": "80202",'\
|
|
106
|
+
'"country": "United States",'\
|
|
107
|
+
'"verified":{'\
|
|
108
|
+
'"status":false,"reason":null'\
|
|
109
|
+
'},'\
|
|
110
|
+
'"updated_at": 1449872165,'\
|
|
111
|
+
'"created_at": 1449872165,'\
|
|
112
|
+
'"locked": false'\
|
|
113
|
+
'}'
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
let(:senders) do
|
|
117
|
+
'['\
|
|
91
118
|
'{'\
|
|
92
|
-
'"id":
|
|
93
|
-
'"nickname":
|
|
94
|
-
'"from":
|
|
95
|
-
'"email":
|
|
96
|
-
'"name": "Example INC"'\
|
|
119
|
+
'"id":1,'\
|
|
120
|
+
'"nickname":"My Sender ID",'\
|
|
121
|
+
'"from":{'\
|
|
122
|
+
'"email":"from@example.com","name":"Example INC"'\
|
|
97
123
|
'},'\
|
|
98
|
-
'"reply_to":
|
|
99
|
-
'"email":
|
|
100
|
-
'"name": "Example INC"'\
|
|
124
|
+
'"reply_to":{'\
|
|
125
|
+
'"email":"replyto@example.com","name":"Example INC"'\
|
|
101
126
|
'},'\
|
|
102
|
-
'"address":
|
|
103
|
-
'"address_2":
|
|
104
|
-
'"city":
|
|
105
|
-
'"state":
|
|
106
|
-
'"zip":
|
|
107
|
-
'"country":
|
|
127
|
+
'"address":"123 Elm St.",'\
|
|
128
|
+
'"address_2":"Apt. 456",'\
|
|
129
|
+
'"city":"Denver",'\
|
|
130
|
+
'"state":"Co",'\
|
|
131
|
+
'"zip":"80202",'\
|
|
132
|
+
'"country":"United States",'\
|
|
108
133
|
'"verified":{'\
|
|
109
134
|
'"status":false,"reason":null'\
|
|
110
135
|
'},'\
|
|
111
|
-
'"updated_at":
|
|
112
|
-
'"created_at":
|
|
113
|
-
'"locked":
|
|
114
|
-
'}'
|
|
115
|
-
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
let(:senders) do
|
|
119
|
-
JSON.parse(
|
|
120
|
-
'['\
|
|
121
|
-
'{'\
|
|
122
|
-
'"id":1,'\
|
|
123
|
-
'"nickname":"My Sender ID",'\
|
|
124
|
-
'"from":{'\
|
|
125
|
-
'"email":"from@example.com","name":"Example INC"'\
|
|
126
|
-
'},'\
|
|
127
|
-
'"reply_to":{'\
|
|
128
|
-
'"email":"replyto@example.com","name":"Example INC"'\
|
|
129
|
-
'},'\
|
|
130
|
-
'"address":"123 Elm St.",'\
|
|
131
|
-
'"address_2":"Apt. 456",'\
|
|
132
|
-
'"city":"Denver",'\
|
|
133
|
-
'"state":"Co",'\
|
|
134
|
-
'"zip":"80202",'\
|
|
135
|
-
'"country":"United States",'\
|
|
136
|
-
'"verified":{'\
|
|
137
|
-
'"status":false,"reason":null'\
|
|
138
|
-
'},'\
|
|
139
|
-
'"updated_at":1464187035,'\
|
|
140
|
-
'"created_at":1464187035,'\
|
|
141
|
-
'"locked":false'\
|
|
142
|
-
'}'\
|
|
143
|
-
']'
|
|
144
|
-
)
|
|
136
|
+
'"updated_at":1464187035,'\
|
|
137
|
+
'"created_at":1464187035,'\
|
|
138
|
+
'"locked":false'\
|
|
139
|
+
'}'\
|
|
140
|
+
']'
|
|
145
141
|
end
|
|
146
142
|
|
|
147
143
|
it '#post_sender' do
|
|
@@ -182,7 +178,9 @@ module SendGrid4r::REST::MarketingCampaigns
|
|
|
182
178
|
end
|
|
183
179
|
|
|
184
180
|
it 'creates sender instance' do
|
|
185
|
-
actual = SendGrid4r::REST::MarketingCampaigns.create_sender(
|
|
181
|
+
actual = SendGrid4r::REST::MarketingCampaigns.create_sender(
|
|
182
|
+
JSON.parse(sender)
|
|
183
|
+
)
|
|
186
184
|
expect(actual).to be_a(Sender)
|
|
187
185
|
expect(actual.id).to eq(1)
|
|
188
186
|
expect(actual.nickname).to eq('My Sender ID')
|
|
@@ -204,7 +202,9 @@ module SendGrid4r::REST::MarketingCampaigns
|
|
|
204
202
|
end
|
|
205
203
|
|
|
206
204
|
it 'creates senders instance' do
|
|
207
|
-
actual = SendGrid4r::REST::MarketingCampaigns.create_senders(
|
|
205
|
+
actual = SendGrid4r::REST::MarketingCampaigns.create_senders(
|
|
206
|
+
JSON.parse(senders)
|
|
207
|
+
)
|
|
208
208
|
expect(actual).to be_a(Array)
|
|
209
209
|
sender = actual[0]
|
|
210
210
|
expect(sender.id).to eq(1)
|