sendgrid4r 1.13.0 → 1.14.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 (116) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -1
  3. data/lib/sendgrid4r/version.rb +1 -1
  4. data/lib/sendgrid4r.rb +0 -58
  5. data/sendgrid4r.gemspec +0 -3
  6. data/spec/client_spec.rb +1 -1
  7. metadata +5 -183
  8. data/exe/sg +0 -5
  9. data/lib/sendgrid4r/cli/alert.rb +0 -51
  10. data/lib/sendgrid4r/cli/api_keys/api_key.rb +0 -53
  11. data/lib/sendgrid4r/cli/api_keys/permission.rb +0 -15
  12. data/lib/sendgrid4r/cli/campaign/campaign.rb +0 -134
  13. data/lib/sendgrid4r/cli/campaign/contact/contact.rb +0 -25
  14. data/lib/sendgrid4r/cli/campaign/contact/custom_field.rb +0 -42
  15. data/lib/sendgrid4r/cli/campaign/contact/list.rb +0 -71
  16. data/lib/sendgrid4r/cli/campaign/contact/recipient.rb +0 -78
  17. data/lib/sendgrid4r/cli/campaign/contact/reserved_field.rb +0 -17
  18. data/lib/sendgrid4r/cli/campaign/contact/segment.rb +0 -105
  19. data/lib/sendgrid4r/cli/campaign/sender.rb +0 -83
  20. data/lib/sendgrid4r/cli/cancel_schedules/batch_id.rb +0 -23
  21. data/lib/sendgrid4r/cli/cancel_schedules/cancel_schedule.rb +0 -55
  22. data/lib/sendgrid4r/cli/category.rb +0 -16
  23. data/lib/sendgrid4r/cli/ipam/activity.rb +0 -16
  24. data/lib/sendgrid4r/cli/ipam/ipam.rb +0 -14
  25. data/lib/sendgrid4r/cli/ipam/whitelist.rb +0 -39
  26. data/lib/sendgrid4r/cli/ips/address.rb +0 -48
  27. data/lib/sendgrid4r/cli/ips/ip.rb +0 -17
  28. data/lib/sendgrid4r/cli/ips/pool.rb +0 -48
  29. data/lib/sendgrid4r/cli/ips/warmup.rb +0 -39
  30. data/lib/sendgrid4r/cli/mail.rb +0 -34
  31. data/lib/sendgrid4r/cli/settings/enforced_tls.rb +0 -24
  32. data/lib/sendgrid4r/cli/settings/mail.rb +0 -195
  33. data/lib/sendgrid4r/cli/settings/partner.rb +0 -37
  34. data/lib/sendgrid4r/cli/settings/settings.rb +0 -20
  35. data/lib/sendgrid4r/cli/settings/tracking.rb +0 -101
  36. data/lib/sendgrid4r/cli/sg.rb +0 -61
  37. data/lib/sendgrid4r/cli/sg_thor.rb +0 -50
  38. data/lib/sendgrid4r/cli/stats/advanced.rb +0 -74
  39. data/lib/sendgrid4r/cli/stats/category.rb +0 -35
  40. data/lib/sendgrid4r/cli/stats/global.rb +0 -18
  41. data/lib/sendgrid4r/cli/stats/parse.rb +0 -18
  42. data/lib/sendgrid4r/cli/stats/stats.rb +0 -23
  43. data/lib/sendgrid4r/cli/stats/subuser.rb +0 -67
  44. data/lib/sendgrid4r/cli/subusers/monitor.rb +0 -44
  45. data/lib/sendgrid4r/cli/subusers/subuser.rb +0 -77
  46. data/lib/sendgrid4r/cli/suppressions/block.rb +0 -43
  47. data/lib/sendgrid4r/cli/suppressions/bounce.rb +0 -41
  48. data/lib/sendgrid4r/cli/suppressions/global_unsubscribe.rb +0 -43
  49. data/lib/sendgrid4r/cli/suppressions/group.rb +0 -61
  50. data/lib/sendgrid4r/cli/suppressions/group_unsubscribe.rb +0 -43
  51. data/lib/sendgrid4r/cli/suppressions/invalid_email.rb +0 -43
  52. data/lib/sendgrid4r/cli/suppressions/spam_report.rb +0 -43
  53. data/lib/sendgrid4r/cli/suppressions/suppression.rb +0 -36
  54. data/lib/sendgrid4r/cli/templates/template.rb +0 -51
  55. data/lib/sendgrid4r/cli/templates/version.rb +0 -78
  56. data/lib/sendgrid4r/cli/user.rb +0 -86
  57. data/lib/sendgrid4r/cli/webhooks/event.rb +0 -53
  58. data/lib/sendgrid4r/cli/webhooks/parse.rb +0 -55
  59. data/lib/sendgrid4r/cli/webhooks/webhook.rb +0 -14
  60. data/lib/sendgrid4r/cli/whitelabel/domain.rb +0 -117
  61. data/lib/sendgrid4r/cli/whitelabel/ip.rb +0 -52
  62. data/lib/sendgrid4r/cli/whitelabel/link.rb +0 -96
  63. data/lib/sendgrid4r/cli/whitelabel/whitelabel.rb +0 -17
  64. data/spec/cli/alert_spec.rb +0 -71
  65. data/spec/cli/api_keys/api_key_spec.rb +0 -77
  66. data/spec/cli/api_keys/permission_spec.rb +0 -29
  67. data/spec/cli/campaign/campaign_spec.rb +0 -136
  68. data/spec/cli/campaign/contact/custom_field_spec.rb +0 -48
  69. data/spec/cli/campaign/contact/list_spec.rb +0 -88
  70. data/spec/cli/campaign/contact/recipient_spec.rb +0 -93
  71. data/spec/cli/campaign/contact/reserved_field_spec.rb +0 -20
  72. data/spec/cli/campaign/contact/segment_spec.rb +0 -93
  73. data/spec/cli/campaign/sender_spec.rb +0 -83
  74. data/spec/cli/cancel_schedules/batch_id_spec.rb +0 -33
  75. data/spec/cli/cancel_schedules/cancel_schedule_spec.rb +0 -69
  76. data/spec/cli/category_spec.rb +0 -23
  77. data/spec/cli/ipam/activity_spec.rb +0 -21
  78. data/spec/cli/ipam/ipam_spec.rb +0 -26
  79. data/spec/cli/ipam/whitelist_spec.rb +0 -47
  80. data/spec/cli/ips/address_spec.rb +0 -57
  81. data/spec/cli/ips/ip_spec.rb +0 -33
  82. data/spec/cli/ips/pool_spec.rb +0 -57
  83. data/spec/cli/ips/warmup_spec.rb +0 -47
  84. data/spec/cli/mail_spec.rb +0 -37
  85. data/spec/cli/settings/enforced_tls_spec.rb +0 -30
  86. data/spec/cli/settings/mail_spec.rb +0 -255
  87. data/spec/cli/settings/partner_spec.rb +0 -47
  88. data/spec/cli/settings/settings_spec.rb +0 -40
  89. data/spec/cli/settings/tracking_spec.rb +0 -128
  90. data/spec/cli/sg_spec.rb +0 -87
  91. data/spec/cli/stats/advanced_spec.rb +0 -137
  92. data/spec/cli/stats/category_spec.rb +0 -57
  93. data/spec/cli/stats/global_spec.rb +0 -32
  94. data/spec/cli/stats/parse_spec.rb +0 -32
  95. data/spec/cli/stats/stats_spec.rb +0 -40
  96. data/spec/cli/stats/subuser_spec.rb +0 -104
  97. data/spec/cli/subusers/monitor_spec.rb +0 -52
  98. data/spec/cli/subusers/subuser_spec.rb +0 -88
  99. data/spec/cli/suppressions/block_spec.rb +0 -60
  100. data/spec/cli/suppressions/bounce_spec.rb +0 -58
  101. data/spec/cli/suppressions/global_unsubscribe_spec.rb +0 -59
  102. data/spec/cli/suppressions/group_spec.rb +0 -78
  103. data/spec/cli/suppressions/group_unsubscribe_spec.rb +0 -51
  104. data/spec/cli/suppressions/invalid_email_spec.rb +0 -60
  105. data/spec/cli/suppressions/spam_report_spec.rb +0 -60
  106. data/spec/cli/suppressions/suppression_spec.rb +0 -68
  107. data/spec/cli/templates/template_spec.rb +0 -65
  108. data/spec/cli/templates/version_spec.rb +0 -71
  109. data/spec/cli/user_spec.rb +0 -82
  110. data/spec/cli/webhooks/event_spec.rb +0 -67
  111. data/spec/cli/webhooks/parse_spec.rb +0 -72
  112. data/spec/cli/webhooks/webhook_spec.rb +0 -28
  113. data/spec/cli/whitelabel/domain_spec.rb +0 -112
  114. data/spec/cli/whitelabel/ip_spec.rb +0 -61
  115. data/spec/cli/whitelabel/link_spec.rb +0 -110
  116. data/spec/cli/whitelabel/whitelabel_spec.rb +0 -27
