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