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,34 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
#
|
3
|
+
# SendGrid Web API v3 SgThor
|
4
|
+
#
|
5
|
+
class SgThor < Thor
|
6
|
+
class_option :api_key, desc: 'API Key'
|
7
|
+
class_option :user, desc: 'SendGrid username for Basic Auth'
|
8
|
+
class_option :pass, desc: 'SendGrid password for Basic Auth'
|
9
|
+
|
10
|
+
def initialize(*args)
|
11
|
+
super
|
12
|
+
@client = SendGrid4r::Client.new(
|
13
|
+
username: options[:user], password: options[:pass],
|
14
|
+
api_key: options[:api_key], raw_response: true
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def parameterise(options)
|
21
|
+
# symbolize keys
|
22
|
+
params = options.each_with_object({}) do |(k, v), memo|
|
23
|
+
memo[k.to_s.to_sym] = v
|
24
|
+
end
|
25
|
+
# remove auth info
|
26
|
+
params.delete(:api_key)
|
27
|
+
params.delete(:user)
|
28
|
+
params.delete(:pass)
|
29
|
+
# remove empty key and value
|
30
|
+
params.delete_if { |_k, v| v.nil? }
|
31
|
+
params
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Stats
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Stats Advanced
|
5
|
+
#
|
6
|
+
class Advanced < SgThor
|
7
|
+
desc 'geo', 'Gets email statistics by country and state/province'
|
8
|
+
option :start_date, require: true
|
9
|
+
option :end_date
|
10
|
+
option :aggregated_by
|
11
|
+
option :country
|
12
|
+
def geo
|
13
|
+
puts @client.get_geo_stats(parameterise(options))
|
14
|
+
rescue RestClient::ExceptionWithResponse => e
|
15
|
+
puts e.inspect
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'device', 'Gets email statistics by device type'
|
19
|
+
option :start_date, require: true
|
20
|
+
option :end_date
|
21
|
+
option :aggregated_by
|
22
|
+
def device
|
23
|
+
puts @client.get_devices_stats(parameterise(options))
|
24
|
+
rescue RestClient::ExceptionWithResponse => e
|
25
|
+
puts e.inspect
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'client', 'Gets email statistics by client type'
|
29
|
+
option :start_date, require: true
|
30
|
+
option :end_date
|
31
|
+
option :aggregated_by
|
32
|
+
def client
|
33
|
+
puts @client.get_clients_stats(parameterise(options))
|
34
|
+
rescue RestClient::ExceptionWithResponse => e
|
35
|
+
puts e.inspect
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'client_type', 'Gets email statistics for a single client type'
|
39
|
+
option :start_date, require: true
|
40
|
+
option :end_date
|
41
|
+
option :aggregated_by
|
42
|
+
option :client_type, require: true
|
43
|
+
def client_type
|
44
|
+
puts @client.get_clients_type_stats(parameterise(options))
|
45
|
+
rescue RestClient::ExceptionWithResponse => e
|
46
|
+
puts e.inspect
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'mailbox_provider', 'Gets email statistics by mailbox provider'
|
50
|
+
option :start_date, require: true
|
51
|
+
option :end_date
|
52
|
+
option :aggregated_by
|
53
|
+
option :mailbox_providers
|
54
|
+
def mailbox_provider
|
55
|
+
puts @client.get_mailbox_providers_stats(parameterise(options))
|
56
|
+
rescue RestClient::ExceptionWithResponse => e
|
57
|
+
puts e.inspect
|
58
|
+
end
|
59
|
+
|
60
|
+
desc 'browser', 'Gets email statistics by browser'
|
61
|
+
option :start_date, require: true
|
62
|
+
option :end_date
|
63
|
+
option :aggregated_by
|
64
|
+
option :browsers
|
65
|
+
def browser
|
66
|
+
puts @client.get_browsers_stats(parameterise(options))
|
67
|
+
rescue RestClient::ExceptionWithResponse => e
|
68
|
+
puts e.inspect
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Stats
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Stats Category
|
5
|
+
#
|
6
|
+
class Category < SgThor
|
7
|
+
desc 'get', 'Gets email statistics for the given categories.'
|
8
|
+
option :start_date, require: true
|
9
|
+
option :end_date
|
10
|
+
option :aggregated_by
|
11
|
+
option :categories, require: true
|
12
|
+
def get
|
13
|
+
puts @client.get_categories_stats(parameterise(options))
|
14
|
+
rescue RestClient::ExceptionWithResponse => e
|
15
|
+
puts e.inspect
|
16
|
+
end
|
17
|
+
|
18
|
+
desc(
|
19
|
+
'sums',
|
20
|
+
'Gets the total sums of each email statistic metric for all categories'
|
21
|
+
)
|
22
|
+
option :start_date, require: true
|
23
|
+
option :end_date
|
24
|
+
option :sort_by_metric
|
25
|
+
option :sort_by_direction
|
26
|
+
option :limit
|
27
|
+
option :offset
|
28
|
+
def sums
|
29
|
+
puts @client.get_categories_stats_sums(parameterise(options))
|
30
|
+
rescue RestClient::ExceptionWithResponse => e
|
31
|
+
puts e.inspect
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Stats
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Stats Global
|
5
|
+
#
|
6
|
+
class Global < SgThor
|
7
|
+
desc 'get', 'Gets all of your user’s email statistics.'
|
8
|
+
option :start_date, require: true
|
9
|
+
option :end_date
|
10
|
+
option :aggregated_by
|
11
|
+
def get
|
12
|
+
puts @client.get_global_stats(parameterise(options))
|
13
|
+
rescue RestClient::ExceptionWithResponse => e
|
14
|
+
puts e.inspect
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Stats
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Stats Parse
|
5
|
+
#
|
6
|
+
class Parse < SgThor
|
7
|
+
desc 'get', 'Gets statistics for Parse Webhook usage'
|
8
|
+
option :start_date, require: true
|
9
|
+
option :end_date
|
10
|
+
option :aggregated_by
|
11
|
+
def get
|
12
|
+
puts @client.get_parse_stats(parameterise(options))
|
13
|
+
rescue RestClient::ExceptionWithResponse => e
|
14
|
+
puts e.inspect
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Stats
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Stats
|
5
|
+
#
|
6
|
+
class Stats < SgThor
|
7
|
+
desc('advanced SUBCOMMAND ...ARGS', 'Get advanced stats')
|
8
|
+
subcommand('advanced', Advanced)
|
9
|
+
|
10
|
+
desc('category SUBCOMMAND ...ARGS', 'Get category stats')
|
11
|
+
subcommand('category', Category)
|
12
|
+
|
13
|
+
desc('global SUBCOMMAND ...ARGS', 'Get global stats')
|
14
|
+
subcommand('global', Global)
|
15
|
+
|
16
|
+
desc('parse SUBCOMMAND ...ARGS', 'Get parse stats')
|
17
|
+
subcommand('parse', Parse)
|
18
|
+
|
19
|
+
desc('subuser SUBCOMMAND ...ARGS', 'Get subuser stats')
|
20
|
+
subcommand('subuser', Subuser)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Stats
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Stats Subuser
|
5
|
+
#
|
6
|
+
class Subuser < SgThor
|
7
|
+
desc 'get', 'Gets email statistics for the given subusers'
|
8
|
+
option :start_date, require: true
|
9
|
+
option :end_date
|
10
|
+
option :aggregated_by
|
11
|
+
option :subusers, type: :array, require: true
|
12
|
+
def get
|
13
|
+
puts @client.get_subusers_stats(parameterise(options))
|
14
|
+
rescue RestClient::ExceptionWithResponse => e
|
15
|
+
puts e.inspect
|
16
|
+
end
|
17
|
+
|
18
|
+
desc(
|
19
|
+
'sums',
|
20
|
+
'Gets the total sums of each email statistic metric for all subusers'
|
21
|
+
)
|
22
|
+
option :start_date, require: true
|
23
|
+
option :end_date
|
24
|
+
option :sort_by_metric
|
25
|
+
option :sort_by_direction
|
26
|
+
option :limit, type: :numeric
|
27
|
+
option :offset, type: :numeric
|
28
|
+
def sums
|
29
|
+
puts @client.get_subusers_stats_sums(parameterise(options))
|
30
|
+
rescue RestClient::ExceptionWithResponse => e
|
31
|
+
puts e.inspect
|
32
|
+
end
|
33
|
+
|
34
|
+
desc(
|
35
|
+
'list_monthly',
|
36
|
+
'Retrieve the monthly email statistics for all subusers'
|
37
|
+
)
|
38
|
+
option :date, require: true
|
39
|
+
option :subuser
|
40
|
+
option :sort_by_metric
|
41
|
+
option :sort_by_direction
|
42
|
+
option :limit, type: :numeric
|
43
|
+
option :offset, type: :numeric
|
44
|
+
def list_monthly
|
45
|
+
puts @client.get_subusers_stats_monthly(parameterise(options))
|
46
|
+
rescue RestClient::ExceptionWithResponse => e
|
47
|
+
puts e.inspect
|
48
|
+
end
|
49
|
+
|
50
|
+
desc(
|
51
|
+
'get_monthly',
|
52
|
+
'Retrieve the monthly email statistics for a single subuser'
|
53
|
+
)
|
54
|
+
option :subuser_name, require: true
|
55
|
+
option :date, require: true
|
56
|
+
option :sort_by_metric
|
57
|
+
option :sort_by_direction
|
58
|
+
option :limit, type: :numeric
|
59
|
+
option :offset, type: :numeric
|
60
|
+
def get_monthly
|
61
|
+
puts @client.get_subuser_stats_monthly(parameterise(options))
|
62
|
+
rescue RestClient::ExceptionWithResponse => e
|
63
|
+
puts e.inspect
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Subusers
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Subusers Monitor
|
5
|
+
#
|
6
|
+
class Monitor < SgThor
|
7
|
+
desc 'list', 'Retrieve monitor settings'
|
8
|
+
option :username, require: true
|
9
|
+
def list
|
10
|
+
puts @client.get_subuser_monitor(parameterise(options))
|
11
|
+
rescue RestClient::ExceptionWithResponse => e
|
12
|
+
puts e.inspect
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'create', 'Create monitor settings'
|
16
|
+
option :username, require: true
|
17
|
+
option :email, require: true
|
18
|
+
option :frequency, type: :numeric, require: true
|
19
|
+
def create
|
20
|
+
puts @client.post_subuser_monitor(parameterise(options))
|
21
|
+
rescue RestClient::ExceptionWithResponse => e
|
22
|
+
puts e.inspect
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'update', 'Update monitor settings'
|
26
|
+
option :username, require: true
|
27
|
+
option :email, require: true
|
28
|
+
option :frequency, type: :numeric, require: true
|
29
|
+
def update
|
30
|
+
puts @client.put_subuser_monitor(parameterise(options))
|
31
|
+
rescue RestClient::ExceptionWithResponse => e
|
32
|
+
puts e.inspect
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'delete', 'Delete monitor settings'
|
36
|
+
option :username, require: true
|
37
|
+
def delete
|
38
|
+
puts @client.delete_subuser_monitor(parameterise(options))
|
39
|
+
rescue RestClient::ExceptionWithResponse => e
|
40
|
+
puts e.inspect
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Subusers
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Subusers Subuser
|
5
|
+
#
|
6
|
+
class Subuser < SgThor
|
7
|
+
desc 'list', 'List subusers for a parent'
|
8
|
+
option :limit, type: :numeric
|
9
|
+
option :offset, type: :numeric
|
10
|
+
option :username
|
11
|
+
def list
|
12
|
+
puts @client.get_subusers(parameterise(options))
|
13
|
+
rescue RestClient::ExceptionWithResponse => e
|
14
|
+
puts e.inspect
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'create', 'Create a subuser'
|
18
|
+
option :username, require: true
|
19
|
+
option :email, require: true
|
20
|
+
option :password, require: true
|
21
|
+
option :ips, type: :array, require: true
|
22
|
+
def create
|
23
|
+
puts @client.post_subuser(parameterise(options))
|
24
|
+
rescue RestClient::ExceptionWithResponse => e
|
25
|
+
puts e.inspect
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'enable', 'Enable a subuser'
|
29
|
+
option :username, require: true
|
30
|
+
def enable
|
31
|
+
params = parameterise(options)
|
32
|
+
params[:disabled] = false
|
33
|
+
puts @client.patch_subuser(params)
|
34
|
+
rescue RestClient::ExceptionWithResponse => e
|
35
|
+
puts e.inspect
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'disable', 'Disable a subuser'
|
39
|
+
option :username, require: true
|
40
|
+
def disable
|
41
|
+
params = parameterise(options)
|
42
|
+
params[:disabled] = false
|
43
|
+
puts @client.patch_subuser(params)
|
44
|
+
rescue RestClient::ExceptionWithResponse => e
|
45
|
+
puts e.inspect
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'delete', 'Delete a subuser'
|
49
|
+
option :username, require: true
|
50
|
+
def delete
|
51
|
+
puts @client.delete_subuser(parameterise(options))
|
52
|
+
rescue RestClient::ExceptionWithResponse => e
|
53
|
+
puts e.inspect
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'reputation', 'Retrieve subusers reputation'
|
57
|
+
option :usernames, type: :array, require: true
|
58
|
+
def reputation
|
59
|
+
puts @client.get_subuser_reputation(parameterise(options))
|
60
|
+
rescue RestClient::ExceptionWithResponse => e
|
61
|
+
puts e.inspect
|
62
|
+
end
|
63
|
+
|
64
|
+
desc 'assign_ips', 'Update IPs assigned to a subuser'
|
65
|
+
option :username, require: true
|
66
|
+
option :ips, type: :array, require: true
|
67
|
+
def assign_ips
|
68
|
+
puts @client.put_subuser_assigned_ips(parameterise(options))
|
69
|
+
rescue RestClient::ExceptionWithResponse => e
|
70
|
+
puts e.inspect
|
71
|
+
end
|
72
|
+
|
73
|
+
desc('monitor SUBCOMMAND ...ARGS', 'Manage monitor records for subuser')
|
74
|
+
subcommand('monitor', Monitor)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Suppressions
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Suppressions Block
|
5
|
+
#
|
6
|
+
class Block < SgThor
|
7
|
+
desc 'list', 'List blocks'
|
8
|
+
option :start_time, type: :numeric
|
9
|
+
option :end_time, type: :numeric
|
10
|
+
option :limit, type: :numeric
|
11
|
+
option :offset, type: :numeric
|
12
|
+
def list
|
13
|
+
puts @client.get_blocks(parameterise(options))
|
14
|
+
rescue RestClient::ExceptionWithResponse => e
|
15
|
+
puts e.inspect
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'delete', 'Delete blocks'
|
19
|
+
option :delete_all, type: :boolean
|
20
|
+
option :email
|
21
|
+
option :emails, type: :array
|
22
|
+
def delete
|
23
|
+
if options[:email]
|
24
|
+
puts @client.delete_block(email: options[:email])
|
25
|
+
else
|
26
|
+
puts @client.delete_blocks(
|
27
|
+
delete_all: options[:delete_all], emails: options[:emails]
|
28
|
+
)
|
29
|
+
end
|
30
|
+
rescue RestClient::ExceptionWithResponse => e
|
31
|
+
puts e.inspect
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'get', 'Get a block'
|
35
|
+
option :email, require: true
|
36
|
+
def get
|
37
|
+
puts @client.get_block(parameterise(options))
|
38
|
+
rescue RestClient::ExceptionWithResponse => e
|
39
|
+
puts e.inspect
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|