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,64 +1,132 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
module SendGrid4r
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
module SendGrid4r::REST
|
4
|
+
#
|
5
|
+
# SendGrid Web API v3 Users
|
6
|
+
#
|
7
|
+
module Users
|
8
|
+
include Request
|
9
|
+
|
10
|
+
Profile = Struct.new(
|
11
|
+
:address, :city, :company, :country, :first_name, :last_name,
|
12
|
+
:phone, :state, :website, :zip
|
13
|
+
)
|
14
|
+
|
15
|
+
Account = Struct.new(:type, :reputation)
|
16
|
+
|
17
|
+
Email = Struct.new(:email)
|
18
|
+
|
19
|
+
Username = Struct.new(:username, :user_id)
|
20
|
+
|
21
|
+
Credits = Struct.new(
|
22
|
+
:remain, :total, :overage, :used, :last_reset, :next_reset,
|
23
|
+
:reset_frequency
|
24
|
+
)
|
25
|
+
|
26
|
+
Password = Struct.new(:new_password, :old_password)
|
27
|
+
|
28
|
+
def self.url(path)
|
29
|
+
"#{BASE_URL}/user/#{path}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.create_profile(resp)
|
33
|
+
return resp if resp.nil?
|
34
|
+
Profile.new(
|
35
|
+
resp['address'],
|
36
|
+
resp['city'],
|
37
|
+
resp['company'],
|
38
|
+
resp['country'],
|
39
|
+
resp['first_name'],
|
40
|
+
resp['last_name'],
|
41
|
+
resp['phone'],
|
42
|
+
resp['state'],
|
43
|
+
resp['website'],
|
44
|
+
resp['zip']
|
14
45
|
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.create_account(resp)
|
49
|
+
return resp if resp.nil?
|
50
|
+
Account.new(resp['type'], resp['reputation'])
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.create_email(resp)
|
54
|
+
return resp if resp.nil?
|
55
|
+
Email.new(resp['email'])
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.create_username(resp)
|
59
|
+
return resp if resp.nil?
|
60
|
+
Username.new(resp['username'], resp['user_id'])
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.create_credits(resp)
|
64
|
+
return resp if resp.nil?
|
65
|
+
Credits.new(
|
66
|
+
resp['remain'],
|
67
|
+
resp['total'],
|
68
|
+
resp['overage'],
|
69
|
+
resp['used'],
|
70
|
+
resp['last_reset'],
|
71
|
+
resp['next_reset'],
|
72
|
+
resp['reset_frequency']
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.create_password(resp)
|
77
|
+
return resp if resp.nil?
|
78
|
+
Password.new(resp['new_password'], resp['old_password'])
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_user_profile(&block)
|
82
|
+
resp = get(@auth, Users.url(:profile), nil, &block)
|
83
|
+
Users.create_profile(resp)
|
84
|
+
end
|
85
|
+
|
86
|
+
def patch_user_profile(params:, &block)
|
87
|
+
resp = patch(@auth, Users.url(:profile), params, &block)
|
88
|
+
Users.create_profile(resp)
|
89
|
+
end
|
90
|
+
|
91
|
+
def get_user_account(&block)
|
92
|
+
resp = get(@auth, Users.url(:account), nil, &block)
|
93
|
+
Users.create_account(resp)
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_user_email(&block)
|
97
|
+
resp = get(@auth, Users.url(:email), nil, &block)
|
98
|
+
Users.create_email(resp)
|
99
|
+
end
|
100
|
+
|
101
|
+
def put_user_email(email:, &block)
|
102
|
+
params = { email: email }
|
103
|
+
resp = put(@auth, Users.url(:email), params, &block)
|
104
|
+
Users.create_email(resp)
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_user_username(&block)
|
108
|
+
resp = get(@auth, Users.url(:username), nil, &block)
|
109
|
+
Users.create_username(resp)
|
110
|
+
end
|
111
|
+
|
112
|
+
def put_user_username(username:, &block)
|
113
|
+
params = { username: username }
|
114
|
+
resp = put(@auth, Users.url(:username), params, &block)
|
115
|
+
Users.create_username(resp)
|
116
|
+
end
|
117
|
+
|
118
|
+
def get_user_credits(&block)
|
119
|
+
resp = get(@auth, Users.url(:credits), &block)
|
120
|
+
Users.create_credits(resp)
|
121
|
+
end
|
15
122
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def self.create_profile(resp)
|
24
|
-
return resp if resp.nil?
|
25
|
-
Profile.new(
|
26
|
-
resp['address'],
|
27
|
-
resp['city'],
|
28
|
-
resp['company'],
|
29
|
-
resp['country'],
|
30
|
-
resp['first_name'],
|
31
|
-
resp['last_name'],
|
32
|
-
resp['phone'],
|
33
|
-
resp['state'],
|
34
|
-
resp['website'],
|
35
|
-
resp['zip']
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.create_account(resp)
|
40
|
-
return resp if resp.nil?
|
41
|
-
Account.new(
|
42
|
-
resp['type'],
|
43
|
-
resp['reputation']
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
def get_user_profile(&block)
|
48
|
-
resp = get(@auth, SendGrid4r::REST::Users.url('profile'), nil, &block)
|
49
|
-
SendGrid4r::REST::Users.create_profile(resp)
|
50
|
-
end
|
51
|
-
|
52
|
-
def patch_user_profile(params:, &block)
|
53
|
-
endpoint = SendGrid4r::REST::Users.url('profile')
|
54
|
-
resp = patch(@auth, endpoint, params, &block)
|
55
|
-
SendGrid4r::REST::Users.create_profile(resp)
|
56
|
-
end
|
57
|
-
|
58
|
-
def get_user_account(&block)
|
59
|
-
resp = get(@auth, SendGrid4r::REST::Users.url('account'), nil, &block)
|
60
|
-
SendGrid4r::REST::Users.create_account(resp)
|
61
|
-
end
|
123
|
+
def put_user_password(new_password:, old_password:, &block)
|
124
|
+
params = {
|
125
|
+
new_password: new_password,
|
126
|
+
old_password: old_password
|
127
|
+
}
|
128
|
+
resp = put(@auth, Users.url(:password), params, &block)
|
129
|
+
Users.create_password(resp)
|
62
130
|
end
|
63
131
|
end
|
64
132
|
end
|
@@ -1,55 +1,49 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
module SendGrid4r
|
4
|
-
|
3
|
+
module SendGrid4r::REST
|
4
|
+
#
|
5
|
+
# SendGrid Web API v3 Webhooks
|
6
|
+
#
|
7
|
+
module Webhooks
|
5
8
|
#
|
6
|
-
# SendGrid Web API v3 Webhooks
|
9
|
+
# SendGrid Web API v3 Webhooks ParseApi
|
7
10
|
#
|
8
|
-
module
|
9
|
-
|
10
|
-
# SendGrid Web API v3 Webhooks ParseApi
|
11
|
-
#
|
12
|
-
module Event
|
13
|
-
include SendGrid4r::REST::Request
|
11
|
+
module Event
|
12
|
+
include Request
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def self.url_event(path)
|
15
|
+
"#{BASE_URL}/user/webhooks/event/#{path}"
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
EventNotification = Struct.new(
|
19
|
+
:enabled, :url, :group_resubscribe, :delivered, :group_unsubscribe,
|
20
|
+
:spam_report, :bounce, :deferred, :unsubscribe, :processed, :open,
|
21
|
+
:click, :dropped
|
22
|
+
)
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
24
|
+
def self.create_event_notification(resp)
|
25
|
+
return resp if resp.nil?
|
26
|
+
EventNotification.new(
|
27
|
+
resp['enabled'], resp['url'], resp['group_resubscribe'],
|
28
|
+
resp['delivered'], resp['group_unsubscribe'], resp['spam_report'],
|
29
|
+
resp['bounce'], resp['deferred'], resp['unsubscribe'],
|
30
|
+
resp['processed'], resp['open'], resp['click'], resp['dropped']
|
31
|
+
)
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
34
|
+
def get_settings_event_notification(&block)
|
35
|
+
resp = get(@auth, Event.url_event(:settings), &block)
|
36
|
+
Event.create_event_notification(resp)
|
37
|
+
end
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
39
|
+
def patch_settings_event_notification(params:, &block)
|
40
|
+
resp = patch(@auth, Event.url_event(:settings), params.to_h, &block)
|
41
|
+
Event.create_event_notification(resp)
|
42
|
+
end
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
endpoint = SendGrid4r::REST::Webhooks::Event.url_event('test')
|
51
|
-
post(@auth, endpoint, params, &block)
|
52
|
-
end
|
44
|
+
def test_settings_event_notification(url:, &block)
|
45
|
+
params = { url: url }
|
46
|
+
post(@auth, Event.url_event(:test), params, &block)
|
53
47
|
end
|
54
48
|
end
|
55
49
|
end
|
@@ -1,50 +1,41 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
module SendGrid4r
|
4
|
-
|
3
|
+
module SendGrid4r::REST
|
4
|
+
#
|
5
|
+
# SendGrid Web API v3 Webhooks
|
6
|
+
#
|
7
|
+
module Webhooks
|
5
8
|
#
|
6
|
-
# SendGrid Web API v3 Webhooks
|
9
|
+
# SendGrid Web API v3 Webhooks Parse
|
7
10
|
#
|
8
|
-
module
|
9
|
-
|
10
|
-
# SendGrid Web API v3 Webhooks Parse
|
11
|
-
#
|
12
|
-
module Parse
|
13
|
-
include SendGrid4r::REST::Request
|
11
|
+
module Parse
|
12
|
+
include Request
|
14
13
|
|
15
|
-
|
16
|
-
|
14
|
+
ParseSettings = Struct.new(:result)
|
15
|
+
ParseSetting = Struct.new(:url, :hostname, :spam_check_outgoing)
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
def self.url
|
18
|
+
"#{BASE_URL}/user/webhooks/parse/settings"
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
parse_settings.push(
|
27
|
-
SendGrid4r::REST::Webhooks::Parse.create_parse_setting(
|
28
|
-
setting
|
29
|
-
)
|
30
|
-
)
|
31
|
-
end
|
32
|
-
ParseSettings.new(parse_settings)
|
21
|
+
def self.create_parse_settings(resp)
|
22
|
+
return resp if resp.nil?
|
23
|
+
parse_settings = resp['result'].map do |setting|
|
24
|
+
Parse.create_parse_setting(setting)
|
33
25
|
end
|
26
|
+
ParseSettings.new(parse_settings)
|
27
|
+
end
|
34
28
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
)
|
42
|
-
end
|
29
|
+
def self.create_parse_setting(resp)
|
30
|
+
return resp if resp.nil?
|
31
|
+
ParseSetting.new(
|
32
|
+
resp['url'], resp['hostname'], resp['spam_check_outgoing']
|
33
|
+
)
|
34
|
+
end
|
43
35
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
36
|
+
def get_parse_settings(&block)
|
37
|
+
resp = get(@auth, Parse.url, &block)
|
38
|
+
Parse.create_parse_settings(resp)
|
48
39
|
end
|
49
40
|
end
|
50
41
|
end
|