sendgrid4r 1.11.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -1
  3. data/exe/sg +5 -0
  4. data/lib/sendgrid4r/cli/api_keys/api_key.rb +53 -0
  5. data/lib/sendgrid4r/cli/api_keys/permission.rb +15 -0
  6. data/lib/sendgrid4r/cli/campaign/campaign.rb +134 -0
  7. data/lib/sendgrid4r/cli/campaign/contact/contact.rb +25 -0
  8. data/lib/sendgrid4r/cli/campaign/contact/custom_field.rb +42 -0
  9. data/lib/sendgrid4r/cli/campaign/contact/list.rb +71 -0
  10. data/lib/sendgrid4r/cli/campaign/contact/recipient.rb +78 -0
  11. data/lib/sendgrid4r/cli/campaign/contact/reserved_field.rb +17 -0
  12. data/lib/sendgrid4r/cli/campaign/contact/segment.rb +96 -0
  13. data/lib/sendgrid4r/cli/campaign/sender.rb +83 -0
  14. data/lib/sendgrid4r/cli/cancel_schedules/batch_id.rb +23 -0
  15. data/lib/sendgrid4r/cli/cancel_schedules/cancel_schedule.rb +55 -0
  16. data/lib/sendgrid4r/cli/category.rb +16 -0
  17. data/lib/sendgrid4r/cli/ipam/activity.rb +16 -0
  18. data/lib/sendgrid4r/cli/ipam/ipam.rb +14 -0
  19. data/lib/sendgrid4r/cli/ipam/whitelist.rb +39 -0
  20. data/lib/sendgrid4r/cli/ips/address.rb +48 -0
  21. data/lib/sendgrid4r/cli/ips/ip.rb +17 -0
  22. data/lib/sendgrid4r/cli/ips/pool.rb +48 -0
  23. data/lib/sendgrid4r/cli/ips/warmup.rb +39 -0
  24. data/lib/sendgrid4r/cli/mail.rb +34 -0
  25. data/lib/sendgrid4r/cli/settings/enforced_tls.rb +24 -0
  26. data/lib/sendgrid4r/cli/settings/mail.rb +171 -0
  27. data/lib/sendgrid4r/cli/settings/partner.rb +34 -0
  28. data/lib/sendgrid4r/cli/settings/settings.rb +20 -0
  29. data/lib/sendgrid4r/cli/settings/tracking.rb +92 -0
  30. data/lib/sendgrid4r/cli/sg.rb +55 -0
  31. data/lib/sendgrid4r/cli/sg_thor.rb +34 -0
  32. data/lib/sendgrid4r/cli/stats/advanced.rb +72 -0
  33. data/lib/sendgrid4r/cli/stats/category.rb +35 -0
  34. data/lib/sendgrid4r/cli/stats/global.rb +18 -0
  35. data/lib/sendgrid4r/cli/stats/parse.rb +18 -0
  36. data/lib/sendgrid4r/cli/stats/stats.rb +23 -0
  37. data/lib/sendgrid4r/cli/stats/subuser.rb +67 -0
  38. data/lib/sendgrid4r/cli/subusers/monitor.rb +44 -0
  39. data/lib/sendgrid4r/cli/subusers/subuser.rb +77 -0
  40. data/lib/sendgrid4r/cli/suppressions/block.rb +43 -0
  41. data/lib/sendgrid4r/cli/suppressions/bounce.rb +41 -0
  42. data/lib/sendgrid4r/cli/suppressions/global_unsubscribe.rb +43 -0
  43. data/lib/sendgrid4r/cli/suppressions/group.rb +56 -0
  44. data/lib/sendgrid4r/cli/suppressions/group_unsubscribe.rb +34 -0
  45. data/lib/sendgrid4r/cli/suppressions/invalid_email.rb +43 -0
  46. data/lib/sendgrid4r/cli/suppressions/spam_report.rb +43 -0
  47. data/lib/sendgrid4r/cli/suppressions/suppression.rb +36 -0
  48. data/lib/sendgrid4r/cli/templates/template.rb +51 -0
  49. data/lib/sendgrid4r/cli/templates/version.rb +78 -0
  50. data/lib/sendgrid4r/cli/user.rb +86 -0
  51. data/lib/sendgrid4r/cli/webhooks/event.rb +53 -0
  52. data/lib/sendgrid4r/cli/webhooks/parse.rb +15 -0
  53. data/lib/sendgrid4r/cli/webhooks/webhook.rb +14 -0
  54. data/lib/sendgrid4r/cli/whitelabel/domain.rb +117 -0
  55. data/lib/sendgrid4r/cli/whitelabel/ip.rb +52 -0
  56. data/lib/sendgrid4r/cli/whitelabel/link.rb +96 -0
  57. data/lib/sendgrid4r/cli/whitelabel/whitelabel.rb +17 -0
  58. data/lib/sendgrid4r/client.rb +4 -1
  59. data/lib/sendgrid4r/factory/campaign_factory.rb +1 -1
  60. data/lib/sendgrid4r/factory/condition_factory.rb +2 -2
  61. data/lib/sendgrid4r/factory/event_factory.rb +21 -0
  62. data/lib/sendgrid4r/rest/api_keys_management/api_keys.rb +5 -5
  63. data/lib/sendgrid4r/rest/api_keys_management/permissions.rb +3 -1
  64. data/lib/sendgrid4r/rest/blocks.rb +2 -2
  65. data/lib/sendgrid4r/rest/bounces.rb +2 -2
  66. data/lib/sendgrid4r/rest/cancel_scheduled_sends.rb +12 -4
  67. data/lib/sendgrid4r/rest/categories.rb +1 -1
  68. data/lib/sendgrid4r/rest/email_activity.rb +1 -1
  69. data/lib/sendgrid4r/rest/invalid_emails.rb +2 -2
  70. data/lib/sendgrid4r/rest/ip_access_management.rb +12 -4
  71. data/lib/sendgrid4r/rest/ips/addresses.rb +4 -4
  72. data/lib/sendgrid4r/rest/ips/pools.rb +4 -4
  73. data/lib/sendgrid4r/rest/ips/warmup.rb +3 -3
  74. data/lib/sendgrid4r/rest/marketing_campaigns/contacts/custom_fields.rb +9 -3
  75. data/lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb +7 -5
  76. data/lib/sendgrid4r/rest/marketing_campaigns/contacts/recipients.rb +22 -7
  77. data/lib/sendgrid4r/rest/marketing_campaigns/contacts/reserved_fields.rb +3 -1
  78. data/lib/sendgrid4r/rest/marketing_campaigns/contacts/segments.rb +7 -5
  79. data/lib/sendgrid4r/rest/marketing_campaigns/marketing_campaigns.rb +8 -8
  80. data/lib/sendgrid4r/rest/marketing_campaigns/senders.rb +4 -4
  81. data/lib/sendgrid4r/rest/request.rb +6 -4
  82. data/lib/sendgrid4r/rest/settings/enforced_tls.rb +6 -2
  83. data/lib/sendgrid4r/rest/settings/mail.rb +71 -17
  84. data/lib/sendgrid4r/rest/settings/partner.rb +3 -3
  85. data/lib/sendgrid4r/rest/settings/tracking.rb +17 -9
  86. data/lib/sendgrid4r/rest/sm/global_unsubscribes.rb +5 -3
  87. data/lib/sendgrid4r/rest/sm/groups.rb +4 -4
  88. data/lib/sendgrid4r/rest/sm/suppressions.rb +6 -3
  89. data/lib/sendgrid4r/rest/spam_reports.rb +2 -2
  90. data/lib/sendgrid4r/rest/stats/advanced.rb +8 -8
  91. data/lib/sendgrid4r/rest/stats/category.rb +2 -2
  92. data/lib/sendgrid4r/rest/stats/global.rb +1 -1
  93. data/lib/sendgrid4r/rest/stats/parse.rb +1 -1
  94. data/lib/sendgrid4r/rest/stats/subuser.rb +4 -4
  95. data/lib/sendgrid4r/rest/subusers.rb +15 -10
  96. data/lib/sendgrid4r/rest/transactional_templates/templates.rb +12 -4
  97. data/lib/sendgrid4r/rest/transactional_templates/versions.rb +4 -4
  98. data/lib/sendgrid4r/rest/users.rb +9 -9
  99. data/lib/sendgrid4r/rest/webhooks/event.rb +2 -2
  100. data/lib/sendgrid4r/rest/webhooks/parse.rb +1 -1
  101. data/lib/sendgrid4r/rest/whitelabel/domains.rb +10 -11
  102. data/lib/sendgrid4r/rest/whitelabel/ips.rb +4 -4
  103. data/lib/sendgrid4r/rest/whitelabel/links.rb +8 -8
  104. data/lib/sendgrid4r/version.rb +1 -1
  105. data/lib/sendgrid4r.rb +57 -0
  106. data/sendgrid4r.gemspec +3 -1
  107. data/spec/cli/api_keys/api_key_spec.rb +77 -0
  108. data/spec/cli/api_keys/permission_spec.rb +29 -0
  109. data/spec/cli/campaign/campaign_spec.rb +136 -0
  110. data/spec/cli/campaign/contact/custom_field_spec.rb +48 -0
  111. data/spec/cli/campaign/contact/list_spec.rb +88 -0
  112. data/spec/cli/campaign/contact/recipient_spec.rb +93 -0
  113. data/spec/cli/campaign/contact/reserved_field_spec.rb +20 -0
  114. data/spec/cli/campaign/contact/segment_spec.rb +93 -0
  115. data/spec/cli/campaign/sender_spec.rb +83 -0
  116. data/spec/cli/cancel_schedules/batch_id_spec.rb +33 -0
  117. data/spec/cli/cancel_schedules/cancel_schedule_spec.rb +69 -0
  118. data/spec/cli/category_spec.rb +23 -0
  119. data/spec/cli/ipam/activity_spec.rb +21 -0
  120. data/spec/cli/ipam/ipam_spec.rb +26 -0
  121. data/spec/cli/ipam/whitelist_spec.rb +47 -0
  122. data/spec/cli/ips/address_spec.rb +57 -0
  123. data/spec/cli/ips/ip_spec.rb +33 -0
  124. data/spec/cli/ips/pool_spec.rb +57 -0
  125. data/spec/cli/ips/warmup_spec.rb +47 -0
  126. data/spec/cli/mail_spec.rb +37 -0
  127. data/spec/cli/settings/enforced_tls_spec.rb +30 -0
  128. data/spec/cli/settings/mail_spec.rb +255 -0
  129. data/spec/cli/settings/partner_spec.rb +47 -0
  130. data/spec/cli/settings/settings_spec.rb +40 -0
  131. data/spec/cli/settings/tracking_spec.rb +128 -0
  132. data/spec/cli/sg_spec.rb +82 -0
  133. data/spec/cli/stats/advanced_spec.rb +137 -0
  134. data/spec/cli/stats/category_spec.rb +57 -0
  135. data/spec/cli/stats/global_spec.rb +32 -0
  136. data/spec/cli/stats/parse_spec.rb +32 -0
  137. data/spec/cli/stats/stats_spec.rb +40 -0
  138. data/spec/cli/stats/subuser_spec.rb +104 -0
  139. data/spec/cli/subusers/monitor_spec.rb +52 -0
  140. data/spec/cli/subusers/subuser_spec.rb +88 -0
  141. data/spec/cli/suppressions/block_spec.rb +60 -0
  142. data/spec/cli/suppressions/bounce_spec.rb +58 -0
  143. data/spec/cli/suppressions/global_unsubscribe_spec.rb +59 -0
  144. data/spec/cli/suppressions/group_spec.rb +69 -0
  145. data/spec/cli/suppressions/group_unsubscribe_spec.rb +41 -0
  146. data/spec/cli/suppressions/invalid_email_spec.rb +60 -0
  147. data/spec/cli/suppressions/spam_report_spec.rb +60 -0
  148. data/spec/cli/suppressions/suppression_spec.rb +68 -0
  149. data/spec/cli/templates/template_spec.rb +65 -0
  150. data/spec/cli/templates/version_spec.rb +71 -0
  151. data/spec/cli/user_spec.rb +82 -0
  152. data/spec/cli/webhooks/event_spec.rb +67 -0
  153. data/spec/cli/webhooks/parse_spec.rb +20 -0
  154. data/spec/cli/webhooks/webhook_spec.rb +28 -0
  155. data/spec/cli/whitelabel/domain_spec.rb +112 -0
  156. data/spec/cli/whitelabel/ip_spec.rb +61 -0
  157. data/spec/cli/whitelabel/link_spec.rb +110 -0
  158. data/spec/cli/whitelabel/whitelabel_spec.rb +27 -0
  159. data/spec/client_spec.rb +1 -1
  160. data/spec/factory/campaign_factory_spec.rb +2 -2
  161. data/spec/factory/event_factory_spec.rb +36 -0
  162. data/spec/rest/api_keys_management/api_keys_spec.rb +24 -24
  163. data/spec/rest/api_keys_management/permissions_spec.rb +8 -10
  164. data/spec/rest/blocks_spec.rb +14 -18
  165. data/spec/rest/bounces_spec.rb +28 -32
  166. data/spec/rest/cancel_scheduled_sends_spec.rb +15 -19
  167. data/spec/rest/categories_spec.rb +8 -10
  168. data/spec/rest/email_activity_spec.rb +18 -22
  169. data/spec/rest/invalid_emails_spec.rb +19 -23
  170. data/spec/rest/ip_access_management_spec.rb +46 -52
  171. data/spec/rest/ips/addresses_spec.rb +21 -25
  172. data/spec/rest/ips/pools_spec.rb +20 -24
  173. data/spec/rest/ips/warmup_spec.rb +11 -15
  174. data/spec/rest/marketing_campaigns/contacts/custom_fields_spec.rb +26 -30
  175. data/spec/rest/marketing_campaigns/contacts/lists_spec.rb +58 -66
  176. data/spec/rest/marketing_campaigns/contacts/recipients_spec.rb +77 -87
  177. data/spec/rest/marketing_campaigns/contacts/reserved_fields_spec.rb +46 -50
  178. data/spec/rest/marketing_campaigns/contacts/segments_spec.rb +75 -78
  179. data/spec/rest/marketing_campaigns/marketing_campaigns_spec.rb +92 -94
  180. data/spec/rest/marketing_campaigns/senders_spec.rb +51 -51
  181. data/spec/rest/settings/enforced_tls_spec.rb +5 -7
  182. data/spec/rest/settings/mail_spec.rb +89 -60
  183. data/spec/rest/settings/partner_spec.rb +5 -7
  184. data/spec/rest/settings/settings_spec.rb +18 -22
  185. data/spec/rest/settings/tracking_spec.rb +26 -34
  186. data/spec/rest/sm/global_unsubscribes_spec.rb +9 -13
  187. data/spec/rest/sm/groups_spec.rb +24 -28
  188. data/spec/rest/sm/sm_spec.rb +15 -15
  189. data/spec/rest/sm/suppressions_spec.rb +34 -44
  190. data/spec/rest/spam_reports_spec.rb +19 -23
  191. data/spec/rest/stats/advanced_spec.rb +4 -4
  192. data/spec/rest/stats/global_spec.rb +0 -21
  193. data/spec/rest/subusers_spec.rb +38 -47
  194. data/spec/rest/transactional_templates/templates_spec.rb +29 -33
  195. data/spec/rest/transactional_templates/versions_spec.rb +11 -93
  196. data/spec/rest/users_spec.rb +42 -54
  197. data/spec/rest/webhooks/event_spec.rb +16 -18
  198. data/spec/rest/webhooks/parse_spec.rb +16 -20
  199. data/spec/rest/whitelabel/domains_spec.rb +93 -100
  200. data/spec/rest/whitelabel/ips_spec.rb +28 -32
  201. data/spec/rest/whitelabel/links_spec.rb +41 -45
  202. 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