sendgrid4r 1.12.0 → 1.13.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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/README.md +2 -1
  4. data/lib/sendgrid4r/cli/alert.rb +51 -0
  5. data/lib/sendgrid4r/cli/campaign/campaign.rb +2 -2
  6. data/lib/sendgrid4r/cli/campaign/contact/custom_field.rb +1 -1
  7. data/lib/sendgrid4r/cli/campaign/contact/list.rb +1 -1
  8. data/lib/sendgrid4r/cli/campaign/contact/recipient.rb +2 -2
  9. data/lib/sendgrid4r/cli/campaign/contact/segment.rb +12 -3
  10. data/lib/sendgrid4r/cli/ipam/whitelist.rb +1 -1
  11. data/lib/sendgrid4r/cli/settings/enforced_tls.rb +2 -2
  12. data/lib/sendgrid4r/cli/settings/mail.rb +33 -9
  13. data/lib/sendgrid4r/cli/settings/partner.rb +4 -1
  14. data/lib/sendgrid4r/cli/settings/tracking.rb +13 -4
  15. data/lib/sendgrid4r/cli/sg.rb +16 -10
  16. data/lib/sendgrid4r/cli/sg_thor.rb +27 -11
  17. data/lib/sendgrid4r/cli/stats/advanced.rb +22 -20
  18. data/lib/sendgrid4r/cli/stats/category.rb +8 -8
  19. data/lib/sendgrid4r/cli/stats/global.rb +3 -3
  20. data/lib/sendgrid4r/cli/stats/parse.rb +3 -3
  21. data/lib/sendgrid4r/cli/stats/subuser.rb +10 -10
  22. data/lib/sendgrid4r/cli/suppressions/block.rb +2 -2
  23. data/lib/sendgrid4r/cli/suppressions/bounce.rb +2 -2
  24. data/lib/sendgrid4r/cli/suppressions/global_unsubscribe.rb +2 -2
  25. data/lib/sendgrid4r/cli/suppressions/group.rb +6 -1
  26. data/lib/sendgrid4r/cli/suppressions/group_unsubscribe.rb +9 -0
  27. data/lib/sendgrid4r/cli/suppressions/invalid_email.rb +2 -2
  28. data/lib/sendgrid4r/cli/suppressions/spam_report.rb +2 -2
  29. data/lib/sendgrid4r/cli/templates/version.rb +2 -2
  30. data/lib/sendgrid4r/cli/user.rb +5 -5
  31. data/lib/sendgrid4r/cli/webhooks/parse.rb +42 -2
  32. data/lib/sendgrid4r/cli/whitelabel/domain.rb +3 -3
  33. data/lib/sendgrid4r/cli/whitelabel/link.rb +2 -2
  34. data/lib/sendgrid4r/rest/alerts.rb +81 -0
  35. data/lib/sendgrid4r/rest/api.rb +1 -0
  36. data/lib/sendgrid4r/rest/blocks.rb +2 -4
  37. data/lib/sendgrid4r/rest/bounces.rb +2 -4
  38. data/lib/sendgrid4r/rest/invalid_emails.rb +2 -4
  39. data/lib/sendgrid4r/rest/request.rb +10 -6
  40. data/lib/sendgrid4r/rest/sm/groups.rb +3 -2
  41. data/lib/sendgrid4r/rest/sm/suppressions.rb +61 -14
  42. data/lib/sendgrid4r/rest/spam_reports.rb +2 -4
  43. data/lib/sendgrid4r/rest/webhooks/parse.rb +47 -6
  44. data/lib/sendgrid4r/version.rb +1 -1
  45. data/lib/sendgrid4r.rb +3 -0
  46. data/spec/cli/alert_spec.rb +71 -0
  47. data/spec/cli/sg_spec.rb +5 -0
  48. data/spec/cli/suppressions/group_spec.rb +11 -2
  49. data/spec/cli/suppressions/group_unsubscribe_spec.rb +12 -2
  50. data/spec/cli/webhooks/parse_spec.rb +53 -1
  51. data/spec/client_spec.rb +17 -1
  52. data/spec/rest/alerts_spec.rb +188 -0
  53. data/spec/rest/mail/mail_spec.rb +10 -10
  54. data/spec/rest/request_spec.rb +41 -0
  55. data/spec/rest/sm/groups_spec.rb +9 -0
  56. data/spec/rest/sm/suppressions_spec.rb +122 -35
  57. data/spec/rest/webhooks/parse_spec.rb +94 -7
  58. metadata +10 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f63d8884d3b1ca8b9eb7091d85b912efa8bf4560
