sendgrid4r 1.11.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
3
|
+
|
4
|
+
module SendGrid4r::CLI::Whitelabel
|
5
|
+
describe Whitelabel do
|
6
|
+
describe 'integration test', :it do
|
7
|
+
before do
|
8
|
+
Dotenv.load
|
9
|
+
end
|
10
|
+
|
11
|
+
it '#domain subcommand' do
|
12
|
+
args = ['domain' 'help']
|
13
|
+
Whitelabel.start(args)
|
14
|
+
end
|
15
|
+
|
16
|
+
it '#link subcommand' do
|
17
|
+
args = ['link']
|
18
|
+
Whitelabel.start(args)
|
19
|
+
end
|
20
|
+
|
21
|
+
it '#ip subcommand' do
|
22
|
+
args = ['ip']
|
23
|
+
Whitelabel.start(args)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/client_spec.rb
CHANGED
@@ -48,8 +48,8 @@ module SendGrid4r::Factory
|
|
48
48
|
address = CampaignFactory.new.create_address(
|
49
49
|
email: 'from@example.com', name: 'Example INC'
|
50
50
|
)
|
51
|
-
expect(address
|
52
|
-
expect(address
|
51
|
+
expect(address[:email]).to eq('from@example.com')
|
52
|
+
expect(address[:name]).to eq('Example INC')
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'create sender with full parameters' do
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
3
|
+
|
4
|
+
module SendGrid4r::Factory
|
5
|
+
describe EventFactory do
|
6
|
+
describe 'unit test', :ut do
|
7
|
+
before do
|
8
|
+
Dotenv.load
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'create with full parameters' do
|
12
|
+
event = EventFactory.create(
|
13
|
+
enabled: true, url: 'test.test.test', group_resubscribe: true,
|
14
|
+
delivered: true, group_unsubscribe: true, spam_report: true,
|
15
|
+
bounce: true, deferred: true, unsubscribe: true, processed: true,
|
16
|
+
open: true, click: true, dropped: true)
|
17
|
+
expect(event).to be_a(
|
18
|
+
SendGrid4r::REST::Webhooks::Event::EventNotification
|
19
|
+
)
|
20
|
+
expect(event.enabled).to eq(true)
|
21
|
+
expect(event.url).to eq('test.test.test')
|
22
|
+
expect(event.group_resubscribe).to eq(true)
|
23
|
+
expect(event.delivered).to eq(true)
|
24
|
+
expect(event.group_unsubscribe).to eq(true)
|
25
|
+
expect(event.spam_report).to eq(true)
|
26
|
+
expect(event.bounce).to eq(true)
|
27
|
+
expect(event.deferred).to eq(true)
|
28
|
+
expect(event.unsubscribe).to eq(true)
|
29
|
+
expect(event.processed).to eq(true)
|
30
|
+
expect(event.open).to eq(true)
|
31
|
+
expect(event.click).to eq(true)
|
32
|
+
expect(event.dropped).to eq(true)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -92,31 +92,27 @@ module SendGrid4r::REST::ApiKeysManagement
|
|
92
92
|
end
|
93
93
|
|
94
94
|
let(:api_keys) do
|
95
|
-
|
96
|
-
'
|
97
|
-
'
|
98
|
-
'
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
'}'
|
104
|
-
)
|
95
|
+
'{'\
|
96
|
+
'"result": ['\
|
97
|
+
'{'\
|
98
|
+
'"name": "A New Hope",'\
|
99
|
+
'"api_key_id": "xxxxxxxx"'\
|
100
|
+
'}'\
|
101
|
+
']'\
|
102
|
+
'}'
|
105
103
|
end
|
106
104
|
|
107
105
|
let(:api_key) do
|
108
|
-
|
109
|
-
'
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
'"
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
'}'
|
119
|
-
)
|
106
|
+
'{'\
|
107
|
+
'"api_key": "SG.xxxxxxxx.yyyyyyyy",'\
|
108
|
+
'"api_key_id": "xxxxxxxx",'\
|
109
|
+
'"name": "My API Key",'\
|
110
|
+
'"scopes": ['\
|
111
|
+
'"mail.send",'\
|
112
|
+
'"alerts.create",'\
|
113
|
+
'"alerts.read"'\
|
114
|
+
']'\
|
115
|
+
'}'
|
120
116
|
end
|
121
117
|
|
122
118
|
it '#get_api_keys' do
|
@@ -150,7 +146,9 @@ module SendGrid4r::REST::ApiKeysManagement
|
|
150
146
|
end
|
151
147
|
|
152
148
|
it 'creates api_key instance' do
|
153
|
-
actual = SendGrid4r::REST::ApiKeysManagement.create_api_key(
|
149
|
+
actual = SendGrid4r::REST::ApiKeysManagement.create_api_key(
|
150
|
+
JSON.parse(api_key)
|
151
|
+
)
|
154
152
|
expect(actual).to be_a(ApiKey)
|
155
153
|
expect(actual.api_key).to eq('SG.xxxxxxxx.yyyyyyyy')
|
156
154
|
expect(actual.api_key_id).to eq('xxxxxxxx')
|
@@ -161,7 +159,9 @@ module SendGrid4r::REST::ApiKeysManagement
|
|
161
159
|
end
|
162
160
|
|
163
161
|
it 'creates api_keys instance' do
|
164
|
-
actual = SendGrid4r::REST::ApiKeysManagement.create_api_keys(
|
162
|
+
actual = SendGrid4r::REST::ApiKeysManagement.create_api_keys(
|
163
|
+
JSON.parse(api_keys)
|
164
|
+
)
|
165
165
|
expect(actual).to be_a(ApiKeys)
|
166
166
|
expect(actual.result).to be_a(Array)
|
167
167
|
actual.result.each do |api_key|
|
@@ -24,15 +24,13 @@ module SendGrid4r::REST::ApiKeysManagement
|
|
24
24
|
end
|
25
25
|
|
26
26
|
let(:permissions) do
|
27
|
-
|
28
|
-
'
|
29
|
-
'"
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
'}'
|
35
|
-
)
|
27
|
+
'{'\
|
28
|
+
'"scopes": ['\
|
29
|
+
'"alerts.create",'\
|
30
|
+
'"alerts.read",'\
|
31
|
+
'"alerts.update"'\
|
32
|
+
']'\
|
33
|
+
'}'
|
36
34
|
end
|
37
35
|
|
38
36
|
it '#get_permissions' do
|
@@ -42,7 +40,7 @@ module SendGrid4r::REST::ApiKeysManagement
|
|
42
40
|
end
|
43
41
|
|
44
42
|
it 'creates permissions instance' do
|
45
|
-
actual = Permissions.create_permissions(permissions)
|
43
|
+
actual = Permissions.create_permissions(JSON.parse(permissions))
|
46
44
|
expect(actual).to be_a(Permissions::Permissions)
|
47
45
|
expect(actual.scopes).to be_a(Array)
|
48
46
|
expect(actual.scopes[0]).to eq('alerts.create')
|
data/spec/rest/blocks_spec.rb
CHANGED
@@ -50,21 +50,7 @@ module SendGrid4r::REST
|
|
50
50
|
end
|
51
51
|
|
52
52
|
let(:blocks) do
|
53
|
-
|
54
|
-
'['\
|
55
|
-
'{'\
|
56
|
-
'"created": 1443651154,'\
|
57
|
-
'"email": "user1@example.com",'\
|
58
|
-
'"reason": "error dialing remote address: dial tcp '\
|
59
|
-
'10.57.152.165:25: no route to host",'\
|
60
|
-
'"status": "4.0.0"'\
|
61
|
-
'}'\
|
62
|
-
']'
|
63
|
-
)
|
64
|
-
end
|
65
|
-
|
66
|
-
let(:block) do
|
67
|
-
JSON.parse(
|
53
|
+
'['\
|
68
54
|
'{'\
|
69
55
|
'"created": 1443651154,'\
|
70
56
|
'"email": "user1@example.com",'\
|
@@ -72,7 +58,17 @@ module SendGrid4r::REST
|
|
72
58
|
'10.57.152.165:25: no route to host",'\
|
73
59
|
'"status": "4.0.0"'\
|
74
60
|
'}'\
|
75
|
-
|
61
|
+
']'
|
62
|
+
end
|
63
|
+
|
64
|
+
let(:block) do
|
65
|
+
'{'\
|
66
|
+
'"created": 1443651154,'\
|
67
|
+
'"email": "user1@example.com",'\
|
68
|
+
'"reason": "error dialing remote address: dial tcp '\
|
69
|
+
'10.57.152.165:25: no route to host",'\
|
70
|
+
'"status": "4.0.0"'\
|
71
|
+
'}'\
|
76
72
|
end
|
77
73
|
|
78
74
|
it '#get_blocks' do
|
@@ -111,7 +107,7 @@ module SendGrid4r::REST
|
|
111
107
|
end
|
112
108
|
|
113
109
|
it 'creates blocks instance' do
|
114
|
-
actual = Blocks.create_blocks(blocks)
|
110
|
+
actual = Blocks.create_blocks(JSON.parse(blocks))
|
115
111
|
expect(actual).to be_a(Array)
|
116
112
|
actual.each do |subuser|
|
117
113
|
expect(subuser).to be_a(Blocks::Block)
|
@@ -119,7 +115,7 @@ module SendGrid4r::REST
|
|
119
115
|
end
|
120
116
|
|
121
117
|
it 'creates block instance' do
|
122
|
-
actual = Blocks.create_block(block)
|
118
|
+
actual = Blocks.create_block(JSON.parse(block))
|
123
119
|
expect(actual).to be_a(Blocks::Block)
|
124
120
|
expect(actual.created).to eq(Time.at(1443651154))
|
125
121
|
expect(actual.email).to eq('user1@example.com')
|
data/spec/rest/bounces_spec.rb
CHANGED
@@ -50,41 +50,37 @@ module SendGrid4r::REST
|
|
50
50
|
end
|
51
51
|
|
52
52
|
let(:bounces) do
|
53
|
-
|
54
|
-
'
|
55
|
-
'
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
'},'\
|
66
|
-
'{'\
|
67
|
-
'"created": 1433800303,'\
|
68
|
-
'"email": "testemail2@testing.com",'\
|
69
|
-
'"reason": "550 5.1.1 <testemail2@testing.com>: '\
|
70
|
-
'Recipient address '\
|
71
|
-
'rejected: User unknown in virtual alias table ",'\
|
72
|
-
'"status": "5.1.1"'\
|
73
|
-
'}'\
|
74
|
-
']'
|
75
|
-
)
|
76
|
-
end
|
77
|
-
|
78
|
-
let(:bounce) do
|
79
|
-
JSON.parse(
|
53
|
+
'['\
|
54
|
+
'{'\
|
55
|
+
'"created": 1443651125,'\
|
56
|
+
'"email": "testemail1@test.com",'\
|
57
|
+
'"reason": "550 5.1.1 The email account that you tried to reach '\
|
58
|
+
'does not exist.'\
|
59
|
+
'Please try double-checking the recipient\'s email address for '\
|
60
|
+
'typos or unnecessary spaces. Learn more at '\
|
61
|
+
'https://support.google.com/mail/answer/6596'\
|
62
|
+
'o186si2389584ioe.63 - gsmtp ",'\
|
63
|
+
'"status": "5.1.1"'\
|
64
|
+
'},'\
|
80
65
|
'{'\
|
81
66
|
'"created": 1433800303,'\
|
82
67
|
'"email": "testemail2@testing.com",'\
|
83
|
-
'"reason": "550 5.1.1 <testemail2@testing.com>:
|
68
|
+
'"reason": "550 5.1.1 <testemail2@testing.com>: '\
|
69
|
+
'Recipient address '\
|
84
70
|
'rejected: User unknown in virtual alias table ",'\
|
85
71
|
'"status": "5.1.1"'\
|
86
|
-
'}'
|
87
|
-
|
72
|
+
'}'\
|
73
|
+
']'
|
74
|
+
end
|
75
|
+
|
76
|
+
let(:bounce) do
|
77
|
+
'{'\
|
78
|
+
'"created": 1433800303,'\
|
79
|
+
'"email": "testemail2@testing.com",'\
|
80
|
+
'"reason": "550 5.1.1 <testemail2@testing.com>: Recipient address '\
|
81
|
+
'rejected: User unknown in virtual alias table ",'\
|
82
|
+
'"status": "5.1.1"'\
|
83
|
+
'}'
|
88
84
|
end
|
89
85
|
|
90
86
|
it '#get_bounces' do
|
@@ -123,7 +119,7 @@ module SendGrid4r::REST
|
|
123
119
|
end
|
124
120
|
|
125
121
|
it 'creates bounces instance' do
|
126
|
-
actual = Bounces.create_bounces(bounces)
|
122
|
+
actual = Bounces.create_bounces(JSON.parse(bounces))
|
127
123
|
expect(actual).to be_a(Array)
|
128
124
|
actual.each do |subuser|
|
129
125
|
expect(subuser).to be_a(Bounces::Bounce)
|
@@ -131,7 +127,7 @@ module SendGrid4r::REST
|
|
131
127
|
end
|
132
128
|
|
133
129
|
it 'creates bounce instance' do
|
134
|
-
actual = Bounces.create_bounce(bounce)
|
130
|
+
actual = Bounces.create_bounce(JSON.parse(bounce))
|
135
131
|
expect(actual).to be_a(Bounces::Bounce)
|
136
132
|
expect(actual.created).to eq(Time.at(1433800303))
|
137
133
|
expect(actual.email).to eq('testemail2@testing.com')
|
@@ -65,26 +65,22 @@ module SendGrid4r::REST
|
|
65
65
|
end
|
66
66
|
|
67
67
|
let(:scheduled_send) do
|
68
|
-
|
69
|
-
'
|
70
|
-
|
71
|
-
'}'
|
72
|
-
)
|
68
|
+
'{'\
|
69
|
+
'"batch_id": "YOUR_BATCH_ID"'\
|
70
|
+
'}'
|
73
71
|
end
|
74
72
|
|
75
73
|
let(:scheduled_sends) do
|
76
|
-
|
77
|
-
'
|
78
|
-
'
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
'
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
']'
|
87
|
-
)
|
74
|
+
'['\
|
75
|
+
'{'\
|
76
|
+
'"batch_id": "BATCH_ID_1",'\
|
77
|
+
'"status": "cancel"'\
|
78
|
+
'},'\
|
79
|
+
'{'\
|
80
|
+
'"batch_id": "BATCH_ID_2",'\
|
81
|
+
'"status": "pause"'\
|
82
|
+
'}'\
|
83
|
+
']'
|
88
84
|
end
|
89
85
|
|
90
86
|
it '#generate_batch_id' do
|
@@ -131,7 +127,7 @@ module SendGrid4r::REST
|
|
131
127
|
|
132
128
|
it 'creates scheduled_sends instance' do
|
133
129
|
actual = CancelScheduledSends.create_scheduled_sends(
|
134
|
-
scheduled_sends
|
130
|
+
JSON.parse(scheduled_sends)
|
135
131
|
)
|
136
132
|
expect(actual).to be_a(Array)
|
137
133
|
actual.each do |scheduled_send|
|
@@ -145,7 +141,7 @@ module SendGrid4r::REST
|
|
145
141
|
|
146
142
|
it 'creates scheduled_send instance' do
|
147
143
|
actual = CancelScheduledSends.create_scheduled_send(
|
148
|
-
scheduled_send
|
144
|
+
JSON.parse(scheduled_send)
|
149
145
|
)
|
150
146
|
expect(actual).to be_a(CancelScheduledSends::ScheduledSend)
|
151
147
|
expect(actual.batch_id).to eq('YOUR_BATCH_ID')
|
@@ -44,15 +44,13 @@ module SendGrid4r::REST
|
|
44
44
|
end
|
45
45
|
|
46
46
|
let(:categories) do
|
47
|
-
|
48
|
-
'
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
']'
|
55
|
-
)
|
47
|
+
'['\
|
48
|
+
'{"category": "cat1"},'\
|
49
|
+
'{"category": "cat2"},'\
|
50
|
+
'{"category": "cat3"},'\
|
51
|
+
'{"category": "cat4"},'\
|
52
|
+
'{"category": "cat5"}'\
|
53
|
+
']'
|
56
54
|
end
|
57
55
|
|
58
56
|
it '#get_categories' do
|
@@ -65,7 +63,7 @@ module SendGrid4r::REST
|
|
65
63
|
end
|
66
64
|
|
67
65
|
it 'creates categories instance' do
|
68
|
-
actual = Categories.create_categories(categories)
|
66
|
+
actual = Categories.create_categories(JSON.parse(categories))
|
69
67
|
expect(actual).to be_a(Array)
|
70
68
|
actual.each do |category|
|
71
69
|
expect(category).to be_a(Categories::Category)
|
@@ -80,25 +80,7 @@ module SendGrid4r::REST
|
|
80
80
|
end
|
81
81
|
|
82
82
|
let(:activities) do
|
83
|
-
|
84
|
-
'['\
|
85
|
-
'{'\
|
86
|
-
'"email": "test@example.com",'\
|
87
|
-
'"event": "processed",'\
|
88
|
-
'"created": 1431624000,'\
|
89
|
-
'"category": ["my_category"],'\
|
90
|
-
'"smtp_id": "filter001-2348927389",'\
|
91
|
-
'"asm_group_id": null,'\
|
92
|
-
'"msg_id": "xxx-abc-123",'\
|
93
|
-
'"ip": null,'\
|
94
|
-
'"url": null'\
|
95
|
-
'}'\
|
96
|
-
']'
|
97
|
-
)
|
98
|
-
end
|
99
|
-
|
100
|
-
let(:activity) do
|
101
|
-
JSON.parse(
|
83
|
+
'['\
|
102
84
|
'{'\
|
103
85
|
'"email": "test@example.com",'\
|
104
86
|
'"event": "processed",'\
|
@@ -110,7 +92,21 @@ module SendGrid4r::REST
|
|
110
92
|
'"ip": null,'\
|
111
93
|
'"url": null'\
|
112
94
|
'}'\
|
113
|
-
|
95
|
+
']'
|
96
|
+
end
|
97
|
+
|
98
|
+
let(:activity) do
|
99
|
+
'{'\
|
100
|
+
'"email": "test@example.com",'\
|
101
|
+
'"event": "processed",'\
|
102
|
+
'"created": 1431624000,'\
|
103
|
+
'"category": ["my_category"],'\
|
104
|
+
'"smtp_id": "filter001-2348927389",'\
|
105
|
+
'"asm_group_id": null,'\
|
106
|
+
'"msg_id": "xxx-abc-123",'\
|
107
|
+
'"ip": null,'\
|
108
|
+
'"url": null'\
|
109
|
+
'}'\
|
114
110
|
end
|
115
111
|
|
116
112
|
it '#get_email_activities' do
|
@@ -123,7 +119,7 @@ module SendGrid4r::REST
|
|
123
119
|
end
|
124
120
|
|
125
121
|
it 'creates activity instance' do
|
126
|
-
actual = EmailActivity.create_activity(activity)
|
122
|
+
actual = EmailActivity.create_activity(JSON.parse(activity))
|
127
123
|
expect(actual).to be_a(EmailActivity::Activity)
|
128
124
|
expect(actual.email).to eq('test@example.com')
|
129
125
|
expect(actual.event).to eq('processed')
|
@@ -140,7 +136,7 @@ module SendGrid4r::REST
|
|
140
136
|
end
|
141
137
|
|
142
138
|
it 'creates activities instance' do
|
143
|
-
actual = EmailActivity.create_activities(activities)
|
139
|
+
actual = EmailActivity.create_activities(JSON.parse(activities))
|
144
140
|
expect(actual).to be_a(Array)
|
145
141
|
actual.each do |activity|
|
146
142
|
expect(activity).to be_a(EmailActivity::Activity)
|