sendgrid4r 1.11.0 → 1.12.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 -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,39 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Ips
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Ips Warmup
|
|
5
|
+
#
|
|
6
|
+
class Warmup < SgThor
|
|
7
|
+
desc 'list', 'List all IP addresses that are currently warming up'
|
|
8
|
+
def list
|
|
9
|
+
puts @client.get_warmup_ips
|
|
10
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
11
|
+
puts e.inspect
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
desc 'get', 'Get warmup status for a particular IP address'
|
|
15
|
+
option :ip, require: true
|
|
16
|
+
def get
|
|
17
|
+
puts @client.get_warmup_ip(parameterise(options))
|
|
18
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
19
|
+
puts e.inspect
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
desc 'start', 'Start warmup'
|
|
23
|
+
option :ip, require: true
|
|
24
|
+
def start
|
|
25
|
+
puts @client.post_warmup_ip(parameterise(options))
|
|
26
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
27
|
+
puts e.inspect
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
desc 'stop', 'Stop warmup'
|
|
31
|
+
option :ip, require: true
|
|
32
|
+
def stop
|
|
33
|
+
puts @client.delete_warmup_ip(parameterise(options))
|
|
34
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
35
|
+
puts e.inspect
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
#
|
|
3
|
+
# SendGrid Web API v3 Mail
|
|
4
|
+
#
|
|
5
|
+
class Mail < SgThor
|
|
6
|
+
desc 'send', 'Send mail'
|
|
7
|
+
option :to, type: :hash
|
|
8
|
+
option :from, type: :hash, require: true
|
|
9
|
+
option :content, type: :array, require: true
|
|
10
|
+
option :subject, require: true
|
|
11
|
+
def send
|
|
12
|
+
to = SendGrid4r::Factory::MailFactory.create_address(
|
|
13
|
+
parameterise(options[:to])
|
|
14
|
+
)
|
|
15
|
+
from = SendGrid4r::Factory::MailFactory.create_address(
|
|
16
|
+
parameterise(options[:from])
|
|
17
|
+
)
|
|
18
|
+
per = SendGrid4r::Factory::MailFactory.create_personalization(to: [to])
|
|
19
|
+
cont = options[:content].map do |c|
|
|
20
|
+
hash = c.split(/[:,]/).each_slice(2).map do |k, v|
|
|
21
|
+
[k.to_sym, v.nil? ? '' : v]
|
|
22
|
+
end.to_h
|
|
23
|
+
SendGrid4r::Factory::MailFactory.create_content(hash)
|
|
24
|
+
end
|
|
25
|
+
params = SendGrid4r::Factory::MailFactory.create_params(
|
|
26
|
+
personalizations: [per], from: from, content: cont,
|
|
27
|
+
subject: options[:subject]
|
|
28
|
+
)
|
|
29
|
+
puts @client.send(params: params)
|
|
30
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
31
|
+
puts e.inspect
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Settings
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Settings EnforcedTls
|
|
5
|
+
#
|
|
6
|
+
class EnforcedTls < SgThor
|
|
7
|
+
desc 'get', 'Get the current Enforced TLS settings'
|
|
8
|
+
def get
|
|
9
|
+
puts @client.get_enforced_tls
|
|
10
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
11
|
+
puts e.inspect
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
desc 'update', 'Change the Enforced TLS settings'
|
|
15
|
+
option :require_tls
|
|
16
|
+
option :require_valid_cert
|
|
17
|
+
def update
|
|
18
|
+
puts @client.patch_enforced_tls(params: parameterise(options))
|
|
19
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
20
|
+
puts e.inspect
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Settings
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Settings Mail
|
|
5
|
+
#
|
|
6
|
+
class Mail < SgThor
|
|
7
|
+
desc 'list', 'List mail settings'
|
|
8
|
+
option :limit, type: :numeric
|
|
9
|
+
option :offset, type: :numeric
|
|
10
|
+
def list
|
|
11
|
+
puts @client.get_mail_settings(parameterise(options))
|
|
12
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
13
|
+
puts e.inspect
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc 'whitelist', 'Get, Enable and Disable address whitelist settings'
|
|
17
|
+
option :list, type: :array
|
|
18
|
+
def whitelist(action)
|
|
19
|
+
case action
|
|
20
|
+
when 'get'
|
|
21
|
+
puts @client.get_settings_address_whitelist
|
|
22
|
+
when 'enable', 'disable'
|
|
23
|
+
params = parameterise(options)
|
|
24
|
+
params[:enabled] = action == 'enable'
|
|
25
|
+
puts @client.patch_settings_address_whitelist(params: params)
|
|
26
|
+
else
|
|
27
|
+
puts "error: #{action} is not supported in action parameter"
|
|
28
|
+
end
|
|
29
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
30
|
+
puts e.inspect
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
desc 'bcc', 'Get, Enable and Disable bcc settings'
|
|
34
|
+
option :email
|
|
35
|
+
def bcc(action)
|
|
36
|
+
case action
|
|
37
|
+
when 'get'
|
|
38
|
+
puts @client.get_settings_bcc
|
|
39
|
+
when 'enable', 'disable'
|
|
40
|
+
params = parameterise(options)
|
|
41
|
+
params[:enabled] = action == 'enable'
|
|
42
|
+
puts @client.patch_settings_bcc(params: params)
|
|
43
|
+
else
|
|
44
|
+
puts "error: #{action} is not supported in action parameter"
|
|
45
|
+
end
|
|
46
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
47
|
+
puts e.inspect
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
desc 'bounce_purge', 'Get, Enable and Disable bounce purge settings'
|
|
51
|
+
option :hard_bounces, type: :numeric
|
|
52
|
+
option :soft_bounces, type: :numeric
|
|
53
|
+
def bounce_purge(action)
|
|
54
|
+
case action
|
|
55
|
+
when 'get'
|
|
56
|
+
puts @client.get_settings_bounce_purge
|
|
57
|
+
when 'enable', 'disable'
|
|
58
|
+
params = parameterise(options)
|
|
59
|
+
params[:enabled] = action == 'enable'
|
|
60
|
+
puts @client.patch_settings_bounce_purge(params: params)
|
|
61
|
+
else
|
|
62
|
+
puts "error: #{action} is not supported in action parameter"
|
|
63
|
+
end
|
|
64
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
65
|
+
puts e.inspect
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
desc 'footer', 'Get, Enable and Disable footer settings'
|
|
69
|
+
option :html_content
|
|
70
|
+
option :plain_content
|
|
71
|
+
def footer(action)
|
|
72
|
+
case action
|
|
73
|
+
when 'get'
|
|
74
|
+
puts @client.get_settings_footer
|
|
75
|
+
when 'enable', 'disable'
|
|
76
|
+
params = parameterise(options)
|
|
77
|
+
params[:enabled] = action == 'enable'
|
|
78
|
+
puts @client.patch_settings_footer(params: params)
|
|
79
|
+
else
|
|
80
|
+
puts "error: #{action} is not supported in action parameter"
|
|
81
|
+
end
|
|
82
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
83
|
+
puts e.inspect
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
desc 'forward_bounce', 'Get, Enable and Disable forward bounce settings'
|
|
87
|
+
option :email
|
|
88
|
+
def forward_bounce(action)
|
|
89
|
+
case action
|
|
90
|
+
when 'get'
|
|
91
|
+
puts @client.get_settings_forward_bounce
|
|
92
|
+
when 'enable', 'disable'
|
|
93
|
+
params = parameterise(options)
|
|
94
|
+
params[:enabled] = action == 'enable'
|
|
95
|
+
puts @client.patch_settings_forward_bounce(params: params)
|
|
96
|
+
else
|
|
97
|
+
puts "error: #{action} is not supported in action parameter"
|
|
98
|
+
end
|
|
99
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
100
|
+
puts e.inspect
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
desc 'forward_spam', 'Get, Enable and Disable forward spam settings'
|
|
104
|
+
option :email
|
|
105
|
+
def forward_spam(action)
|
|
106
|
+
case action
|
|
107
|
+
when 'get'
|
|
108
|
+
puts @client.get_settings_forward_spam
|
|
109
|
+
when 'enable', 'disable'
|
|
110
|
+
params = parameterise(options)
|
|
111
|
+
params[:enabled] = action == 'enable'
|
|
112
|
+
puts @client.patch_settings_forward_spam(params: params)
|
|
113
|
+
else
|
|
114
|
+
puts "error: #{action} is not supported in action parameter"
|
|
115
|
+
end
|
|
116
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
117
|
+
puts e.inspect
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
desc 'spam_check', 'Get, Enable and Disable spam check settings'
|
|
121
|
+
option :url
|
|
122
|
+
option :max_score
|
|
123
|
+
def spam_check(action)
|
|
124
|
+
case action
|
|
125
|
+
when 'get'
|
|
126
|
+
puts @client.get_settings_spam_check
|
|
127
|
+
when 'enable', 'disable'
|
|
128
|
+
params = parameterise(options)
|
|
129
|
+
params[:enabled] = action == 'enable'
|
|
130
|
+
puts @client.patch_settings_spam_check(params: params)
|
|
131
|
+
else
|
|
132
|
+
puts "error: #{action} is not supported in action parameter"
|
|
133
|
+
end
|
|
134
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
135
|
+
puts e.inspect
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
desc 'template', 'Get, Enable and Disable template settings'
|
|
139
|
+
option :html_content
|
|
140
|
+
def template(action)
|
|
141
|
+
case action
|
|
142
|
+
when 'get'
|
|
143
|
+
puts @client.get_settings_template
|
|
144
|
+
when 'enable', 'disable'
|
|
145
|
+
params = parameterise(options)
|
|
146
|
+
params[:enabled] = action == 'enable'
|
|
147
|
+
puts @client.patch_settings_template(params: params)
|
|
148
|
+
else
|
|
149
|
+
puts "error: #{action} is not supported in action parameter"
|
|
150
|
+
end
|
|
151
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
152
|
+
puts e.inspect
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
desc 'plain_content', 'Get, Enable and Disable plain content settings'
|
|
156
|
+
def plain_content(action)
|
|
157
|
+
case action
|
|
158
|
+
when 'get'
|
|
159
|
+
puts @client.get_settings_plain_content
|
|
160
|
+
when 'enable', 'disable'
|
|
161
|
+
params = { enabled: action == 'enable' }
|
|
162
|
+
puts @client.patch_settings_plain_content(params: params)
|
|
163
|
+
else
|
|
164
|
+
puts "error: #{action} is not supported in action parameter"
|
|
165
|
+
end
|
|
166
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
167
|
+
puts e.inspect
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Settings
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Settings Partner
|
|
5
|
+
#
|
|
6
|
+
class Partner < SgThor
|
|
7
|
+
desc 'list', 'List partner settings'
|
|
8
|
+
option :limit, type: :numeric
|
|
9
|
+
option :offset, type: :numeric
|
|
10
|
+
def list
|
|
11
|
+
puts @client.get_partner_settings(parameterise(options))
|
|
12
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
13
|
+
puts e.inspect
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc 'new_relic', 'Get, Enable and Disable new relic settings'
|
|
17
|
+
option :license_key
|
|
18
|
+
def new_relic(action)
|
|
19
|
+
case action
|
|
20
|
+
when 'get'
|
|
21
|
+
puts @client.get_settings_new_relic
|
|
22
|
+
when 'enable', 'disabple'
|
|
23
|
+
params = parameterise(options)
|
|
24
|
+
params[:enabled] = action == 'enable'
|
|
25
|
+
puts @client.patch_settings_new_relic(params: params)
|
|
26
|
+
else
|
|
27
|
+
puts "error: #{action} is not supported in action parameter"
|
|
28
|
+
end
|
|
29
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
30
|
+
puts e.inspect
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Settings
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Settings
|
|
5
|
+
#
|
|
6
|
+
class Settings < SgThor
|
|
7
|
+
desc('enforced_tls SUBCOMMAND ...ARGS', 'Manage enforced TLS settings')
|
|
8
|
+
subcommand('enforced_tls', EnforcedTls)
|
|
9
|
+
|
|
10
|
+
desc('mail SUBCOMMAND ...ARGS', 'Manage mail settings')
|
|
11
|
+
subcommand('mail', Mail)
|
|
12
|
+
|
|
13
|
+
desc('partner SUBCOMMAND ...ARGS', 'Manage partner settings')
|
|
14
|
+
subcommand('partner', Partner)
|
|
15
|
+
|
|
16
|
+
desc('tracking SUBCOMMAND ...ARGS', 'Manage tracking settings')
|
|
17
|
+
subcommand('tracking', Tracking)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Settings
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Settings Tracking
|
|
5
|
+
#
|
|
6
|
+
class Tracking < SgThor
|
|
7
|
+
desc 'list', 'List tracking settings'
|
|
8
|
+
option :limit, type: :numeric
|
|
9
|
+
option :offset, type: :numeric
|
|
10
|
+
def list
|
|
11
|
+
puts @client.get_tracking_settings(parameterise(options))
|
|
12
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
13
|
+
puts e.inspect
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc 'click', 'Get, Enable and Disable click tracking settings'
|
|
17
|
+
def click(action)
|
|
18
|
+
case action
|
|
19
|
+
when 'get'
|
|
20
|
+
puts @client.get_settings_click
|
|
21
|
+
when 'enable', 'disable'
|
|
22
|
+
params = { enabled: action == 'enable' }
|
|
23
|
+
puts @client.patch_settings_click(params: params)
|
|
24
|
+
else
|
|
25
|
+
puts "error: #{action} is not supported in action parameter"
|
|
26
|
+
end
|
|
27
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
28
|
+
puts e.inspect
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
desc 'ganalytics', 'Get, Enable and Disable google analytics settings'
|
|
32
|
+
option :utm_source
|
|
33
|
+
option :utm_medium
|
|
34
|
+
option :utm_term
|
|
35
|
+
option :utm_content
|
|
36
|
+
option :utm_campaign
|
|
37
|
+
def ganalytics(action)
|
|
38
|
+
case action
|
|
39
|
+
when 'get'
|
|
40
|
+
puts @client.get_settings_google_analytics
|
|
41
|
+
when 'enable', 'disable'
|
|
42
|
+
params = parameterise(options)
|
|
43
|
+
params[:enabled] = action == 'enable'
|
|
44
|
+
puts @client.patch_settings_google_analytics(params: params)
|
|
45
|
+
else
|
|
46
|
+
puts "error: #{action} is not supported in action parameter"
|
|
47
|
+
end
|
|
48
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
49
|
+
puts e.inspect
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
desc 'open', 'Get, Enable and Disable open tracking settings'
|
|
53
|
+
def open(action)
|
|
54
|
+
case action
|
|
55
|
+
when 'get'
|
|
56
|
+
puts @client.get_settings_open
|
|
57
|
+
when 'enable', 'disable'
|
|
58
|
+
params = { enabled: action == 'enable' }
|
|
59
|
+
puts @client.patch_settings_open(params: params)
|
|
60
|
+
else
|
|
61
|
+
puts "error: #{action} is not supported in action parameter"
|
|
62
|
+
end
|
|
63
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
64
|
+
puts e.inspect
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
desc(
|
|
68
|
+
'subscription',
|
|
69
|
+
'Get, Enable and Disable subscription tracking settings'
|
|
70
|
+
)
|
|
71
|
+
option :landing
|
|
72
|
+
option :url
|
|
73
|
+
option :replace
|
|
74
|
+
option :html_content
|
|
75
|
+
option :plain_content
|
|
76
|
+
def subscription(action)
|
|
77
|
+
case action
|
|
78
|
+
when 'get'
|
|
79
|
+
puts @client.get_settings_subscription
|
|
80
|
+
when 'enable', 'disable'
|
|
81
|
+
params = parameterise(options)
|
|
82
|
+
params[:enabled] = action == 'enable'
|
|
83
|
+
puts @client.patch_settings_subscription(params: params)
|
|
84
|
+
else
|
|
85
|
+
puts "error: #{action} is not supported in action parameter"
|
|
86
|
+
end
|
|
87
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
88
|
+
puts e.inspect
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
#
|
|
3
|
+
# SendGrid Web API v3 ClI
|
|
4
|
+
#
|
|
5
|
+
class SG < Thor
|
|
6
|
+
map %w(--version -v) => :print_version
|
|
7
|
+
|
|
8
|
+
desc '--version, -v', 'print the version'
|
|
9
|
+
def print_version
|
|
10
|
+
puts SendGrid4r::VERSION
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
desc('api_key SUBCOMMAND ...ARGS', 'Manage API keys')
|
|
14
|
+
subcommand('api_key', ApiKeys::ApiKey)
|
|
15
|
+
|
|
16
|
+
desc('cancel_schedule SUBCOMMAND ...ARGS', 'Manage canceling schedule send')
|
|
17
|
+
subcommand('cancel_schedule', CancelSchedules::CancelSchedule)
|
|
18
|
+
|
|
19
|
+
desc('ip SUBCOMMAND ...ARGS', 'Manage ips')
|
|
20
|
+
subcommand('ip', Ips::Ip)
|
|
21
|
+
|
|
22
|
+
desc('ipam SUBCOMMAND ...ARGS', 'Manage ip access')
|
|
23
|
+
subcommand('ipam', Ipam::Ipam)
|
|
24
|
+
|
|
25
|
+
desc('settings SUBCOMMAND ...ARGS', 'Manage settings')
|
|
26
|
+
subcommand('settings', Settings::Settings)
|
|
27
|
+
|
|
28
|
+
desc('subuser SUBCOMMAND ...ARGS', 'Manage subuser')
|
|
29
|
+
subcommand('subuser', Subusers::Subuser)
|
|
30
|
+
|
|
31
|
+
desc('suppression SUBCOMMAND ...ARGS', 'Manage suppressions')
|
|
32
|
+
subcommand('suppressions', Suppressions::Suppression)
|
|
33
|
+
|
|
34
|
+
desc('template SUBCOMMAND ...ARGS', 'Manage templates')
|
|
35
|
+
subcommand('template', Templates::Template)
|
|
36
|
+
|
|
37
|
+
desc('webhook SUBCOMMAND ...ARGS', 'Manage webhook settings')
|
|
38
|
+
subcommand('webhook', Webhooks::Webhook)
|
|
39
|
+
|
|
40
|
+
desc('whitelabel SUBCOMMAND ...ARGS', 'Manage whitelabel settings')
|
|
41
|
+
subcommand('whitelabel', Whitelabel::Whitelabel)
|
|
42
|
+
|
|
43
|
+
desc('category SUBCOMMAND ...ARGS', 'Manage categories')
|
|
44
|
+
subcommand('category', Category)
|
|
45
|
+
|
|
46
|
+
desc('user SUBCOMMAND ...ARGS', 'Manage user')
|
|
47
|
+
subcommand('user', User)
|
|
48
|
+
|
|
49
|
+
desc('campaign SUBCOMMAND ...ARGS', 'Manage Marketing Campaigns')
|
|
50
|
+
subcommand('campaign', Campaign::Campaign)
|
|
51
|
+
|
|
52
|
+
desc('mail SUBCOMMAND ...ARGS', 'Send mail')
|
|
53
|
+
subcommand('mail', Mail)
|
|
54
|
+
end
|
|
55
|
+
end
|