sendgrid4r 1.11.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -150,79 +150,71 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
150
150
  end
151
151
 
152
152
  let(:list) do
153
- JSON.parse(
154
- '{'\
155
- '"id": 1,'\
156
- '"name": "listname",'\
157
- '"recipient_count": 0'\
158
- '}'
159
- )
153
+ '{'\
154
+ '"id": 1,'\
155
+ '"name": "listname",'\
156
+ '"recipient_count": 0'\
157
+ '}'
160
158
  end
161
159
 
162
160
  let(:lists) do
163
- JSON.parse(
164
- '{'\
165
- '"lists": ['\
166
- '{'\
167
- '"id": 1,'\
168
- '"name": "the jones",'\
169
- '"recipient_count": 1'\
170
- '}'\
171
- ']'\
172
- '}'
173
- )
161
+ '{'\
162
+ '"lists": ['\
163
+ '{'\
164
+ '"id": 1,'\
165
+ '"name": "the jones",'\
166
+ '"recipient_count": 1'\
167
+ '}'\
168
+ ']'\
169
+ '}'
174
170
  end
175
171
 
176
172
  let(:recipient) do
177
- JSON.parse(
178
- '{'\
179
- '"created_at": 1422313607,'\
180
- '"email": "jones@example.com",'\
181
- '"first_name": null,'\
182
- '"id": "jones@example.com",'\
183
- '"last_clicked": null,'\
184
- '"last_emailed": null,'\
185
- '"last_name": "Jones",'\
186
- '"last_opened": null,'\
187
- '"updated_at": 1422313790,'\
188
- '"custom_fields": ['\
189
- '{'\
190
- '"id": 23,'\
191
- '"name": "pet",'\
192
- '"value": "Fluffy",'\
193
- '"type": "text"'\
194
- '}'\
195
- ']'\
196
- '}'
197
- )
173
+ '{'\
174
+ '"created_at": 1422313607,'\
175
+ '"email": "jones@example.com",'\
176
+ '"first_name": null,'\
177
+ '"id": "jones@example.com",'\
178
+ '"last_clicked": null,'\
179
+ '"last_emailed": null,'\
180
+ '"last_name": "Jones",'\
181
+ '"last_opened": null,'\
182
+ '"updated_at": 1422313790,'\
183
+ '"custom_fields": ['\
184
+ '{'\
185
+ '"id": 23,'\
186
+ '"name": "pet",'\
187
+ '"value": "Fluffy",'\
188
+ '"type": "text"'\
189
+ '}'\
190
+ ']'\
191
+ '}'
198
192
  end
199
193
 
200
194
  let(:recipients) do
201
- JSON.parse(
202
- '{'\
203
- '"recipients": ['\
204
- '{'\
205
- '"created_at": 1422313607,'\
206
- '"email": "jones@example.com",'\
207
- '"first_name": null,'\
208
- '"id": "jones@example.com",'\
209
- '"last_clicked": null,'\
210
- '"last_emailed": null,'\
211
- '"last_name": "Jones",'\
212
- '"last_opened": null,'\
213
- '"updated_at": 1422313790,'\
214
- '"custom_fields": ['\
215
- '{'\
216
- '"id": 23,'\
217
- '"name": "pet",'\
218
- '"value": "Fluffy",'\
219
- '"type": "text"'\
220
- '}'\
221
- ']'\
222
- '}'\
223
- ']'\
224
- '}'
225
- )
195
+ '{'\
196
+ '"recipients": ['\
197
+ '{'\
198
+ '"created_at": 1422313607,'\
199
+ '"email": "jones@example.com",'\
200
+ '"first_name": null,'\
201
+ '"id": "jones@example.com",'\
202
+ '"last_clicked": null,'\
203
+ '"last_emailed": null,'\
204
+ '"last_name": "Jones",'\
205
+ '"last_opened": null,'\
206
+ '"updated_at": 1422313790,'\
207
+ '"custom_fields": ['\
208
+ '{'\
209
+ '"id": 23,'\
210
+ '"name": "pet",'\
211
+ '"value": "Fluffy",'\
212
+ '"type": "text"'\
213
+ '}'\
214
+ ']'\
215
+ '}'\
216
+ ']'\
217
+ '}'
226
218
  end
227
219
 
228
220
  it '#post_list' do
@@ -288,7 +280,7 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
288
280
  end
289
281
 
290
282
  it 'creates list instance' do
291
- actual = Lists.create_list(list)
283
+ actual = Lists.create_list(JSON.parse(list))
292
284
  expect(actual).to be_a(Lists::List)
293
285
  expect(actual.id).to eq(1)
294
286
  expect(actual.name).to eq('listname')
@@ -296,7 +288,7 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
296
288
  end
297
289
 
298
290
  it 'creates lists instance' do
299
- actual = Lists.create_lists(lists)
291
+ actual = Lists.create_lists(JSON.parse(lists))
300
292
  expect(actual.lists).to be_a(Array)
301
293
  actual.lists.each do |list|
302
294
  expect(list).to be_a(Lists::List)
@@ -128,102 +128,92 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
128
128
  end
129
129
 
130
130
  let(:recipient) do
