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
|
@@ -67,19 +67,19 @@ module SendGrid4r::REST
|
|
|
67
67
|
def post_sender(params:, &block)
|
|
68
68
|
endpoint = MarketingCampaigns.url_sender
|
|
69
69
|
resp = post(@auth, endpoint, params.to_h, &block)
|
|
70
|
-
MarketingCampaigns.create_sender(
|
|
70
|
+
finish(resp, @raw_resp) { |r| MarketingCampaigns.create_sender(r) }
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
def get_senders(&block)
|
|
74
74
|
endpoint = MarketingCampaigns.url_sender
|
|
75
75
|
resp = get(@auth, endpoint, &block)
|
|
76
|
-
MarketingCampaigns.create_senders(
|
|
76
|
+
finish(resp, @raw_resp) { |r| MarketingCampaigns.create_senders(r) }
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def patch_sender(sender_id:, params:, &block)
|
|
80
80
|
endpoint = MarketingCampaigns.url_sender(sender_id)
|
|
81
81
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
82
|
-
MarketingCampaigns.create_sender(
|
|
82
|
+
finish(resp, @raw_resp) { |r| MarketingCampaigns.create_sender(r) }
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
def delete_sender(sender_id:, &block)
|
|
@@ -95,7 +95,7 @@ module SendGrid4r::REST
|
|
|
95
95
|
def get_sender(sender_id:, &block)
|
|
96
96
|
endpoint = MarketingCampaigns.url_sender(sender_id)
|
|
97
97
|
resp = get(@auth, endpoint, &block)
|
|
98
|
-
MarketingCampaigns.create_sender(
|
|
98
|
+
finish(resp, @raw_resp) { |r| MarketingCampaigns.create_sender(r) }
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
end
|
|
@@ -33,10 +33,7 @@ module SendGrid4r::REST
|
|
|
33
33
|
|
|
34
34
|
def execute(method, auth, endpoint, params, payload, &block)
|
|
35
35
|
args = create_args(method, auth, endpoint, params, payload)
|
|
36
|
-
|
|
37
|
-
return nil if block_given?
|
|
38
|
-
return JSON.parse(body) unless body.nil? || body.length < 2
|
|
39
|
-
body
|
|
36
|
+
RestClient::Request.execute(args, &block)
|
|
40
37
|
rescue RestClient::TooManyRequests => e
|
|
41
38
|
duration = e.response.headers[:x_ratelimit_remaining].to_i
|
|
42
39
|
sleep duration if duration > 0
|
|
@@ -77,5 +74,10 @@ module SendGrid4r::REST
|
|
|
77
74
|
def process_array_params(v)
|
|
78
75
|
v.is_a?(Array) ? v.join(',') : v.to_s
|
|
79
76
|
end
|
|
77
|
+
|
|
78
|
+
def finish(resp, raw_resp = false)
|
|
79
|
+
return resp if raw_resp || resp.nil? || resp.length < 2
|
|
80
|
+
yield(JSON.parse(resp))
|
|
81
|
+
end
|
|
80
82
|
end
|
|
81
83
|
end
|
|
@@ -21,12 +21,16 @@ module SendGrid4r::REST
|
|
|
21
21
|
|
|
22
22
|
def get_enforced_tls(&block)
|
|
23
23
|
resp = get(@auth, Settings::EnforcedTls.url, &block)
|
|
24
|
-
|
|
24
|
+
finish(resp, @raw_resp) do |r|
|
|
25
|
+
Settings::EnforcedTls.create_enforced_tls(r)
|
|
26
|
+
end
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
def patch_enforced_tls(params:, &block)
|
|
28
30
|
resp = patch(@auth, Settings::EnforcedTls.url, params.to_h, &block)
|
|
29
|
-
|
|
31
|
+
finish(resp, @raw_resp) do |r|
|
|
32
|
+
Settings::EnforcedTls.create_enforced_tls(r)
|
|
33
|
+
end
|
|
30
34
|
end
|
|
31
35
|
end
|
|
32
36
|
end
|
|
@@ -54,6 +54,13 @@ module SendGrid4r::REST
|
|
|
54
54
|
ForwardSpam.new(resp['enabled'], resp['email'])
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
SpamCheck = Struct.new(:enabled, :url, :max_score)
|
|
58
|
+
|
|
59
|
+
def self.create_spam_check(resp)
|
|
60
|
+
return resp if resp.nil?
|
|
61
|
+
SpamCheck.new(resp['enabled'], resp['url'], resp['max_score'])
|
|
62
|
+
end
|
|
63
|
+
|
|
57
64
|
Template = Struct.new(:enabled, :html_content)
|
|
58
65
|
|
|
59
66
|
def self.create_template(resp)
|
|
@@ -79,94 +86,141 @@ module SendGrid4r::REST
|
|
|
79
86
|
params[:limit] = limit unless limit.nil?
|
|
80
87
|
params[:offset] = offset unless offset.nil?
|
|
81
88
|
resp = get(@auth, Settings::Mail.url, params, &block)
|
|
82
|
-
Settings.create_results(
|
|
89
|
+
finish(resp, @raw_resp) { |r| Settings.create_results(r) }
|
|
83
90
|
end
|
|
84
91
|
|
|
85
92
|
def get_settings_address_whitelist(&block)
|
|
86
93
|
resp = get(@auth, Settings::Mail.url(:address_whitelist), &block)
|
|
87
|
-
|
|
94
|
+
finish(resp, @raw_resp) do |r|
|
|
95
|
+
Settings::Mail.create_address_whitelist(r)
|
|
96
|
+
end
|
|
88
97
|
end
|
|
89
98
|
|
|
90
99
|
def patch_settings_address_whitelist(params:, &block)
|
|
91
100
|
endpoint = Settings::Mail.url(:address_whitelist)
|
|
92
101
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
93
|
-
|
|
102
|
+
finish(resp, @raw_resp) do |r|
|
|
103
|
+
Settings::Mail.create_address_whitelist(r)
|
|
104
|
+
end
|
|
94
105
|
end
|
|
95
106
|
|
|
96
107
|
def get_settings_bcc(&block)
|
|
97
108
|
resp = get(@auth, Settings::Mail.url(:bcc), &block)
|
|
98
|
-
|
|
109
|
+
finish(resp, @raw_resp) do |r|
|
|
110
|
+
Settings::Mail.create_bcc(r)
|
|
111
|
+
end
|
|
99
112
|
end
|
|
100
113
|
|
|
101
114
|
def patch_settings_bcc(params:, &block)
|
|
102
115
|
endpoint = Settings::Mail.url(:bcc)
|
|
103
116
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
104
|
-
|
|
117
|
+
finish(resp, @raw_resp) do |r|
|
|
118
|
+
Settings::Mail.create_bcc(r)
|
|
119
|
+
end
|
|
105
120
|
end
|
|
106
121
|
|
|
107
122
|
def get_settings_bounce_purge(&block)
|
|
108
123
|
resp = get(@auth, Settings::Mail.url(:bounce_purge), &block)
|
|
109
|
-
|
|
124
|
+
finish(resp, @raw_resp) do |r|
|
|
125
|
+
Settings::Mail.create_bounce_purge(r)
|
|
126
|
+
end
|
|
110
127
|
end
|
|
111
128
|
|
|
112
129
|
def patch_settings_bounce_purge(params:, &block)
|
|
113
130
|
endpoint = Settings::Mail.url(:bounce_purge)
|
|
114
131
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
115
|
-
|
|
132
|
+
finish(resp, @raw_resp) do |r|
|
|
133
|
+
Settings::Mail.create_bounce_purge(r)
|
|
134
|
+
end
|
|
116
135
|
end
|
|
117
136
|
|
|
118
137
|
def get_settings_footer(&block)
|
|
119
138
|
resp = get(@auth, Settings::Mail.url(:footer), &block)
|
|
120
|
-
|
|
139
|
+
finish(resp, @raw_resp) do |r|
|
|
140
|
+
Settings::Mail.create_footer(r)
|
|
141
|
+
end
|
|
121
142
|
end
|
|
122
143
|
|
|
123
144
|
def patch_settings_footer(params:, &block)
|
|
124
145
|
resp = patch(@auth, Settings::Mail.url(:footer), params.to_h, &block)
|
|
125
|
-
|
|
146
|
+
finish(resp, @raw_resp) do |r|
|
|
147
|
+
Settings::Mail.create_footer(r)
|
|
148
|
+
end
|
|
126
149
|
end
|
|
127
150
|
|
|
128
151
|
def get_settings_forward_bounce(&block)
|
|
129
152
|
resp = get(@auth, Settings::Mail.url(:forward_bounce), &block)
|
|
130
|
-
|
|
153
|
+
finish(resp, @raw_resp) do |r|
|
|
154
|
+
Settings::Mail.create_forward_bounce(r)
|
|
155
|
+
end
|
|
131
156
|
end
|
|
132
157
|
|
|
133
158
|
def patch_settings_forward_bounce(params:, &block)
|
|
134
159
|
endpoint = Settings::Mail.url(:forward_bounce)
|
|
135
160
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
136
|
-
|
|
161
|
+
finish(resp, @raw_resp) do |r|
|
|
162
|
+
Settings::Mail.create_forward_bounce(r)
|
|
163
|
+
end
|
|
137
164
|
end
|
|
138
165
|
|
|
139
166
|
def get_settings_forward_spam(&block)
|
|
140
167
|
resp = get(@auth, Settings::Mail.url(:forward_spam), &block)
|
|
141
|
-
|
|
168
|
+
finish(resp, @raw_resp) do |r|
|
|
169
|
+
Settings::Mail.create_forward_spam(r)
|
|
170
|
+
end
|
|
142
171
|
end
|
|
143
172
|
|
|
144
173
|
def patch_settings_forward_spam(params:, &block)
|
|
145
174
|
endpoint = Settings::Mail.url(:forward_spam)
|
|
146
175
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
147
|
-
|
|
176
|
+
finish(resp, @raw_resp) do |r|
|
|
177
|
+
Settings::Mail.create_forward_spam(r)
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def get_settings_spam_check(&block)
|
|
182
|
+
resp = get(@auth, Settings::Mail.url(:spam_check), &block)
|
|
183
|
+
finish(resp, @raw_resp) do |r|
|
|
184
|
+
Settings::Mail.create_spam_check(r)
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def patch_settings_spam_check(params:, &block)
|
|
189
|
+
endpoint = Settings::Mail.url(:spam_check)
|
|
190
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
191
|
+
finish(resp, @raw_resp) do |r|
|
|
192
|
+
Settings::Mail.create_spam_check(r)
|
|
193
|
+
end
|
|
148
194
|
end
|
|
149
195
|
|
|
150
196
|
def get_settings_template(&block)
|
|
151
197
|
resp = get(@auth, Settings::Mail.url(:template), &block)
|
|
152
|
-
|
|
198
|
+
finish(resp, @raw_resp) do |r|
|
|
199
|
+
Settings::Mail.create_template(r)
|
|
200
|
+
end
|
|
153
201
|
end
|
|
154
202
|
|
|
155
203
|
def patch_settings_template(params:, &block)
|
|
156
204
|
endpoint = Settings::Mail.url(:template)
|
|
157
205
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
158
|
-
|
|
206
|
+
finish(resp, @raw_resp) do |r|
|
|
207
|
+
Settings::Mail.create_template(r)
|
|
208
|
+
end
|
|
159
209
|
end
|
|
160
210
|
|
|
161
211
|
def get_settings_plain_content(&block)
|
|
162
212
|
resp = get(@auth, Settings::Mail.url(:plain_content), &block)
|
|
163
|
-
|
|
213
|
+
finish(resp, @raw_resp) do |r|
|
|
214
|
+
Settings::Mail.create_plain_content(r)
|
|
215
|
+
end
|
|
164
216
|
end
|
|
165
217
|
|
|
166
218
|
def patch_settings_plain_content(params:, &block)
|
|
167
219
|
endpoint = Settings::Mail.url(:plain_content)
|
|
168
220
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
169
|
-
|
|
221
|
+
finish(resp, @raw_resp) do |r|
|
|
222
|
+
Settings::Mail.create_plain_content(r)
|
|
223
|
+
end
|
|
170
224
|
end
|
|
171
225
|
end
|
|
172
226
|
end
|
|
@@ -26,18 +26,18 @@ module SendGrid4r::REST
|
|
|
26
26
|
params[:limit] = limit unless limit.nil?
|
|
27
27
|
params[:offset] = offset unless offset.nil?
|
|
28
28
|
resp = get(@auth, Settings::Partner.url, params, &block)
|
|
29
|
-
Settings.create_results(
|
|
29
|
+
finish(resp, @raw_resp) { |r| Settings.create_results(r) }
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def get_settings_new_relic(&block)
|
|
33
33
|
resp = get(@auth, Settings::Partner.url(:new_relic), &block)
|
|
34
|
-
Settings::Partner.create_partner(
|
|
34
|
+
finish(resp, @raw_resp) { |r| Settings::Partner.create_partner(r) }
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def patch_settings_new_relic(params:, &block)
|
|
38
38
|
endpoint = Settings::Partner.url(:new_relic)
|
|
39
39
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
40
|
-
Settings::Partner.create_partner(
|
|
40
|
+
finish(resp, @raw_resp) { |r| Settings::Partner.create_partner(r) }
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
end
|
|
@@ -58,52 +58,60 @@ module SendGrid4r::REST
|
|
|
58
58
|
params[:limit] = limit unless limit.nil?
|
|
59
59
|
params[:offset] = offset unless offset.nil?
|
|
60
60
|
resp = get(@auth, Settings::Tracking.url, params, &block)
|
|
61
|
-
Settings.create_results(
|
|
61
|
+
finish(resp, @raw_resp) { |r| Settings.create_results(r) }
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def get_settings_click(&block)
|
|
65
65
|
resp = get(@auth, Settings::Tracking.url(:click), &block)
|
|
66
|
-
Settings::Tracking.create_click(
|
|
66
|
+
finish(resp, @raw_resp) { |r| Settings::Tracking.create_click(r) }
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def patch_settings_click(params:, &block)
|
|
70
70
|
endpoint = Settings::Tracking.url(:click)
|
|
71
71
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
72
|
-
Settings::Tracking.create_click(
|
|
72
|
+
finish(resp, @raw_resp) { |r| Settings::Tracking.create_click(r) }
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
def get_settings_google_analytics(&block)
|
|
76
76
|
endpoint = Settings::Tracking.url(:google_analytics)
|
|
77
77
|
resp = get(@auth, endpoint, &block)
|
|
78
|
-
|
|
78
|
+
finish(resp, @raw_resp) do |r|
|
|
79
|
+
Settings::Tracking.create_google_analytics(r)
|
|
80
|
+
end
|
|
79
81
|
end
|
|
80
82
|
|
|
81
83
|
def patch_settings_google_analytics(params:, &block)
|
|
82
84
|
endpoint = Settings::Tracking.url(:google_analytics)
|
|
83
85
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
84
|
-
|
|
86
|
+
finish(resp, @raw_resp) do |r|
|
|
87
|
+
Settings::Tracking.create_google_analytics(r)
|
|
88
|
+
end
|
|
85
89
|
end
|
|
86
90
|
|
|
87
91
|
def get_settings_open(&block)
|
|
88
92
|
resp = get(@auth, Settings::Tracking.url(:open), &block)
|
|
89
|
-
Settings::Tracking.create_open(
|
|
93
|
+
finish(resp, @raw_resp) { |r| Settings::Tracking.create_open(r) }
|
|
90
94
|
end
|
|
91
95
|
|
|
92
96
|
def patch_settings_open(params:, &block)
|
|
93
97
|
resp = patch(@auth, Settings::Tracking.url(:open), params.to_h, &block)
|
|
94
|
-
Settings::Tracking.create_open(
|
|
98
|
+
finish(resp, @raw_resp) { |r| Settings::Tracking.create_open(r) }
|
|
95
99
|
end
|
|
96
100
|
|
|
97
101
|
def get_settings_subscription(&block)
|
|
98
102
|
endpoint = Settings::Tracking.url(:subscription)
|
|
99
103
|
resp = get(@auth, endpoint, &block)
|
|
100
|
-
|
|
104
|
+
finish(resp, @raw_resp) do |r|
|
|
105
|
+
Settings::Tracking.create_subscription(r)
|
|
106
|
+
end
|
|
101
107
|
end
|
|
102
108
|
|
|
103
109
|
def patch_settings_subscription(params:, &block)
|
|
104
110
|
endpoint = Settings::Tracking.url(:subscription)
|
|
105
111
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
106
|
-
|
|
112
|
+
finish(resp, @raw_resp) do |r|
|
|
113
|
+
Settings::Tracking.create_subscription(r)
|
|
114
|
+
end
|
|
107
115
|
end
|
|
108
116
|
end
|
|
109
117
|
end
|
|
@@ -38,19 +38,21 @@ module SendGrid4r::REST
|
|
|
38
38
|
params[:offset] = offset.to_i unless offset.nil?
|
|
39
39
|
endpoint = Sm::GlobalUnsubscribes.url_unsubscribes
|
|
40
40
|
resp = get(@auth, endpoint, params, &block)
|
|
41
|
-
|
|
41
|
+
finish(resp, @raw_resp) do |r|
|
|
42
|
+
Sm::GlobalUnsubscribes.create_supressions(r)
|
|
43
|
+
end
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
def post_global_suppressed_emails(recipient_emails:, &block)
|
|
45
47
|
params = { recipient_emails: recipient_emails }
|
|
46
48
|
endpoint = Sm::GlobalUnsubscribes.url
|
|
47
49
|
resp = post(@auth, endpoint, params, &block)
|
|
48
|
-
Sm.create_recipient_emails(
|
|
50
|
+
finish(resp, @raw_resp) { |r| Sm.create_recipient_emails(r) }
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
def get_global_suppressed_email(email_address:, &block)
|
|
52
54
|
resp = get(@auth, Sm::GlobalUnsubscribes.url(email_address), &block)
|
|
53
|
-
Sm.create_recipient_email(
|
|
55
|
+
finish(resp, @raw_resp) { |r| Sm.create_recipient_email(r) }
|
|
54
56
|
end
|
|
55
57
|
|
|
56
58
|
def delete_global_suppressed_email(email_address:, &block)
|
|
@@ -40,23 +40,23 @@ module SendGrid4r::REST
|
|
|
40
40
|
params = { name: name, description: description }
|
|
41
41
|
params[:is_default] = is_default unless is_default.nil?
|
|
42
42
|
resp = post(@auth, Sm::Groups.url, params, &block)
|
|
43
|
-
Sm::Groups.create_group(
|
|
43
|
+
finish(resp, @raw_resp) { |r| Sm::Groups.create_group(r) }
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def get_groups(&block)
|
|
47
47
|
resp = get(@auth, Sm::Groups.url, &block)
|
|
48
|
-
Sm::Groups.create_groups(
|
|
48
|
+
finish(resp, @raw_resp) { |r| Sm::Groups.create_groups(r) }
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def get_group(group_id:, &block)
|
|
52
52
|
resp = get(@auth, Sm::Groups.url(group_id), &block)
|
|
53
|
-
Sm::Groups.create_group(
|
|
53
|
+
finish(resp, @raw_resp) { |r| Sm::Groups.create_group(r) }
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def patch_group(group_id:, group:, &block)
|
|
57
57
|
endpoint = Sm::Groups.url(group_id)
|
|
58
58
|
resp = patch(@auth, endpoint, group.to_h, &block)
|
|
59
|
-
Sm::Groups.create_group(
|
|
59
|
+
finish(resp, @raw_resp) { |r| Sm::Groups.create_group(r) }
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def delete_group(group_id:, &block)
|
|
@@ -39,18 +39,21 @@ module SendGrid4r::REST
|
|
|
39
39
|
recipient_emails: recipient_emails,
|
|
40
40
|
&block
|
|
41
41
|
)
|
|
42
|
-
Sm.create_recipient_emails(
|
|
42
|
+
finish(resp, @raw_resp) { |r| Sm.create_recipient_emails(r) }
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def get_suppressed_emails(group_id:, &block)
|
|
46
46
|
endpoint = Sm::Suppressions.url(group_id)
|
|
47
|
-
get(@auth, endpoint, &block)
|
|
47
|
+
resp = get(@auth, endpoint, &block)
|
|
48
|
+
finish(resp, @raw_resp) { |r| r }
|
|
48
49
|
end
|
|
49
50
|
|
|
50
51
|
def get_suppressions(email_address:, &block)
|
|
51
52
|
endpoint = "#{BASE_URL}/asm/suppressions/#{email_address}"
|
|
52
53
|
resp = get(@auth, endpoint, &block)
|
|
53
|
-
|
|
54
|
+
finish(resp, @raw_resp) do |r|
|
|
55
|
+
Sm::Suppressions.create_suppressions(r)
|
|
56
|
+
end
|
|
54
57
|
end
|
|
55
58
|
|
|
56
59
|
def delete_suppressed_email(group_id:, email_address:, &block)
|
|
@@ -35,7 +35,7 @@ module SendGrid4r::REST
|
|
|
35
35
|
params[:limit] = limit.to_i unless limit.nil?
|
|
36
36
|
params[:offset] = offset.to_i unless offset.nil?
|
|
37
37
|
resp = get(@auth, SpamReports.url, params, &block)
|
|
38
|
-
SpamReports.create_spam_reports(
|
|
38
|
+
finish(resp, @raw_resp) { |r| SpamReports.create_spam_reports(r) }
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def delete_spam_reports(delete_all: nil, emails: nil, &block)
|
|
@@ -50,7 +50,7 @@ module SendGrid4r::REST
|
|
|
50
50
|
def get_spam_report(email:, &block)
|
|
51
51
|
params = { email: email }
|
|
52
52
|
resp = get(@auth, SpamReports.url(email), params, &block)
|
|
53
|
-
SpamReports.create_spam_reports(
|
|
53
|
+
finish(resp, @raw_resp) { |r| SpamReports.create_spam_reports(r) }
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def delete_spam_report(email:, &block)
|
|
@@ -22,7 +22,7 @@ module SendGrid4r::REST
|
|
|
22
22
|
country: country
|
|
23
23
|
}
|
|
24
24
|
resp = get(@auth, "#{BASE_URL}/geo/stats", params, &block)
|
|
25
|
-
Stats.create_top_stats(
|
|
25
|
+
finish(resp, @raw_resp) { |r| Stats.create_top_stats(r) }
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def get_devices_stats(
|
|
@@ -37,7 +37,7 @@ module SendGrid4r::REST
|
|
|
37
37
|
aggregated_by: aggregated_by
|
|
38
38
|
}
|
|
39
39
|
resp = get(@auth, "#{BASE_URL}/devices/stats", params, &block)
|
|
40
|
-
Stats.create_top_stats(
|
|
40
|
+
finish(resp, @raw_resp) { |r| Stats.create_top_stats(r) }
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def get_clients_stats(
|
|
@@ -52,7 +52,7 @@ module SendGrid4r::REST
|
|
|
52
52
|
aggregated_by: aggregated_by
|
|
53
53
|
}
|
|
54
54
|
resp = get(@auth, "#{BASE_URL}/clients/stats", params, &block)
|
|
55
|
-
Stats.create_top_stats(
|
|
55
|
+
finish(resp, @raw_resp) { |r| Stats.create_top_stats(r) }
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def get_clients_type_stats(
|
|
@@ -70,25 +70,25 @@ module SendGrid4r::REST
|
|
|
70
70
|
}
|
|
71
71
|
endpoint = "#{BASE_URL}/clients/#{client_type}/stats"
|
|
72
72
|
resp = get(@auth, endpoint, params, &block)
|
|
73
|
-
Stats.create_top_stats(
|
|
73
|
+
finish(resp, @raw_resp) { |r| Stats.create_top_stats(r) }
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def get_mailbox_providers_stats(
|
|
77
77
|
start_date:,
|
|
78
78
|
end_date: nil,
|
|
79
79
|
aggregated_by: nil,
|
|
80
|
-
|
|
80
|
+
mailbox_providers: nil,
|
|
81
81
|
&block
|
|
82
82
|
)
|
|
83
83
|
params = {
|
|
84
84
|
start_date: start_date,
|
|
85
85
|
end_date: end_date,
|
|
86
86
|
aggregated_by: aggregated_by,
|
|
87
|
-
|
|
87
|
+
mailbox_providers: mailbox_providers
|
|
88
88
|
}
|
|
89
89
|
endpoint = "#{BASE_URL}/mailbox_providers/stats"
|
|
90
90
|
resp = get(@auth, endpoint, params, &block)
|
|
91
|
-
Stats.create_top_stats(
|
|
91
|
+
finish(resp, @raw_resp) { |r| Stats.create_top_stats(r) }
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
def get_browsers_stats(
|
|
@@ -105,7 +105,7 @@ module SendGrid4r::REST
|
|
|
105
105
|
browsers: browsers
|
|
106
106
|
}
|
|
107
107
|
resp = get(@auth, "#{BASE_URL}/browsers/stats", params, &block)
|
|
108
|
-
Stats.create_top_stats(
|
|
108
|
+
finish(resp, @raw_resp) { |r| Stats.create_top_stats(r) }
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
end
|