sendgrid4r 1.11.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,53 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Webhooks
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Webhooks Event
|
5
|
+
#
|
6
|
+
class Event < SgThor
|
7
|
+
desc 'get', 'Get Event Webhook Settings'
|
8
|
+
def get
|
9
|
+
puts @client.get_settings_event_notification
|
10
|
+
rescue RestClient::ExceptionWithResponse => e
|
11
|
+
puts e.inspect
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'enable', 'Enable Event Webhook Settings'
|
15
|
+
option :url
|
16
|
+
option :group_resubscribe, type: :boolean
|
17
|
+
option :delivered, type: :boolean
|
18
|
+
option :group_unsubscribe, type: :boolean
|
19
|
+
option :spam_report, type: :boolean
|
20
|
+
option :bounce, type: :boolean
|
21
|
+
option :deferred, type: :boolean
|
22
|
+
option :unsubscribe, type: :boolean
|
23
|
+
option :processed, type: :boolean
|
24
|
+
option :open, type: :boolean
|
25
|
+
option :click, type: :boolean
|
26
|
+
option :dropped, type: :boolean
|
27
|
+
def enable
|
28
|
+
params = parameterise(options)
|
29
|
+
params[:enabled] = true
|
30
|
+
event = SendGrid4r::Factory::EventFactory.create(params)
|
31
|
+
puts @client.patch_settings_event_notification(params: event)
|
32
|
+
rescue RestClient::ExceptionWithResponse => e
|
33
|
+
puts e.inspect
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'disable', 'Disable Event Webhook Settings'
|
37
|
+
def disable
|
38
|
+
params = { enabled: false }
|
39
|
+
puts @client.patch_settings_event_notification(params: params)
|
40
|
+
rescue RestClient::ExceptionWithResponse => e
|
41
|
+
puts e.inspect
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'test', 'Sends a fake event notification post to the provided URL'
|
45
|
+
option :url
|
46
|
+
def test
|
47
|
+
puts @client.test_settings_event_notification(parameterise(options))
|
48
|
+
rescue RestClient::ExceptionWithResponse => e
|
49
|
+
puts e.inspect
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Webhooks
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Webhook Parse
|
5
|
+
#
|
6
|
+
class Parse < SgThor
|
7
|
+
desc 'get', 'Get Parse Webhook Settings'
|
8
|
+
def get
|
9
|
+
puts @client.get_parse_settings
|
10
|
+
rescue RestClient::ExceptionWithResponse => e
|
11
|
+
puts e.inspect
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Webhooks
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Webhooks Webhook
|
5
|
+
#
|
6
|
+
class Webhook < SgThor
|
7
|
+
desc('event SUBCOMMAND ...ARGS', 'Manage event webhook settings')
|
8
|
+
subcommand('event', Event)
|
9
|
+
|
10
|
+
desc('parse SUBCOMMAND ...ARGS', 'Manage parse webhook settings')
|
11
|
+
subcommand('parse', Parse)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Whitelabel
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Whitelabel Domain
|
5
|
+
#
|
6
|
+
class Domain < SgThor
|
7
|
+
desc 'list', 'List all Domain whitelabels'
|
8
|
+
option :limit
|
9
|
+
option :offset
|
10
|
+
option :exclude_subusers
|
11
|
+
option :username
|
12
|
+
option :domain
|
13
|
+
def list
|
14
|
+
puts @client.get_wl_domains(parameterise(options))
|
15
|
+
rescue RestClient::ExceptionWithResponse => e
|
16
|
+
puts e.inspect
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'create', 'Create a domain whitelabel'
|
20
|
+
option :domain, require: true
|
21
|
+
option :subdomain, require: true
|
22
|
+
option :automatic_security, type: :boolean
|
23
|
+
option :custom_spf, type: :boolean
|
24
|
+
option :default, type: :boolean
|
25
|
+
def create
|
26
|
+
puts @client.post_wl_domain(parameterise(options))
|
27
|
+
rescue RestClient::ExceptionWithResponse => e
|
28
|
+
puts e.inspect
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'get', 'Retrieve a domain whitelabel'
|
32
|
+
option :id, require: true
|
33
|
+
def get
|
34
|
+
puts @client.get_wl_domain(parameterise(options))
|
35
|
+
rescue RestClient::ExceptionWithResponse => e
|
36
|
+
puts e.inspect
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'update', 'Update a domain whitelabel'
|
40
|
+
option :id, require: true
|
41
|
+
option :custom_spf, type: :boolean
|
42
|
+
option :default, type: :boolean
|
43
|
+
def update
|
44
|
+
puts @client.patch_wl_domain(parameterise(options))
|
45
|
+
rescue RestClient::ExceptionWithResponse => e
|
46
|
+
puts e.inspect
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'delete', 'Delete a domain whitelabel'
|
50
|
+
option :id, require: true
|
51
|
+
def delete
|
52
|
+
puts @client.delete_wl_domain(parameterise(options))
|
53
|
+
rescue RestClient::ExceptionWithResponse => e
|
54
|
+
puts e.inspect
|
55
|
+
end
|
56
|
+
|
57
|
+
desc 'default', 'Default a domain'
|
58
|
+
option :domain
|
59
|
+
def default
|
60
|
+
puts @client.get_default_wl_domain(parameterise(options))
|
61
|
+
rescue RestClient::ExceptionWithResponse => e
|
62
|
+
puts e.inspect
|
63
|
+
end
|
64
|
+
|
65
|
+
desc 'add_ip', 'Add an IP to a Domain'
|
66
|
+
option :id, require: true
|
67
|
+
option :ip, require: true
|
68
|
+
def add_ip
|
69
|
+
puts @client.add_ip_to_wl_domain(parameterise(options))
|
70
|
+
rescue RestClient::ExceptionWithResponse => e
|
71
|
+
puts e.inspect
|
72
|
+
end
|
73
|
+
|
74
|
+
desc 'remove_ip', 'Remove an IP from a Domain'
|
75
|
+
option :id, require: true
|
76
|
+
option :ip, require: true
|
77
|
+
def remove_ip
|
78
|
+
puts @client.remove_ip_from_wl_domain(parameterise(options))
|
79
|
+
rescue RestClient::ExceptionWithResponse => e
|
80
|
+
puts e.inspect
|
81
|
+
end
|
82
|
+
|
83
|
+
desc 'validate', 'Validate a Domain'
|
84
|
+
option :id, require: true
|
85
|
+
def validate
|
86
|
+
puts @client.validate_wl_domain(parameterise(options))
|
87
|
+
rescue RestClient::ExceptionWithResponse => e
|
88
|
+
puts e.inspect
|
89
|
+
end
|
90
|
+
|
91
|
+
desc 'list_associated', 'List Associated Domain'
|
92
|
+
option :username, require: true
|
93
|
+
def list_associated
|
94
|
+
puts @client.get_associated_wl_domain(parameterise(options))
|
95
|
+
rescue RestClient::ExceptionWithResponse => e
|
96
|
+
puts e.inspect
|
97
|
+
end
|
98
|
+
|
99
|
+
desc 'disassociate', 'Disassociate Domain'
|
100
|
+
option :username, require: true
|
101
|
+
def disassociate
|
102
|
+
puts @client.disassociate_wl_domain(parameterise(options))
|
103
|
+
rescue RestClient::ExceptionWithResponse => e
|
104
|
+
puts e.inspect
|
105
|
+
end
|
106
|
+
|
107
|
+
desc 'associate', 'Associate Domain'
|
108
|
+
option :id, require: true
|
109
|
+
option :username, require: true
|
110
|
+
def associate
|
111
|
+
puts @client.associate_wl_domain(parameterise(options))
|
112
|
+
rescue RestClient::ExceptionWithResponse => e
|
113
|
+
puts e.inspect
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Whitelabel
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Whitelabel Ip
|
5
|
+
#
|
6
|
+
class Ip < SgThor
|
7
|
+
desc 'list', 'List all IP whitelabels'
|
8
|
+
option :ip
|
9
|
+
option :limit, type: :numeric
|
10
|
+
option :offset, type: :numeric
|
11
|
+
def list
|
12
|
+
puts @client.get_wl_ips(parameterise(options))
|
13
|
+
rescue RestClient::ExceptionWithResponse => e
|
14
|
+
puts e.inspect
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'create', 'Create an IP whitelabel'
|
18
|
+
option :ip, require: true
|
19
|
+
option :domain, require: true
|
20
|
+
option :subdomain, require: true
|
21
|
+
def create
|
22
|
+
puts @client.post_wl_ip(parameterise(options))
|
23
|
+
rescue RestClient::ExceptionWithResponse => e
|
24
|
+
puts e.inspect
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'get', 'Retrieve an IP whitelabel'
|
28
|
+
option :id, require: true
|
29
|
+
def get
|
30
|
+
puts @client.get_wl_ip(parameterise(options))
|
31
|
+
rescue RestClient::ExceptionWithResponse => e
|
32
|
+
puts e.inspect
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'delete', 'Delete an IP whitelabel'
|
36
|
+
option :id, require: true
|
37
|
+
def delete
|
38
|
+
puts @client.delete_wl_ip(parameterise(options))
|
39
|
+
rescue RestClient::ExceptionWithResponse => e
|
40
|
+
puts e.inspect
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'validate', 'Validate IP whitelabel'
|
44
|
+
option :id, require: true
|
45
|
+
def validate
|
46
|
+
puts @client.validate_wl_ip(parameterise(options))
|
47
|
+
rescue RestClient::ExceptionWithResponse => e
|
48
|
+
puts e.inspect
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Whitelabel
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Whitelabel Link
|
5
|
+
#
|
6
|
+
class Link < SgThor
|
7
|
+
desc 'list', 'List all Link whitelabels'
|
8
|
+
option :limit
|
9
|
+
option :offset
|
10
|
+
option :exclude_subusers
|
11
|
+
option :username
|
12
|
+
option :domain
|
13
|
+
def list
|
14
|
+
puts @client.get_wl_links(parameterise(options))
|
15
|
+
rescue RestClient::ExceptionWithResponse => e
|
16
|
+
puts e.inspect
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'create', 'Create a link whitelabel'
|
20
|
+
option :domain, require: true
|
21
|
+
option :subdomain, require: true
|
22
|
+
option :default, type: :boolean
|
23
|
+
def create
|
24
|
+
puts @client.post_wl_link(parameterise(options))
|
25
|
+
rescue RestClient::ExceptionWithResponse => e
|
26
|
+
puts e.inspect
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'get', 'Retrieve a link whitelabel'
|
30
|
+
option :id, require: true
|
31
|
+
def get
|
32
|
+
puts @client.get_wl_link(parameterise(options))
|
33
|
+
rescue RestClient::ExceptionWithResponse => e
|
34
|
+
puts e.inspect
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'update', 'Update a link whitelabel'
|
38
|
+
option :id, require: true
|
39
|
+
option :default, type: :boolean, require: true
|
40
|
+
def update
|
41
|
+
puts @client.patch_wl_link(parameterise(options))
|
42
|
+
rescue RestClient::ExceptionWithResponse => e
|
43
|
+
puts e.inspect
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'delete', 'Delete a link whitelabel'
|
47
|
+
option :id, require: true
|
48
|
+
def delete
|
49
|
+
puts @client.delete_wl_link(parameterise(options))
|
50
|
+
rescue RestClient::ExceptionWithResponse => e
|
51
|
+
puts e.inspect
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'default', 'Default a link whitelabel'
|
55
|
+
option :domain
|
56
|
+
def default
|
57
|
+
puts @client.get_default_wl_link(parameterise(options))
|
58
|
+
rescue RestClient::ExceptionWithResponse => e
|
59
|
+
puts e.inspect
|
60
|
+
end
|
61
|
+
|
62
|
+
desc 'validate', 'Validate a link whitelabel'
|
63
|
+
option :id, require: true
|
64
|
+
def validate
|
65
|
+
puts @client.validate_wl_link(parameterise(options))
|
66
|
+
rescue RestClient::ExceptionWithResponse => e
|
67
|
+
puts e.inspect
|
68
|
+
end
|
69
|
+
|
70
|
+
desc 'list_associated', 'List Associated link'
|
71
|
+
option :username, require: true
|
72
|
+
def list_associated
|
73
|
+
puts @client.get_associated_wl_link(parameterise(options))
|
74
|
+
rescue RestClient::ExceptionWithResponse => e
|
75
|
+
puts e.inspect
|
76
|
+
end
|
77
|
+
|
78
|
+
desc 'disassociate', 'Disassociate link'
|
79
|
+
option :username, require: true
|
80
|
+
def disassociate
|
81
|
+
puts @client.disassociate_wl_link(parameterise(options))
|
82
|
+
rescue RestClient::ExceptionWithResponse => e
|
83
|
+
puts e.inspect
|
84
|
+
end
|
85
|
+
|
86
|
+
desc 'associate', 'Associate link'
|
87
|
+
option :id, require: true
|
88
|
+
option :username, require: true
|
89
|
+
def associate
|
90
|
+
puts @client.associate_wl_link(parameterise(options))
|
91
|
+
rescue RestClient::ExceptionWithResponse => e
|
92
|
+
puts e.inspect
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Whitelabel
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Whitelabel
|
5
|
+
#
|
6
|
+
class Whitelabel < SgThor
|
7
|
+
desc('domain SUBCOMMAND ...ARGS', 'Manage domain whitelabel settings')
|
8
|
+
subcommand('domain', Domain)
|
9
|
+
|
10
|
+
desc('link SUBCOMMAND ...ARGS', 'Manage link whitelabel settings')
|
11
|
+
subcommand('link', Link)
|
12
|
+
|
13
|
+
desc('ip SUBCOMMAND ...ARGS', 'Manage IP whitelabel settings')
|
14
|
+
subcommand('ip', Ip)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/sendgrid4r/client.rb
CHANGED
@@ -7,10 +7,13 @@ module SendGrid4r
|
|
7
7
|
class Client
|
8
8
|
include SendGrid4r::REST::API
|
9
9
|
|
10
|
+
attr_accessor :raw_resp
|
11
|
+
|
10
12
|
def initialize(
|
11
|
-
username: nil, password: nil, api_key: nil
|
13
|
+
username: nil, password: nil, api_key: nil, raw_response: false
|
12
14
|
)
|
13
15
|
@auth = Auth.new(username: username, password: password, api_key: api_key)
|
16
|
+
@raw_resp = raw_response
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|
@@ -6,12 +6,12 @@ module SendGrid4r
|
|
6
6
|
# SendGrid Web API v3 Condition Factory Class implementation
|
7
7
|
#
|
8
8
|
class ConditionFactory
|
9
|
-
def create(field:, value:, operator:, and_or:)
|
9
|
+
def create(field:, value:, operator:, and_or: nil)
|
10
10
|
REST::MarketingCampaigns::Contacts::Segments::Condition.new(
|
11
11
|
field,
|
12
12
|
value,
|
13
13
|
operator,
|
14
|
-
and_or
|
14
|
+
and_or.nil? ? '' : and_or
|
15
15
|
).to_h
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module SendGrid4r
|
4
|
+
module Factory
|
5
|
+
#
|
6
|
+
# SendGrid Web API v3 Event Factory Class implementation
|
7
|
+
#
|
8
|
+
module EventFactory
|
9
|
+
def self.create(enabled:, url: nil, group_resubscribe: nil,
|
10
|
+
delivered: nil, group_unsubscribe: nil, spam_report: nil,
|
11
|
+
bounce: nil, deferred: nil, unsubscribe: nil, processed: nil,
|
12
|
+
open: nil, click: nil, dropped: nil)
|
13
|
+
REST::Webhooks::Event::EventNotification.new(
|
14
|
+
enabled, url, group_resubscribe, delivered,
|
15
|
+
group_unsubscribe, spam_report, bounce, deferred,
|
16
|
+
unsubscribe, processed, open, click, dropped
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -36,20 +36,20 @@ module SendGrid4r::REST
|
|
36
36
|
|
37
37
|
def get_api_keys(&block)
|
38
38
|
resp = get(@auth, ApiKeysManagement.url, &block)
|
39
|
-
ApiKeysManagement.create_api_keys(
|
39
|
+
finish(resp, @raw_resp) { |r| ApiKeysManagement.create_api_keys(r) }
|
40
40
|
end
|
41
41
|
|
42
42
|
def post_api_key(name:, scopes: nil, &block)
|
43
43
|
params = { name: name }
|
44
44
|
params[:scopes] = scopes unless scopes.nil?
|
45
45
|
resp = post(@auth, ApiKeysManagement.url, params, &block)
|
46
|
-
ApiKeysManagement.create_api_key(
|
46
|
+
finish(resp, @raw_resp) { |r| ApiKeysManagement.create_api_key(r) }
|
47
47
|
end
|
48
48
|
|
49
49
|
def get_api_key(api_key_id:, &block)
|
50
50
|
endpoint = ApiKeysManagement.url(api_key_id)
|
51
51
|
resp = get(@auth, endpoint, &block)
|
52
|
-
ApiKeysManagement.create_api_key(
|
52
|
+
finish(resp, @raw_resp) { |r| ApiKeysManagement.create_api_key(r) }
|
53
53
|
end
|
54
54
|
|
55
55
|
def delete_api_key(api_key_id:, &block)
|
@@ -60,7 +60,7 @@ module SendGrid4r::REST
|
|
60
60
|
params = { name: name }
|
61
61
|
endpoint = ApiKeysManagement.url(api_key_id)
|
62
62
|
resp = patch(@auth, endpoint, params, &block)
|
63
|
-
ApiKeysManagement.create_api_key(
|
63
|
+
finish(resp, @raw_resp) { |r| ApiKeysManagement.create_api_key(r) }
|
64
64
|
end
|
65
65
|
|
66
66
|
def put_api_key(api_key_id:, name:, scopes:, &block)
|
@@ -69,7 +69,7 @@ module SendGrid4r::REST
|
|
69
69
|
params[:scopes] = scopes unless scopes.nil?
|
70
70
|
endpoint = ApiKeysManagement.url(api_key_id)
|
71
71
|
resp = put(@auth, endpoint, params, &block)
|
72
|
-
ApiKeysManagement.create_api_key(
|
72
|
+
finish(resp, @raw_resp) { |r| ApiKeysManagement.create_api_key(r) }
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|