131
- JSON.parse(
132
- '{'\
133
- '"created_at": 1422313607,'\
134
- '"email": "jones@example.com",'\
135
- '"first_name": null,'\
136
- '"id": "YUBh",'\
137
- '"last_clicked": null,'\
138
- '"last_emailed": null,'\
139
- '"last_name": "Jones",'\
140
- '"last_opened": null,'\
141
- '"updated_at": 1422313790,'\
142
- '"custom_fields": ['\
143
- '{'\
144
- '"id": 23,'\
145
- '"name": "pet",'\
146
- '"value": "Fluffy",'\
147
- '"type": "text"'\
148
- '}'\
149
- ']'\
150
- '}'
151
- )
131
+ '{'\
132
+ '"created_at": 1422313607,'\
133
+ '"email": "jones@example.com",'\
134
+ '"first_name": null,'\
135
+ '"id": "YUBh",'\
136
+ '"last_clicked": null,'\
137
+ '"last_emailed": null,'\
138
+ '"last_name": "Jones",'\
139
+ '"last_opened": null,'\
140
+ '"updated_at": 1422313790,'\
141
+ '"custom_fields": ['\
142
+ '{'\
143
+ '"id": 23,'\
144
+ '"name": "pet",'\
145
+ '"value": "Fluffy",'\
146
+ '"type": "text"'\
147
+ '}'\
148
+ ']'\
149
+ '}'
152
150
  end
153
151
 
154
152
  let(:recipients) do
155
- JSON.parse(
156
- '{'\
157
- '"recipients": ['\
158
- '{'\
159
- '"created_at": 1422313607,'\
160
- '"email": "jones@example.com",'\
161
- '"first_name": null,'\
162
- '"id": "YUBh",'\
163
- '"last_clicked": null,'\
164
- '"last_emailed": null,'\
165
- '"last_name": "Jones",'\
166
- '"last_opened": null,'\
167
- '"updated_at": 1422313790,'\
168
- '"custom_fields": ['\
169
- '{'\
170
- '"id": 23,'\
171
- '"name": "pet",'\
172
- '"value": "Fluffy",'\
173
- '"type": "text"'\
174
- '}'\
175
- ']'\
176
- '}'\
177
- ']'\
178
- '}'
179
- )
153
+ '{'\
154
+ '"recipients": ['\
155
+ '{'\
156
+ '"created_at": 1422313607,'\
157
+ '"email": "jones@example.com",'\
158
+ '"first_name": null,'\
159
+ '"id": "YUBh",'\
160
+ '"last_clicked": null,'\
161
+ '"last_emailed": null,'\
162
+ '"last_name": "Jones",'\
163
+ '"last_opened": null,'\
164
+ '"updated_at": 1422313790,'\
165
+ '"custom_fields": ['\
166
+ '{'\
167
+ '"id": 23,'\
168
+ '"name": "pet",'\
169
+ '"value": "Fluffy",'\
170
+ '"type": "text"'\
171
+ '}'\
172
+ ']'\
173
+ '}'\
174
+ ']'\
175
+ '}'
180
176
  end
181
177
 
182
178
  let(:recipient_count) do
183
- JSON.parse(
184
- '{'\
185
- '"recipient_count": 2'\
186
- '}'
187
- )
179
+ '{'\
180
+ '"recipient_count": 2'\
181
+ '}'
188
182
  end
189
183
 
190
184
  let(:lists) do
191
- JSON.parse(
192
- '{'\
193
- '"lists": ['\
194
- '{'\
195
- '"id": 1,'\
196
- '"name": "the jones",'\
197
- '"recipient_count": 1'\
198
- '}'\
199
- ']'\
200
- '}'
201
- )
185
+ '{'\
186
+ '"lists": ['\
187
+ '{'\
188
+ '"id": 1,'\
189
+ '"name": "the jones",'\
190
+ '"recipient_count": 1'\
191
+ '}'\
192
+ ']'\
193
+ '}'
202
194
  end
203
195
 
204
196
  let(:result) do
205
- JSON.parse(
206
- '{'\
207
- '"error_count": 1,'\
208
- '"error_indices": ['\
209
- '2'\
210
- '],'\
211
- '"new_count": 2,'\
212
- '"persisted_recipients": ['\
213
- '"YUBh",'\
214
- '"bWlsbGVyQG1pbGxlci50ZXN0"'\
215
- '],'\
216
- '"updated_count": 0,'\
217
- '"errors": ['\
218
- '{'\
219
- '"message": "Invalid email.",'\
220
- '"error_indices": ['\
221
- '2'\
222
- ']'\
223
- '}'\
224
- ']'\
225
- '}'
226
- )
197
+ '{'\
198
+ '"error_count": 1,'\
199
+ '"error_indices": ['\
200
+ '2'\
201
+ '],'\
202
+ '"new_count": 2,'\
203
+ '"persisted_recipients": ['\
204
+ '"YUBh",'\
205
+ '"bWlsbGVyQG1pbGxlci50ZXN0"'\
206
+ '],'\
207
+ '"updated_count": 0,'\
208
+ '"errors": ['\
209
+ '{'\
210
+ '"message": "Invalid email.",'\
211
+ '"error_indices": ['\
212
+ '2'\
213
+ ']'\
214
+ '}'\
215
+ ']'\
216
+ '}'
227
217
  end
