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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f63d8884d3b1ca8b9eb7091d85b912efa8bf4560
|
4
|
+
data.tar.gz: 3561561011662deb924811afc9b171d574b075e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9c8576c472b175ed404c66c47d2582191166e6c577fe490309c9342afb9916361b6914286ff478a177414293af4df1f9f8ab631e2ec438ba9cbc185a2f96fcd
|
7
|
+
data.tar.gz: 0705ed5391a47a46014cd88f26ad5101331c97576dc2535ca31ea2616bf23feb00f161304843a210d17dfa14b9a46a39c30e9a6f7441f6883709dddd16b12b67
|
data/.rubocop.yml
CHANGED
@@ -18,7 +18,7 @@ ParameterLists:
|
|
18
18
|
|
19
19
|
# Change limitation of AbcSize
|
20
20
|
AbcSize:
|
21
|
-
Max:
|
21
|
+
Max: 27
|
22
22
|
|
23
23
|
# Change numeric literals
|
24
24
|
NumericLiterals:
|
@@ -27,3 +27,8 @@ NumericLiterals:
|
|
27
27
|
# Disable force module and class style
|
28
28
|
ClassAndModuleChildren:
|
29
29
|
Enabled: false
|
30
|
+
|
31
|
+
# Change limitation of the class length
|
32
|
+
ClassLength:
|
33
|
+
CountComments: false # count full line comments?
|
34
|
+
Max: 160
|
data/exe/sg
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module ApiKeys
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 ApiKeys ApiKey
|
5
|
+
#
|
6
|
+
class ApiKey < SgThor
|
7
|
+
desc 'list', 'List API keys'
|
8
|
+
def list
|
9
|
+
puts @client.get_api_keys
|
10
|
+
rescue RestClient::ExceptionWithResponse => e
|
11
|
+
puts e.inspect
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'create', 'Create an API key'
|
15
|
+
option :name, require: true
|
16
|
+
option :scopes, type: :array
|
17
|
+
def create
|
18
|
+
puts @client.post_api_key(parameterise(options))
|
19
|
+
rescue RestClient::ExceptionWithResponse => e
|
20
|
+
puts e.inspect
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'get', 'Get an API key'
|
24
|
+
option :api_key_id, require: true
|
25
|
+
def get
|
26
|
+
puts @client.get_api_key(parameterise(options))
|
27
|
+
rescue RestClient::ExceptionWithResponse => e
|
28
|
+
puts e.inspect
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'delete', 'Delete an API key'
|
32
|
+
option :api_key_id, require: true
|
33
|
+
def delete
|
34
|
+
puts @client.delete_api_key(parameterise(options))
|
35
|
+
rescue RestClient::ExceptionWithResponse => e
|
36
|
+
puts e.inspect
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'update', 'Update an API key'
|
40
|
+
option :api_key_id, require: true
|
41
|
+
option :name, require: true
|
42
|
+
option :scopes, type: :array
|
43
|
+
def update
|
44
|
+
puts @client.put_api_key(parameterise(options))
|
45
|
+
rescue RestClient::ExceptionWithResponse => e
|
46
|
+
puts e.inspect
|
47
|
+
end
|
48
|
+
|
49
|
+
desc('permission SUBCOMMAND ...ARGS', 'Manage permission for API key')
|
50
|
+
subcommand('permission', Permission)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module ApiKeys
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 ApiKeys Permission
|
5
|
+
#
|
6
|
+
class Permission < SgThor
|
7
|
+
desc 'list', 'List all available scopes for a user'
|
8
|
+
def list
|
9
|
+
puts @client.get_permissions
|
10
|
+
rescue RestClient::ExceptionWithResponse => e
|
11
|
+
puts e.inspect
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Campaign
|
3
|
+
#
|
4
|
+
# SendGrid Web API v3 Marketing Campaigns
|
5
|
+
#
|
6
|
+
class Campaign < SgThor
|
7
|
+
desc 'create', 'Create a campaign'
|
8
|
+
option :title
|
9
|
+
option :subject
|
10
|
+
option :sender_id, type: :numeric
|
11
|
+
option :list_ids, type: :array
|
12
|
+
option :segment_ids, type: :array
|
13
|
+
option :categories, type: :array
|
14
|
+
option :suppression_group_id, type: :numeric
|
15
|
+
option :html_content
|
16
|
+
option :plain_content
|
17
|
+
def create
|
18
|
+
params = SendGrid4r::Factory::CampaignFactory.new.create(
|
19
|
+
parameterise(options)
|
20
|
+
)
|
21
|
+
res = @client.post_campaign(params: params)
|
22
|
+
puts URI.decode(JSON.load(res).to_s)
|
23
|
+
rescue RestClient::ExceptionWithResponse => e
|
24
|
+
puts e.inspect
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'list', 'List campaigns'
|
28
|
+
def list
|
29
|
+
res = @client.get_campaigns
|
30
|
+
puts URI.decode(JSON.load(res).to_s)
|
31
|
+
rescue RestClient::ExceptionWithResponse => e
|
32
|
+
puts e.inspect
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'get', 'Get a campaign'
|
36
|
+
option :campaign_id, type: :numeric, require: true
|
37
|
+
def get
|
38
|
+
res = @client.get_campaign(parameterise(options))
|
39
|
+
puts URI.decode(JSON.load(res).to_s)
|
40
|
+
rescue RestClient::ExceptionWithResponse => e
|
41
|
+
puts e.inspect
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'delete', 'Delete a campaign'
|
45
|
+
option :campaign_id, type: :numeric, require: true
|
46
|
+
def delete
|
47
|
+
puts @client.delete_campaign(parameterise(options))
|
48
|
+
rescue RestClient::ExceptionWithResponse => e
|
49
|
+
puts e.inspect
|
50
|
+
end
|
51
|
+
|
52
|
+
desc 'update', 'Update a campaign'
|
53
|
+
option :campaign_id, type: :numeric, require: true
|
54
|
+
option :title
|
55
|
+
option :subject
|
56
|
+
option :sender_id, type: :numeric
|
57
|
+
option :list_ids, type: :array
|
58
|
+
option :categories, type: :array
|
59
|
+
option :suppression_group_id, type: :numeric
|
60
|
+
option :html_content
|
61
|
+
option :plain_content
|
62
|
+
def update
|
63
|
+
factory = SendGrid4r::Factory::CampaignFactory.new
|
64
|
+
params = parameterise(options)
|
65
|
+
params.delete(:campaign_id)
|
66
|
+
campaign = factory.create(params)
|
67
|
+
res = @client.patch_campaign(
|
68
|
+
campaign_id: options[:campaign_id],
|
69
|
+
params: campaign
|
70
|
+
)
|
71
|
+
puts URI.decode(JSON.load(res).to_s)
|
72
|
+
rescue RestClient::ExceptionWithResponse => e
|
73
|
+
puts e.inspect
|
74
|
+
end
|
75
|
+
|
76
|
+
desc 'send', 'Send a campaign'
|
77
|
+
option :campaign_id, type: :numeric, require: true
|
78
|
+
def send
|
79
|
+
puts @client.send_campaign(parameterise(options))
|
80
|
+
rescue RestClient::ExceptionWithResponse => e
|
81
|
+
puts e.inspect
|
82
|
+
end
|
83
|
+
|
84
|
+
desc 'schedule', 'Schedule a campaign'
|
85
|
+
option :campaign_id, type: :numeric, require: true
|
86
|
+
option :send_at, type: :numeric, require: true
|
87
|
+
def schedule
|
88
|
+
puts @client.schedule_campaign(parameterise(options))
|
89
|
+
rescue RestClient::ExceptionWithResponse => e
|
90
|
+
puts e.inspect
|
91
|
+
end
|
92
|
+
|
93
|
+
desc 'reschedule', 'Reschedule a campaign'
|
94
|
+
option :campaign_id, type: :numeric, require: true
|
95
|
+
option :send_at, type: :numeric, require: true
|
96
|
+
def reschedule
|
97
|
+
puts @client.reschedule_campaign(parameterise(options))
|
98
|
+
rescue RestClient::ExceptionWithResponse => e
|
99
|
+
puts e.inspect
|
100
|
+
end
|
101
|
+
|
102
|
+
desc 'unschedule', 'Unschedule a campaign'
|
103
|
+
option :campaign_id, type: :numeric, require: true
|
104
|
+
def unschedule
|
105
|
+
puts @client.unschedule_campaign(parameterise(options))
|
106
|
+
rescue RestClient::ExceptionWithResponse => e
|
107
|
+
puts e.inspect
|
108
|
+
end
|
109
|
+
|
110
|
+
desc 'time', 'View scheduled time of a campaign'
|
111
|
+
option :campaign_id, type: :numeric, require: true
|
112
|
+
def time
|
113
|
+
puts @client.get_schedule_time_campaign(parameterise(options))
|
114
|
+
rescue RestClient::ExceptionWithResponse => e
|
115
|
+
puts e.inspect
|
116
|
+
end
|
117
|
+
|
118
|
+
desc 'test', 'Send a test campaign'
|
119
|
+
option :campaign_id, type: :numeric, require: true
|
120
|
+
option :to, require: true
|
121
|
+
def test
|
122
|
+
puts @client.test_campaign(parameterise(options))
|
123
|
+
rescue RestClient::ExceptionWithResponse => e
|
124
|
+
puts e.inspect
|
125
|
+
end
|
126
|
+
|
127
|
+
desc('sender SUBCOMMAND ...ARGS', 'Manage senders')
|
128
|
+
subcommand('sender', Sender)
|
129
|
+
|
130
|
+
desc('contact SUBCOMMAND ...ARGS', 'Manage contacts')
|
131
|
+
subcommand('contact', Contact::Contact)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Campaign
|
3
|
+
module Contact
|
4
|
+
#
|
5
|
+
# SendGrid Web API v3 Marketing Campaigns - Contact
|
6
|
+
#
|
7
|
+
class Contact < SgThor
|
8
|
+
desc('custom SUBCOMMAND ...ARGS', 'Manage custom fields')
|
9
|
+
subcommand('custom', CustomField)
|
10
|
+
|
11
|
+
desc('list SUBCOMMAND ...ARGS', 'Manage lists')
|
12
|
+
subcommand('list', List)
|
13
|
+
|
14
|
+
desc('recipient SUBCOMMAND ...ARGS', 'Manage recipients')
|
15
|
+
subcommand('recipint', Recipient)
|
16
|
+
|
17
|
+
desc('reserved SUBCOMMAND ...ARGS', 'Manage reserved fields')
|
18
|
+
subcommand('reserved', ReservedField)
|
19
|
+
|
20
|
+
desc('segment SUBCOMMAND ...ARGS', 'Manage segments')
|
21
|
+
subcommand('segment', Segment)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Campaign
|
3
|
+
module Contact
|
4
|
+
#
|
5
|
+
# SendGrid Web API v3 Marketing Campaigns
|
6
|
+
#
|
7
|
+
class CustomField < SgThor
|
8
|
+
desc 'create', 'Create a custom field'
|
9
|
+
option :name, require: true
|
10
|
+
option :type, require: true
|
11
|
+
def create
|
12
|
+
puts @client.post_custom_field(parameterise(options))
|
13
|
+
rescue RestClient::ExceptionWithResponse => e
|
14
|
+
puts e.inspect
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'list', 'List custom fields'
|
18
|
+
def list
|
19
|
+
puts @client.get_custom_fields
|
20
|
+
rescue RestClient::ExceptionWithResponse => e
|
21
|
+
puts e.inspect
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'get', 'Get a custom field'
|
25
|
+
option :custom_field_id, require: true
|
26
|
+
def get
|
27
|
+
puts @client.get_custom_field(parameterise(options))
|
28
|
+
rescue RestClient::ExceptionWithResponse => e
|
29
|
+
puts e.inspect
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'delete', 'Delete a custom field'
|
33
|
+
option :custom_field_id, require: true
|
34
|
+
def delete
|
35
|
+
puts @client.delete_custom_field(parameterise(options))
|
36
|
+
rescue RestClient::ExceptionWithResponse => e
|
37
|
+
puts e.inspect
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Campaign
|
3
|
+
module Contact
|
4
|
+
#
|
5
|
+
# SendGrid Web API v3 Marketing Campaigns - List
|
6
|
+
#
|
7
|
+
class List < SgThor
|
8
|
+
desc 'create', 'Create a list'
|
9
|
+
option :name, require: true
|
10
|
+
def create
|
11
|
+
puts @client.post_list(parameterise(options))
|
12
|
+
rescue RestClient::ExceptionWithResponse => e
|
13
|
+
puts e.inspect
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'list', 'List lists'
|
17
|
+
def list
|
18
|
+
puts @client.get_lists
|
19
|
+
rescue RestClient::ExceptionWithResponse => e
|
20
|
+
puts e.inspect
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'get', 'Get a list'
|
24
|
+
option :list_id, type: :numeric, require: true
|
25
|
+
def get
|
26
|
+
puts @client.get_list(parameterise(options))
|
27
|
+
rescue RestClient::ExceptionWithResponse => e
|
28
|
+
puts e.inspect
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'rename', 'Rename a list'
|
32
|
+
option :list_id, type: :numeric, require: true
|
33
|
+
option :name
|
34
|
+
def rename
|
35
|
+
puts @client.patch_list(parameterise(options))
|
36
|
+
rescue RestClient::ExceptionWithResponse => e
|
37
|
+
puts e.inspect
|
38
|
+
end
|
39
|
+
|
40
|
+
desc 'delete', 'Delete lists'
|
41
|
+
option :list_ids, type: :array, require: true
|
42
|
+
def delete
|
43
|
+
puts @client.delete_lists(parameterise(options))
|
44
|
+
rescue RestClient::ExceptionWithResponse => e
|
45
|
+
puts e.inspect
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'recipient', 'Add, Remove, List a recipient'
|
49
|
+
option :list_id, type: :numeric, require: true
|
50
|
+
option :recipients, type: :array, desc: 'for add action'
|
51
|
+
option :recipient_id, desc: 'for remove action'
|
52
|
+
option :page, type: :numeric, desc: 'for list action'
|
53
|
+
option :page_size, type: :numeric, desc: 'for list action'
|
54
|
+
def recipient(action)
|
55
|
+
case action
|
56
|
+
when 'add'
|
57
|
+
puts @client.post_recipients_to_list(parameterise(options))
|
58
|
+
when 'remove'
|
59
|
+
puts @client.delete_recipient_from_list(parameterise(options))
|
60
|
+
when 'list'
|
61
|
+
puts @client.get_recipients_from_list(parameterise(options))
|
62
|
+
else
|
63
|
+
puts "error: #{action} is not supported in action parameter"
|
64
|
+
end
|
65
|
+
rescue RestClient::ExceptionWithResponse => e
|
66
|
+
puts e.inspect
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module SendGrid4r::CLI
|
2
|
+
module Campaign
|
3
|
+
module Contact
|
4
|
+
#
|
5
|
+
# SendGrid Web API v3 Marketing Campaigns - Recipient
|
6
|
+
#
|
7
|
+
class Recipient < SgThor
|
8
|
+
desc 'create', 'Create a recipient'
|
9
|
+
option :params, type: :hash, require: true
|
10
|
+
def create
|
11
|
+
puts @client.post_recipients(
|
12
|
+
params: [parameterise(options[:params])]
|
13
|
+
)
|
14
|
+
rescue RestClient::ExceptionWithResponse => e
|
15
|
+
puts e.inspect
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'update', 'Update a recipient'
|
19
|
+
option :params, type: :hash, require: true
|
20
|
+
def update
|
21
|
+
puts @client.patch_recipients(
|
22
|
+
params: [parameterise(options[:params])]
|
23
|
+
)
|
24
|
+
rescue RestClient::ExceptionWithResponse => e
|
25
|
+
puts e.inspect
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'delete', 'Delete recipients'
|
29
|
+
option :recipient_ids, type: :array, require: true
|
30
|
+
def delete
|
31
|
+
puts @client.delete_recipients(parameterise(options))
|
32
|
+
rescue RestClient::ExceptionWithResponse => e
|
33
|
+
puts e.inspect
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'list', 'List recipients'
|
37
|
+
option :page
|
38
|
+
option :page_size
|
39
|
+
def list
|
40
|
+
puts @client.get_recipients(parameterise(options))
|
41
|
+
rescue RestClient::ExceptionWithResponse => e
|
42
|
+
puts e.inspect
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'get', 'Get a recipient'
|
46
|
+
option :recipient_id, require: true
|
47
|
+
def get
|
48
|
+
puts @client.get_recipient(parameterise(options))
|
49
|
+
rescue RestClient::ExceptionWithResponse => e
|
50
|
+
puts e.inspect
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'count', 'Get recipients count'
|
54
|
+
def count
|
55
|
+
puts @client.get_recipients_count
|
56
|
+
rescue RestClient::ExceptionWithResponse => e
|
57
|
+
puts e.inspect
|
58
|
+
end
|
59
|
+
|
60
|
+
desc 'search', 'Search recipients'
|
61
|
+
option :params, type: :hash, require: true
|
62
|
+
def search
|
63
|
+
puts @client.search_recipients(params: options[:params])
|
64
|
+
rescue RestClient::ExceptionWithResponse => e
|
65
|
+
puts e.inspect
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'belong', 'List lists a recipient belongs to'
|
69
|
+
option :recipient_id, require: true
|
70
|
+
def belong
|
71
|
+
puts @client.get_lists_recipient_belong(parameterise(options))
|
72
|
+
rescue RestClient::ExceptionWithResponse => e
|
73
|
+
puts e.inspect
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|