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
@@ -4,80 +4,78 @@ require 'rest-client'
|
|
4
4
|
require 'uri'
|
5
5
|
require 'json'
|
6
6
|
|
7
|
-
module SendGrid4r
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
BASE_URL = 'https://api.sendgrid.com/v3'
|
7
|
+
module SendGrid4r::REST
|
8
|
+
#
|
9
|
+
# SendGrid Web API v3 Request
|
10
|
+
#
|
11
|
+
module Request
|
12
|
+
BASE_URL = 'https://api.sendgrid.com/v3'
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def get(auth, endpoint, params = nil, payload = nil, &block)
|
15
|
+
execute(:get, auth, endpoint, params, payload, &block)
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def post(auth, endpoint, payload = nil, &block)
|
19
|
+
execute(:post, auth, endpoint, nil, payload, &block)
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
def patch(auth, endpoint, payload, &block)
|
23
|
+
execute(:patch, auth, endpoint, nil, payload, &block)
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
def put(auth, endpoint, payload, &block)
|
27
|
+
execute(:put, auth, endpoint, nil, payload, &block)
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
def delete(auth, endpoint, params = nil, payload = nil, &block)
|
31
|
+
execute(:delete, auth, endpoint, params, payload, &block)
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
34
|
+
def execute(method, auth, endpoint, params, payload, &block)
|
35
|
+
args = create_args(method, auth, endpoint, params, payload)
|
36
|
+
body = RestClient::Request.execute(args, &block)
|
37
|
+
return nil if block_given?
|
38
|
+
return JSON.parse(body) unless body.nil? || body.length < 2
|
39
|
+
body
|
40
|
+
rescue RestClient::TooManyRequests => e
|
41
|
+
duration = e.response.headers[:x_ratelimit_remaining].to_i
|
42
|
+
sleep duration if duration > 0
|
43
|
+
retry
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
args[:headers] = headers
|
63
|
-
args[:payload] = payload.to_json unless payload.nil?
|
64
|
-
args
|
46
|
+
def create_args(method, auth, endpoint, params, payload)
|
47
|
+
args = {}
|
48
|
+
args[:method] = method
|
49
|
+
args[:url] = process_url_params(endpoint, params)
|
50
|
+
headers = {}
|
51
|
+
headers[:content_type] = :json
|
52
|
+
# Added for Campaign API
|
53
|
+
headers['Accept-Encoding'] = 'plain'
|
54
|
+
#
|
55
|
+
if !auth.api_key.nil?
|
56
|
+
headers[:authorization] = "Bearer #{auth.api_key}"
|
57
|
+
else
|
58
|
+
args[:user] = auth.username
|
59
|
+
args[:password] = auth.password
|
65
60
|
end
|
61
|
+
args[:headers] = headers
|
62
|
+
args[:payload] = payload.to_json unless payload.nil?
|
63
|
+
args
|
64
|
+
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
66
|
+
def process_url_params(endpoint, params)
|
67
|
+
if params.nil? || params.empty?
|
68
|
+
endpoint
|
69
|
+
else
|
70
|
+
query_string = params.collect do |k, v|
|
71
|
+
"#{k}=#{CGI.escape(process_array_params(v))}"
|
72
|
+
end.join('&')
|
73
|
+
endpoint + "?#{query_string}"
|
76
74
|
end
|
75
|
+
end
|
77
76
|
|
78
|
-
|
79
|
-
|
80
|
-
end
|
77
|
+
def process_array_params(v)
|
78
|
+
v.is_a?(Array) ? v.join(',') : v.to_s
|
81
79
|
end
|
82
80
|
end
|
83
81
|
end
|
@@ -1,35 +1,32 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
module SendGrid4r
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
include SendGrid4r::REST::Request
|
11
|
-
EnforcedTls = Struct.new(:require_tls, :require_valid_cert)
|
3
|
+
module SendGrid4r::REST
|
4
|
+
module Settings
|
5
|
+
#
|
6
|
+
# SendGrid Web API v3 Settings - EnforcedTls
|
7
|
+
#
|
8
|
+
module EnforcedTls
|
9
|
+
include Request
|
12
10
|
|
13
|
-
|
14
|
-
return resp if resp.nil?
|
15
|
-
EnforcedTls.new(resp['require_tls'], resp['require_valid_cert'])
|
16
|
-
end
|
11
|
+
EnforcedTls = Struct.new(:require_tls, :require_valid_cert)
|
17
12
|
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
def self.create_enforced_tls(resp)
|
14
|
+
return resp if resp.nil?
|
15
|
+
EnforcedTls.new(resp['require_tls'], resp['require_valid_cert'])
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.url
|
19
|
+
"#{BASE_URL}/user/settings/enforced_tls"
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
22
|
+
def get_enforced_tls(&block)
|
23
|
+
resp = get(@auth, Settings::EnforcedTls.url, &block)
|
24
|
+
Settings::EnforcedTls.create_enforced_tls(resp)
|
25
|
+
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
SendGrid4r::REST::Settings::EnforcedTls.create_enforced_tls(resp)
|
32
|
-
end
|
27
|
+
def patch_enforced_tls(params:, &block)
|
28
|
+
resp = patch(@auth, Settings::EnforcedTls.url, params.to_h, &block)
|
29
|
+
Settings::EnforcedTls.create_enforced_tls(resp)
|
33
30
|
end
|
34
31
|
end
|
35
32
|
end
|
@@ -1,188 +1,172 @@
|
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
endpoint = SendGrid4r::REST::Settings::Mail.url('template')
|
171
|
-
resp = patch(@auth, endpoint, params.to_h, &block)
|
172
|
-
SendGrid4r::REST::Settings::Mail.create_template(resp)
|
173
|
-
end
|
174
|
-
|
175
|
-
def get_settings_plain_content(&block)
|
176
|
-
endpoint = SendGrid4r::REST::Settings::Mail.url('plain_content')
|
177
|
-
resp = get(@auth, endpoint, &block)
|
178
|
-
SendGrid4r::REST::Settings::Mail.create_plain_content(resp)
|
179
|
-
end
|
180
|
-
|
181
|
-
def patch_settings_plain_content(params:, &block)
|
182
|
-
endpoint = SendGrid4r::REST::Settings::Mail.url('plain_content')
|
183
|
-
resp = patch(@auth, endpoint, params.to_h, &block)
|
184
|
-
SendGrid4r::REST::Settings::Mail.create_plain_content(resp)
|
185
|
-
end
|
3
|
+
module SendGrid4r::REST
|
4
|
+
module Settings
|
5
|
+
#
|
6
|
+
# SendGrid Web API v3 Settings - Mail
|
7
|
+
#
|
8
|
+
module Mail
|
9
|
+
include Request
|
10
|
+
|
11
|
+
AddressWhitelist = Struct.new(:enabled, :list)
|
12
|
+
|
13
|
+
def self.create_address_whitelist(resp)
|
14
|
+
return resp if resp.nil?
|
15
|
+
AddressWhitelist.new(resp['enabled'], resp['list'])
|
16
|
+
end
|
17
|
+
|
18
|
+
Bcc = Struct.new(:enabled, :email)
|
19
|
+
|
20
|
+
def self.create_bcc(resp)
|
21
|
+
return resp if resp.nil?
|
22
|
+
Bcc.new(resp['enabled'], resp['email'])
|
23
|
+
end
|
24
|
+
|
25
|
+
BouncePurge = Struct.new(:enabled, :hard_bounces, :soft_bounces)
|
26
|
+
|
27
|
+
def self.create_bounce_purge(resp)
|
28
|
+
return resp if resp.nil?
|
29
|
+
BouncePurge.new(
|
30
|
+
resp['enabled'], resp['hard_bounces'], resp['soft_bounces']
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
Footer = Struct.new(:enabled, :html_content, :plain_content)
|
35
|
+
|
36
|
+
def self.create_footer(resp)
|
37
|
+
return resp if resp.nil?
|
38
|
+
Footer.new(
|
39
|
+
resp['enabled'], resp['html_content'], resp['plain_content']
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
ForwardBounce = Struct.new(:enabled, :email)
|
44
|
+
|
45
|
+
def self.create_forward_bounce(resp)
|
46
|
+
return resp if resp.nil?
|
47
|
+
ForwardBounce.new(resp['enabled'], resp['email'])
|
48
|
+
end
|
49
|
+
|
50
|
+
ForwardSpam = Struct.new(:enabled, :email)
|
51
|
+
|
52
|
+
def self.create_forward_spam(resp)
|
53
|
+
return resp if resp.nil?
|
54
|
+
ForwardSpam.new(resp['enabled'], resp['email'])
|
55
|
+
end
|
56
|
+
|
57
|
+
Template = Struct.new(:enabled, :html_content)
|
58
|
+
|
59
|
+
def self.create_template(resp)
|
60
|
+
return resp if resp.nil?
|
61
|
+
Template.new(resp['enabled'], resp['html_content'])
|
62
|
+
end
|
63
|
+
|
64
|
+
PlainContent = Struct.new(:enabled)
|
65
|
+
|
66
|
+
def self.create_plain_content(resp)
|
67
|
+
return resp if resp.nil?
|
68
|
+
PlainContent.new(resp['enabled'])
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.url(name = nil)
|
72
|
+
url = "#{BASE_URL}/mail_settings"
|
73
|
+
url = "#{url}/#{name}" unless name.nil?
|
74
|
+
url
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_mail_settings(limit: nil, offset: nil, &block)
|
78
|
+
params = {}
|
79
|
+
params[:limit] = limit unless limit.nil?
|
80
|
+
params[:offset] = offset unless offset.nil?
|
81
|
+
resp = get(@auth, Settings::Mail.url, params, &block)
|
82
|
+
Settings.create_results(resp)
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_settings_address_whitelist(&block)
|
86
|
+
resp = get(@auth, Settings::Mail.url(:address_whitelist), &block)
|
87
|
+
Settings::Mail.create_address_whitelist(resp)
|
88
|
+
end
|
89
|
+
|
90
|
+
def patch_settings_address_whitelist(params:, &block)
|
91
|
+
endpoint = Settings::Mail.url(:address_whitelist)
|
92
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
93
|
+
Settings::Mail.create_address_whitelist(resp)
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_settings_bcc(&block)
|
97
|
+
resp = get(@auth, Settings::Mail.url(:bcc), &block)
|
98
|
+
Settings::Mail.create_bcc(resp)
|
99
|
+
end
|
100
|
+
|
101
|
+
def patch_settings_bcc(params:, &block)
|
102
|
+
endpoint = Settings::Mail.url(:bcc)
|
103
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
104
|
+
Settings::Mail.create_bcc(resp)
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_settings_bounce_purge(&block)
|
108
|
+
resp = get(@auth, Settings::Mail.url(:bounce_purge), &block)
|
109
|
+
Settings::Mail.create_bounce_purge(resp)
|
110
|
+
end
|
111
|
+
|
112
|
+
def patch_settings_bounce_purge(params:, &block)
|
113
|
+
endpoint = Settings::Mail.url(:bounce_purge)
|
114
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
115
|
+
Settings::Mail.create_bounce_purge(resp)
|
116
|
+
end
|
117
|
+
|
118
|
+
def get_settings_footer(&block)
|
119
|
+
resp = get(@auth, Settings::Mail.url(:footer), &block)
|
120
|
+
Settings::Mail.create_footer(resp)
|
121
|
+
end
|
122
|
+
|
123
|
+
def patch_settings_footer(params:, &block)
|
124
|
+
resp = patch(@auth, Settings::Mail.url(:footer), params.to_h, &block)
|
125
|
+
Settings::Mail.create_footer(resp)
|
126
|
+
end
|
127
|
+
|
128
|
+
def get_settings_forward_bounce(&block)
|
129
|
+
resp = get(@auth, Settings::Mail.url(:forward_bounce), &block)
|
130
|
+
Settings::Mail.create_forward_bounce(resp)
|
131
|
+
end
|
132
|
+
|
133
|
+
def patch_settings_forward_bounce(params:, &block)
|
134
|
+
endpoint = Settings::Mail.url(:forward_bounce)
|
135
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
136
|
+
Settings::Mail.create_forward_bounce(resp)
|
137
|
+
end
|
138
|
+
|
139
|
+
def get_settings_forward_spam(&block)
|
140
|
+
resp = get(@auth, Settings::Mail.url(:forward_spam), &block)
|
141
|
+
Settings::Mail.create_forward_spam(resp)
|
142
|
+
end
|
143
|
+
|
144
|
+
def patch_settings_forward_spam(params:, &block)
|
145
|
+
endpoint = Settings::Mail.url(:forward_spam)
|
146
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
147
|
+
Settings::Mail.create_forward_spam(resp)
|
148
|
+
end
|
149
|
+
|
150
|
+
def get_settings_template(&block)
|
151
|
+
resp = get(@auth, Settings::Mail.url(:template), &block)
|
152
|
+
Settings::Mail.create_template(resp)
|
153
|
+
end
|
154
|
+
|
155
|
+
def patch_settings_template(params:, &block)
|
156
|
+
endpoint = Settings::Mail.url(:template)
|
157
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
158
|
+
Settings::Mail.create_template(resp)
|
159
|
+
end
|
160
|
+
|
161
|
+
def get_settings_plain_content(&block)
|
162
|
+
resp = get(@auth, Settings::Mail.url(:plain_content), &block)
|
163
|
+
Settings::Mail.create_plain_content(resp)
|
164
|
+
end
|
165
|
+
|
166
|
+
def patch_settings_plain_content(params:, &block)
|
167
|
+
endpoint = Settings::Mail.url(:plain_content)
|
168
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
169
|
+
Settings::Mail.create_plain_content(resp)
|
186
170
|
end
|
187
171
|
end
|
188
172
|
end
|
@@ -1,46 +1,43 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
module SendGrid4r
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
include SendGrid4r::REST::Request
|
11
|
-
Partner = Struct.new(:enabled, :license_key)
|
3
|
+
module SendGrid4r::REST
|
4
|
+
module Settings
|
5
|
+
#
|
6
|
+
# SendGrid Web API v3 Settings - Partner
|
7
|
+
#
|
8
|
+
module Partner
|
9
|
+
include Request
|
12
10
|
|
13
|
-
|
14
|
-
return resp if resp.nil?
|
15
|
-
Partner.new(resp['enabled'], resp['license_key'])
|
16
|
-
end
|
11
|
+
Partner = Struct.new(:enabled, :license_key)
|
17
12
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
13
|
+
def self.create_partner(resp)
|
14
|
+
return resp if resp.nil?
|
15
|
+
Partner.new(resp['enabled'], resp['license_key'])
|
16
|
+
end
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
resp = get(@auth, endpoint, params, &block)
|
30
|
-
SendGrid4r::REST::Settings.create_results(resp)
|
31
|
-
end
|
18
|
+
def self.url(name = nil)
|
19
|
+
url = "#{BASE_URL}/partner_settings"
|
20
|
+
url = "#{url}/#{name}" unless name.nil?
|
21
|
+
url
|
22
|
+
end
|
32
23
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
24
|
+
def get_partner_settings(limit: nil, offset: nil, &block)
|
25
|
+
params = {}
|
26
|
+
params[:limit] = limit unless limit.nil?
|
27
|
+
params[:offset] = offset unless offset.nil?
|
28
|
+
resp = get(@auth, Settings::Partner.url, params, &block)
|
29
|
+
Settings.create_results(resp)
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_settings_new_relic(&block)
|
33
|
+
resp = get(@auth, Settings::Partner.url(:new_relic), &block)
|
34
|
+
Settings::Partner.create_partner(resp)
|
35
|
+
end
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
37
|
+
def patch_settings_new_relic(params:, &block)
|
38
|
+
endpoint = Settings::Partner.url(:new_relic)
|
39
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
40
|
+
Settings::Partner.create_partner(resp)
|
44
41
|
end
|
45
42
|
end
|
46
43
|
end
|