@@ -1,39 +0,0 @@
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
@@ -1,34 +0,0 @@
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
@@ -1,24 +0,0 @@
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, type: :boolean
16
- option :require_valid_cert, type: :boolean
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
@@ -1,195 +0,0 @@
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(
17
- 'whitelist [get|enable|disable]',
18
- 'Get, Enable and Disable address whitelist settings'
19
- )
20
- option :list, type: :array
21
- def whitelist(action)
22
- case action
23
- when 'get'
24
- puts @client.get_settings_address_whitelist
25
- when 'enable', 'disable'
26
- params = parameterise(options)
27
- params[:enabled] = action == 'enable'
28
- puts @client.patch_settings_address_whitelist(params: params)
29
- else
30
- puts "error: #{action} is not supported in action parameter"
31
- end
32
- rescue RestClient::ExceptionWithResponse => e
33
- puts e.inspect
34
- end
35
-
36
- desc 'bcc [get|enable|disable]', 'Get, Enable and Disable bcc settings'
37
- option :email
38
- def bcc(action)
39
- case action
40
- when 'get'
41
- puts @client.get_settings_bcc
42
- when 'enable', 'disable'
43
- params = parameterise(options)
44
- params[:enabled] = action == 'enable'
45
- puts @client.patch_settings_bcc(params: params)
46
- else
47
- puts "error: #{action} is not supported in action parameter"
48
- end
49
- rescue RestClient::ExceptionWithResponse => e
50
- puts e.inspect
51
- end
52
-
53
- desc(
54
- 'bounce_purge [get|enable|disable]',
55
- 'Get, Enable and Disable bounce purge settings'
56
- )
57
- option :hard_bounces, type: :numeric
58
- option :soft_bounces, type: :numeric
59
- def bounce_purge(action)
60
- case action
61
- when 'get'
62
- puts @client.get_settings_bounce_purge
63
- when 'enable', 'disable'
64
- params = parameterise(options)
65
- params[:enabled] = action == 'enable'
66
- puts @client.patch_settings_bounce_purge(params: params)
67
- else
68
- puts "error: #{action} is not supported in action parameter"
69
- end
70
- rescue RestClient::ExceptionWithResponse => e
71
- puts e.inspect
72
- end
73
-
74
- desc(
75
- 'footer [get|enable|disable]',
76
- 'Get, Enable and Disable footer settings'
77
- )
78
- option :html_content
79
- option :plain_content
80
- def footer(action)
81
- case action
82
- when 'get'
83
- puts @client.get_settings_footer
84
- when 'enable', 'disable'
85
- params = parameterise(options)
86
- params[:enabled] = action == 'enable'
87
- puts @client.patch_settings_footer(params: params)
88
- else
89
- puts "error: #{action} is not supported in action parameter"
90
- end
91
- rescue RestClient::ExceptionWithResponse => e
92
- puts e.inspect
93
- end
94
-
95
- desc(
96
- 'forward_bounce [get|enable|disable]',
97
- 'Get, Enable and Disable forward bounce settings'
98
- )
99
- option :email
100
- def forward_bounce(action)
101
- case action
102
- when 'get'
103
- puts @client.get_settings_forward_bounce
104
- when 'enable', 'disable'
105
- params = parameterise(options)
106
- params[:enabled] = action == 'enable'
107
- puts @client.patch_settings_forward_bounce(params: params)
108
- else
109
- puts "error: #{action} is not supported in action parameter"
110
- end
111
- rescue RestClient::ExceptionWithResponse => e
112
- puts e.inspect
113
- end
114
-
115
- desc(
116
- 'forward_spam [get|enable|disable]',
117
- 'Get, Enable and Disable forward spam settings'
118
- )
119
- option :email
120
- def forward_spam(action)
121
- case action
122
- when 'get'
123
- puts @client.get_settings_forward_spam
124
- when 'enable', 'disable'
125
- params = parameterise(options)
126
- params[:enabled] = action == 'enable'
127
- puts @client.patch_settings_forward_spam(params: params)
128
- else
129
- puts "error: #{action} is not supported in action parameter"
130
- end
131
- rescue RestClient::ExceptionWithResponse => e
132
- puts e.inspect
133
- end
134
-
135
- desc(
136
- 'spam_check [get|enable|disable]',
137
- 'Get, Enable and Disable spam check settings'
138
- )
139
- option :url
140
- option :max_score
141
- def spam_check(action)
142
- case action
143
- when 'get'
144
- puts @client.get_settings_spam_check
145
- when 'enable', 'disable'
146
- params = parameterise(options)
147
- params[:enabled] = action == 'enable'
148
- puts @client.patch_settings_spam_check(params: params)
149
- else
150
- puts "error: #{action} is not supported in action parameter"
151
- end
152
- rescue RestClient::ExceptionWithResponse => e
153
- puts e.inspect
154
- end
155
-
156
- desc(
157
- 'template [get|enable|disable]',
158
- 'Get, Enable and Disable template settings'
159
- )
160
- option :html_content
161
- def template(action)
162
- case action
163
- when 'get'
164
- puts @client.get_settings_template
165
- when 'enable', 'disable'
166
- params = parameterise(options)
167
- params[:enabled] = action == 'enable'
168
- puts @client.patch_settings_template(params: params)
169
- else
170
- puts "error: #{action} is not supported in action parameter"
171
- end
172
- rescue RestClient::ExceptionWithResponse => e
173
- puts e.inspect
174
- end
175
-
176
- desc(
177
- 'plain_content [get|enable|disable]',
178
- 'Get, Enable and Disable plain content settings'
179
- )
180
- def plain_content(action)
181
- case action
182
- when 'get'
183
- puts @client.get_settings_plain_content
184
- when 'enable', 'disable'
185
- params = { enabled: action == 'enable' }
186
- puts @client.patch_settings_plain_content(params: params)
187
- else
188
- puts "error: #{action} is not supported in action parameter"
189
- end
190
- rescue RestClient::ExceptionWithResponse => e
191
- puts e.inspect
192
- end
193
- end
194
- end
195
- end
@@ -1,37 +0,0 @@
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(
17
- 'new_relic [get|enable|disable]',
18
- 'Get, Enable and Disable new relic settings'
19
- )
20
- option :license_key
21
- def new_relic(action)
22
- case action
23
- when 'get'
24
- puts @client.get_settings_new_relic
25
- when 'enable', 'disabple'
26
- params = parameterise(options)
27
- params[:enabled] = action == 'enable'
28
- puts @client.patch_settings_new_relic(params: params)
29
- else
30
- puts "error: #{action} is not supported in action parameter"
31
- end
32
- rescue RestClient::ExceptionWithResponse => e
33
- puts e.inspect
34
- end
35
- end
36
- end
37
- end
@@ -1,20 +0,0 @@
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
@@ -1,101 +0,0 @@
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(
17
- 'click [get|enable|disable]',
18
- 'Get, Enable and Disable click tracking settings'
19
- )
20
- def click(action)
21
- case action
22
- when 'get'
23
- puts @client.get_settings_click
24
- when 'enable', 'disable'
25
- params = { enabled: action == 'enable' }
26
- puts @client.patch_settings_click(params: params)
27
- else
28
- puts "error: #{action} is not supported in action parameter"
29
- end
30
- rescue RestClient::ExceptionWithResponse => e
31
- puts e.inspect
32
- end
33
-
34
- desc(
35
- 'ganalytics [get|enable|disable]',
36
- 'Get, Enable and Disable google analytics settings'
37
- )
38
- option :utm_source
39
- option :utm_medium
40
- option :utm_term
41
- option :utm_content
42
- option :utm_campaign
43
- def ganalytics(action)
44
- case action
45
- when 'get'
46
- puts @client.get_settings_google_analytics
47
- when 'enable', 'disable'
48
- params = parameterise(options)
49
- params[:enabled] = action == 'enable'
50
- puts @client.patch_settings_google_analytics(params: params)
51
- else
52
- puts "error: #{action} is not supported in action parameter"
53
- end
54
- rescue RestClient::ExceptionWithResponse => e
55
- puts e.inspect
56
- end
57
-
58
- desc(
59
- 'open [get|enable|disable]',
60
- 'Get, Enable and Disable open tracking settings'
61
- )
62
- def open(action)
63
- case action
64
- when 'get'
65
- puts @client.get_settings_open
66
- when 'enable', 'disable'
67
- params = { enabled: action == 'enable' }
68
- puts @client.patch_settings_open(params: params)
69
- else
70
- puts "error: #{action} is not supported in action parameter"
71
- end
72
- rescue RestClient::ExceptionWithResponse => e
73
- puts e.inspect
74
- end
75
-
76
- desc(
77
- 'subscription [get|enable|disable]',
78
- 'Get, Enable and Disable subscription tracking settings'
79
- )
80
- option :landing
81
- option :url
82
- option :replace
83
- option :html_content
84
- option :plain_content
85
- def subscription(action)
86
- case action
87
- when 'get'
88
- puts @client.get_settings_subscription
89
- when 'enable', 'disable'
90
- params = parameterise(options)
91
- params[:enabled] = action == 'enable'
92
- puts @client.patch_settings_subscription(params: params)
93
- else
94
- puts "error: #{action} is not supported in action parameter"
95
- end
96
- rescue RestClient::ExceptionWithResponse => e
97
- puts e.inspect
98
- end
99
- end
100
- end
101
- end
@@ -1,61 +0,0 @@
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('alert SUBCOMMAND ...ARGS', 'Manage alert settings')
14
- subcommand('alert', Alert)
15
-
16
- desc('api_key SUBCOMMAND ...ARGS', 'Manage API keys')
17
- subcommand('api_key', ApiKeys::ApiKey)
18
-
19
- desc('campaign SUBCOMMAND ...ARGS', 'Manage Marketing Campaigns')
20
- subcommand('campaign', Campaign::Campaign)
21
-
22
- desc('cancel_schedule SUBCOMMAND ...ARGS', 'Manage canceling schedule send')
23
- subcommand('cancel_schedule', CancelSchedules::CancelSchedule)
24
-
25
- desc('ipam SUBCOMMAND ...ARGS', 'Manage ip access')
26
- subcommand('ipam', Ipam::Ipam)
27
-
28
- desc('ip SUBCOMMAND ...ARGS', 'Manage ips')
29
- subcommand('ip', Ips::Ip)
30
-
31
- desc('settings SUBCOMMAND ...ARGS', 'Manage settings')
32
- subcommand('settings', Settings::Settings)
33
-
34
- desc('stats SUBCOMMAND ...ARGS', 'Get account statistics')
35
- subcommand('stats', Stats::Stats)
36
-
37
- desc('subuser SUBCOMMAND ...ARGS', 'Manage subuser')
38
- subcommand('subuser', Subusers::Subuser)
39
-
40
- desc('suppression SUBCOMMAND ...ARGS', 'Manage suppressions')
41
- subcommand('suppressions', Suppressions::Suppression)
42
-
43
- desc('template SUBCOMMAND ...ARGS', 'Manage templates')
44
- subcommand('template', Templates::Template)
45
-
46
- desc('webhook SUBCOMMAND ...ARGS', 'Manage webhook settings')
47
- subcommand('webhook', Webhooks::Webhook)
48
-
49
- desc('whitelabel SUBCOMMAND ...ARGS', 'Manage whitelabel settings')
50
- subcommand('whitelabel', Whitelabel::Whitelabel)
51
-
52
- desc('category SUBCOMMAND ...ARGS', 'Manage categories')
53
- subcommand('category', Category)
54
-
55
- desc('mail SUBCOMMAND ...ARGS', 'Send mail')
56
- subcommand('mail', Mail)
57
-
58
- desc('user SUBCOMMAND ...ARGS', 'Manage user')
59
- subcommand('user', User)
60
- end
61
- end
@@ -1,50 +0,0 @@
1
- module SendGrid4r::CLI
2
- #
3
- # SendGrid Web API v3 SgThor
4
- #
5
- class SgThor < Thor
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
- )
21
-
22
- def initialize(*args)
23
- super
24
- api_key = options[:api_key]
25
- api_key = ENV['SG_API_KEY'] if options[:envkey]
26
- @client = SendGrid4r::Client.new(
27
- username: options[:user], password: options[:pass],
28
- api_key: api_key, raw_response: true
29
- )
30
- end
31
-
32
- protected
33
-
34
- def parameterise(options)
35
- # symbolize keys
36
- params = options.each_with_object({}) do |(k, v), memo|
37
- memo[k.to_s.to_sym] = v
38
- end
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
48
- end
49
- end
50
- end
@@ -1,74 +0,0 @@
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, 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
- 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, banner: SgThor::ISO, require: true
20
- option :end_date, banner: SgThor::ISO
21
- option :aggregated_by, banner: SgThor::AGG
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, banner: SgThor::ISO, require: true
30
- option :end_date, banner: SgThor::ISO
31
- option :aggregated_by, banner: SgThor::AGG
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, 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
- )
45
- def client_type
46
- puts @client.get_clients_type_stats(parameterise(options))
47
- rescue RestClient::ExceptionWithResponse => e
48
- puts e.inspect
49
- end
50
-
51
- desc 'mailbox_provider', 'Gets email statistics by mailbox provider'
52
- option :start_date, banner: SgThor::ISO, require: true
53
- option :end_date, banner: SgThor::ISO
54
- option :aggregated_by, banner: SgThor::AGG
55
- option :mailbox_providers
56
- def mailbox_provider
57
- puts @client.get_mailbox_providers_stats(parameterise(options))
58
- rescue RestClient::ExceptionWithResponse => e
59
- puts e.inspect
60
- end
61
-
62
- desc 'browser', 'Gets email statistics by browser'
63
- option :start_date, banner: SgThor::ISO, require: true
64
- option :end_date, banner: SgThor::ISO
65
- option :aggregated_by, banner: SgThor::AGG
66
- option :browsers
67
- def browser
68
- puts @client.get_browsers_stats(parameterise(options))
69
- rescue RestClient::ExceptionWithResponse => e
70
- puts e.inspect
71
- end
72
- end
73
- end
74
- end
@@ -1,35 +0,0 @@
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, banner: SgThor::ISO, require: true
9
- option :end_date, banner: SgThor::ISO
10
- option :aggregated_by, banner: SgThor::AGG
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, banner: SgThor::ISO, require: true
23
- option :end_date, banner: SgThor::ISO
24
- option :sort_by_metric
25
- option :sort_by_direction, banner: SgThor::DIR
26
- option :limit, type: :numeric
27
- option :offset, type: :numeric
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
@@ -1,18 +0,0 @@
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, banner: SgThor::ISO, require: true
9
- option :end_date, banner: SgThor::ISO
10
- option :aggregated_by, banner: SgThor::AGG
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