sendgrid4r 1.11.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -1
- data/exe/sg +5 -0
- data/lib/sendgrid4r/cli/api_keys/api_key.rb +53 -0
- data/lib/sendgrid4r/cli/api_keys/permission.rb +15 -0
- data/lib/sendgrid4r/cli/campaign/campaign.rb +134 -0
- data/lib/sendgrid4r/cli/campaign/contact/contact.rb +25 -0
- data/lib/sendgrid4r/cli/campaign/contact/custom_field.rb +42 -0
- data/lib/sendgrid4r/cli/campaign/contact/list.rb +71 -0
- data/lib/sendgrid4r/cli/campaign/contact/recipient.rb +78 -0
- data/lib/sendgrid4r/cli/campaign/contact/reserved_field.rb +17 -0
- data/lib/sendgrid4r/cli/campaign/contact/segment.rb +96 -0
- data/lib/sendgrid4r/cli/campaign/sender.rb +83 -0
- data/lib/sendgrid4r/cli/cancel_schedules/batch_id.rb +23 -0
- data/lib/sendgrid4r/cli/cancel_schedules/cancel_schedule.rb +55 -0
- data/lib/sendgrid4r/cli/category.rb +16 -0
- data/lib/sendgrid4r/cli/ipam/activity.rb +16 -0
- data/lib/sendgrid4r/cli/ipam/ipam.rb +14 -0
- data/lib/sendgrid4r/cli/ipam/whitelist.rb +39 -0
- data/lib/sendgrid4r/cli/ips/address.rb +48 -0
- data/lib/sendgrid4r/cli/ips/ip.rb +17 -0
- data/lib/sendgrid4r/cli/ips/pool.rb +48 -0
- data/lib/sendgrid4r/cli/ips/warmup.rb +39 -0
- data/lib/sendgrid4r/cli/mail.rb +34 -0
- data/lib/sendgrid4r/cli/settings/enforced_tls.rb +24 -0
- data/lib/sendgrid4r/cli/settings/mail.rb +171 -0
- data/lib/sendgrid4r/cli/settings/partner.rb +34 -0
- data/lib/sendgrid4r/cli/settings/settings.rb +20 -0
- data/lib/sendgrid4r/cli/settings/tracking.rb +92 -0
- data/lib/sendgrid4r/cli/sg.rb +55 -0
- data/lib/sendgrid4r/cli/sg_thor.rb +34 -0
- data/lib/sendgrid4r/cli/stats/advanced.rb +72 -0
- data/lib/sendgrid4r/cli/stats/category.rb +35 -0
- data/lib/sendgrid4r/cli/stats/global.rb +18 -0
- data/lib/sendgrid4r/cli/stats/parse.rb +18 -0
- data/lib/sendgrid4r/cli/stats/stats.rb +23 -0
- data/lib/sendgrid4r/cli/stats/subuser.rb +67 -0
- data/lib/sendgrid4r/cli/subusers/monitor.rb +44 -0
- data/lib/sendgrid4r/cli/subusers/subuser.rb +77 -0
- data/lib/sendgrid4r/cli/suppressions/block.rb +43 -0
- data/lib/sendgrid4r/cli/suppressions/bounce.rb +41 -0
- data/lib/sendgrid4r/cli/suppressions/global_unsubscribe.rb +43 -0
- data/lib/sendgrid4r/cli/suppressions/group.rb +56 -0
- data/lib/sendgrid4r/cli/suppressions/group_unsubscribe.rb +34 -0
- data/lib/sendgrid4r/cli/suppressions/invalid_email.rb +43 -0
- data/lib/sendgrid4r/cli/suppressions/spam_report.rb +43 -0
- data/lib/sendgrid4r/cli/suppressions/suppression.rb +36 -0
- data/lib/sendgrid4r/cli/templates/template.rb +51 -0
- data/lib/sendgrid4r/cli/templates/version.rb +78 -0
- data/lib/sendgrid4r/cli/user.rb +86 -0
- data/lib/sendgrid4r/cli/webhooks/event.rb +53 -0
- data/lib/sendgrid4r/cli/webhooks/parse.rb +15 -0
- data/lib/sendgrid4r/cli/webhooks/webhook.rb +14 -0
- data/lib/sendgrid4r/cli/whitelabel/domain.rb +117 -0
- data/lib/sendgrid4r/cli/whitelabel/ip.rb +52 -0
- data/lib/sendgrid4r/cli/whitelabel/link.rb +96 -0
- data/lib/sendgrid4r/cli/whitelabel/whitelabel.rb +17 -0
- data/lib/sendgrid4r/client.rb +4 -1
- data/lib/sendgrid4r/factory/campaign_factory.rb +1 -1
- data/lib/sendgrid4r/factory/condition_factory.rb +2 -2
- data/lib/sendgrid4r/factory/event_factory.rb +21 -0
- data/lib/sendgrid4r/rest/api_keys_management/api_keys.rb +5 -5
- data/lib/sendgrid4r/rest/api_keys_management/permissions.rb +3 -1
- data/lib/sendgrid4r/rest/blocks.rb +2 -2
- data/lib/sendgrid4r/rest/bounces.rb +2 -2
- data/lib/sendgrid4r/rest/cancel_scheduled_sends.rb +12 -4
- data/lib/sendgrid4r/rest/categories.rb +1 -1
- data/lib/sendgrid4r/rest/email_activity.rb +1 -1
- data/lib/sendgrid4r/rest/invalid_emails.rb +2 -2
- data/lib/sendgrid4r/rest/ip_access_management.rb +12 -4
- data/lib/sendgrid4r/rest/ips/addresses.rb +4 -4
- data/lib/sendgrid4r/rest/ips/pools.rb +4 -4
- data/lib/sendgrid4r/rest/ips/warmup.rb +3 -3
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/custom_fields.rb +9 -3
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb +7 -5
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/recipients.rb +22 -7
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/reserved_fields.rb +3 -1
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/segments.rb +7 -5
- data/lib/sendgrid4r/rest/marketing_campaigns/marketing_campaigns.rb +8 -8
- data/lib/sendgrid4r/rest/marketing_campaigns/senders.rb +4 -4
- data/lib/sendgrid4r/rest/request.rb +6 -4
- data/lib/sendgrid4r/rest/settings/enforced_tls.rb +6 -2
- data/lib/sendgrid4r/rest/settings/mail.rb +71 -17
- data/lib/sendgrid4r/rest/settings/partner.rb +3 -3
- data/lib/sendgrid4r/rest/settings/tracking.rb +17 -9
- data/lib/sendgrid4r/rest/sm/global_unsubscribes.rb +5 -3
- data/lib/sendgrid4r/rest/sm/groups.rb +4 -4
- data/lib/sendgrid4r/rest/sm/suppressions.rb +6 -3
- data/lib/sendgrid4r/rest/spam_reports.rb +2 -2
- data/lib/sendgrid4r/rest/stats/advanced.rb +8 -8
- data/lib/sendgrid4r/rest/stats/category.rb +2 -2
- data/lib/sendgrid4r/rest/stats/global.rb +1 -1
- data/lib/sendgrid4r/rest/stats/parse.rb +1 -1
- data/lib/sendgrid4r/rest/stats/subuser.rb +4 -4
- data/lib/sendgrid4r/rest/subusers.rb +15 -10
- data/lib/sendgrid4r/rest/transactional_templates/templates.rb +12 -4
- data/lib/sendgrid4r/rest/transactional_templates/versions.rb +4 -4
- data/lib/sendgrid4r/rest/users.rb +9 -9
- data/lib/sendgrid4r/rest/webhooks/event.rb +2 -2
- data/lib/sendgrid4r/rest/webhooks/parse.rb +1 -1
- data/lib/sendgrid4r/rest/whitelabel/domains.rb +10 -11
- data/lib/sendgrid4r/rest/whitelabel/ips.rb +4 -4
- data/lib/sendgrid4r/rest/whitelabel/links.rb +8 -8
- data/lib/sendgrid4r/version.rb +1 -1
- data/lib/sendgrid4r.rb +57 -0
- data/sendgrid4r.gemspec +3 -1
- data/spec/cli/api_keys/api_key_spec.rb +77 -0
- data/spec/cli/api_keys/permission_spec.rb +29 -0
- data/spec/cli/campaign/campaign_spec.rb +136 -0
- data/spec/cli/campaign/contact/custom_field_spec.rb +48 -0
- data/spec/cli/campaign/contact/list_spec.rb +88 -0
- data/spec/cli/campaign/contact/recipient_spec.rb +93 -0
- data/spec/cli/campaign/contact/reserved_field_spec.rb +20 -0
- data/spec/cli/campaign/contact/segment_spec.rb +93 -0
- data/spec/cli/campaign/sender_spec.rb +83 -0
- data/spec/cli/cancel_schedules/batch_id_spec.rb +33 -0
- data/spec/cli/cancel_schedules/cancel_schedule_spec.rb +69 -0
- data/spec/cli/category_spec.rb +23 -0
- data/spec/cli/ipam/activity_spec.rb +21 -0
- data/spec/cli/ipam/ipam_spec.rb +26 -0
- data/spec/cli/ipam/whitelist_spec.rb +47 -0
- data/spec/cli/ips/address_spec.rb +57 -0
- data/spec/cli/ips/ip_spec.rb +33 -0
- data/spec/cli/ips/pool_spec.rb +57 -0
- data/spec/cli/ips/warmup_spec.rb +47 -0
- data/spec/cli/mail_spec.rb +37 -0
- data/spec/cli/settings/enforced_tls_spec.rb +30 -0
- data/spec/cli/settings/mail_spec.rb +255 -0
- data/spec/cli/settings/partner_spec.rb +47 -0
- data/spec/cli/settings/settings_spec.rb +40 -0
- data/spec/cli/settings/tracking_spec.rb +128 -0
- data/spec/cli/sg_spec.rb +82 -0
- data/spec/cli/stats/advanced_spec.rb +137 -0
- data/spec/cli/stats/category_spec.rb +57 -0
- data/spec/cli/stats/global_spec.rb +32 -0
- data/spec/cli/stats/parse_spec.rb +32 -0
- data/spec/cli/stats/stats_spec.rb +40 -0
- data/spec/cli/stats/subuser_spec.rb +104 -0
- data/spec/cli/subusers/monitor_spec.rb +52 -0
- data/spec/cli/subusers/subuser_spec.rb +88 -0
- data/spec/cli/suppressions/block_spec.rb +60 -0
- data/spec/cli/suppressions/bounce_spec.rb +58 -0
- data/spec/cli/suppressions/global_unsubscribe_spec.rb +59 -0
- data/spec/cli/suppressions/group_spec.rb +69 -0
- data/spec/cli/suppressions/group_unsubscribe_spec.rb +41 -0
- data/spec/cli/suppressions/invalid_email_spec.rb +60 -0
- data/spec/cli/suppressions/spam_report_spec.rb +60 -0
- data/spec/cli/suppressions/suppression_spec.rb +68 -0
- data/spec/cli/templates/template_spec.rb +65 -0
- data/spec/cli/templates/version_spec.rb +71 -0
- data/spec/cli/user_spec.rb +82 -0
- data/spec/cli/webhooks/event_spec.rb +67 -0
- data/spec/cli/webhooks/parse_spec.rb +20 -0
- data/spec/cli/webhooks/webhook_spec.rb +28 -0
- data/spec/cli/whitelabel/domain_spec.rb +112 -0
- data/spec/cli/whitelabel/ip_spec.rb +61 -0
- data/spec/cli/whitelabel/link_spec.rb +110 -0
- data/spec/cli/whitelabel/whitelabel_spec.rb +27 -0
- data/spec/client_spec.rb +1 -1
- data/spec/factory/campaign_factory_spec.rb +2 -2
- data/spec/factory/event_factory_spec.rb +36 -0
- data/spec/rest/api_keys_management/api_keys_spec.rb +24 -24
- data/spec/rest/api_keys_management/permissions_spec.rb +8 -10
- data/spec/rest/blocks_spec.rb +14 -18
- data/spec/rest/bounces_spec.rb +28 -32
- data/spec/rest/cancel_scheduled_sends_spec.rb +15 -19
- data/spec/rest/categories_spec.rb +8 -10
- data/spec/rest/email_activity_spec.rb +18 -22
- data/spec/rest/invalid_emails_spec.rb +19 -23
- data/spec/rest/ip_access_management_spec.rb +46 -52
- data/spec/rest/ips/addresses_spec.rb +21 -25
- data/spec/rest/ips/pools_spec.rb +20 -24
- data/spec/rest/ips/warmup_spec.rb +11 -15
- data/spec/rest/marketing_campaigns/contacts/custom_fields_spec.rb +26 -30
- data/spec/rest/marketing_campaigns/contacts/lists_spec.rb +58 -66
- data/spec/rest/marketing_campaigns/contacts/recipients_spec.rb +77 -87
- data/spec/rest/marketing_campaigns/contacts/reserved_fields_spec.rb +46 -50
- data/spec/rest/marketing_campaigns/contacts/segments_spec.rb +75 -78
- data/spec/rest/marketing_campaigns/marketing_campaigns_spec.rb +92 -94
- data/spec/rest/marketing_campaigns/senders_spec.rb +51 -51
- data/spec/rest/settings/enforced_tls_spec.rb +5 -7
- data/spec/rest/settings/mail_spec.rb +89 -60
- data/spec/rest/settings/partner_spec.rb +5 -7
- data/spec/rest/settings/settings_spec.rb +18 -22
- data/spec/rest/settings/tracking_spec.rb +26 -34
- data/spec/rest/sm/global_unsubscribes_spec.rb +9 -13
- data/spec/rest/sm/groups_spec.rb +24 -28
- data/spec/rest/sm/sm_spec.rb +15 -15
- data/spec/rest/sm/suppressions_spec.rb +34 -44
- data/spec/rest/spam_reports_spec.rb +19 -23
- data/spec/rest/stats/advanced_spec.rb +4 -4
- data/spec/rest/stats/global_spec.rb +0 -21
- data/spec/rest/subusers_spec.rb +38 -47
- data/spec/rest/transactional_templates/templates_spec.rb +29 -33
- data/spec/rest/transactional_templates/versions_spec.rb +11 -93
- data/spec/rest/users_spec.rb +42 -54
- data/spec/rest/webhooks/event_spec.rb +16 -18
- data/spec/rest/webhooks/parse_spec.rb +16 -20
- data/spec/rest/whitelabel/domains_spec.rb +93 -100
- data/spec/rest/whitelabel/ips_spec.rb +28 -32
- data/spec/rest/whitelabel/links_spec.rb +41 -45
- metadata +181 -4
@@ -0,0 +1,41 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Suppressions
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Suppressions Bounce
|
5
|
+
#
|
6
|
+
class Bounce < SgThor
|
7
|
+
desc 'list', 'List bounces'
|
8
|
+
option :start_time, type: :numeric
|
9
|
+
option :end_time, type: :numeric
|
10
|
+
def list
|
11
|
+
puts @client.get_bounces(parameterise(options))
|
12
|
+
rescue RestClient::ExceptionWithResponse => e
|
13
|
+
puts e.inspect
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'delete', 'Delete bounces'
|
17
|
+
option :delete_all, type: :boolean
|
18
|
+
option :email
|
19
|
+
option :emails, type: :array
|
20
|
+
def delete
|
21
|
+
if options[:email]
|
22
|
+
puts @client.delete_bounce(email: options[:email])
|
23
|
+
else
|
24
|
+
puts @client.delete_bounces(
|
25
|
+
delete_all: options[:delete_all], emails: options[:emails]
|
26
|
+
)
|
27
|
+
end
|
28
|
+
rescue RestClient::ExceptionWithResponse => e
|
29
|
+
puts e.inspect
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'get', 'Get a bounce'
|
33
|
+
option :email, require: true
|
34
|
+
def get
|
35
|
+
puts @client.get_bounce(parameterise(options))
|
36
|
+
rescue RestClient::ExceptionWithResponse => e
|
37
|
+
puts e.inspect
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Suppressions
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Suppressions GlobalUnsubscribe
|
5
|
+
#
|
6
|
+
class GlobalUnsubscribe < SgThor
|
7
|
+
desc 'list', 'List global unsubscribes'
|
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_global_unsubscribes(parameterise(options))
|
14
|
+
rescue RestClient::ExceptionWithResponse => e
|
15
|
+
puts e.inspect
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'add', 'Add email addresses to the Global Unsubscribes'
|
19
|
+
option :recipient_emails, type: :array, require: true
|
20
|
+
def add
|
21
|
+
puts @client.post_global_unsubscribes(parameterise(options))
|
22
|
+
rescue RestClient::ExceptionWithResponse => e
|
23
|
+
puts e.inspect
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'delete', 'Delete global unsubscribes'
|
27
|
+
option :email_address, require: true
|
28
|
+
def delete
|
29
|
+
puts @client.delete_global_unsubscribe(parameterise(options))
|
30
|
+
rescue RestClient::ExceptionWithResponse => e
|
31
|
+
puts e.inspect
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'get', 'Get a global unsubscribe'
|
35
|
+
option :email_address, require: true
|
36
|
+
def get
|
37
|
+
puts @client.get_global_unsubscribe(parameterise(options))
|
38
|
+
rescue RestClient::ExceptionWithResponse => e
|
39
|
+
puts e.inspect
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Suppressions
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Suppressions Group
|
5
|
+
#
|
6
|
+
class Group < SgThor
|
7
|
+
desc 'create', 'Create a new supression group'
|
8
|
+
option :name, require: true
|
9
|
+
option :description, require: true
|
10
|
+
option :is_default, type: :boolean
|
11
|
+
def create
|
12
|
+
puts @client.post_group(parameterise(options))
|
13
|
+
rescue RestClient::ExceptionWithResponse => e
|
14
|
+
puts e.inspect
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'list', 'List supression groups'
|
18
|
+
def list
|
19
|
+
puts @client.get_groups
|
20
|
+
rescue RestClient::ExceptionWithResponse => e
|
21
|
+
puts e.inspect
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'get', 'Get a supression group'
|
25
|
+
option :group_id, require: true
|
26
|
+
def get
|
27
|
+
puts @client.get_group(parameterise(options))
|
28
|
+
rescue RestClient::ExceptionWithResponse => e
|
29
|
+
puts e.inspect
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'update', 'Update a supression group'
|
33
|
+
option :group_id, require: true
|
34
|
+
option :name
|
35
|
+
option :description
|
36
|
+
def update
|
37
|
+
group = parameterise(options)
|
38
|
+
group.delete(:group_id)
|
39
|
+
puts @client.patch_group(
|
40
|
+
group_id: options[:group_id],
|
41
|
+
group: group
|
42
|
+
)
|
43
|
+
rescue RestClient::ExceptionWithResponse => e
|
44
|
+
puts e.inspect
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'delete', 'Delete a supression group'
|
48
|
+
option :group_id, require: true
|
49
|
+
def delete
|
50
|
+
puts @client.delete_group(parameterise(options))
|
51
|
+
rescue RestClient::ExceptionWithResponse => e
|
52
|
+
puts e.inspect
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Suppressions
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Suppressions GroupUnsubscribe
|
5
|
+
#
|
6
|
+
class GroupUnsubscribe < SgThor
|
7
|
+
desc 'add', 'Add email addresses to the group supressions'
|
8
|
+
option :group_id, require: true
|
9
|
+
option :recipient_emails, type: :array, require: true
|
10
|
+
def add
|
11
|
+
puts @client.post_suppressed_emails(parameterise(options))
|
12
|
+
rescue RestClient::ExceptionWithResponse => e
|
13
|
+
puts e.inspect
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'list', 'List suppressed addresses for a given group'
|
17
|
+
option :group_id, require: true
|
18
|
+
def list
|
19
|
+
puts @client.get_suppressed_emails(parameterise(options))
|
20
|
+
rescue RestClient::ExceptionWithResponse => e
|
21
|
+
puts e.inspect
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'remove', 'Remove an email address from the given group'
|
25
|
+
option :group_id, require: true
|
26
|
+
option :email_address, require: true
|
27
|
+
def remove
|
28
|
+
@client.delete_suppressed_email(parameterise(options))
|
29
|
+
rescue RestClient::ExceptionWithResponse => e
|
30
|
+
puts e.inspect
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Suppressions
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Suppressions InvalidEmail
|
5
|
+
#
|
6
|
+
class InvalidEmail < 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_invalid_emails(parameterise(options))
|
14
|
+
rescue RestClient::ExceptionWithResponse => e
|
15
|
+
puts e.inspect
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'delete', 'Delete invalid emails'
|
19
|
+
option :delete_all, type: :boolean
|
20
|
+
option :email
|
21
|
+
option :emails, type: :array
|
22
|
+
def delete
|
23
|
+
if options[:email]
|
24
|
+
@client.delete_invalid_email(email: options[:email])
|
25
|
+
else
|
26
|
+
@client.delete_invalid_emails(
|
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 invalid email'
|
35
|
+
option :email, require: true
|
36
|
+
def get
|
37
|
+
puts @client.get_invalid_email(parameterise(options))
|
38
|
+
rescue RestClient::ExceptionWithResponse => e
|
39
|
+
puts e.inspect
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Suppressions
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Suppressions SpamReport
|
5
|
+
#
|
6
|
+
class SpamReport < SgThor
|
7
|
+
desc 'list', 'List spam reports'
|
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_spam_reports(parameterise(options))
|
14
|
+
rescue RestClient::ExceptionWithResponse => e
|
15
|
+
puts e.inspect
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'delete', 'Delete spam reports'
|
19
|
+
option :delete_all, type: :boolean
|
20
|
+
option :email
|
21
|
+
option :emails, type: :array
|
22
|
+
def delete
|
23
|
+
if options[:email]
|
24
|
+
@client.delete_spam_report(email: options[:email])
|
25
|
+
else
|
26
|
+
@client.delete_spam_reports(
|
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 spam report'
|
35
|
+
option :email, require: true
|
36
|
+
def get
|
37
|
+
puts @client.get_spam_report(parameterise(options))
|
38
|
+
rescue RestClient::ExceptionWithResponse => e
|
39
|
+
puts e.inspect
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Suppressions
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Suppressions Suppression
|
5
|
+
#
|
6
|
+
class Suppression < SgThor
|
7
|
+
desc('block SUBCOMMAND ...ARGS', 'Manage blocks list')
|
8
|
+
subcommand('block', Block)
|
9
|
+
|
10
|
+
desc('bounce SUBCOMMAND ...ARGS', 'Manage bounces list')
|
11
|
+
subcommand('bounce', Bounce)
|
12
|
+
|
13
|
+
desc('invalid_email SUBCOMMAND ...ARGS', 'Manage invalid emails list')
|
14
|
+
subcommand('invalid_email', InvalidEmail)
|
15
|
+
|
16
|
+
desc('spam_report SUBCOMMAND ...ARGS', 'Manage spam reports list')
|
17
|
+
subcommand('spam_report', SpamReport)
|
18
|
+
|
19
|
+
desc(
|
20
|
+
'global_unsubscribe SUBCOMMAND ...ARGS',
|
21
|
+
'Manage global unsubscribe list'
|
22
|
+
)
|
23
|
+
subcommand('global_unsubscribe', GlobalUnsubscribe)
|
24
|
+
|
25
|
+
desc(
|
26
|
+
'group SUBCOMMAND ...ARGS', 'Manage suppression groups'
|
27
|
+
)
|
28
|
+
subcommand('group', Group)
|
29
|
+
|
30
|
+
desc(
|
31
|
+
'group_unsubscribe SUBCOMMAND ...ARGS', 'Manage group unsubscribes'
|
32
|
+
)
|
33
|
+
subcommand('group_unsubscribe', GroupUnsubscribe)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Templates
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Templates
|
5
|
+
#
|
6
|
+
class Template < SgThor
|
7
|
+
desc 'create', 'Create a template'
|
8
|
+
option :name, require: true
|
9
|
+
def create
|
10
|
+
puts @client.post_template(parameterise(options))
|
11
|
+
rescue RestClient::ExceptionWithResponse => e
|
12
|
+
puts e.inspect
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'list', 'Retrieve all templates'
|
16
|
+
def list
|
17
|
+
puts @client.get_templates
|
18
|
+
rescue RestClient::ExceptionWithResponse => e
|
19
|
+
puts e.inspect
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'get', 'Get a template'
|
23
|
+
option :template_id, require: true
|
24
|
+
def get
|
25
|
+
puts @client.get_template(parameterise(options))
|
26
|
+
rescue RestClient::ExceptionWithResponse => e
|
27
|
+
puts e.inspect
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'update', 'Edit a template'
|
31
|
+
option :template_id, require: true
|
32
|
+
option :name, require: true
|
33
|
+
def update
|
34
|
+
puts @client.patch_template(parameterise(options))
|
35
|
+
rescue RestClient::ExceptionWithResponse => e
|
36
|
+
puts e.inspect
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'delete', 'Delete a template'
|
40
|
+
option :template_id, require: true
|
41
|
+
def delete
|
42
|
+
puts @client.delete_template(parameterise(options))
|
43
|
+
rescue RestClient::ExceptionWithResponse => e
|
44
|
+
puts e.inspect
|
45
|
+
end
|
46
|
+
|
47
|
+
desc('version SUBCOMMAND ...ARGS', 'Manage template versions')
|
48
|
+
subcommand('version', Version)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Templates
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Templates Version
|
5
|
+
#
|
6
|
+
class Version < SgThor
|
7
|
+
desc 'create', 'Create a version'
|
8
|
+
option :template_id, require: true
|
9
|
+
option :name, require: true
|
10
|
+
option :subject, require: true
|
11
|
+
option :html_content, require: true
|
12
|
+
option :plain_content, require: true
|
13
|
+
option :active, type: :numeric
|
14
|
+
def create
|
15
|
+
factory = SendGrid4r::Factory::VersionFactory.new
|
16
|
+
params = parameterise(options)
|
17
|
+
params.delete(:template_id)
|
18
|
+
version = factory.create(params)
|
19
|
+
puts @client.post_version(
|
20
|
+
template_id: options[:template_id],
|
21
|
+
version: version
|
22
|
+
)
|
23
|
+
rescue RestClient::ExceptionWithResponse => e
|
24
|
+
puts e.inspect
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'activate', 'Activate a version'
|
28
|
+
option :template_id, require: true
|
29
|
+
option :version_id, require: true
|
30
|
+
def activate
|
31
|
+
puts @client.activate_version(parameterise(options))
|
32
|
+
rescue RestClient::ExceptionWithResponse => e
|
33
|
+
puts e.inspect
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'get', 'Get a version'
|
37
|
+
option :template_id, require: true
|
38
|
+
option :version_id, require: true
|
39
|
+
def get
|
40
|
+
puts @client.get_version(parameterise(options))
|
41
|
+
rescue RestClient::ExceptionWithResponse => e
|
42
|
+
puts e.inspect
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'update', 'Edit a version'
|
46
|
+
option :template_id, require: true
|
47
|
+
option :version_id, require: true
|
48
|
+
option :name
|
49
|
+
option :subject
|
50
|
+
option :html_content
|
51
|
+
option :plain_content
|
52
|
+
option :active
|
53
|
+
def update
|
54
|
+
factory = SendGrid4r::Factory::VersionFactory.new
|
55
|
+
params = parameterise(options)
|
56
|
+
params.delete(:template_id)
|
57
|
+
params.delete(:version_id)
|
58
|
+
version = factory.create(params)
|
59
|
+
puts @client.patch_version(
|
60
|
+
template_id: options[:template_id],
|
61
|
+
version_id: options[:version_id],
|
62
|
+
version: version
|
63
|
+
)
|
64
|
+
rescue RestClient::ExceptionWithResponse => e
|
65
|
+
puts e.inspect
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'delete', 'Delete a version'
|
69
|
+
option :template_id, require: true
|
70
|
+
option :version_id, require: true
|
71
|
+
def delete
|
72
|
+
puts @client.delete_version(parameterise(options))
|
73
|
+
rescue RestClient::ExceptionWithResponse => e
|
74
|
+
puts e.inspect
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
#
|
3
|
+
# SendGrid Web API v3 User
|
4
|
+
#
|
5
|
+
class User < SgThor
|
6
|
+
desc 'profile', 'Get or Update user Profile'
|
7
|
+
option :address
|
8
|
+
option :city
|
9
|
+
option :company
|
10
|
+
option :country
|
11
|
+
option :first_name
|
12
|
+
option :last_name
|
13
|
+
option :phone
|
14
|
+
option :state
|
15
|
+
option :website
|
16
|
+
option :zip
|
17
|
+
def profile(action)
|
18
|
+
case action
|
19
|
+
when 'get'
|
20
|
+
puts @client.get_user_profile
|
21
|
+
when 'update'
|
22
|
+
puts @client.patch_user_profile(params: parameterise(options))
|
23
|
+
else
|
24
|
+
puts "error: #{action} is not supported in action parameter"
|
25
|
+
end
|
26
|
+
rescue RestClient::ExceptionWithResponse => e
|
27
|
+
puts e.inspect
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'account', 'Get user account'
|
31
|
+
def account(action)
|
32
|
+
case action
|
33
|
+
when 'get'
|
34
|
+
puts @client.get_user_account
|
35
|
+
else
|
36
|
+
puts "error: #{action} is not supported in action parameter"
|
37
|
+
end
|
38
|
+
rescue RestClient::ExceptionWithResponse => e
|
39
|
+
puts e.inspect
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'email', 'Get or update user email'
|
43
|
+
option :email
|
44
|
+
def email(action)
|
45
|
+
case action
|
46
|
+
when 'get'
|
47
|
+
puts @client.get_user_email
|
48
|
+
when 'update'
|
49
|
+
puts @client.put_user_email(parameterise(options))
|
50
|
+
else
|
51
|
+
puts "error: #{action} is not supported in action parameter"
|
52
|
+
end
|
53
|
+
rescue RestClient::ExceptionWithResponse => e
|
54
|
+
puts e.inspect
|
55
|
+
end
|
56
|
+
|
57
|
+
desc 'username', 'Get or update username'
|
58
|
+
option :username
|
59
|
+
def username(action)
|
60
|
+
case action
|
61
|
+
when 'get'
|
62
|
+
puts @client.get_user_username
|
63
|
+
when 'update'
|
64
|
+
puts @client.put_user_username(parameterise(options))
|
65
|
+
else
|
66
|
+
puts "error: #{action} is not supported in action parameter"
|
67
|
+
end
|
68
|
+
rescue RestClient::ExceptionWithResponse => e
|
69
|
+
puts e.inspect
|
70
|
+
end
|
71
|
+
|
72
|
+
desc('password', 'Update password')
|
73
|
+
option :new_password, require: true
|
74
|
+
option :old_password, require: true
|
75
|
+
def password(action)
|
76
|
+
case action
|
77
|
+
when 'update'
|
78
|
+
puts @client.put_user_password(parameterise(options))
|
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
|
+
end
|
86
|
+
end
|