sendgrid4r 1.8.1 → 1.10.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 -2
- data/README.md +1 -0
- data/lib/sendgrid4r/factory/campaign_factory.rb +18 -5
- data/lib/sendgrid4r/factory/condition_factory.rb +1 -1
- data/lib/sendgrid4r/factory/mail_factory.rb +57 -0
- data/lib/sendgrid4r/factory/segment_factory.rb +2 -5
- data/lib/sendgrid4r/factory/version_factory.rb +1 -1
- data/lib/sendgrid4r/rest/api.rb +48 -49
- data/lib/sendgrid4r/rest/api_keys_management/api_keys.rb +75 -0
- data/lib/sendgrid4r/rest/api_keys_management/permissions.rb +31 -0
- data/lib/sendgrid4r/rest/blocks.rb +49 -68
- data/lib/sendgrid4r/rest/bounces.rb +45 -64
- data/lib/sendgrid4r/rest/cancel_scheduled_sends.rb +53 -72
- data/lib/sendgrid4r/rest/categories.rb +31 -0
- data/lib/sendgrid4r/rest/email_activity.rb +72 -0
- data/lib/sendgrid4r/rest/invalid_emails.rb +50 -68
- data/lib/sendgrid4r/rest/ip_access_management.rb +86 -111
- data/lib/sendgrid4r/rest/ips/addresses.rb +50 -59
- data/lib/sendgrid4r/rest/ips/pools.rb +42 -53
- data/lib/sendgrid4r/rest/ips/warmup.rb +46 -55
- data/lib/sendgrid4r/rest/mail/address.rb +14 -0
- data/lib/sendgrid4r/rest/mail/attachment.rb +22 -0
- data/lib/sendgrid4r/rest/mail/content.rb +10 -0
- data/lib/sendgrid4r/rest/mail/mail.rb +28 -0
- data/lib/sendgrid4r/rest/mail/mail_settings.rb +62 -0
- data/lib/sendgrid4r/rest/mail/params.rb +64 -0
- data/lib/sendgrid4r/rest/mail/personalization.rb +33 -0
- data/lib/sendgrid4r/rest/mail/tracking_settings.rb +74 -0
- data/lib/sendgrid4r/rest/{contacts → marketing_campaigns/contacts}/custom_fields.rb +12 -27
- data/lib/sendgrid4r/rest/{contacts → marketing_campaigns/contacts}/lists.rb +20 -34
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/recipients.rb +134 -0
- data/lib/sendgrid4r/rest/{contacts → marketing_campaigns/contacts}/reserved_fields.rb +6 -9
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/segments.rb +86 -0
- data/lib/sendgrid4r/rest/marketing_campaigns/marketing_campaigns.rb +119 -0
- data/lib/sendgrid4r/rest/marketing_campaigns/senders.rb +101 -0
- data/lib/sendgrid4r/rest/request.rb +61 -63
- data/lib/sendgrid4r/rest/settings/enforced_tls.rb +23 -26
- data/lib/sendgrid4r/rest/settings/mail.rb +167 -183
- data/lib/sendgrid4r/rest/settings/partner.rb +33 -36
- data/lib/sendgrid4r/rest/settings/settings.rb +17 -22
- data/lib/sendgrid4r/rest/settings/tracking.rb +97 -107
- data/lib/sendgrid4r/rest/sm/global_unsubscribes.rb +52 -60
- data/lib/sendgrid4r/rest/sm/groups.rb +52 -58
- data/lib/sendgrid4r/rest/sm/sm.rb +15 -17
- data/lib/sendgrid4r/rest/sm/suppressions.rb +50 -67
- data/lib/sendgrid4r/rest/spam_reports.rb +49 -69
- data/lib/sendgrid4r/rest/stats/advanced.rb +100 -102
- data/lib/sendgrid4r/rest/stats/category.rb +31 -33
- data/lib/sendgrid4r/rest/stats/global.rb +17 -19
- data/lib/sendgrid4r/rest/stats/parse.rb +18 -20
- data/lib/sendgrid4r/rest/stats/stats.rb +59 -69
- data/lib/sendgrid4r/rest/stats/subuser.rb +70 -32
- data/lib/sendgrid4r/rest/subusers.rb +106 -134
- data/lib/sendgrid4r/rest/transactional_templates/templates.rb +63 -0
- data/lib/sendgrid4r/rest/transactional_templates/versions.rb +90 -0
- data/lib/sendgrid4r/rest/users.rb +125 -57
- data/lib/sendgrid4r/rest/webhooks/event.rb +36 -42
- data/lib/sendgrid4r/rest/webhooks/parse.rb +28 -37
- data/lib/sendgrid4r/rest/whitelabel/domains.rb +176 -222
- data/lib/sendgrid4r/rest/whitelabel/ips.rb +107 -128
- data/lib/sendgrid4r/rest/whitelabel/links.rb +131 -167
- data/lib/sendgrid4r/version.rb +1 -1
- data/lib/sendgrid4r.rb +23 -13
- data/sendgrid4r.gemspec +1 -1
- data/spec/client_spec.rb +12 -1
- data/spec/factory/campaign_factory_spec.rb +75 -35
- data/spec/factory/condition_factory_spec.rb +19 -18
- data/spec/factory/segment_factory_spec.rb +28 -21
- data/spec/factory/version_factory_spec.rb +28 -27
- data/spec/photo.jpg +0 -0
- data/spec/rest/api_keys_management/api_keys_spec.rb +174 -0
- data/spec/rest/api_keys_management/permissions_spec.rb +54 -0
- data/spec/rest/blocks_spec.rb +78 -106
- data/spec/rest/bounces_spec.rb +91 -118
- data/spec/rest/cancel_scheduled_sends_spec.rb +94 -149
- data/spec/rest/categories_spec.rb +77 -0
- data/spec/rest/email_activity_spec.rb +151 -0
- data/spec/rest/invalid_emails_spec.rb +85 -119
- data/spec/rest/ip_access_management_spec.rb +157 -195
- data/spec/rest/ips/addresses_spec.rb +94 -122
- data/spec/rest/ips/pools_spec.rb +84 -112
- data/spec/rest/ips/warmup_spec.rb +63 -71
- data/spec/rest/mail/address_spec.rb +28 -0
- data/spec/rest/mail/attachment_spec.rb +48 -0
- data/spec/rest/mail/content_spec.rb +32 -0
- data/spec/rest/mail/mail_settings_spec.rb +51 -0
- data/spec/rest/mail/mail_spec.rb +136 -0
- data/spec/rest/mail/params_spec.rb +152 -0
- data/spec/rest/mail/personalization_spec.rb +66 -0
- data/spec/rest/mail/tracking_settings_spec.rb +63 -0
- data/spec/rest/marketing_campaigns/contacts/custom_fields_spec.rb +146 -0
- data/spec/rest/marketing_campaigns/contacts/lists_spec.rb +307 -0
- data/spec/rest/marketing_campaigns/contacts/recipients_spec.rb +331 -0
- data/spec/rest/marketing_campaigns/contacts/reserved_fields_spec.rb +119 -0
- data/spec/rest/marketing_campaigns/contacts/segments_spec.rb +268 -0
- data/spec/rest/marketing_campaigns/marketing_campaigns_spec.rb +427 -0
- data/spec/rest/marketing_campaigns/senders_spec.rb +230 -0
- data/spec/rest/settings/enforced_tls_spec.rb +38 -54
- data/spec/rest/settings/mail_spec.rb +227 -330
- data/spec/rest/settings/partner_spec.rb +40 -59
- data/spec/rest/settings/settings_spec.rb +44 -42
- data/spec/rest/settings/tracking_spec.rb +130 -189
- data/spec/rest/sm/global_unsubscribes_spec.rb +47 -72
- data/spec/rest/sm/groups_spec.rb +88 -123
- data/spec/rest/sm/sm_spec.rb +32 -30
- data/spec/rest/sm/suppressions_spec.rb +105 -140
- data/spec/rest/spam_reports_spec.rb +81 -109
- data/spec/rest/stats/advanced_spec.rb +67 -125
- data/spec/rest/stats/category_spec.rb +27 -45
- data/spec/rest/stats/global_spec.rb +34 -42
- data/spec/rest/stats/parse_spec.rb +32 -30
- data/spec/rest/stats/stats_spec.rb +174 -172
- data/spec/rest/stats/subuser_spec.rb +97 -57
- data/spec/rest/subusers_spec.rb +156 -209
- data/spec/rest/transactional_templates/templates_spec.rb +199 -0
- data/spec/rest/transactional_templates/versions_spec.rb +228 -0
- data/spec/rest/users_spec.rb +176 -91
- data/spec/rest/webhooks/event_spec.rb +59 -85
- data/spec/rest/webhooks/parse_spec.rb +51 -71
- data/spec/rest/whitelabel/domains_spec.rb +333 -513
- data/spec/rest/whitelabel/ips_spec.rb +109 -147
- data/spec/rest/whitelabel/links_spec.rb +181 -265
- metadata +70 -40
- data/lib/sendgrid4r/rest/api_keys/api_keys.rb +0 -80
- data/lib/sendgrid4r/rest/api_keys/permissions.rb +0 -33
- data/lib/sendgrid4r/rest/campaigns/campaigns.rb +0 -126
- data/lib/sendgrid4r/rest/categories/categories.rb +0 -43
- data/lib/sendgrid4r/rest/contacts/recipients.rb +0 -150
- data/lib/sendgrid4r/rest/contacts/segments.rb +0 -97
- data/lib/sendgrid4r/rest/email_activity/email_activity.rb +0 -81
- data/lib/sendgrid4r/rest/templates/templates.rb +0 -69
- data/lib/sendgrid4r/rest/templates/versions.rb +0 -95
- data/spec/rest/api_keys/api_keys_spec.rb +0 -210
- data/spec/rest/api_keys/permissions_spec.rb +0 -65
- data/spec/rest/campaigns/campaigns_spec.rb +0 -492
- data/spec/rest/categories/categories_spec.rb +0 -96
- data/spec/rest/contacts/custom_fields_spec.rb +0 -174
- data/spec/rest/contacts/lists_spec.rb +0 -372
- data/spec/rest/contacts/recipients_spec.rb +0 -343
- data/spec/rest/contacts/reserved_fields_spec.rb +0 -146
- data/spec/rest/contacts/segments_spec.rb +0 -307
- data/spec/rest/email_activity/email_activity_spec.rb +0 -179
- data/spec/rest/templates/templates_spec.rb +0 -222
- data/spec/rest/templates/versions_spec.rb +0 -252
@@ -1,29 +1,24 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
module SendGrid4r
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
Result = Struct.new(:name, :title, :description, :enabled)
|
3
|
+
module SendGrid4r::REST
|
4
|
+
#
|
5
|
+
# SendGrid Web API v3 Settings
|
6
|
+
#
|
7
|
+
module Settings
|
8
|
+
Results = Struct.new(:result)
|
9
|
+
Result = Struct.new(:name, :title, :description, :enabled)
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
Results.new(results)
|
19
|
-
end
|
11
|
+
def self.create_results(resp)
|
12
|
+
return resp if resp.nil?
|
13
|
+
results = resp['result'].map { |result| Settings.create_result(result) }
|
14
|
+
Results.new(results)
|
15
|
+
end
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
17
|
+
def self.create_result(resp)
|
18
|
+
return resp if resp.nil?
|
19
|
+
Result.new(
|
20
|
+
resp['name'], resp['title'], resp['description'], resp['enabled']
|
21
|
+
)
|
27
22
|
end
|
28
23
|
end
|
29
24
|
end
|
@@ -1,119 +1,109 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
module SendGrid4r
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
3
|
+
module SendGrid4r::REST
|
4
|
+
module Settings
|
5
|
+
#
|
6
|
+
# SendGrid Web API v3 Settings - Tracking
|
7
|
+
#
|
8
|
+
module Tracking
|
9
|
+
include Request
|
10
|
+
|
11
|
+
Click = Struct.new(:enabled)
|
12
|
+
|
13
|
+
def self.create_click(resp)
|
14
|
+
return resp if resp.nil?
|
15
|
+
Click.new(resp['enabled'])
|
16
|
+
end
|
17
|
+
|
18
|
+
GoogleAnalytics = Struct.new(
|
19
|
+
:enabled, :utm_source, :utm_medium, :utm_term, :utm_content,
|
20
|
+
:utm_campaign
|
21
|
+
)
|
22
|
+
|
23
|
+
def self.create_google_analytics(resp)
|
24
|
+
return resp if resp.nil?
|
25
|
+
GoogleAnalytics.new(
|
26
|
+
resp['enabled'], resp['utm_source'], resp['utm_medium'],
|
27
|
+
resp['utm_term'], resp['utm_content'], resp['utm_campaign']
|
22
28
|
)
|
29
|
+
end
|
23
30
|
|
24
|
-
|
25
|
-
return resp if resp.nil?
|
26
|
-
GoogleAnalytics.new(
|
27
|
-
resp['enabled'], resp['utm_source'], resp['utm_medium'],
|
28
|
-
resp['utm_term'], resp['utm_content'], resp['utm_campaign']
|
29
|
-
)
|
30
|
-
end
|
31
|
+
Open = Struct.new(:enabled)
|
31
32
|
|
32
|
-
|
33
|
+
def self.create_open(resp)
|
34
|
+
return resp if resp.nil?
|
35
|
+
Open.new(resp['enabled'])
|
36
|
+
end
|
33
37
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
+
Subscription = Struct.new(
|
39
|
+
:enabled, :landing, :url, :replace, :html_content, :plain_content
|
40
|
+
)
|
38
41
|
|
39
|
-
|
40
|
-
|
42
|
+
def self.create_subscription(resp)
|
43
|
+
return resp if resp.nil?
|
44
|
+
Subscription.new(
|
45
|
+
resp['enabled'], resp['landing'], resp['url'], resp['replace'],
|
46
|
+
resp['html_content'], resp['plain_content']
|
41
47
|
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.url(name = nil)
|
51
|
+
url = "#{BASE_URL}/tracking_settings"
|
52
|
+
url = "#{url}/#{name}" unless name.nil?
|
53
|
+
url
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_tracking_settings(limit: nil, offset: nil, &block)
|
57
|
+
params = {}
|
58
|
+
params[:limit] = limit unless limit.nil?
|
59
|
+
params[:offset] = offset unless offset.nil?
|
60
|
+
resp = get(@auth, Settings::Tracking.url, params, &block)
|
61
|
+
Settings.create_results(resp)
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_settings_click(&block)
|
65
|
+
resp = get(@auth, Settings::Tracking.url(:click), &block)
|
66
|
+
Settings::Tracking.create_click(resp)
|
67
|
+
end
|
68
|
+
|
69
|
+
def patch_settings_click(params:, &block)
|
70
|
+
endpoint = Settings::Tracking.url(:click)
|
71
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
72
|
+
Settings::Tracking.create_click(resp)
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_settings_google_analytics(&block)
|
76
|
+
endpoint = Settings::Tracking.url(:google_analytics)
|
77
|
+
resp = get(@auth, endpoint, &block)
|
78
|
+
Settings::Tracking.create_google_analytics(resp)
|
79
|
+
end
|
80
|
+
|
81
|
+
def patch_settings_google_analytics(params:, &block)
|
82
|
+
endpoint = Settings::Tracking.url(:google_analytics)
|
83
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
84
|
+
Settings::Tracking.create_google_analytics(resp)
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_settings_open(&block)
|
88
|
+
resp = get(@auth, Settings::Tracking.url(:open), &block)
|
89
|
+
Settings::Tracking.create_open(resp)
|
90
|
+
end
|
91
|
+
|
92
|
+
def patch_settings_open(params:, &block)
|
93
|
+
resp = patch(@auth, Settings::Tracking.url(:open), params.to_h, &block)
|
94
|
+
Settings::Tracking.create_open(resp)
|
95
|
+
end
|
96
|
+
|
97
|
+
def get_settings_subscription(&block)
|
98
|
+
endpoint = Settings::Tracking.url(:subscription)
|
99
|
+
resp = get(@auth, endpoint, &block)
|
100
|
+
Settings::Tracking.create_subscription(resp)
|
101
|
+
end
|
42
102
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
resp['html_content'], resp['plain_content']
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.url(name = nil)
|
52
|
-
url = "#{BASE_URL}/tracking_settings"
|
53
|
-
url = "#{url}/#{name}" unless name.nil?
|
54
|
-
url
|
55
|
-
end
|
56
|
-
|
57
|
-
def get_tracking_settings(limit: nil, offset: nil, &block)
|
58
|
-
params = {}
|
59
|
-
params['limit'] = limit unless limit.nil?
|
60
|
-
params['offset'] = offset unless offset.nil?
|
61
|
-
endpoint = SendGrid4r::REST::Settings::Tracking.url
|
62
|
-
resp = get(@auth, endpoint, params, &block)
|
63
|
-
SendGrid4r::REST::Settings.create_results(resp)
|
64
|
-
end
|
65
|
-
|
66
|
-
def get_settings_click(&block)
|
67
|
-
endpoint = SendGrid4r::REST::Settings::Tracking.url('click')
|
68
|
-
resp = get(@auth, endpoint, &block)
|
69
|
-
SendGrid4r::REST::Settings::Tracking.create_click(resp)
|
70
|
-
end
|
71
|
-
|
72
|
-
def patch_settings_click(params:, &block)
|
73
|
-
endpoint = SendGrid4r::REST::Settings::Tracking.url('click')
|
74
|
-
resp = patch(@auth, endpoint, params.to_h, &block)
|
75
|
-
SendGrid4r::REST::Settings::Tracking.create_click(resp)
|
76
|
-
end
|
77
|
-
|
78
|
-
def get_settings_google_analytics(&block)
|
79
|
-
endpoint = SendGrid4r::REST::Settings::Tracking.url(
|
80
|
-
'google_analytics'
|
81
|
-
)
|
82
|
-
resp = get(@auth, endpoint, &block)
|
83
|
-
SendGrid4r::REST::Settings::Tracking.create_google_analytics(resp)
|
84
|
-
end
|
85
|
-
|
86
|
-
def patch_settings_google_analytics(params:, &block)
|
87
|
-
endpoint = SendGrid4r::REST::Settings::Tracking.url(
|
88
|
-
'google_analytics'
|
89
|
-
)
|
90
|
-
resp = patch(@auth, endpoint, params.to_h, &block)
|
91
|
-
SendGrid4r::REST::Settings::Tracking.create_google_analytics(resp)
|
92
|
-
end
|
93
|
-
|
94
|
-
def get_settings_open(&block)
|
95
|
-
endpoint = SendGrid4r::REST::Settings::Tracking.url('open')
|
96
|
-
resp = get(@auth, endpoint, &block)
|
97
|
-
SendGrid4r::REST::Settings::Tracking.create_open(resp)
|
98
|
-
end
|
99
|
-
|
100
|
-
def patch_settings_open(params:, &block)
|
101
|
-
endpoint = SendGrid4r::REST::Settings::Tracking.url('open')
|
102
|
-
resp = patch(@auth, endpoint, params.to_h, &block)
|
103
|
-
SendGrid4r::REST::Settings::Tracking.create_open(resp)
|
104
|
-
end
|
105
|
-
|
106
|
-
def get_settings_subscription(&block)
|
107
|
-
endpoint = SendGrid4r::REST::Settings::Tracking.url('subscription')
|
108
|
-
resp = get(@auth, endpoint, &block)
|
109
|
-
SendGrid4r::REST::Settings::Tracking.create_subscription(resp)
|
110
|
-
end
|
111
|
-
|
112
|
-
def patch_settings_subscription(params:, &block)
|
113
|
-
endpoint = SendGrid4r::REST::Settings::Tracking.url('subscription')
|
114
|
-
resp = patch(@auth, endpoint, params.to_h, &block)
|
115
|
-
SendGrid4r::REST::Settings::Tracking.create_subscription(resp)
|
116
|
-
end
|
103
|
+
def patch_settings_subscription(params:, &block)
|
104
|
+
endpoint = Settings::Tracking.url(:subscription)
|
105
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
106
|
+
Settings::Tracking.create_subscription(resp)
|
117
107
|
end
|
118
108
|
end
|
119
109
|
end
|
@@ -1,75 +1,67 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
module SendGrid4r
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
include SendGrid4r::REST::Request
|
3
|
+
module SendGrid4r::REST
|
4
|
+
module Sm
|
5
|
+
#
|
6
|
+
# SendGrid Web API v3 Suppression Management - Global Unsubscribes
|
7
|
+
#
|
8
|
+
module GlobalUnsubscribes
|
9
|
+
include Request
|
11
10
|
|
12
|
-
|
11
|
+
Unsubscribe = Struct.new(:created, :email)
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def self.url_unsubscribes
|
21
|
-
"#{BASE_URL}/suppression/unsubscribes"
|
22
|
-
end
|
13
|
+
def self.url(email_address = nil)
|
14
|
+
url = "#{BASE_URL}/asm/suppressions/global"
|
15
|
+
url = "#{url}/#{email_address}" unless email_address.nil?
|
16
|
+
url
|
17
|
+
end
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
resp.each do |suppression|
|
28
|
-
created = Time.at(suppression['created'])
|
29
|
-
suppressions.push(Unsubscribe.new(created, suppression['email']))
|
30
|
-
end
|
31
|
-
suppressions
|
32
|
-
end
|
19
|
+
def self.url_unsubscribes
|
20
|
+
"#{BASE_URL}/suppression/unsubscribes"
|
21
|
+
end
|
33
22
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
params['end_time'] = end_time.to_i unless end_time.nil?
|
40
|
-
params['limit'] = limit.to_i unless limit.nil?
|
41
|
-
params['offset'] = offset.to_i unless offset.nil?
|
42
|
-
endpoint = SendGrid4r::REST::Sm::GlobalUnsubscribes.url_unsubscribes
|
43
|
-
resp = get(@auth, endpoint, params, &block)
|
44
|
-
SendGrid4r::REST::Sm::GlobalUnsubscribes.create_supressions(resp)
|
23
|
+
def self.create_supressions(resp)
|
24
|
+
return resp if resp.nil?
|
25
|
+
resp.map do |suppression|
|
26
|
+
created = Time.at(suppression['created'])
|
27
|
+
Unsubscribe.new(created, suppression['email'])
|
45
28
|
end
|
29
|
+
end
|
46
30
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
31
|
+
def get_global_unsubscribes(
|
32
|
+
start_time: nil, end_time: nil, limit: nil, offset: nil, &block
|
33
|
+
)
|
34
|
+
params = {}
|
35
|
+
params[:start_time] = start_time.to_i unless start_time.nil?
|
36
|
+
params[:end_time] = end_time.to_i unless end_time.nil?
|
37
|
+
params[:limit] = limit.to_i unless limit.nil?
|
38
|
+
params[:offset] = offset.to_i unless offset.nil?
|
39
|
+
endpoint = Sm::GlobalUnsubscribes.url_unsubscribes
|
40
|
+
resp = get(@auth, endpoint, params, &block)
|
41
|
+
Sm::GlobalUnsubscribes.create_supressions(resp)
|
42
|
+
end
|
53
43
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
44
|
+
def post_global_suppressed_emails(recipient_emails:, &block)
|
45
|
+
params = { recipient_emails: recipient_emails }
|
46
|
+
endpoint = Sm::GlobalUnsubscribes.url
|
47
|
+
resp = post(@auth, endpoint, params, &block)
|
48
|
+
Sm.create_recipient_emails(resp)
|
49
|
+
end
|
60
50
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
51
|
+
def get_global_suppressed_email(email_address:, &block)
|
52
|
+
resp = get(@auth, Sm::GlobalUnsubscribes.url(email_address), &block)
|
53
|
+
Sm.create_recipient_email(resp)
|
54
|
+
end
|
66
55
|
|
67
|
-
|
68
|
-
|
69
|
-
alias_method(
|
70
|
-
:delete_global_unsubscribe, :delete_global_suppressed_email
|
71
|
-
)
|
56
|
+
def delete_global_suppressed_email(email_address:, &block)
|
57
|
+
delete(@auth, Sm::GlobalUnsubscribes.url(email_address), &block)
|
72
58
|
end
|
59
|
+
|
60
|
+
alias_method(:post_global_unsubscribes, :post_global_suppressed_emails)
|
61
|
+
alias_method(:get_global_unsubscribe, :get_global_suppressed_email)
|
62
|
+
alias_method(
|
63
|
+
:delete_global_unsubscribe, :delete_global_suppressed_email
|
64
|
+
)
|
73
65
|
end
|
74
66
|
end
|
75
67
|
end
|
@@ -1,72 +1,66 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
module SendGrid4r
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
include SendGrid4r::REST::Request
|
3
|
+
module SendGrid4r::REST
|
4
|
+
module Sm
|
5
|
+
#
|
6
|
+
# SendGrid Web API v3 Suppression Management - Groups
|
7
|
+
#
|
8
|
+
module Groups
|
9
|
+
include Request
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
Group = Struct.new(
|
12
|
+
:id, :name, :description, :last_email_sent_at, :is_default,
|
13
|
+
:unsubscribes
|
14
|
+
)
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
def self.url(group_id = nil)
|
17
|
+
url = "#{BASE_URL}/asm/groups"
|
18
|
+
url = "#{url}/#{group_id}" unless group_id.nil?
|
19
|
+
url
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
groups.push(SendGrid4r::REST::Sm::Groups.create_group(group))
|
28
|
-
end
|
29
|
-
groups
|
30
|
-
end
|
22
|
+
def self.create_groups(resp)
|
23
|
+
return resp if resp.nil?
|
24
|
+
resp.map { |group| Sm::Groups.create_group(group) }
|
25
|
+
end
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
27
|
+
def self.create_group(resp)
|
28
|
+
return resp if resp.nil?
|
29
|
+
Group.new(
|
30
|
+
resp['id'],
|
31
|
+
resp['name'],
|
32
|
+
resp['description'],
|
33
|
+
resp['last_email_sent_at'],
|
34
|
+
resp['is_default'],
|
35
|
+
resp['unsubscribes']
|
36
|
+
)
|
37
|
+
end
|
43
38
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
def post_group(name:, description:, is_default: nil, &block)
|
40
|
+
params = { name: name, description: description }
|
41
|
+
params[:is_default] = is_default unless is_default.nil?
|
42
|
+
resp = post(@auth, Sm::Groups.url, params, &block)
|
43
|
+
Sm::Groups.create_group(resp)
|
44
|
+
end
|
50
45
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
46
|
+
def get_groups(&block)
|
47
|
+
resp = get(@auth, Sm::Groups.url, &block)
|
48
|
+
Sm::Groups.create_groups(resp)
|
49
|
+
end
|
55
50
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
def get_group(group_id:, &block)
|
52
|
+
resp = get(@auth, Sm::Groups.url(group_id), &block)
|
53
|
+
Sm::Groups.create_group(resp)
|
54
|
+
end
|
60
55
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
56
|
+
def patch_group(group_id:, group:, &block)
|
57
|
+
endpoint = Sm::Groups.url(group_id)
|
58
|
+
resp = patch(@auth, endpoint, group.to_h, &block)
|
59
|
+
Sm::Groups.create_group(resp)
|
60
|
+
end
|
66
61
|
|
67
|
-
|
68
|
-
|
69
|
-
end
|
62
|
+
def delete_group(group_id:, &block)
|
63
|
+
delete(@auth, Sm::Groups.url(group_id), &block)
|
70
64
|
end
|
71
65
|
end
|
72
66
|
end
|
@@ -1,25 +1,23 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
module SendGrid4r
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
include SendGrid4r::REST::Request
|
3
|
+
module SendGrid4r::REST
|
4
|
+
#
|
5
|
+
# SendGrid Web API v3 Suppression Management
|
6
|
+
#
|
7
|
+
module Sm
|
8
|
+
include Request
|
10
9
|
|
11
|
-
|
12
|
-
|
10
|
+
RecipientEmails = Struct.new(:recipient_emails)
|
11
|
+
RecipientEmail = Struct.new(:recipient_email)
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
def self.create_recipient_emails(resp)
|
14
|
+
return resp if resp.nil?
|
15
|
+
RecipientEmails.new(resp['recipient_emails'])
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
18
|
+
def self.create_recipient_email(resp)
|
19
|
+
return resp if resp.nil?
|
20
|
+
RecipientEmail.new(resp['recipient_email'])
|
23
21
|
end
|
24
22
|
end
|
25
23
|
end
|