sendgrid4r 1.11.0 → 1.12.0

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