4
- data.tar.gz: 3561561011662deb924811afc9b171d574b075e2
3
+ metadata.gz: f8127a4d5294077d6b12ed4f655dc6781a931f96
4
+ data.tar.gz: fd2478d82a6423d5dcb2e783407c114f546d9f5a
5
5
  SHA512:
6
- metadata.gz: b9c8576c472b175ed404c66c47d2582191166e6c577fe490309c9342afb9916361b6914286ff478a177414293af4df1f9f8ab631e2ec438ba9cbc185a2f96fcd
7
- data.tar.gz: 0705ed5391a47a46014cd88f26ad5101331c97576dc2535ca31ea2616bf23feb00f161304843a210d17dfa14b9a46a39c30e9a6f7441f6883709dddd16b12b67
6
+ metadata.gz: 9fc84962129b6444f935727954c8bfa6434e6a174f5490d2f062242c0da985101d92c6d5d09c21b3c6f7b05db040072117f82a1cf01e08293bc67d37a6251527
7
+ data.tar.gz: 58effad12a4cdf569e1dcc7b7e26642e03523193d934f78fb743ec1544e35844a9bc1888106900830f9ffa57ab0d384c5f391e8d03e776c03a48e72ced664e83
data/.rubocop.yml CHANGED
@@ -31,4 +31,4 @@ ClassAndModuleChildren:
31
31
  # Change limitation of the class length
32
32
  ClassLength:
33
33
  CountComments: false # count full line comments?
34
- Max: 160
34
+ Max: 180
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # Sendgrid4r
2
2
 
3
3
  This gem allows you to quickly and easily access to SendGrid Web API v3 for Ruby.
4
- See [api reference](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) for more detail
4
+ See [api reference](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) for more details.
5
+ Also this gem provides `sg` command. `sg` is the command line interface to access SendGrid APIs. See [Command line interface Usage](Cli) for more details.
5
6
 
