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,136 +1,115 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
module SendGrid4r
|
4
|
-
|
3
|
+
module SendGrid4r::REST
|
4
|
+
#
|
5
|
+
# SendGrid Web API v3 Whitelabel
|
6
|
+
#
|
7
|
+
module Whitelabel
|
5
8
|
#
|
6
|
-
# SendGrid Web API v3 Whitelabel
|
9
|
+
# SendGrid Web API v3 Whitelabel Ips
|
7
10
|
#
|
8
|
-
module
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
module Ips
|
12
|
+
include Request
|
13
|
+
|
14
|
+
Ip = Struct.new(
|
15
|
+
:id, :ip, :rdns, :users, :subdomain, :domain, :valid, :legacy,
|
16
|
+
:a_record
|
17
|
+
)
|
18
|
+
User = Struct.new(:username, :user_id)
|
19
|
+
ARecord = Struct.new(:host, :type, :data, :valid)
|
20
|
+
|
21
|
+
def self.url(id = nil)
|
22
|
+
url = "#{BASE_URL}/whitelabel/ips"
|
23
|
+
url = "#{url}/#{id}" unless id.nil?
|
24
|
+
url
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.create_ips(resp)
|
28
|
+
return resp if resp.nil?
|
29
|
+
resp.map { |ip| Ips.create_ip(ip) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.create_ip(resp)
|
33
|
+
return resp if resp.nil?
|
34
|
+
Ip.new(
|
35
|
+
resp['id'],
|
36
|
+
resp['ip'],
|
37
|
+
resp['rdns'],
|
38
|
+
Ips.create_users(resp['users']),
|
39
|
+
resp['subdomain'],
|
40
|
+
resp['domain'],
|
41
|
+
resp['valid'],
|
42
|
+
resp['legacy'],
|
43
|
+
Ips.create_a_record(resp['a_record'])
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.create_users(resp)
|
48
|
+
return resp if resp.nil?
|
49
|
+
resp.map { |user| Ips.create_a_record(user) }
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.create_a_record(resp)
|
53
|
+
return resp if resp.nil?
|
54
|
+
ARecord.new(resp['host'], resp['type'], resp['data'], resp['valid'])
|
55
|
+
end
|
56
|
+
|
57
|
+
Result = Struct.new(:id, :valid, :validation_results)
|
58
|
+
ValidationResults = Struct.new(:a_record)
|
59
|
+
ValidationResult = Struct.new(:valid, :reason)
|
60
|
+
|
61
|
+
def self.create_result(resp)
|
62
|
+
return resp if resp.nil?
|
63
|
+
Result.new(
|
64
|
+
resp['id'],
|
65
|
+
resp['valid'],
|
66
|
+
Ips.create_validation_results(resp['validation_results'])
|
18
67
|
)
|
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
|
-
return resp if resp.nil?
|
65
|
-
ARecord.new(resp['host'], resp['type'], resp['data'], resp['valid'])
|
66
|
-
end
|
67
|
-
|
68
|
-
Result = Struct.new(:id, :valid, :validation_results)
|
69
|
-
ValidationResults = Struct.new(:a_record)
|
70
|
-
ValidationResult = Struct.new(:valid, :reason)
|
71
|
-
|
72
|
-
def self.create_result(resp)
|
73
|
-
return resp if resp.nil?
|
74
|
-
Result.new(
|
75
|
-
resp['id'],
|
76
|
-
resp['valid'],
|
77
|
-
SendGrid4r::REST::Whitelabel::Ips.create_validation_results(
|
78
|
-
resp['validation_results']
|
79
|
-
)
|
80
|
-
)
|
81
|
-
end
|
82
|
-
|
83
|
-
def self.create_validation_results(resp)
|
84
|
-
return resp if resp.nil?
|
85
|
-
ValidationResults.new(
|
86
|
-
SendGrid4r::REST::Whitelabel::Ips.create_validation_result(
|
87
|
-
resp['a_record']
|
88
|
-
)
|
89
|
-
)
|
90
|
-
end
|
91
|
-
|
92
|
-
def self.create_validation_result(resp)
|
93
|
-
return resp if resp.nil?
|
94
|
-
ValidationResult.new(resp['valid'], resp['reason'])
|
95
|
-
end
|
96
|
-
|
97
|
-
def get_wl_ips(ip: nil, limit: nil, offset: nil, &block)
|
98
|
-
params = {}
|
99
|
-
params['ip'] = ip unless ip.nil?
|
100
|
-
params['limit'] = limit unless limit.nil?
|
101
|
-
params['offset'] = offset unless offset.nil?
|
102
|
-
endpoint = SendGrid4r::REST::Whitelabel::Ips.url
|
103
|
-
resp = get(@auth, endpoint, params, &block)
|
104
|
-
SendGrid4r::REST::Whitelabel::Ips.create_ips(resp)
|
105
|
-
end
|
106
|
-
|
107
|
-
def post_wl_ip(ip:, subdomain:, domain:, &block)
|
108
|
-
params = {}
|
109
|
-
params['ip'] = ip
|
110
|
-
params['subdomain'] = subdomain
|
111
|
-
params['domain'] = domain
|
112
|
-
endpoint = SendGrid4r::REST::Whitelabel::Ips.url
|
113
|
-
resp = post(@auth, endpoint, params, &block)
|
114
|
-
SendGrid4r::REST::Whitelabel::Ips.create_ip(resp)
|
115
|
-
end
|
116
|
-
|
117
|
-
def get_wl_ip(id:, &block)
|
118
|
-
endpoint = SendGrid4r::REST::Whitelabel::Ips.url(id)
|
119
|
-
resp = get(@auth, endpoint, nil, &block)
|
120
|
-
SendGrid4r::REST::Whitelabel::Ips.create_ip(resp)
|
121
|
-
end
|
122
|
-
|
123
|
-
def delete_wl_ip(id:, &block)
|
124
|
-
endpoint = SendGrid4r::REST::Whitelabel::Ips.url(id)
|
125
|
-
delete(@auth, endpoint, &block)
|
126
|
-
end
|
127
|
-
|
128
|
-
def validate_wl_ip(id:, &block)
|
129
|
-
endpoint = SendGrid4r::REST::Whitelabel::Ips.url(id)
|
130
|
-
endpoint = "#{endpoint}/validate"
|
131
|
-
resp = post(@auth, endpoint, &block)
|
132
|
-
SendGrid4r::REST::Whitelabel::Ips.create_result(resp)
|
133
|
-
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.create_validation_results(resp)
|
71
|
+
return resp if resp.nil?
|
72
|
+
ValidationResults.new(
|
73
|
+
Ips.create_validation_result(resp['a_record'])
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.create_validation_result(resp)
|
78
|
+
return resp if resp.nil?
|
79
|
+
ValidationResult.new(resp['valid'], resp['reason'])
|
80
|
+
end
|
81
|
+
|
82
|
+
def get_wl_ips(ip: nil, limit: nil, offset: nil, &block)
|
83
|
+
params = {}
|
84
|
+
params[:ip] = ip unless ip.nil?
|
85
|
+
params[:limit] = limit unless limit.nil?
|
86
|
+
params[:offset] = offset unless offset.nil?
|
87
|
+
resp = get(@auth, Ips.url, params, &block)
|
88
|
+
Ips.create_ips(resp)
|
89
|
+
end
|
90
|
+
|
91
|
+
def post_wl_ip(ip:, subdomain:, domain:, &block)
|
92
|
+
params = {
|
93
|
+
ip: ip,
|
94
|
+
subdomain: subdomain,
|
95
|
+
domain: domain
|
96
|
+
}
|
97
|
+
resp = post(@auth, Ips.url, params, &block)
|
98
|
+
Ips.create_ip(resp)
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_wl_ip(id:, &block)
|
102
|
+
resp = get(@auth, Ips.url(id), nil, &block)
|
103
|
+
Ips.create_ip(resp)
|
104
|
+
end
|
105
|
+
|
106
|
+
def delete_wl_ip(id:, &block)
|
107
|
+
delete(@auth, Ips.url(id), &block)
|
108
|
+
end
|
109
|
+
|
110
|
+
def validate_wl_ip(id:, &block)
|
111
|
+
resp = post(@auth, "#{Ips.url(id)}/validate", &block)
|
112
|
+
Ips.create_result(resp)
|
134
113
|
end
|
135
114
|
end
|
136
115
|
end
|
@@ -1,192 +1,156 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
module SendGrid4r
|
4
|
-
|
3
|
+
module SendGrid4r::REST
|
4
|
+
#
|
5
|
+
# SendGrid Web API v3 Whitelabel
|
6
|
+
#
|
7
|
+
module Whitelabel
|
5
8
|
#
|
6
|
-
# SendGrid Web API v3 Whitelabel
|
9
|
+
# SendGrid Web API v3 Whitelabel Links
|
7
10
|
#
|
8
|
-
module
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
module Links
|
12
|
+
include Request
|
13
|
+
|
14
|
+
Link = Struct.new(
|
15
|
+
:id, :domain, :subdomain, :username, :user_id, :default,
|
16
|
+
:valid, :legacy, :dns
|
17
|
+
)
|
18
|
+
Dns = Struct.new(:domain_cname, :owner_cname)
|
19
|
+
Record = Struct.new(:host, :type, :data, :valid)
|
20
|
+
|
21
|
+
def self.url(id = nil)
|
22
|
+
url = "#{BASE_URL}/whitelabel/links"
|
23
|
+
url = "#{url}/#{id}" unless id.nil?
|
24
|
+
url
|
25
|
+
end
|
21
26
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
+
def self.create_links(resp)
|
28
|
+
return resp if resp.nil?
|
29
|
+
resp.map { |link| Links.create_link(link) }
|
30
|
+
end
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
resp
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
def self.create_link(resp)
|
33
|
+
return resp if resp.nil?
|
34
|
+
Link.new(
|
35
|
+
resp['id'],
|
36
|
+
resp['domain'],
|
37
|
+
resp['subdomain'],
|
38
|
+
resp['username'],
|
39
|
+
resp['user_id'],
|
40
|
+
resp['default'],
|
41
|
+
resp['valid'],
|
42
|
+
resp['legacy'],
|
43
|
+
Links.create_dns(resp['dns'])
|
44
|
+
)
|
45
|
+
end
|
38
46
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
resp['user_id'],
|
47
|
-
resp['default'],
|
48
|
-
resp['valid'],
|
49
|
-
resp['legacy'],
|
50
|
-
SendGrid4r::REST::Whitelabel::Links.create_dns(resp['dns'])
|
51
|
-
)
|
52
|
-
end
|
47
|
+
def self.create_dns(resp)
|
48
|
+
return resp if resp.nil?
|
49
|
+
Dns.new(
|
50
|
+
Links.create_record(resp['domain_cname']),
|
51
|
+
Links.create_record(resp['owner_cname'])
|
52
|
+
)
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
resp['domain_cname']
|
59
|
-
),
|
60
|
-
SendGrid4r::REST::Whitelabel::Links.create_record(
|
61
|
-
resp['owner_cname']
|
62
|
-
)
|
63
|
-
)
|
64
|
-
end
|
55
|
+
def self.create_record(resp)
|
56
|
+
return resp if resp.nil?
|
57
|
+
Record.new(resp['host'], resp['type'], resp['data'], resp['valid'])
|
58
|
+
end
|
65
59
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
60
|
+
Result = Struct.new(:id, :valid, :validation_results)
|
61
|
+
ValidationResults = Struct.new(:domain_cname, :owner_cname)
|
62
|
+
ValidationResult = Struct.new(:valid, :reason)
|
70
63
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
resp['valid'],
|
80
|
-
SendGrid4r::REST::Whitelabel::Links.create_validation_results(
|
81
|
-
resp['validation_results']
|
82
|
-
)
|
83
|
-
)
|
84
|
-
end
|
64
|
+
def self.create_result(resp)
|
65
|
+
return resp if resp.nil?
|
66
|
+
Result.new(
|
67
|
+
resp['id'],
|
68
|
+
resp['valid'],
|
69
|
+
Links.create_validation_results(resp['validation_results'])
|
70
|
+
)
|
71
|
+
end
|
85
72
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
resp['owner_cname']
|
94
|
-
)
|
95
|
-
)
|
96
|
-
end
|
73
|
+
def self.create_validation_results(resp)
|
74
|
+
return resp if resp.nil?
|
75
|
+
ValidationResults.new(
|
76
|
+
Links.create_validation_result(resp['domain_cname']),
|
77
|
+
Links.create_validation_result(resp['owner_cname'])
|
78
|
+
)
|
79
|
+
end
|
97
80
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
81
|
+
def self.create_validation_result(resp)
|
82
|
+
return resp if resp.nil?
|
83
|
+
ValidationResult.new(resp['valid'], resp['reason'])
|
84
|
+
end
|
102
85
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
86
|
+
def get_wl_links(
|
87
|
+
limit: nil, offset: nil, exclude_subusers: nil, username: nil,
|
88
|
+
domain: nil, &block
|
89
|
+
)
|
90
|
+
params = {}
|
91
|
+
params[:limit] = limit unless limit.nil?
|
92
|
+
params[:offset] = offset unless offset.nil?
|
93
|
+
unless exclude_subusers.nil?
|
94
|
+
params[:exclude_subusers] = exclude_subusers
|
95
|
+
end
|
96
|
+
params[:username] = username unless username.nil?
|
97
|
+
params[:domain] = domain unless domain.nil?
|
98
|
+
resp = get(@auth, Links.url, params, &block)
|
99
|
+
Links.create_links(resp)
|
100
|
+
end
|
119
101
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
102
|
+
def post_wl_link(subdomain:, domain:, default: nil, &block)
|
103
|
+
params = {
|
104
|
+
subdomain: subdomain,
|
105
|
+
domain: domain
|
106
|
+
}
|
107
|
+
params[:default] = default unless default.nil?
|
108
|
+
resp = post(@auth, Links.url, params, &block)
|
109
|
+
Links.create_link(resp)
|
110
|
+
end
|
129
111
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
end
|
112
|
+
def get_wl_link(id:, &block)
|
113
|
+
resp = get(@auth, Links.url(id), nil, &block)
|
114
|
+
Links.create_link(resp)
|
115
|
+
end
|
135
116
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
SendGrid4r::REST::Whitelabel::Links.create_link(resp)
|
142
|
-
end
|
117
|
+
def patch_wl_link(id:, default:, &block)
|
118
|
+
params = { default: default }
|
119
|
+
resp = patch(@auth, Links.url(id), params, &block)
|
120
|
+
Links.create_link(resp)
|
121
|
+
end
|
143
122
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
end
|
123
|
+
def delete_wl_link(id:, &block)
|
124
|
+
delete(@auth, Links.url(id), &block)
|
125
|
+
end
|
148
126
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
SendGrid4r::REST::Whitelabel::Links.create_link(resp)
|
156
|
-
end
|
127
|
+
def get_default_wl_link(domain: nil, &block)
|
128
|
+
params = {}
|
129
|
+
params[:domain] = domain unless domain.nil?
|
130
|
+
resp = get(@auth, "#{Links.url}/default", params, &block)
|
131
|
+
Links.create_link(resp)
|
132
|
+
end
|
157
133
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
SendGrid4r::REST::Whitelabel::Links.create_result(resp)
|
163
|
-
end
|
134
|
+
def validate_wl_link(id:, &block)
|
135
|
+
resp = post(@auth, "#{Links.url(id)}/validate", &block)
|
136
|
+
Links.create_result(resp)
|
137
|
+
end
|
164
138
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
resp = get(@auth, endpoint, params, &block)
|
171
|
-
SendGrid4r::REST::Whitelabel::Links.create_link(resp)
|
172
|
-
end
|
139
|
+
def get_associated_wl_link(username:, &block)
|
140
|
+
params = { username: username }
|
141
|
+
resp = get(@auth, "#{Links.url}/subuser", params, &block)
|
142
|
+
Links.create_link(resp)
|
143
|
+
end
|
173
144
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
params['username'] = username
|
179
|
-
delete(@auth, endpoint, params, &block)
|
180
|
-
end
|
145
|
+
def disassociate_wl_link(username:, &block)
|
146
|
+
params = { username: username }
|
147
|
+
delete(@auth, "#{Links.url}/subuser", params, &block)
|
148
|
+
end
|
181
149
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
params['username'] = username
|
187
|
-
resp = post(@auth, endpoint, params, &block)
|
188
|
-
SendGrid4r::REST::Whitelabel::Links.create_link(resp)
|
189
|
-
end
|
150
|
+
def associate_wl_link(id:, username:, &block)
|
151
|
+
params = { username: username }
|
152
|
+
resp = post(@auth, "#{Links.url(id)}/subuser", params, &block)
|
153
|
+
Links.create_link(resp)
|
190
154
|
end
|
191
155
|
end
|
192
156
|
end
|
data/lib/sendgrid4r/version.rb
CHANGED
data/lib/sendgrid4r.rb
CHANGED
@@ -6,11 +6,11 @@ require 'sendgrid4r/rest/request'
|
|
6
6
|
require 'sendgrid4r/rest/subusers'
|
7
7
|
require 'sendgrid4r/rest/users'
|
8
8
|
|
9
|
-
require 'sendgrid4r/rest/
|
10
|
-
require 'sendgrid4r/rest/
|
9
|
+
require 'sendgrid4r/rest/transactional_templates/templates'
|
10
|
+
require 'sendgrid4r/rest/transactional_templates/versions'
|
11
11
|
|
12
|
-
require 'sendgrid4r/rest/
|
13
|
-
require 'sendgrid4r/rest/
|
12
|
+
require 'sendgrid4r/rest/api_keys_management/api_keys'
|
13
|
+
require 'sendgrid4r/rest/api_keys_management/permissions'
|
14
14
|
|
15
15
|
require 'sendgrid4r/rest/sm/sm'
|
16
16
|
require 'sendgrid4r/rest/sm/global_unsubscribes'
|
@@ -23,17 +23,17 @@ require 'sendgrid4r/rest/invalid_emails'
|
|
23
23
|
require 'sendgrid4r/rest/spam_reports'
|
24
24
|
require 'sendgrid4r/rest/cancel_scheduled_sends'
|
25
25
|
|
26
|
-
require 'sendgrid4r/rest/
|
26
|
+
require 'sendgrid4r/rest/marketing_campaigns/marketing_campaigns'
|
27
|
+
require 'sendgrid4r/rest/marketing_campaigns/senders'
|
28
|
+
require 'sendgrid4r/rest/marketing_campaigns/contacts/custom_fields'
|
29
|
+
require 'sendgrid4r/rest/marketing_campaigns/contacts/lists'
|
30
|
+
require 'sendgrid4r/rest/marketing_campaigns/contacts/recipients'
|
31
|
+
require 'sendgrid4r/rest/marketing_campaigns/contacts/reserved_fields'
|
32
|
+
require 'sendgrid4r/rest/marketing_campaigns/contacts/segments'
|
27
33
|
|
28
|
-
require 'sendgrid4r/rest/categories
|
34
|
+
require 'sendgrid4r/rest/categories'
|
29
35
|
|
30
|
-
require 'sendgrid4r/rest/
|
31
|
-
require 'sendgrid4r/rest/contacts/lists'
|
32
|
-
require 'sendgrid4r/rest/contacts/recipients'
|
33
|
-
require 'sendgrid4r/rest/contacts/reserved_fields'
|
34
|
-
require 'sendgrid4r/rest/contacts/segments'
|
35
|
-
|
36
|
-
require 'sendgrid4r/rest/email_activity/email_activity'
|
36
|
+
require 'sendgrid4r/rest/email_activity'
|
37
37
|
|
38
38
|
require 'sendgrid4r/rest/ip_access_management'
|
39
39
|
|
@@ -61,10 +61,20 @@ require 'sendgrid4r/rest/whitelabel/domains'
|
|
61
61
|
require 'sendgrid4r/rest/whitelabel/ips'
|
62
62
|
require 'sendgrid4r/rest/whitelabel/links'
|
63
63
|
|
64
|
+
require 'sendgrid4r/rest/mail/attachment'
|
65
|
+
require 'sendgrid4r/rest/mail/content'
|
66
|
+
require 'sendgrid4r/rest/mail/address'
|
67
|
+
require 'sendgrid4r/rest/mail/mail_settings'
|
68
|
+
require 'sendgrid4r/rest/mail/mail'
|
69
|
+
require 'sendgrid4r/rest/mail/params'
|
70
|
+
require 'sendgrid4r/rest/mail/personalization'
|
71
|
+
require 'sendgrid4r/rest/mail/tracking_settings'
|
72
|
+
|
64
73
|
require 'sendgrid4r/factory/campaign_factory'
|
65
74
|
require 'sendgrid4r/factory/condition_factory'
|
66
75
|
require 'sendgrid4r/factory/segment_factory'
|
67
76
|
require 'sendgrid4r/factory/version_factory'
|
77
|
+
require 'sendgrid4r/factory/mail_factory'
|
68
78
|
|
69
79
|
require 'sendgrid4r/rest/api'
|
70
80
|
|
data/sendgrid4r.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency('rest-client', '>=1.8.0', '<1.9.0')
|
22
22
|
spec.add_development_dependency('rubocop', '>=0.29.0', '<0.34.3')
|
23
|
-
spec.add_development_dependency('bundler', '>=1.6.0', '<1.
|
23
|
+
spec.add_development_dependency('bundler', '>=1.6.0', '<1.13.0')
|
24
24
|
spec.add_development_dependency('rspec', '3.3.0')
|
25
25
|
spec.add_development_dependency('dotenv', '=0.11.0', '<=2.0.2')
|
26
26
|
end
|