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.
- 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,17 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Campaign
|
|
3
|
+
module Contact
|
|
4
|
+
#
|
|
5
|
+
# SendGrid Web API v3 Marketing Campaigns - Reserved Field
|
|
6
|
+
#
|
|
7
|
+
class ReservedField < SgThor
|
|
8
|
+
desc 'list', 'List reserved fields'
|
|
9
|
+
def list
|
|
10
|
+
puts @client.get_reserved_fields
|
|
11
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
12
|
+
puts e.inspect
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Campaign
|
|
3
|
+
module Contact
|
|
4
|
+
#
|
|
5
|
+
# SendGrid Web API v3 Marketing Campaigns - Segment
|
|
6
|
+
#
|
|
7
|
+
class Segment < SgThor
|
|
8
|
+
def initialize(*args)
|
|
9
|
+
super
|
|
10
|
+
@condition_factory = SendGrid4r::Factory::ConditionFactory.new
|
|
11
|
+
@segment_factory = SendGrid4r::Factory::SegmentFactory.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
desc 'create', 'Create a segment'
|
|
15
|
+
option :name, require: true
|
|
16
|
+
option :list_id, type: :numeric, require: true
|
|
17
|
+
option :conditions, type: :array, require: true
|
|
18
|
+
def create
|
|
19
|
+
conditions = options[:conditions].map do |c|
|
|
20
|
+
array = c.delete(' ').split(/[:,]/)
|
|
21
|
+
hash = array.each_slice(2).map do |k, v|
|
|
22
|
+
[k.to_sym, v.nil? ? '' : v]
|
|
23
|
+
end.to_h
|
|
24
|
+
@condition_factory.create(hash)
|
|
25
|
+
end
|
|
26
|
+
params = @segment_factory.create(
|
|
27
|
+
name: options[:name],
|
|
28
|
+
list_id: options[:list_id],
|
|
29
|
+
conditions: conditions
|
|
30
|
+
)
|
|
31
|
+
puts @client.post_segment(params: params)
|
|
32
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
33
|
+
puts e.inspect
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
desc 'list', 'List segments'
|
|
37
|
+
def list
|
|
38
|
+
puts @client.get_segments
|
|
39
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
40
|
+
puts e.inspect
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
desc 'get', 'Get a segment'
|
|
44
|
+
option :segment_id, require: true
|
|
45
|
+
def get
|
|
46
|
+
puts @client.get_segment(parameterise(options))
|
|
47
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
48
|
+
puts e.inspect
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
desc 'update', 'Update a segment'
|
|
52
|
+
option :segment_id, require: true
|
|
53
|
+
option :name
|
|
54
|
+
option :conditions, type: :array
|
|
55
|
+
def update
|
|
56
|
+
conditions = options[:conditions].map do |c|
|
|
57
|
+
array = c.delete(' ').split(/[:,]/)
|
|
58
|
+
hash = array.each_slice(2).map do |k, v|
|
|
59
|
+
[k.to_sym, v.nil? ? '' : v]
|
|
60
|
+
end.to_h
|
|
61
|
+
@condition_factory.create(hash)
|
|
62
|
+
end
|
|
63
|
+
params = @segment_factory.create(
|
|
64
|
+
name: options[:name],
|
|
65
|
+
conditions: conditions
|
|
66
|
+
)
|
|
67
|
+
puts @client.patch_segment(
|
|
68
|
+
segment_id: options[:segment_id],
|
|
69
|
+
params: params
|
|
70
|
+
)
|
|
71
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
72
|
+
puts e.inspect
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
desc 'delete', 'Delete a segment'
|
|
76
|
+
option :segment_id, require: true
|
|
77
|
+
def delete
|
|
78
|
+
puts @client.delete_segment(parameterise(options))
|
|
79
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
80
|
+
puts e.inspect
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
desc 'recipient', 'List recipients'
|
|
84
|
+
option :segment_id, require: true
|
|
85
|
+
def recipient(action)
|
|
86
|
+
case action
|
|
87
|
+
when 'list'
|
|
88
|
+
puts @client.get_recipients_on_segment(parameterise(options))
|
|
89
|
+
else
|
|
90
|
+
puts "error: #{action} is not supported in action parameter"
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Campaign
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Marketing Campaigns - Sender
|
|
5
|
+
#
|
|
6
|
+
class Sender < SgThor
|
|
7
|
+
def initialize(*args)
|
|
8
|
+
super
|
|
9
|
+
@factory = SendGrid4r::Factory::CampaignFactory.new
|
|
10
|
+
end
|
|
11
|
+
desc 'create', 'Create a sender'
|
|
12
|
+
option :nickname
|
|
13
|
+
option :from, type: :hash
|
|
14
|
+
option :reply_to, type: :hash
|
|
15
|
+
option :address
|
|
16
|
+
option :address_2
|
|
17
|
+
option :city
|
|
18
|
+
option :state
|
|
19
|
+
option :zip
|
|
20
|
+
option :country
|
|
21
|
+
def create
|
|
22
|
+
sender = @factory.create_sender(parameterise(options))
|
|
23
|
+
puts @client.post_sender(params: sender)
|
|
24
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
25
|
+
puts e.inspect
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
desc 'list', 'List senders'
|
|
29
|
+
def list
|
|
30
|
+
puts @client.get_senders
|
|
31
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
32
|
+
puts e.inspect
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
desc 'update', 'Update a sender'
|
|
36
|
+
option :sender_id, type: :numeric, require: true
|
|
37
|
+
option :nickname
|
|
38
|
+
option :from, type: :hash
|
|
39
|
+
option :reply_to, type: :hash
|
|
40
|
+
option :address
|
|
41
|
+
option :address_2
|
|
42
|
+
option :city
|
|
43
|
+
option :state
|
|
44
|
+
option :zip
|
|
45
|
+
option :country
|
|
46
|
+
def update
|
|
47
|
+
params = parameterise(options)
|
|
48
|
+
params.delete(:sender_id)
|
|
49
|
+
sender = @factory.create_sender(params)
|
|
50
|
+
puts @client.patch_sender(
|
|
51
|
+
sender_id: options[:sender_id],
|
|
52
|
+
params: sender
|
|
53
|
+
)
|
|
54
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
55
|
+
puts e.inspect
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
desc 'delete', 'Delete a sender'
|
|
59
|
+
option :sender_id, type: :numeric, require: true
|
|
60
|
+
def delete
|
|
61
|
+
puts @client.delete_sender(parameterise(options))
|
|
62
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
63
|
+
puts e.inspect
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
desc 'verify', 'Resend sender identity verification'
|
|
67
|
+
option :sender_id, type: :numeric, require: true
|
|
68
|
+
def verify
|
|
69
|
+
puts @client.resend_sender_verification(parameterise(options))
|
|
70
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
71
|
+
puts e.inspect
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
desc 'get', 'Get a sender'
|
|
75
|
+
option :sender_id, type: :numeric, require: true
|
|
76
|
+
def get
|
|
77
|
+
puts @client.get_sender(parameterise(options))
|
|
78
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
79
|
+
puts e.inspect
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module CancelSchedules
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 CancelSchedules BatchId
|
|
5
|
+
#
|
|
6
|
+
class BatchId < SgThor
|
|
7
|
+
desc 'generate', 'Generate Batch ID'
|
|
8
|
+
def generate_batch_id
|
|
9
|
+
puts @client.generate_batch_id
|
|
10
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
11
|
+
puts e.inspect
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
desc 'validate', 'Validate Batch ID'
|
|
15
|
+
option :batch_id, require: true
|
|
16
|
+
def validate_batch_id
|
|
17
|
+
puts @client.validate_batch_id(parameterise(options))
|
|
18
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
19
|
+
puts e.inspect
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module CancelSchedules
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 CancelSchedules CancelSchedule
|
|
5
|
+
#
|
|
6
|
+
class CancelSchedule < SgThor
|
|
7
|
+
desc 'add', 'Cancel shceduled sends'
|
|
8
|
+
option :batch_id, require: true
|
|
9
|
+
option :status, require: true
|
|
10
|
+
def add
|
|
11
|
+
puts @client.post_scheduled_send(parameterise(options))
|
|
12
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
13
|
+
puts e.inspect
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc 'list', 'Get all cancel/paused scheduled send information'
|
|
17
|
+
def list
|
|
18
|
+
puts @client.get_scheduled_sends
|
|
19
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
20
|
+
puts e.inspect
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc 'get', 'Get a single cancel/paused scheduled send information'
|
|
24
|
+
option :batch_id, require: true
|
|
25
|
+
def get
|
|
26
|
+
puts @client.get_scheduled_sends(parameterise(options))
|
|
27
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
28
|
+
puts e.inspect
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
desc 'update', 'Update the status of a scheduled send'
|
|
32
|
+
option :batch_id, require: true
|
|
33
|
+
option :status, require: true
|
|
34
|
+
def update
|
|
35
|
+
puts @client.patch_scheduled_send(parameterise(options))
|
|
36
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
37
|
+
puts e.inspect
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
desc 'delete', 'Delete the cancel/pause of a scheduled send'
|
|
41
|
+
option :batch_id, require: true
|
|
42
|
+
def delete
|
|
43
|
+
puts @client.delete_scheduled_send(parameterise(options))
|
|
44
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
45
|
+
puts e.inspect
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
desc(
|
|
49
|
+
'batch_id SUBCOMMAND ...ARGS',
|
|
50
|
+
'Manage batch ID for canceling schedule sends'
|
|
51
|
+
)
|
|
52
|
+
subcommand('batch_id', BatchId)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
#
|
|
3
|
+
# SendGrid Web API v3 Category
|
|
4
|
+
#
|
|
5
|
+
class Category < SgThor
|
|
6
|
+
desc 'list', 'List categories'
|
|
7
|
+
option :category
|
|
8
|
+
option :limit, type: :numeric
|
|
9
|
+
option :offset, type: :numeric
|
|
10
|
+
def list
|
|
11
|
+
puts @client.get_categories(parameterise(options))
|
|
12
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
13
|
+
puts e.inspect
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Ipam
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Ipam Activity
|
|
5
|
+
#
|
|
6
|
+
class Activity < SgThor
|
|
7
|
+
desc 'list', 'History Collection'
|
|
8
|
+
option :limit, type: :numeric
|
|
9
|
+
def list
|
|
10
|
+
puts @client.get_ip_activities(parameterise(options))
|
|
11
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
12
|
+
puts e.inspect
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Ipam
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Ipam Whitelist
|
|
5
|
+
#
|
|
6
|
+
class Ipam < SgThor
|
|
7
|
+
desc('activity SUBCOMMAND ...ARGS', 'Manage IP access activity')
|
|
8
|
+
subcommand('activity', Activity)
|
|
9
|
+
|
|
10
|
+
desc('whitelist SUBCOMMAND ...ARGS', 'Manage IP access whitelist')
|
|
11
|
+
subcommand('whitelist', Whitelist)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Ipam
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Ipam Whitelist
|
|
5
|
+
#
|
|
6
|
+
class Whitelist < SgThor
|
|
7
|
+
desc 'list', 'List Whitelisted IPs'
|
|
8
|
+
def list
|
|
9
|
+
puts @client.get_whitelisted_ips
|
|
10
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
11
|
+
puts e.inspect
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
desc 'add', 'Add Whitelisted IPs'
|
|
15
|
+
option :ips, type: :array, require: true
|
|
16
|
+
def add
|
|
17
|
+
puts @client.post_whitelisted_ips(parameterise(options))
|
|
18
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
19
|
+
puts e.inspect
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
desc 'delete', 'Delete Whitelisted IPs'
|
|
23
|
+
option :ids, type: :array
|
|
24
|
+
def delete
|
|
25
|
+
puts @client.delete_whitelisted_ips(parameterise(options))
|
|
26
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
27
|
+
puts e.inspect
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
desc 'get', 'Get a Whitelisted IP'
|
|
31
|
+
option :rule_id, type: :numeric, require: true
|
|
32
|
+
def get
|
|
33
|
+
puts @client.get_whitelisted_ip(parameterise(options))
|
|
34
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
35
|
+
puts e.inspect
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Ips
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Ips Address
|
|
5
|
+
#
|
|
6
|
+
class Address < SgThor
|
|
7
|
+
desc 'add_to_pool', 'Add an IP address to a pool'
|
|
8
|
+
option :pool_name, require: true
|
|
9
|
+
option :ip, require: true
|
|
10
|
+
def add_to_pool
|
|
11
|
+
puts @client.post_ip_to_pool(parameterise(options))
|
|
12
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
13
|
+
puts e.inspect
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc 'list', 'List all IP addresses'
|
|
17
|
+
def list
|
|
18
|
+
puts @client.get_ips
|
|
19
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
20
|
+
puts e.inspect
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc 'assigned', 'List only assigned IP addresses'
|
|
24
|
+
def assigned
|
|
25
|
+
puts @client.get_ips_assigned
|
|
26
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
27
|
+
puts e.inspect
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
desc 'get', 'Get an IP address'
|
|
31
|
+
option :ip, require: true
|
|
32
|
+
def get
|
|
33
|
+
puts @client.get_ip(parameterise(options))
|
|
34
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
35
|
+
puts e.inspect
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
desc 'delete_from_pool', 'Remove an IP address from a pool'
|
|
39
|
+
option :pool_name, require: true
|
|
40
|
+
option :ip, require: true
|
|
41
|
+
def delete_from_pool
|
|
42
|
+
puts @client.delete_ip_from_pool(parameterise(options))
|
|
43
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
44
|
+
puts e.inspect
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Ips
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Ips Ip
|
|
5
|
+
#
|
|
6
|
+
class Ip < SgThor
|
|
7
|
+
desc('address SUBCOMMAND ...ARGS', 'Manage IP addresses')
|
|
8
|
+
subcommand('address', Address)
|
|
9
|
+
|
|
10
|
+
desc('pool SUBCOMMAND ...ARGS', 'Manage IP pools')
|
|
11
|
+
subcommand('pool', Pool)
|
|
12
|
+
|
|
13
|
+
desc('warmup SUBCOMMAND ...ARGS', 'Manage IP warmup')
|
|
14
|
+
subcommand('warmup', Warmup)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module SendGrid4r::CLI
|
|
2
|
+
module Ips
|
|
3
|
+
#
|
|
4
|
+
# SendGrid Web API v3 Ips Pool
|
|
5
|
+
#
|
|
6
|
+
class Pool < SgThor
|
|
7
|
+
desc 'create', 'Create an IP pool'
|
|
8
|
+
option :name, require: true
|
|
9
|
+
def create
|
|
10
|
+
puts @client.post_pool(parameterise(options))
|
|
11
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
12
|
+
puts e.inspect
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc 'list', 'List all IP pools'
|
|
16
|
+
def list
|
|
17
|
+
puts @client.get_pools
|
|
18
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
19
|
+
puts e.inspect
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
desc 'get', 'Get an IP pool'
|
|
23
|
+
option :name, require: true
|
|
24
|
+
def get
|
|
25
|
+
puts @client.get_pool(parameterise(options))
|
|
26
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
27
|
+
puts e.inspect
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
desc 'rename', 'Rename an IP pool'
|
|
31
|
+
option :name, require: true
|
|
32
|
+
option :new_name, require: true
|
|
33
|
+
def rename
|
|
34
|
+
puts @client.put_pool(parameterise(options))
|
|
35
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
36
|
+
puts e.inspect
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
desc 'delete', 'Delete an IP pool'
|
|
40
|
+
option :name, require: true
|
|
41
|
+
def delete
|
|
42
|
+
puts @client.delete_pool(parameterise(options))
|
|
43
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
44
|
+
puts e.inspect
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|