6
7
  [![Build Status](https://travis-ci.org/awwa/sendgrid4r.svg?branch=master)](https://travis-ci.org/awwa/sendgrid4r)
7
8
  [![Gem Version](https://badge.fury.io/rb/sendgrid4r.svg)](https://badge.fury.io/rb/sendgrid4r)
@@ -0,0 +1,51 @@
1
+ module SendGrid4r::CLI
2
+ #
3
+ # SendGrid Web API v3 Alert
4
+ #
5
+ class Alert < SgThor
6
+ desc 'list', 'List alerts'
7
+ def list
8
+ puts @client.get_alerts
9
+ rescue RestClient::ExceptionWithResponse => e
10
+ puts e.inspect
11
+ end
12
+
13
+ desc 'create', 'Create an alert'
14
+ option :type, banner: '[stats_notification|usage_limit]', require: true
15
+ option :email_to, require: true
16
+ option :percentage, type: :numeric
17
+ option :frequency, banner: '[daily|weekly|monthly]'
18
+ def create
19
+ puts @client.post_alert(parameterise(options))
20
+ rescue RestClient::ExceptionWithResponse => e
21
+ puts e.inspect
22
+ end
23
+
24
+ desc 'get', 'Get an alert'
25
+ option :alert_id, type: :numeric, require: true
26
+ def get
27
+ puts @client.get_alert(parameterise(options))
28
+ rescue RestClient::ExceptionWithResponse => e
29
+ puts e.inspect
30
+ end
31
+
32
+ desc 'delete', 'Delete an alert'
33
+ option :alert_id, type: :numeric, require: true
34
+ def delete
35
+ puts @client.delete_alert(parameterise(options))
36
+ rescue RestClient::ExceptionWithResponse => e
37
+ puts e.inspect
38
+ end
39
+
40
+ desc 'update', 'Update an alert'
41
+ option :alert_id, type: :numeric, require: true
42
+ option :email_to, require: true
43
+ option :percentage, type: :numeric
44
+ option :frequency, banner: '[daily|weekly|monthly]'
45
+ def update
46
+ puts @client.patch_alert(parameterise(options))
47
+ rescue RestClient::ExceptionWithResponse => e
48
+ puts e.inspect
49
+ end
50
+ end
51
+ end
@@ -83,7 +83,7 @@ module SendGrid4r::CLI
83
83
 
84
84
  desc 'schedule', 'Schedule a campaign'
85
85
  option :campaign_id, type: :numeric, require: true
86
- option :send_at, type: :numeric, require: true
86
+ option :send_at, banner: SgThor::UTS, type: :numeric, require: true
87
87
  def schedule
88
88
  puts @client.schedule_campaign(parameterise(options))
89
89
  rescue RestClient::ExceptionWithResponse => e
@@ -92,7 +92,7 @@ module SendGrid4r::CLI
92
92
 
93
93
  desc 'reschedule', 'Reschedule a campaign'
94
94
  option :campaign_id, type: :numeric, require: true
95
- option :send_at, type: :numeric, require: true
95
+ option :send_at, banner: SgThor::UTS, type: :numeric, require: true
96
96
  def reschedule
97
97
  puts @client.reschedule_campaign(parameterise(options))
98
98
  rescue RestClient::ExceptionWithResponse => e
@@ -7,7 +7,7 @@ module SendGrid4r::CLI
7
7
  class CustomField < SgThor
8
8
  desc 'create', 'Create a custom field'
9
9
  option :name, require: true
10
- option :type, require: true
10
+ option :type, banner: SgThor::TYP, require: true
11
11
  def create
12
12
  puts @client.post_custom_field(parameterise(options))
13
13
  rescue RestClient::ExceptionWithResponse => e
@@ -45,7 +45,7 @@ module SendGrid4r::CLI
45
45
  puts e.inspect
46
46
  end
47
47
 
48
- desc 'recipient', 'Add, Remove, List a recipient'
48
+ desc 'recipient [add|remove|list]', 'Add, Remove, List a recipient'
49
49
  option :list_id, type: :numeric, require: true
50
50
  option :recipients, type: :array, desc: 'for add action'
51
51
  option :recipient_id, desc: 'for remove action'
@@ -34,8 +34,8 @@ module SendGrid4r::CLI
34
34
  end
35
35
 
36
36
  desc 'list', 'List recipients'
37
- option :page
38
- option :page_size
37
+ option :page, type: :numeric
38
+ option :page_size, type: :numeric
39
39
  def list
40
40
  puts @client.get_recipients(parameterise(options))
41
41
  rescue RestClient::ExceptionWithResponse => e
@@ -14,7 +14,12 @@ module SendGrid4r::CLI
14
14
  desc 'create', 'Create a segment'
15
15
  option :name, require: true
16
16
  option :list_id, type: :numeric, require: true
17
- option :conditions, type: :array, require: true
17
+ option(
18
+ :conditions,
19
+ type: :array,
20
+ require: true,
21
+ banner: 'field:email,value:abc@abc.abc,operator:eq,and_or:'
22
+ )
18
23
  def create
19
24
  conditions = options[:conditions].map do |c|
20
25
  array = c.delete(' ').split(/[:,]/)
@@ -51,7 +56,11 @@ module SendGrid4r::CLI
51
56
  desc 'update', 'Update a segment'
52
57
  option :segment_id, require: true
53
58
  option :name
54
- option :conditions, type: :array
59
+ option(
60
+ :conditions,
61
+ type: :array,
62
+ banner: 'field:email,value:abc@abc.abc,operator:eq,and_or:'
63
+ )
55
64
  def update
56
65
  conditions = options[:conditions].map do |c|
57
66
  array = c.delete(' ').split(/[:,]/)
@@ -80,7 +89,7 @@ module SendGrid4r::CLI
80
89
  puts e.inspect
81
90
  end
82
91
 
83
- desc 'recipient', 'List recipients'
92
+ desc 'recipient [list]', 'List recipients'
84
93
  option :segment_id, require: true
85
94
  def recipient(action)
86
95
  case action
@@ -20,7 +20,7 @@ module SendGrid4r::CLI
20
20
  end
21
21
 
22
22
  desc 'delete', 'Delete Whitelisted IPs'
23
- option :ids, type: :array
23
+ option :ids, type: :array, require: true
24
24
  def delete
25
25
  puts @client.delete_whitelisted_ips(parameterise(options))
26
26
  rescue RestClient::ExceptionWithResponse => e
@@ -12,8 +12,8 @@ module SendGrid4r::CLI
12
12
  end
13
13
 
14
14
  desc 'update', 'Change the Enforced TLS settings'
15
- option :require_tls
16
- option :require_valid_cert
15
+ option :require_tls, type: :boolean
16
+ option :require_valid_cert, type: :boolean
17
17
  def update
18
18
  puts @client.patch_enforced_tls(params: parameterise(options))
19
19
  rescue RestClient::ExceptionWithResponse => e
@@ -13,7 +13,10 @@ module SendGrid4r::CLI
13
13
  puts e.inspect
14
14
  end
15
15
 
16
- desc 'whitelist', 'Get, Enable and Disable address whitelist settings'
16
+ desc(
17
+ 'whitelist [get|enable|disable]',
18
+ 'Get, Enable and Disable address whitelist settings'
19
+ )
17
20
  option :list, type: :array
18
21
  def whitelist(action)
19
22
  case action
@@ -30,7 +33,7 @@ module SendGrid4r::CLI
30
33
  puts e.inspect
31
34
  end
32
35
 
33
- desc 'bcc', 'Get, Enable and Disable bcc settings'
36
+ desc 'bcc [get|enable|disable]', 'Get, Enable and Disable bcc settings'
34
37
  option :email
35
38
  def bcc(action)
36
39
  case action
@@ -47,7 +50,10 @@ module SendGrid4r::CLI
47
50
  puts e.inspect
48
51
  end
49
52
 
50
- desc 'bounce_purge', 'Get, Enable and Disable bounce purge settings'
53
+ desc(
54
+ 'bounce_purge [get|enable|disable]',
55
+ 'Get, Enable and Disable bounce purge settings'
56
+ )
51
57
  option :hard_bounces, type: :numeric
52
58
  option :soft_bounces, type: :numeric
53
59
  def bounce_purge(action)
@@ -65,7 +71,10 @@ module SendGrid4r::CLI
65
71
  puts e.inspect
66
72
  end
67
73
 
68
- desc 'footer', 'Get, Enable and Disable footer settings'
74
+ desc(
75
+ 'footer [get|enable|disable]',
76
+ 'Get, Enable and Disable footer settings'
77
+ )
69
78
  option :html_content
70
79
  option :plain_content
71
80
  def footer(action)
@@ -83,7 +92,10 @@ module SendGrid4r::CLI
83
92
  puts e.inspect
84
93
  end
85
94
 
86
- desc 'forward_bounce', 'Get, Enable and Disable forward bounce settings'
95
+ desc(
96
+ 'forward_bounce [get|enable|disable]',
97
+ 'Get, Enable and Disable forward bounce settings'
98
+ )
87
99
  option :email
88
100
  def forward_bounce(action)
89
101
  case action
@@ -100,7 +112,10 @@ module SendGrid4r::CLI
100
112
  puts e.inspect
101
113
  end
102
114
 
103
- desc 'forward_spam', 'Get, Enable and Disable forward spam settings'
115
+ desc(
116
+ 'forward_spam [get|enable|disable]',
117
+ 'Get, Enable and Disable forward spam settings'
118
+ )
104
119
  option :email
105
120
  def forward_spam(action)
106
121
  case action
@@ -117,7 +132,10 @@ module SendGrid4r::CLI
117
132
  puts e.inspect
118
133
  end
119
134
 
120
- desc 'spam_check', 'Get, Enable and Disable spam check settings'
135
+ desc(
136
+ 'spam_check [get|enable|disable]',
137
+ 'Get, Enable and Disable spam check settings'
138
+ )
121
139
  option :url
122
140
  option :max_score
123
141
  def spam_check(action)
@@ -135,7 +153,10 @@ module SendGrid4r::CLI
135
153
  puts e.inspect
136
154
  end
137
155
 
138
- desc 'template', 'Get, Enable and Disable template settings'
156
+ desc(
157
+ 'template [get|enable|disable]',
158
+ 'Get, Enable and Disable template settings'
159
+ )
139
160
  option :html_content
140
161
  def template(action)
141
162
  case action
@@ -152,7 +173,10 @@ module SendGrid4r::CLI
152
173
  puts e.inspect
153
174
  end
154
175
 
155
- desc 'plain_content', 'Get, Enable and Disable plain content settings'
176
+ desc(
177
+ 'plain_content [get|enable|disable]',
178
+ 'Get, Enable and Disable plain content settings'
179
+ )
156
180
  def plain_content(action)
157
181
  case action
158
182
  when 'get'
@@ -13,7 +13,10 @@ module SendGrid4r::CLI
13
13
  puts e.inspect
14
14
  end
15
15
 
16
- desc 'new_relic', 'Get, Enable and Disable new relic settings'
16
+ desc(
17
+ 'new_relic [get|enable|disable]',
18
+ 'Get, Enable and Disable new relic settings'
19
+ )
17
20
  option :license_key
18
21
  def new_relic(action)
19
22
  case action
@@ -13,7 +13,10 @@ module SendGrid4r::CLI
13
13
  puts e.inspect
14
14
  end
15
15
 
16
- desc 'click', 'Get, Enable and Disable click tracking settings'
16
+ desc(
17
+ 'click [get|enable|disable]',
18
+ 'Get, Enable and Disable click tracking settings'
19
+ )
17
20
  def click(action)
18
21
  case action
19
22
  when 'get'
@@ -28,7 +31,10 @@ module SendGrid4r::CLI
28
31
  puts e.inspect
29
32
  end
30
33
 
31
- desc 'ganalytics', 'Get, Enable and Disable google analytics settings'
34
+ desc(
35
+ 'ganalytics [get|enable|disable]',
36
+ 'Get, Enable and Disable google analytics settings'
37
+ )
32
38
  option :utm_source
33
39
  option :utm_medium
34
40
  option :utm_term
@@ -49,7 +55,10 @@ module SendGrid4r::CLI
49
55
  puts e.inspect
50
56
  end
51
57
 
52
- desc 'open', 'Get, Enable and Disable open tracking settings'
58
+ desc(
59
+ 'open [get|enable|disable]',
60
+ 'Get, Enable and Disable open tracking settings'
61
+ )
53
62
  def open(action)
54
63
  case action
55
64
  when 'get'
@@ -65,7 +74,7 @@ module SendGrid4r::CLI
65
74
  end
66
75
 
67
76
  desc(
68
- 'subscription',
77
+ 'subscription [get|enable|disable]',
69
78
  'Get, Enable and Disable subscription tracking settings'
70
79
  )
71
80
  option :landing
@@ -5,26 +5,35 @@ module SendGrid4r::CLI
5
5
  class SG < Thor
6
6
  map %w(--version -v) => :print_version
7
7
 
8
- desc '--version, -v', 'print the version'
8
+ desc '--version, -v', 'Print the version'
9
9
  def print_version
10
10
  puts SendGrid4r::VERSION
11
11
  end
12
12
 
13
+ desc('alert SUBCOMMAND ...ARGS', 'Manage alert settings')
14
+ subcommand('alert', Alert)
15
+
13
16
  desc('api_key SUBCOMMAND ...ARGS', 'Manage API keys')
14
17
  subcommand('api_key', ApiKeys::ApiKey)
15
18
 
19
+ desc('campaign SUBCOMMAND ...ARGS', 'Manage Marketing Campaigns')
20
+ subcommand('campaign', Campaign::Campaign)
21
+
16
22
  desc('cancel_schedule SUBCOMMAND ...ARGS', 'Manage canceling schedule send')
17
23
  subcommand('cancel_schedule', CancelSchedules::CancelSchedule)
18
24
 
19
- desc('ip SUBCOMMAND ...ARGS', 'Manage ips')
20
- subcommand('ip', Ips::Ip)
21
-
22
25
  desc('ipam SUBCOMMAND ...ARGS', 'Manage ip access')
23
26
  subcommand('ipam', Ipam::Ipam)
24
27
 
28
+ desc('ip SUBCOMMAND ...ARGS', 'Manage ips')
29
+ subcommand('ip', Ips::Ip)
30
+
25
31
  desc('settings SUBCOMMAND ...ARGS', 'Manage settings')
26
32
  subcommand('settings', Settings::Settings)
27
33
 
34
+ desc('stats SUBCOMMAND ...ARGS', 'Get account statistics')
35
+ subcommand('stats', Stats::Stats)
36
+
28
37
  desc('subuser SUBCOMMAND ...ARGS', 'Manage subuser')
29
38
  subcommand('subuser', Subusers::Subuser)
30
39
 
@@ -43,13 +52,10 @@ module SendGrid4r::CLI
43
52
  desc('category SUBCOMMAND ...ARGS', 'Manage categories')
44
53
  subcommand('category', Category)
45
54
 
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
55
  desc('mail SUBCOMMAND ...ARGS', 'Send mail')
53
56
  subcommand('mail', Mail)
57
+
58
+ desc('user SUBCOMMAND ...ARGS', 'Manage user')
59
+ subcommand('user', User)
54
60
  end
55
61
  end
@@ -3,15 +3,29 @@ module SendGrid4r::CLI
3
3
  # SendGrid Web API v3 SgThor
4
4
  #
5
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'
6
+ ISO = 'YYYY-MM-DD'
7
+ UTS = 'UNIX TIMESTAMP'
8
+ AGG = '[day|week|month]'
9
+ DIR = '[desc|asc]'
10
+ TYP = '[date|text|number]'
11
+
12
+ class_option :api_key, aliases: '-k', desc: 'API Key for APIKey Auth'
13
+ class_option :user, aliases: '-u', desc: 'Username for Basic Auth'
14
+ class_option :pass, aliases: '-p', desc: 'Password for Basic Auth'
15
+ class_option(
16
+ :envkey,
17
+ aliases: '-e',
18
+ desc: 'Load API Key from environment variable "SG_API_KEY"',
19
+ banner: ''
20
+ )
9
21
 
10
22
  def initialize(*args)
11
23
  super
24
+ api_key = options[:api_key]
25
+ api_key = ENV['SG_API_KEY'] if options[:envkey]
12
26
  @client = SendGrid4r::Client.new(
13
27
  username: options[:user], password: options[:pass],
14
- api_key: options[:api_key], raw_response: true
28
+ api_key: api_key, raw_response: true
15
29
  )
16
30
  end
17
31
 
@@ -22,13 +36,15 @@ module SendGrid4r::CLI
22
36
  params = options.each_with_object({}) do |(k, v), memo|
23
37
  memo[k.to_s.to_sym] = v
24
38
  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
39
+ params.tap do |p|
40
+ # remove auth info
41
+ p.delete(:api_key)
42
+ p.delete(:user)
43
+ p.delete(:pass)
44
+ p.delete(:envkey)
45
+ # remove empty key and value
46
+ p.delete_if { |_k, v| v.nil? }
47
+ end
32
48
  end
33
49
  end
34
50
  end
@@ -5,10 +5,10 @@ module SendGrid4r::CLI
5
5
  #
6
6
  class Advanced < SgThor
7
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
8
+ option :start_date, banner: SgThor::ISO, require: true
9
+ option :end_date, banner: SgThor::ISO
10
+ option :aggregated_by, banner: SgThor::AGG
11
+ option :country, banner: '[US|CA]'
12
12
  def geo
13
13
  puts @client.get_geo_stats(parameterise(options))
14
14
  rescue RestClient::ExceptionWithResponse => e
@@ -16,9 +16,9 @@ module SendGrid4r::CLI
16
16
  end
17
17
 
18
18
  desc 'device', 'Gets email statistics by device type'
19
- option :start_date, require: true
20
- option :end_date
21
- option :aggregated_by
19
+ option :start_date, banner: SgThor::ISO, require: true
20
+ option :end_date, banner: SgThor::ISO
21
+ option :aggregated_by, banner: SgThor::AGG
22
22
  def device
23
23
  puts @client.get_devices_stats(parameterise(options))
24
24
  rescue RestClient::ExceptionWithResponse => e
@@ -26,9 +26,9 @@ module SendGrid4r::CLI
26
26
  end
27
27
 
28
28
  desc 'client', 'Gets email statistics by client type'
29
- option :start_date, require: true
30
- option :end_date
31
- option :aggregated_by
29
+ option :start_date, banner: SgThor::ISO, require: true
30
+ option :end_date, banner: SgThor::ISO
31
+ option :aggregated_by, banner: SgThor::AGG
32
32
  def client
33
33
  puts @client.get_clients_stats(parameterise(options))
34
34
  rescue RestClient::ExceptionWithResponse => e
@@ -36,10 +36,12 @@ module SendGrid4r::CLI
36
36
  end
37
37
 
38
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
39
+ option :start_date, banner: SgThor::ISO, require: true
40
+ option :end_date, banner: SgThor::ISO
41
+ option :aggregated_by, banner: SgThor::AGG
42
+ option(
43
+ :client_type, banner: '[phone|tablet|webmail|desktop]', require: true
44
+ )
43
45
  def client_type
44
46
  puts @client.get_clients_type_stats(parameterise(options))
45
47
  rescue RestClient::ExceptionWithResponse => e
@@ -47,9 +49,9 @@ module SendGrid4r::CLI
47
49
  end
48
50
 
49
51
  desc 'mailbox_provider', 'Gets email statistics by mailbox provider'
50
- option :start_date, require: true
51
- option :end_date
52
- option :aggregated_by
52
+ option :start_date, banner: SgThor::ISO, require: true
53
+ option :end_date, banner: SgThor::ISO
54
+ option :aggregated_by, banner: SgThor::AGG
53
55
  option :mailbox_providers
54
56
  def mailbox_provider
55
57
  puts @client.get_mailbox_providers_stats(parameterise(options))
@@ -58,9 +60,9 @@ module SendGrid4r::CLI
58
60
  end
59
61
 
60
62
  desc 'browser', 'Gets email statistics by browser'
61
- option :start_date, require: true
62
- option :end_date
63
- option :aggregated_by
63
+ option :start_date, banner: SgThor::ISO, require: true
64
+ option :end_date, banner: SgThor::ISO
65
+ option :aggregated_by, banner: SgThor::AGG
64
66
  option :browsers
65
67
  def browser
66
68
  puts @client.get_browsers_stats(parameterise(options))
@@ -5,9 +5,9 @@ module SendGrid4r::CLI
5
5
  #
6
6
  class Category < SgThor
7
7
  desc 'get', 'Gets email statistics for the given categories.'
8
- option :start_date, require: true
9
- option :end_date
10
- option :aggregated_by
8
+ option :start_date, banner: SgThor::ISO, require: true
9
+ option :end_date, banner: SgThor::ISO
10
+ option :aggregated_by, banner: SgThor::AGG
11
11
  option :categories, require: true
12
12
  def get
13
13
  puts @client.get_categories_stats(parameterise(options))
@@ -19,12 +19,12 @@ module SendGrid4r::CLI
19
19
  'sums',
20
20
  'Gets the total sums of each email statistic metric for all categories'
21
21
  )
22
- option :start_date, require: true
23
- option :end_date
22
+ option :start_date, banner: SgThor::ISO, require: true
23
+ option :end_date, banner: SgThor::ISO
24
24
  option :sort_by_metric
25
- option :sort_by_direction
26
- option :limit
27
- option :offset
25
+ option :sort_by_direction, banner: SgThor::DIR
26
+ option :limit, type: :numeric
27
+ option :offset, type: :numeric
28
28
  def sums
29
29
  puts @client.get_categories_stats_sums(parameterise(options))
30
30
  rescue RestClient::ExceptionWithResponse => e
@@ -5,9 +5,9 @@ module SendGrid4r::CLI
5
5
  #
6
6
  class Global < SgThor
7
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
8
+ option :start_date, banner: SgThor::ISO, require: true
9
+ option :end_date, banner: SgThor::ISO
10
+ option :aggregated_by, banner: SgThor::AGG
11
11
  def get
12
12
  puts @client.get_global_stats(parameterise(options))
13
13
  rescue RestClient::ExceptionWithResponse => e
@@ -5,9 +5,9 @@ module SendGrid4r::CLI
5
5
  #
6
6
  class Parse < SgThor
7
7
  desc 'get', 'Gets statistics for Parse Webhook usage'
8
- option :start_date, require: true
9
- option :end_date
10
- option :aggregated_by
8
+ option :start_date, banner: SgThor::ISO, require: true
9
+ option :end_date, banner: SgThor::ISO
10
+ option :aggregated_by, banner: SgThor::AGG
11
11
  def get
12
12
  puts @client.get_parse_stats(parameterise(options))
13
13
  rescue RestClient::ExceptionWithResponse => e
@@ -5,9 +5,9 @@ module SendGrid4r::CLI
5
5
  #
6
6
  class Subuser < SgThor
7
7
  desc 'get', 'Gets email statistics for the given subusers'
8
- option :start_date, require: true
9
- option :end_date
10
- option :aggregated_by
8
+ option :start_date, banner: SgThor::ISO, require: true
9
+ option :end_date, banner: SgThor::ISO
10
+ option :aggregated_by, banner: SgThor::AGG
11
11
  option :subusers, type: :array, require: true
12
12
  def get
13
13
  puts @client.get_subusers_stats(parameterise(options))
@@ -19,10 +19,10 @@ module SendGrid4r::CLI
19
19
  'sums',
20
20
  'Gets the total sums of each email statistic metric for all subusers'
21
21
  )
22
- option :start_date, require: true
23
- option :end_date
22
+ option :start_date, banner: SgThor::ISO, require: true
23
+ option :end_date, banner: SgThor::ISO
24
24
  option :sort_by_metric
25
- option :sort_by_direction
25
+ option :sort_by_direction, banner: SgThor::DIR
26
26
  option :limit, type: :numeric
27
27
  option :offset, type: :numeric
28
28
  def sums
@@ -35,10 +35,10 @@ module SendGrid4r::CLI
35
35
  'list_monthly',
36
36
  'Retrieve the monthly email statistics for all subusers'
37
37
  )
38
- option :date, require: true
38
+ option :date, banner: SgThor::ISO, require: true
39
39
  option :subuser
40
40
  option :sort_by_metric
41
- option :sort_by_direction
41
+ option :sort_by_direction, banner: SgThor::DIR
42
42
  option :limit, type: :numeric
43
43
  option :offset, type: :numeric
44
44
  def list_monthly
@@ -52,9 +52,9 @@ module SendGrid4r::CLI
52
52
  'Retrieve the monthly email statistics for a single subuser'
53
53
  )
54
54
  option :subuser_name, require: true
55
- option :date, require: true
55
+ option :date, banner: SgThor::ISO, require: true
56
56
  option :sort_by_metric
57
- option :sort_by_direction
57
+ option :sort_by_direction, banner: SgThor::DIR
58
58
  option :limit, type: :numeric
59
59
  option :offset, type: :numeric
60
60
  def get_monthly