228
218
 
229
219
  it '#post_recipients' do
@@ -282,7 +272,7 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
282
272
 
283
273
  it 'creates recipient instance' do
284
274
  actual = Recipients.create_recipient(
285
- recipient
275
+ JSON.parse(recipient)
286
276
  )
287
277
  expect(actual).to be_a(Recipients::Recipient)
288
278
  expect(actual.created_at).to eq(Time.at(1422313607))
@@ -302,7 +292,7 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
302
292
  end
303
293
 
304
294
  it 'creates recipients instance' do
305
- actual = Recipients.create_recipients(recipients)
295
+ actual = Recipients.create_recipients(JSON.parse(recipients))
306
296
  expect(actual.recipients).to be_a(Array)
307
297
  actual.recipients.each do |recipient|
308
298
  expect(recipient).to be_a(Recipients::Recipient)
@@ -310,7 +300,7 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
310
300
  end
311
301
 
312
302
  it 'creates result instance' do
313
- actual = Recipients.create_result(result)
303
+ actual = Recipients.create_result(JSON.parse(result))
314
304
  expect(actual.error_count).to eq(1)
315
305
  expect(actual.error_indices).to be_a(Array)
316
306
  expect(actual.error_indices[0]).to eq(2)
@@ -41,57 +41,53 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
41
41
  end
42
42
 
43
43
  let(:field) do
44
- JSON.parse(
45
- '{'\
46
- '"name": "first_name",'\
47
- '"type": "text"'\
48
- '}'
49
- )
44
+ '{'\
45
+ '"name": "first_name",'\
46
+ '"type": "text"'\
47
+ '}'
50
48
  end
51
49
 
52
50
  let(:fields) do
53
- JSON.parse(
54
- '{'\
55
- '"reserved_fields": ['\
56
- '{'\
57
- '"name": "first_name",'\
58
- '"type": "text"'\
59
- '},'\
60
- '{'\
61
- '"name": "last_name",'\
62
- '"type": "text"'\
63
- '},'\
64
- '{'\
65
- '"name": "email",'\
66
- '"type": "text"'\
67
- '},'\
68
- '{'\
69
- '"name": "created_at",'\
70
- '"type": "date"'\
71
- '},'\
72
- '{'\
73
- '"name": "updated_at",'\
74
- '"type": "date"'\
75
- '},'\
76
- '{'\
77
- '"name": "last_emailed",'\
78
- '"type": "date"'\
79
- '},'\
80
- '{'\
81
- '"name": "last_clicked",'\
82
- '"type": "date"'\
83
- '},'\
84
- '{'\
85
- '"name": "last_opened",'\
86
- '"type": "date"'\
87
- '},'\
88
- '{'\
89
- '"name": "my_custom_field",'\
90
- '"type": "text"'\
91
- '}'\
92
- ']'\
93
- '}'
94
- )
51
+ '{'\
52
+ '"reserved_fields": ['\
53
+ '{'\
54
+ '"name": "first_name",'\
55
+ '"type": "text"'\
56
+ '},'\
57
+ '{'\
58
+ '"name": "last_name",'\
59
+ '"type": "text"'\
60
+ '},'\
61
+ '{'\
62
+ '"name": "email",'\
63
+ '"type": "text"'\
64
+ '},'\
65
+ '{'\
66
+ '"name": "created_at",'\
67
+ '"type": "date"'\
68
+ '},'\
69
+ '{'\
70
+ '"name": "updated_at",'\
71
+ '"type": "date"'\
72
+ '},'\
73
+ '{'\
74
+ '"name": "last_emailed",'\
75
+ '"type": "date"'\
76
+ '},'\
77
+ '{'\
78
+ '"name": "last_clicked",'\
79
+ '"type": "date"'\
80
+ '},'\
81
+ '{'\
82
+ '"name": "last_opened",'\
83
+ '"type": "date"'\
84
+ '},'\
85
+ '{'\
86
+ '"name": "my_custom_field",'\
87
+ '"type": "text"'\
88
+ '}'\
89
+ ']'\
90
+ '}'
95
91
  end
96
92
 
97
93
  it '#get_reserved_fields' do
@@ -101,13 +97,13 @@ module SendGrid4r::REST::MarketingCampaigns::Contacts
101
97
  end
102
98
 
103
99
  it 'creates field instance' do
104
- actual = CustomFields.create_field(field)
100
+ actual = CustomFields.create_field(JSON.parse(field))
105
101
  expect(actual.name).to eq('first_name')
106
102
  expect(actual.type).to eq('text')
107
103
  end
108
104
 
109
105
  it 'creates fields instance' do
110
- actual = ReservedFields.create_fields(fields)
106
+ actual = ReservedFields.create_fields(JSON.parse(fields))
111
107
  expect(actual).to be_a(ReservedFields::Fields)
112
108
  expect(actual.reserved_fields).to be_a(Array)
113
109
  actual.reserved_fields.each do |field|