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
|
@@ -83,22 +83,18 @@ module SendGrid4r::REST::Sm
|
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
let(:recipient_emails) do
|
|
86
|
-
|
|
87
|
-
'
|
|
88
|
-
'"
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
'}'
|
|
93
|
-
)
|
|
86
|
+
'{'\
|
|
87
|
+
'"recipient_emails": ['\
|
|
88
|
+
'"test1@example.com",'\
|
|
89
|
+
'"test2@example.com"'\
|
|
90
|
+
']'\
|
|
91
|
+
'}'
|
|
94
92
|
end
|
|
95
93
|
|
|
96
94
|
let(:recipient_email) do
|
|
97
|
-
|
|
98
|
-
'
|
|
99
|
-
|
|
100
|
-
'}'
|
|
101
|
-
)
|
|
95
|
+
'{'\
|
|
96
|
+
'"recipient_email": "test1@example.com"'\
|
|
97
|
+
'}'
|
|
102
98
|
end
|
|
103
99
|
|
|
104
100
|
it '#post_global_suppressed_emails' do
|
data/spec/rest/sm/groups_spec.rb
CHANGED
|
@@ -90,7 +90,18 @@ module SendGrid4r::REST::Sm
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
let(:group) do
|
|
93
|
-
|
|
93
|
+
'{'\
|
|
94
|
+
'"id": 100,'\
|
|
95
|
+
'"name": "Newsletters",'\
|
|
96
|
+
'"description": "Our monthly newsletter.",'\
|
|
97
|
+
'"last_email_sent_at": null,'\
|
|
98
|
+
'"is_default": true,'\
|
|
99
|
+
'"unsubscribes": 400'\
|
|
100
|
+
'}'
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
let(:groups) do
|
|
104
|
+
'['\
|
|
94
105
|
'{'\
|
|
95
106
|
'"id": 100,'\
|
|
96
107
|
'"name": "Newsletters",'\
|
|
@@ -98,31 +109,16 @@ module SendGrid4r::REST::Sm
|
|
|
98
109
|
'"last_email_sent_at": null,'\
|
|
99
110
|
'"is_default": true,'\
|
|
100
111
|
'"unsubscribes": 400'\
|
|
101
|
-
'}'
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
'
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
'"description": "Our monthly newsletter.",'\
|
|
112
|
-
'"last_email_sent_at": null,'\
|
|
113
|
-
'"is_default": true,'\
|
|
114
|
-
'"unsubscribes": 400'\
|
|
115
|
-
'},'\
|
|
116
|
-
'{'\
|
|
117
|
-
'"id": 101,'\
|
|
118
|
-
'"name": "Alerts",'\
|
|
119
|
-
'"description": "Emails triggered by user-defined rules.",'\
|
|
120
|
-
'"last_email_sent_at": null,'\
|
|
121
|
-
'"is_default": false,'\
|
|
122
|
-
'"unsubscribes": 1'\
|
|
123
|
-
'}'\
|
|
124
|
-
']'
|
|
125
|
-
)
|
|
112
|
+
'},'\
|
|
113
|
+
'{'\
|
|
114
|
+
'"id": 101,'\
|
|
115
|
+
'"name": "Alerts",'\
|
|
116
|
+
'"description": "Emails triggered by user-defined rules.",'\
|
|
117
|
+
'"last_email_sent_at": null,'\
|
|
118
|
+
'"is_default": false,'\
|
|
119
|
+
'"unsubscribes": 1'\
|
|
120
|
+
'}'\
|
|
121
|
+
']'
|
|
126
122
|
end
|
|
127
123
|
|
|
128
124
|
it '#post_group' do
|
|
@@ -159,7 +155,7 @@ module SendGrid4r::REST::Sm
|
|
|
159
155
|
end
|
|
160
156
|
|
|
161
157
|
it 'creates group instance' do
|
|
162
|
-
actual = Groups.create_group(group)
|
|
158
|
+
actual = Groups.create_group(JSON.parse(group))
|
|
163
159
|
expect(actual).to be_a(Groups::Group)
|
|
164
160
|
expect(actual.id).to eq(100)
|
|
165
161
|
expect(actual.name).to eq('Newsletters')
|
|
@@ -170,7 +166,7 @@ module SendGrid4r::REST::Sm
|
|
|
170
166
|
end
|
|
171
167
|
|
|
172
168
|
it 'creates groups instance' do
|
|
173
|
-
actual = Groups.create_groups(groups)
|
|
169
|
+
actual = Groups.create_groups(JSON.parse(groups))
|
|
174
170
|
expect(actual).to be_a(Array)
|
|
175
171
|
actual.each do |group|
|
|
176
172
|
expect(group).to be_a(Groups::Group)
|
data/spec/rest/sm/sm_spec.rb
CHANGED
|
@@ -4,27 +4,25 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
|
4
4
|
module SendGrid4r::REST::Sm
|
|
5
5
|
describe SendGrid4r::REST::Sm do
|
|
6
6
|
let(:recipient_email) do
|
|
7
|
-
|
|
8
|
-
'
|
|
9
|
-
|
|
10
|
-
'}'
|
|
11
|
-
)
|
|
7
|
+
'{'\
|
|
8
|
+
'"recipient_email": "test1@example.com"'\
|
|
9
|
+
'}'
|
|
12
10
|
end
|
|
13
11
|
|
|
14
12
|
let(:recipient_emails) do
|
|
15
|
-
|
|
16
|
-
'
|
|
17
|
-
'"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'}'
|
|
22
|
-
)
|
|
13
|
+
'{'\
|
|
14
|
+
'"recipient_emails": ['\
|
|
15
|
+
'"test1@example.com",'\
|
|
16
|
+
'"test2@example.com"'\
|
|
17
|
+
']'\
|
|
18
|
+
'}'
|
|
23
19
|
end
|
|
24
20
|
|
|
25
21
|
describe 'unit test', :ut do
|
|
26
22
|
it 'creates recipient_emails instance' do
|
|
27
|
-
actual = SendGrid4r::REST::Sm.create_recipient_emails(
|
|
23
|
+
actual = SendGrid4r::REST::Sm.create_recipient_emails(
|
|
24
|
+
JSON.parse(recipient_emails)
|
|
25
|
+
)
|
|
28
26
|
expect(actual).to be_a(RecipientEmails)
|
|
29
27
|
expect(actual.recipient_emails).to be_a(Array)
|
|
30
28
|
expect(actual.recipient_emails).to include('test1@example.com')
|
|
@@ -32,7 +30,9 @@ module SendGrid4r::REST::Sm
|
|
|
32
30
|
end
|
|
33
31
|
|
|
34
32
|
it 'creates recipient_email instance' do
|
|
35
|
-
actual = SendGrid4r::REST::Sm.create_recipient_email(
|
|
33
|
+
actual = SendGrid4r::REST::Sm.create_recipient_email(
|
|
34
|
+
JSON.parse(recipient_email)
|
|
35
|
+
)
|
|
36
36
|
expect(actual).to be_a(RecipientEmail)
|
|
37
37
|
expect(actual.recipient_email).to eq('test1@example.com')
|
|
38
38
|
end
|
|
@@ -80,60 +80,50 @@ module SendGrid4r::REST::Sm
|
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
let(:recipient_emails) do
|
|
83
|
-
|
|
84
|
-
'
|
|
85
|
-
'"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
'}'
|
|
90
|
-
)
|
|
83
|
+
'{'\
|
|
84
|
+
'"recipient_emails": ['\
|
|
85
|
+
'"test1@example.com",'\
|
|
86
|
+
'"test2@example.com"'\
|
|
87
|
+
']'\
|
|
88
|
+
'}'
|
|
91
89
|
end
|
|
92
90
|
|
|
93
91
|
let(:recipient_email) do
|
|
94
|
-
|
|
95
|
-
'
|
|
96
|
-
|
|
97
|
-
'}'
|
|
98
|
-
)
|
|
92
|
+
'{'\
|
|
93
|
+
'"recipient_email": "test1@example.com"'\
|
|
94
|
+
'}'
|
|
99
95
|
end
|
|
100
96
|
|
|
101
97
|
let(:emails) do
|
|
102
|
-
|
|
103
|
-
'["test1@example.com","test2@example.com"]'
|
|
104
|
-
)
|
|
98
|
+
'["test1@example.com","test2@example.com"]'
|
|
105
99
|
end
|
|
106
100
|
|
|
107
101
|
let(:suppression) do
|
|
108
|
-
|
|
109
|
-
'
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
'}'
|
|
115
|
-
)
|
|
102
|
+
'{'\
|
|
103
|
+
'"id": 4,'\
|
|
104
|
+
'"name": "Special Offers",'\
|
|
105
|
+
'"description": "Special offers and coupons",'\
|
|
106
|
+
'"suppressed": false'\
|
|
107
|
+
'}'
|
|
116
108
|
end
|
|
117
109
|
|
|
118
110
|
let(:suppressions) do
|
|
119
|
-
|
|
120
|
-
'
|
|
121
|
-
'
|
|
122
|
-
'
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
'
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
'}'
|
|
136
|
-
)
|
|
111
|
+
'{'\
|
|
112
|
+
'"suppressions": ['\
|
|
113
|
+
'{'\
|
|
114
|
+
'"id": 1,'\
|
|
115
|
+
'"name": "Weekly Newsletter",'\
|
|
116
|
+
'"description": "The weekly newsletter",'\
|
|
117
|
+
'"suppressed": false'\
|
|
118
|
+
'},'\
|
|
119
|
+
'{'\
|
|
120
|
+
'"id": 4,'\
|
|
121
|
+
'"name": "Special Offers",'\
|
|
122
|
+
'"description": "Special offers and coupons",'\
|
|
123
|
+
'"suppressed": false'\
|
|
124
|
+
'}'\
|
|
125
|
+
']'\
|
|
126
|
+
'}'
|
|
137
127
|
end
|
|
138
128
|
|
|
139
129
|
it '#post_suppressed_emails' do
|
|
@@ -166,7 +156,7 @@ module SendGrid4r::REST::Sm
|
|
|
166
156
|
end
|
|
167
157
|
|
|
168
158
|
it 'creates suppression instance' do
|
|
169
|
-
actual = Suppressions.create_suppression(suppression)
|
|
159
|
+
actual = Suppressions.create_suppression(JSON.parse(suppression))
|
|
170
160
|
expect(actual).to be_a(Suppressions::Suppression)
|
|
171
161
|
expect(actual.id).to eq(4)
|
|
172
162
|
expect(actual.name).to eq('Special Offers')
|
|
@@ -175,7 +165,7 @@ module SendGrid4r::REST::Sm
|
|
|
175
165
|
end
|
|
176
166
|
|
|
177
167
|
it 'creates suppressions instance' do
|
|
178
|
-
actual = Suppressions.create_suppressions(suppressions)
|
|
168
|
+
actual = Suppressions.create_suppressions(JSON.parse(suppressions))
|
|
179
169
|
expect(actual).to be_a(Suppressions::Suppressions)
|
|
180
170
|
expect(actual.suppressions).to be_a(Array)
|
|
181
171
|
actual.suppressions.each do |suppression|
|
|
@@ -54,30 +54,26 @@ module SendGrid4r::REST
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
let(:spam_reports) do
|
|
57
|
-
|
|
58
|
-
'
|
|
59
|
-
'
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
'
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
']'
|
|
70
|
-
)
|
|
57
|
+
'['\
|
|
58
|
+
'{'\
|
|
59
|
+
'"created": 1443651141,'\
|
|
60
|
+
'"email": "user1@example.com",'\
|
|
61
|
+
'"ip": "10.63.202.100"'\
|
|
62
|
+
'},'\
|
|
63
|
+
'{'\
|
|
64
|
+
'"created": 1443651154,'\
|
|
65
|
+
'"email": "user2@example.com",'\
|
|
66
|
+
'"ip": "10.63.202.100"'\
|
|
67
|
+
'}'\
|
|
68
|
+
']'
|
|
71
69
|
end
|
|
72
70
|
|
|
73
71
|
let(:spam_report) do
|
|
74
|
-
|
|
75
|
-
'
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
'}'
|
|
80
|
-
)
|
|
72
|
+
'{'\
|
|
73
|
+
'"created": 1454433146,'\
|
|
74
|
+
'"email": "test1@example.com",'\
|
|
75
|
+
'"ip": "10.89.32.5"'\
|
|
76
|
+
'}'
|
|
81
77
|
end
|
|
82
78
|
|
|
83
79
|
it '#get_spam_reports' do
|
|
@@ -116,7 +112,7 @@ module SendGrid4r::REST
|
|
|
116
112
|
end
|
|
117
113
|
|
|
118
114
|
it 'creates spam_reports instance' do
|
|
119
|
-
actual = SpamReports.create_spam_reports(spam_reports)
|
|
115
|
+
actual = SpamReports.create_spam_reports(JSON.parse(spam_reports))
|
|
120
116
|
expect(actual).to be_a(Array)
|
|
121
117
|
actual.each do |subuser|
|
|
122
118
|
expect(subuser).to be_a(SpamReports::SpamReport)
|
|
@@ -124,7 +120,7 @@ module SendGrid4r::REST
|
|
|
124
120
|
end
|
|
125
121
|
|
|
126
122
|
it 'creates spam_report instance' do
|
|
127
|
-
actual = SpamReports.create_spam_report(spam_report)
|
|
123
|
+
actual = SpamReports.create_spam_report(JSON.parse(spam_report))
|
|
128
124
|
expect(actual).to be_a(SpamReports::SpamReport)
|
|
129
125
|
expect(actual.created).to eq(Time.at(1454433146))
|
|
130
126
|
expect(actual.email).to eq('test1@example.com')
|
|
@@ -156,7 +156,7 @@ module SendGrid4r::REST::Stats
|
|
|
156
156
|
|
|
157
157
|
it '#get_mailbox_providers_stats with mandatory params' do
|
|
158
158
|
top_stats =
|
|
159
|
-
@client.get_mailbox_providers_stats(start_date: '2015-01-
|
|
159
|
+
@client.get_mailbox_providers_stats(start_date: '2015-01-23')
|
|
160
160
|
expect(top_stats).to be_a(Array)
|
|
161
161
|
top_stats.each do |top_stat|
|
|
162
162
|
expect(top_stat).to be_a(TopStat)
|
|
@@ -175,7 +175,7 @@ module SendGrid4r::REST::Stats
|
|
|
175
175
|
expect(stat.metrics.spam_reports.nil?).to be(false)
|
|
176
176
|
expect(stat.metrics.unique_clicks.nil?).to be(false)
|
|
177
177
|
expect(stat.metrics.unique_opens.nil?).to be(false)
|
|
178
|
-
expect(stat.name).to
|
|
178
|
+
expect(stat.name).to eq(nil)
|
|
179
179
|
expect(stat.type).to eq('mailbox_provider')
|
|
180
180
|
end
|
|
181
181
|
end
|
|
@@ -184,9 +184,9 @@ module SendGrid4r::REST::Stats
|
|
|
184
184
|
it '#get_mailbox_providers_stats with all params' do
|
|
185
185
|
top_stats = @client.get_mailbox_providers_stats(
|
|
186
186
|
start_date: '2015-01-01',
|
|
187
|
-
end_date: '2015-01-
|
|
187
|
+
end_date: '2015-01-31',
|
|
188
188
|
aggregated_by: :week,
|
|
189
|
-
|
|
189
|
+
mailbox_providers: :Other
|
|
190
190
|
)
|
|
191
191
|
expect(top_stats).to be_a(Array)
|
|
192
192
|
top_stats.each do |top_stat|
|
|
@@ -55,27 +55,6 @@ module SendGrid4r::REST::Stats
|
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
|
-
|
|
59
|
-
context 'with block call' do
|
|
60
|
-
it '#get_global_stats with all params' do
|
|
61
|
-
@client.get_global_stats(
|
|
62
|
-
start_date: '2015-01-01',
|
|
63
|
-
end_date: '2015-01-01',
|
|
64
|
-
aggregated_by: :week
|
|
65
|
-
) do |resp, req, res|
|
|
66
|
-
resp =
|
|
67
|
-
SendGrid4r::REST::Stats.create_top_stats(
|
|
68
|
-
JSON.parse(resp)
|
|
69
|
-
)
|
|
70
|
-
expect(resp).to be_a(Array)
|
|
71
|
-
resp.each do |stat|
|
|
72
|
-
expect(stat).to be_a(TopStat)
|
|
73
|
-
end
|
|
74
|
-
expect(req).to be_a(RestClient::Request)
|
|
75
|
-
expect(res).to be_a(Net::HTTPOK)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
58
|
end
|
|
80
59
|
end
|
|
81
60
|
end
|
data/spec/rest/subusers_spec.rb
CHANGED
|
@@ -55,9 +55,10 @@ module SendGrid4r::REST
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it '#get_subuser_monitor' do
|
|
58
|
-
|
|
58
|
+
@client.post_subuser_monitor(
|
|
59
59
|
username: @username3, email: @email1, frequency: 10
|
|
60
60
|
)
|
|
61
|
+
monitor = @client.get_subuser_monitor(username: @username3)
|
|
61
62
|
expect(monitor).to be_a(Subusers::Monitor)
|
|
62
63
|
end
|
|
63
64
|
|
|
@@ -113,55 +114,47 @@ module SendGrid4r::REST
|
|
|
113
114
|
end
|
|
114
115
|
|
|
115
116
|
let(:subusers) do
|
|
116
|
-
|
|
117
|
-
'
|
|
118
|
-
'
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
'
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
']'
|
|
129
|
-
)
|
|
117
|
+
'['\
|
|
118
|
+
'{'\
|
|
119
|
+
'"id": 1,'\
|
|
120
|
+
'"username": "Test@example.com",'\
|
|
121
|
+
'"email": "Test@example.com"'\
|
|
122
|
+
'},'\
|
|
123
|
+
'{'\
|
|
124
|
+
'"id": 2,'\
|
|
125
|
+
'"username": "John@example.com",'\
|
|
126
|
+
'"email": "John@example.com"'\
|
|
127
|
+
'}'\
|
|
128
|
+
']'
|
|
130
129
|
end
|
|
131
130
|
|
|
132
131
|
let(:subuser) do
|
|
133
|
-
|
|
134
|
-
'
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
'"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
'}'
|
|
144
|
-
)
|
|
132
|
+
'{'\
|
|
133
|
+
'"username": "John@example.com",'\
|
|
134
|
+
'"email": "John@example.com",'\
|
|
135
|
+
'"password": "johns_password",'\
|
|
136
|
+
'"ips": ['\
|
|
137
|
+
'"1.1.1.1",'\
|
|
138
|
+
'"2.2.2.2"'\
|
|
139
|
+
'],'\
|
|
140
|
+
'"disabled": false'\
|
|
141
|
+
'}'
|
|
145
142
|
end
|
|
146
143
|
|
|
147
144
|
let(:ips) do
|
|
148
|
-
|
|
149
|
-
'
|
|
150
|
-
'"
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
'}'
|
|
155
|
-
)
|
|
145
|
+
'{'\
|
|
146
|
+
'"ips": ['\
|
|
147
|
+
'"127.0.0.1",'\
|
|
148
|
+
'"127.0.0.2"'\
|
|
149
|
+
']'\
|
|
150
|
+
'}'
|
|
156
151
|
end
|
|
157
152
|
|
|
158
153
|
let(:monitor) do
|
|
159
|
-
|
|
160
|
-
'
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
'}'
|
|
164
|
-
)
|
|
154
|
+
'{'\
|
|
155
|
+
'"email": "test@example.com",'\
|
|
156
|
+
'"frequency": 500'\
|
|
157
|
+
'}'
|
|
165
158
|
end
|
|
166
159
|
|
|
167
160
|
it '#get_subusers' do
|
|
@@ -195,9 +188,7 @@ module SendGrid4r::REST
|
|
|
195
188
|
|
|
196
189
|
it '#get_subuser_monitor' do
|
|
197
190
|
allow(client).to receive(:execute).and_return(monitor)
|
|
198
|
-
actual = client.get_subuser_monitor(
|
|
199
|
-
username: '', email: '', frequency: 1
|
|
200
|
-
)
|
|
191
|
+
actual = client.get_subuser_monitor(username: '')
|
|
201
192
|
expect(actual).to be_a(Subusers::Monitor)
|
|
202
193
|
end
|
|
203
194
|
|
|
@@ -239,7 +230,7 @@ module SendGrid4r::REST
|
|
|
239
230
|
end
|
|
240
231
|
|
|
241
232
|
it 'creates subusers instance' do
|
|
242
|
-
actual = Subusers.create_subusers(subusers)
|
|
233
|
+
actual = Subusers.create_subusers(JSON.parse(subusers))
|
|
243
234
|
expect(actual).to be_a(Array)
|
|
244
235
|
actual.each do |subuser|
|
|
245
236
|
expect(subuser).to be_a(Subusers::Subuser)
|
|
@@ -247,7 +238,7 @@ module SendGrid4r::REST
|
|
|
247
238
|
end
|
|
248
239
|
|
|
249
240
|
it 'creates subuser instance' do
|
|
250
|
-
actual = Subusers.create_subuser(subuser)
|
|
241
|
+
actual = Subusers.create_subuser(JSON.parse(subuser))
|
|
251
242
|
expect(actual).to be_a(Subusers::Subuser)
|
|
252
243
|
expect(actual.username).to eq('John@example.com')
|
|
253
244
|
expect(actual.email).to eq('John@example.com')
|
|
@@ -259,7 +250,7 @@ module SendGrid4r::REST
|
|
|
259
250
|
end
|
|
260
251
|
|
|
261
252
|
it 'creates monitor instance' do
|
|
262
|
-
actual = Subusers.create_monitor(monitor)
|
|
253
|
+
actual = Subusers.create_monitor(JSON.parse(monitor))
|
|
263
254
|
expect(actual).to be_a(Subusers::Monitor)
|
|
264
255
|
expect(actual.email).to eq('test@example.com')
|
|
265
256
|
expect(actual.frequency).to eq(500)
|