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
|
@@ -24,7 +24,9 @@ module SendGrid4r::REST
|
|
|
24
24
|
|
|
25
25
|
def get_permissions(&block)
|
|
26
26
|
resp = get(@auth, ApiKeysManagement::Permissions.url, &block)
|
|
27
|
-
|
|
27
|
+
finish(resp, @raw_resp) do |r|
|
|
28
|
+
ApiKeysManagement::Permissions.create_permissions(r)
|
|
29
|
+
end
|
|
28
30
|
end
|
|
29
31
|
end
|
|
30
32
|
end
|
|
@@ -35,7 +35,7 @@ module SendGrid4r::REST
|
|
|
35
35
|
params[:limit] = limit.to_i unless limit.nil?
|
|
36
36
|
params[:offset] = offset.to_i unless offset.nil?
|
|
37
37
|
resp = get(@auth, Blocks.url, params, &block)
|
|
38
|
-
Blocks.create_blocks(
|
|
38
|
+
finish(resp, @raw_resp) { |r| Blocks.create_blocks(r) }
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def delete_blocks(delete_all: nil, emails: nil, &block)
|
|
@@ -50,7 +50,7 @@ module SendGrid4r::REST
|
|
|
50
50
|
def get_block(email:, &block)
|
|
51
51
|
params = { email: email }
|
|
52
52
|
resp = get(@auth, Blocks.url(email), params, &block)
|
|
53
|
-
Blocks.create_blocks(
|
|
53
|
+
finish(resp, @raw_resp) { |r| Blocks.create_blocks(r) }
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def delete_block(email:, &block)
|
|
@@ -31,7 +31,7 @@ module SendGrid4r::REST
|
|
|
31
31
|
params[:start_time] = start_time.to_i unless start_time.nil?
|
|
32
32
|
params[:end_time] = end_time.to_i unless end_time.nil?
|
|
33
33
|
resp = get(@auth, Bounces.url, params, &block)
|
|
34
|
-
Bounces.create_bounces(
|
|
34
|
+
finish(resp, @raw_resp) { |r| Bounces.create_bounces(r) }
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def delete_bounces(delete_all: nil, emails: nil, &block)
|
|
@@ -46,7 +46,7 @@ module SendGrid4r::REST
|
|
|
46
46
|
def get_bounce(email:, &block)
|
|
47
47
|
params = { email: email }
|
|
48
48
|
resp = get(@auth, Bounces.url(email), params, &block)
|
|
49
|
-
Bounces.create_bounces(
|
|
49
|
+
finish(resp, @raw_resp) { |r| Bounces.create_bounces(r) }
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def delete_bounce(email:, &block)
|
|
@@ -35,25 +35,33 @@ module SendGrid4r::REST
|
|
|
35
35
|
|
|
36
36
|
def generate_batch_id(&block)
|
|
37
37
|
resp = post(@auth, CancelScheduledSends.batch_url, nil, &block)
|
|
38
|
-
|
|
38
|
+
finish(resp, @raw_resp) do |r|
|
|
39
|
+
CancelScheduledSends.create_scheduled_send(r)
|
|
40
|
+
end
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
def validate_batch_id(batch_id:, &block)
|
|
42
44
|
resp = get(@auth, CancelScheduledSends.batch_url(batch_id), nil, &block)
|
|
43
|
-
|
|
45
|
+
finish(resp, @raw_resp) do |r|
|
|
46
|
+
CancelScheduledSends.create_scheduled_send(r)
|
|
47
|
+
end
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
def post_scheduled_send(batch_id:, status:, &block)
|
|
47
51
|
endpoint = CancelScheduledSends.scheduled_sends_url
|
|
48
52
|
payload = { batch_id: batch_id, status: status }
|
|
49
53
|
resp = post(@auth, endpoint, payload, &block)
|
|
50
|
-
|
|
54
|
+
finish(resp, @raw_resp) do |r|
|
|
55
|
+
CancelScheduledSends.create_scheduled_send(r)
|
|
56
|
+
end
|
|
51
57
|
end
|
|
52
58
|
|
|
53
59
|
def get_scheduled_sends(batch_id: nil, &block)
|
|
54
60
|
endpoint = CancelScheduledSends.scheduled_sends_url(batch_id)
|
|
55
61
|
resp = get(@auth, endpoint, nil, nil, &block)
|
|
56
|
-
|
|
62
|
+
finish(resp, @raw_resp) do |r|
|
|
63
|
+
CancelScheduledSends.create_scheduled_sends(r)
|
|
64
|
+
end
|
|
57
65
|
end
|
|
58
66
|
|
|
59
67
|
def patch_scheduled_send(batch_id:, status:, &block)
|
|
@@ -25,7 +25,7 @@ module SendGrid4r::REST
|
|
|
25
25
|
params['limit'] = limit unless limit.nil?
|
|
26
26
|
params['offset'] = offset unless limit.nil?
|
|
27
27
|
resp = get(@auth, "#{BASE_URL}/categories", params, &block)
|
|
28
|
-
Categories.create_categories(
|
|
28
|
+
finish(resp, @raw_resp) { |r| Categories.create_categories(r) }
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
end
|
|
@@ -66,7 +66,7 @@ module SendGrid4r::REST
|
|
|
66
66
|
params['start_time'] = start_time.to_i unless start_time.nil?
|
|
67
67
|
params['end_time'] = end_time.to_i unless end_time.nil?
|
|
68
68
|
resp = get(@auth, EmailActivity.url, params, &block)
|
|
69
|
-
EmailActivity.create_activities(
|
|
69
|
+
finish(resp, @raw_resp) { |r| EmailActivity.create_activities(r) }
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
end
|
|
@@ -37,7 +37,7 @@ module SendGrid4r::REST
|
|
|
37
37
|
params[:limit] = limit.to_i unless limit.nil?
|
|
38
38
|
params[:offset] = offset.to_i unless offset.nil?
|
|
39
39
|
resp = get(@auth, InvalidEmails.url, params, &block)
|
|
40
|
-
InvalidEmails.create_invalid_emails(
|
|
40
|
+
finish(resp, @raw_resp) { |r| InvalidEmails.create_invalid_emails(r) }
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def delete_invalid_emails(delete_all: nil, emails: nil, &block)
|
|
@@ -52,7 +52,7 @@ module SendGrid4r::REST
|
|
|
52
52
|
def get_invalid_email(email:, &block)
|
|
53
53
|
params = { email: email }
|
|
54
54
|
resp = get(@auth, InvalidEmails.url(email), params, &block)
|
|
55
|
-
InvalidEmails.create_invalid_emails(
|
|
55
|
+
finish(resp, @raw_resp) { |r| InvalidEmails.create_invalid_emails(r) }
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def delete_invalid_email(email:, &block)
|
|
@@ -77,19 +77,25 @@ module SendGrid4r::REST
|
|
|
77
77
|
params = {}
|
|
78
78
|
params[:limit] = limit unless limit.nil?
|
|
79
79
|
resp = get(@auth, IpAccessManagement.url_activity, params, &block)
|
|
80
|
-
|
|
80
|
+
finish(resp, @raw_resp) do |r|
|
|
81
|
+
IpAccessManagement.create_ip_activities(r)
|
|
82
|
+
end
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
def get_whitelisted_ips(&block)
|
|
84
86
|
resp = get(@auth, IpAccessManagement.url_whitelist, &block)
|
|
85
|
-
|
|
87
|
+
finish(resp, @raw_resp) do |r|
|
|
88
|
+
IpAccessManagement.create_whitelisted_ips(r)
|
|
89
|
+
end
|
|
86
90
|
end
|
|
87
91
|
|
|
88
92
|
def post_whitelisted_ips(ips:, &block)
|
|
89
93
|
ips_param = ips.map { |ip| { ip: ip } }
|
|
90
94
|
params = { ips: ips_param }
|
|
91
95
|
resp = post(@auth, IpAccessManagement.url_whitelist, params, &block)
|
|
92
|
-
|
|
96
|
+
finish(resp, @raw_resp) do |r|
|
|
97
|
+
IpAccessManagement.create_whitelisted_ips(r)
|
|
98
|
+
end
|
|
93
99
|
end
|
|
94
100
|
|
|
95
101
|
def delete_whitelisted_ips(ids:, &block)
|
|
@@ -99,7 +105,9 @@ module SendGrid4r::REST
|
|
|
99
105
|
|
|
100
106
|
def get_whitelisted_ip(rule_id:, &block)
|
|
101
107
|
resp = get(@auth, IpAccessManagement.url_whitelist(rule_id), nil, &block)
|
|
102
|
-
|
|
108
|
+
finish(resp, @raw_resp) do |r|
|
|
109
|
+
IpAccessManagement.create_whitelisted_ip(r)
|
|
110
|
+
end
|
|
103
111
|
end
|
|
104
112
|
|
|
105
113
|
def delete_whitelisted_ip(rule_id:, &block)
|
|
@@ -41,22 +41,22 @@ module SendGrid4r::REST
|
|
|
41
41
|
|
|
42
42
|
def post_ip_to_pool(pool_name:, ip:, &block)
|
|
43
43
|
resp = post(@auth, Ips::Pools.url(pool_name, :ips), ip: ip, &block)
|
|
44
|
-
Ips::Addresses.create_address(
|
|
44
|
+
finish(resp, @raw_resp) { |r| Ips::Addresses.create_address(r) }
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def get_ips(&block)
|
|
48
48
|
resp = get(@auth, Ips::Addresses.url, &block)
|
|
49
|
-
Ips::Addresses.create_addresses(
|
|
49
|
+
finish(resp, @raw_resp) { |r| Ips::Addresses.create_addresses(r) }
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def get_ips_assigned(&block)
|
|
53
53
|
resp = get(@auth, Ips::Addresses.url(:assigned), &block)
|
|
54
|
-
Ips::Addresses.create_addresses(
|
|
54
|
+
finish(resp, @raw_resp) { |r| Ips::Addresses.create_addresses(r) }
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def get_ip(ip:, &block)
|
|
58
58
|
resp = get(@auth, Ips::Addresses.url(ip), &block)
|
|
59
|
-
Ips::Addresses.create_address(
|
|
59
|
+
finish(resp, @raw_resp) { |r| Ips::Addresses.create_address(r) }
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def delete_ip_from_pool(pool_name:, ip:, &block)
|
|
@@ -33,22 +33,22 @@ module SendGrid4r::REST
|
|
|
33
33
|
|
|
34
34
|
def post_pool(name:, &block)
|
|
35
35
|
resp = post(@auth, Ips::Pools.url, name: name, &block)
|
|
36
|
-
Ips::Pools.create_pool(
|
|
36
|
+
finish(resp, @raw_resp) { |r| Ips::Pools.create_pool(r) }
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def get_pools(&block)
|
|
40
40
|
resp = get(@auth, Ips::Pools.url, &block)
|
|
41
|
-
Ips::Pools.create_pools(
|
|
41
|
+
finish(resp, @raw_resp) { |r| Ips::Pools.create_pools(r) }
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def get_pool(name:, &block)
|
|
45
45
|
resp = get(@auth, Ips::Pools.url(name), &block)
|
|
46
|
-
Ips::Pools.create_pool(
|
|
46
|
+
finish(resp, @raw_resp) { |r| Ips::Pools.create_pool(r) }
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def put_pool(name:, new_name:, &block)
|
|
50
50
|
resp = put(@auth, Ips::Pools.url(name), name: new_name, &block)
|
|
51
|
-
Ips::Pools.create_pool(
|
|
51
|
+
finish(resp, @raw_resp) { |r| Ips::Pools.create_pool(r) }
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def delete_pool(name:, &block)
|
|
@@ -31,17 +31,17 @@ module SendGrid4r::REST
|
|
|
31
31
|
|
|
32
32
|
def get_warmup_ips(&block)
|
|
33
33
|
resp = get(@auth, Ips::Warmup.url, &block)
|
|
34
|
-
Ips::Warmup.create_warmup_ips(
|
|
34
|
+
finish(resp, @raw_resp) { |r| Ips::Warmup.create_warmup_ips(r) }
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def get_warmup_ip(ip:, &block)
|
|
38
38
|
resp = get(@auth, Ips::Warmup.url(ip), &block)
|
|
39
|
-
Ips::Warmup.create_warmup_ip(
|
|
39
|
+
finish(resp, @raw_resp) { |r| Ips::Warmup.create_warmup_ip(r) }
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def post_warmup_ip(ip:, &block)
|
|
43
43
|
resp = post(@auth, Ips::Warmup.url, ip: ip, &block)
|
|
44
|
-
Ips::Warmup.create_warmup_ip(
|
|
44
|
+
finish(resp, @raw_resp) { |r| Ips::Warmup.create_warmup_ip(r) }
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def delete_warmup_ip(ip:, &block)
|
|
@@ -45,17 +45,23 @@ module SendGrid4r::REST
|
|
|
45
45
|
params['name'] = name
|
|
46
46
|
params['type'] = type
|
|
47
47
|
resp = post(@auth, Contacts::CustomFields.url, params, &block)
|
|
48
|
-
|
|
48
|
+
finish(resp, @raw_resp) do |r|
|
|
49
|
+
Contacts::CustomFields.create_field(r)
|
|
50
|
+
end
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
def get_custom_fields(&block)
|
|
52
54
|
resp = get(@auth, Contacts::CustomFields.url, &block)
|
|
53
|
-
|
|
55
|
+
finish(resp, @raw_resp) do |r|
|
|
56
|
+
Contacts::CustomFields.create_fields(r)
|
|
57
|
+
end
|
|
54
58
|
end
|
|
55
59
|
|
|
56
60
|
def get_custom_field(custom_field_id:, &block)
|
|
57
61
|
resp = get(@auth, Contacts::CustomFields.url(custom_field_id), &block)
|
|
58
|
-
|
|
62
|
+
finish(resp, @raw_resp) do |r|
|
|
63
|
+
Contacts::CustomFields.create_field(r)
|
|
64
|
+
end
|
|
59
65
|
end
|
|
60
66
|
|
|
61
67
|
def delete_custom_field(custom_field_id:, &block)
|
|
@@ -39,24 +39,24 @@ module SendGrid4r::REST
|
|
|
39
39
|
params = {}
|
|
40
40
|
params['name'] = name
|
|
41
41
|
resp = post(@auth, Contacts::Lists.url, params, &block)
|
|
42
|
-
Contacts::Lists.create_list(
|
|
42
|
+
finish(resp, @raw_resp) { |r| Contacts::Lists.create_list(r) }
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def get_lists(&block)
|
|
46
46
|
resp = get(@auth, Contacts::Lists.url, &block)
|
|
47
|
-
Contacts::Lists.create_lists(
|
|
47
|
+
finish(resp, @raw_resp) { |r| Contacts::Lists.create_lists(r) }
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def get_list(list_id:, &block)
|
|
51
51
|
resp = get(@auth, Contacts::Lists.url(list_id), &block)
|
|
52
|
-
Contacts::Lists.create_list(
|
|
52
|
+
finish(resp, @raw_resp) { |r| Contacts::Lists.create_list(r) }
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def patch_list(list_id:, name:, &block)
|
|
56
56
|
params = {}
|
|
57
57
|
params['name'] = name
|
|
58
58
|
resp = patch(@auth, Contacts::Lists.url(list_id), params, &block)
|
|
59
|
-
Contacts::Lists.create_list(
|
|
59
|
+
finish(resp, @raw_resp) { |r| Contacts::Lists.create_list(r) }
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def delete_list(list_id:, &block)
|
|
@@ -77,7 +77,9 @@ module SendGrid4r::REST
|
|
|
77
77
|
params['page_size'] = page_size unless page_size.nil?
|
|
78
78
|
endpoint = Contacts::Lists.recipients_url(list_id)
|
|
79
79
|
resp = get(@auth, endpoint, params, &block)
|
|
80
|
-
|
|
80
|
+
finish(resp, @raw_resp) do |r|
|
|
81
|
+
Contacts::Recipients.create_recipients(r)
|
|
82
|
+
end
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
def post_recipient_to_list(list_id:, recipient_id:, &block)
|
|
@@ -24,6 +24,8 @@ module SendGrid4r::REST
|
|
|
24
24
|
|
|
25
25
|
Recipients = Struct.new(:recipients)
|
|
26
26
|
|
|
27
|
+
Count = Struct.new(:recipient_count)
|
|
28
|
+
|
|
27
29
|
def self.create_recipient(resp)
|
|
28
30
|
return resp if resp.nil?
|
|
29
31
|
custom_fields = []
|
|
@@ -47,6 +49,11 @@ module SendGrid4r::REST
|
|
|
47
49
|
Recipients.new(recipients)
|
|
48
50
|
end
|
|
49
51
|
|
|
52
|
+
def self.create_recipient_count(resp)
|
|
53
|
+
return resp if resp.nil?
|
|
54
|
+
Count.new(resp['recipient_count'])
|
|
55
|
+
end
|
|
56
|
+
|
|
50
57
|
def self.url(recipient_id = nil)
|
|
51
58
|
url = "#{BASE_URL}/contactdb/recipients"
|
|
52
59
|
url = "#{url}/#{recipient_id}" unless recipient_id.nil?
|
|
@@ -55,12 +62,12 @@ module SendGrid4r::REST
|
|
|
55
62
|
|
|
56
63
|
def post_recipients(params:, &block)
|
|
57
64
|
resp = post(@auth, Contacts::Recipients.url, params, &block)
|
|
58
|
-
Contacts::Recipients.create_result(
|
|
65
|
+
finish(resp, @raw_resp) { |r| Contacts::Recipients.create_result(r) }
|
|
59
66
|
end
|
|
60
67
|
|
|
61
68
|
def patch_recipients(params:, &block)
|
|
62
69
|
resp = patch(@auth, Contacts::Recipients.url, params, &block)
|
|
63
|
-
Contacts::Recipients.create_result(
|
|
70
|
+
finish(resp, @raw_resp) { |r| Contacts::Recipients.create_result(r) }
|
|
64
71
|
end
|
|
65
72
|
|
|
66
73
|
def delete_recipients(recipient_ids:, &block)
|
|
@@ -72,12 +79,16 @@ module SendGrid4r::REST
|
|
|
72
79
|
params['page_size'] = page_size unless page_size.nil?
|
|
73
80
|
params['page'] = page unless page.nil?
|
|
74
81
|
resp = get(@auth, Contacts::Recipients.url, params, &block)
|
|
75
|
-
|
|
82
|
+
finish(resp, @raw_resp) do |r|
|
|
83
|
+
Contacts::Recipients.create_recipients(r)
|
|
84
|
+
end
|
|
76
85
|
end
|
|
77
86
|
|
|
78
87
|
def get_recipient(recipient_id:, &block)
|
|
79
88
|
resp = get(@auth, Contacts::Recipients.url(recipient_id), &block)
|
|
80
|
-
|
|
89
|
+
finish(resp, @raw_resp) do |r|
|
|
90
|
+
Contacts::Recipients.create_recipient(r)
|
|
91
|
+
end
|
|
81
92
|
end
|
|
82
93
|
|
|
83
94
|
def delete_recipient(recipient_id:, &block)
|
|
@@ -88,18 +99,22 @@ module SendGrid4r::REST
|
|
|
88
99
|
resp = get(
|
|
89
100
|
@auth, "#{Contacts::Recipients.url(recipient_id)}/lists", &block
|
|
90
101
|
)
|
|
91
|
-
Contacts::Lists.create_lists(
|
|
102
|
+
finish(resp, @raw_resp) { |r| Contacts::Lists.create_lists(r) }
|
|
92
103
|
end
|
|
93
104
|
|
|
94
105
|
def get_recipients_count(&block)
|
|
95
106
|
resp = get(@auth, "#{Contacts::Recipients.url}/count", &block)
|
|
96
|
-
resp
|
|
107
|
+
finish(resp, @raw_resp) do |r|
|
|
108
|
+
Contacts::Recipients.create_recipient_count(r).recipient_count
|
|
109
|
+
end
|
|
97
110
|
end
|
|
98
111
|
|
|
99
112
|
def search_recipients(params:, &block)
|
|
100
113
|
endpoint = "#{Contacts::Recipients.url}/search"
|
|
101
114
|
resp = get(@auth, endpoint, params, &block)
|
|
102
|
-
|
|
115
|
+
finish(resp, @raw_resp) do |r|
|
|
116
|
+
Contacts::Recipients.create_recipients(r)
|
|
117
|
+
end
|
|
103
118
|
end
|
|
104
119
|
|
|
105
120
|
Result = Struct.new(
|
|
@@ -36,7 +36,9 @@ module SendGrid4r::REST
|
|
|
36
36
|
|
|
37
37
|
def get_reserved_fields(&block)
|
|
38
38
|
resp = get(@auth, "#{BASE_URL}/contactdb/reserved_fields", &block)
|
|
39
|
-
|
|
39
|
+
finish(resp, @raw_resp) do |r|
|
|
40
|
+
Contacts::ReservedFields.create_fields(r)
|
|
41
|
+
end
|
|
40
42
|
end
|
|
41
43
|
end
|
|
42
44
|
end
|
|
@@ -52,23 +52,23 @@ module SendGrid4r::REST
|
|
|
52
52
|
|
|
53
53
|
def post_segment(params:, &block)
|
|
54
54
|
resp = post(@auth, Contacts::Segments.url, params.to_h, &block)
|
|
55
|
-
Contacts::Segments.create_segment(
|
|
55
|
+
finish(resp, @raw_resp) { |r| Contacts::Segments.create_segment(r) }
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def get_segments(&block)
|
|
59
59
|
resp = get(@auth, Contacts::Segments.url, &block)
|
|
60
|
-
Contacts::Segments.create_segments(
|
|
60
|
+
finish(resp, @raw_resp) { |r| Contacts::Segments.create_segments(r) }
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
def get_segment(segment_id:, &block)
|
|
64
64
|
resp = get(@auth, Contacts::Segments.url(segment_id), &block)
|
|
65
|
-
Contacts::Segments.create_segment(
|
|
65
|
+
finish(resp, @raw_resp) { |r| Contacts::Segments.create_segment(r) }
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
def patch_segment(segment_id:, params:, &block)
|
|
69
69
|
endpoint = Contacts::Segments.url(segment_id)
|
|
70
70
|
resp = patch(@auth, endpoint, params, &block)
|
|
71
|
-
Contacts::Segments.create_segment(
|
|
71
|
+
finish(resp, @raw_resp) { |r| Contacts::Segments.create_segment(r) }
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def delete_segment(segment_id:, &block)
|
|
@@ -78,7 +78,9 @@ module SendGrid4r::REST
|
|
|
78
78
|
def get_recipients_on_segment(segment_id:, &block)
|
|
79
79
|
endpoint = "#{Contacts::Segments.url(segment_id)}/recipients"
|
|
80
80
|
resp = get(@auth, endpoint, nil, &block)
|
|
81
|
-
|
|
81
|
+
finish(resp, @raw_resp) do |r|
|
|
82
|
+
Contacts::Recipients.create_recipients(r)
|
|
83
|
+
end
|
|
82
84
|
end
|
|
83
85
|
end
|
|
84
86
|
end
|
|
@@ -44,19 +44,19 @@ module SendGrid4r::REST
|
|
|
44
44
|
def post_campaign(params:, &block)
|
|
45
45
|
endpoint = MarketingCampaigns.url
|
|
46
46
|
resp = post(@auth, endpoint, params, &block)
|
|
47
|
-
MarketingCampaigns.create_campaign(
|
|
47
|
+
finish(resp, @raw_resp) { |r| MarketingCampaigns.create_campaign(r) }
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def get_campaigns(&block)
|
|
51
51
|
endpoint = MarketingCampaigns.url
|
|
52
52
|
resp = get(@auth, endpoint, &block)
|
|
53
|
-
MarketingCampaigns.create_campaigns(
|
|
53
|
+
finish(resp, @raw_resp) { |r| MarketingCampaigns.create_campaigns(r) }
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def get_campaign(campaign_id:, &block)
|
|
57
57
|
endpoint = MarketingCampaigns.url(campaign_id)
|
|
58
58
|
resp = get(@auth, endpoint, &block)
|
|
59
|
-
MarketingCampaigns.create_campaign(
|
|
59
|
+
finish(resp, @raw_resp) { |r| MarketingCampaigns.create_campaign(r) }
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def delete_campaign(campaign_id:, &block)
|
|
@@ -67,14 +67,14 @@ module SendGrid4r::REST
|
|
|
67
67
|
def patch_campaign(campaign_id:, params:, &block)
|
|
68
68
|
endpoint = MarketingCampaigns.url(campaign_id)
|
|
69
69
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
|
70
|
-
MarketingCampaigns.create_campaign(
|
|
70
|
+
finish(resp, @raw_resp) { |r| MarketingCampaigns.create_campaign(r) }
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
def send_campaign(campaign_id:, &block)
|
|
74
74
|
endpoint = MarketingCampaigns.url(campaign_id)
|
|
75
75
|
endpoint = "#{endpoint}/schedules/now"
|
|
76
76
|
resp = post(@auth, endpoint, nil, &block)
|
|
77
|
-
MarketingCampaigns.create_campaign(
|
|
77
|
+
finish(resp, @raw_resp) { |r| MarketingCampaigns.create_campaign(r) }
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
def schedule_campaign(campaign_id:, send_at:, &block)
|
|
@@ -83,7 +83,7 @@ module SendGrid4r::REST
|
|
|
83
83
|
payload = {}
|
|
84
84
|
payload['send_at'] = send_at.to_i
|
|
85
85
|
resp = post(@auth, endpoint, payload, &block)
|
|
86
|
-
MarketingCampaigns.create_campaign(
|
|
86
|
+
finish(resp, @raw_resp) { |r| MarketingCampaigns.create_campaign(r) }
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
def reschedule_campaign(campaign_id:, send_at:, &block)
|
|
@@ -92,14 +92,14 @@ module SendGrid4r::REST
|
|
|
92
92
|
payload = {}
|
|
93
93
|
payload['send_at'] = send_at.to_i
|
|
94
94
|
resp = patch(@auth, endpoint, payload, &block)
|
|
95
|
-
MarketingCampaigns.create_campaign(
|
|
95
|
+
finish(resp, @raw_resp) { |r| MarketingCampaigns.create_campaign(r) }
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
def get_schedule_time_campaign(campaign_id:, &block)
|
|
99
99
|
endpoint = MarketingCampaigns.url(campaign_id)
|
|
100
100
|
endpoint = "#{endpoint}/schedules"
|
|
101
101
|
resp = get(@auth, endpoint, &block)
|
|
102
|
-
MarketingCampaigns.create_campaign(
|
|
102
|
+
finish(resp, @raw_resp) { |r| MarketingCampaigns.create_campaign(r) }
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
def unschedule_campaign(campaign_id:, &block)
|