sendgrid4r 0.5.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.env.example +6 -8
  3. data/.rubocop.yml +1 -1
  4. data/README.md +0 -2
  5. data/lib/sendgrid4r/rest/api.rb +6 -0
  6. data/lib/sendgrid4r/rest/api_keys/api_keys.rb +5 -5
  7. data/lib/sendgrid4r/rest/asm/global_suppressions.rb +3 -3
  8. data/lib/sendgrid4r/rest/asm/groups.rb +4 -4
  9. data/lib/sendgrid4r/rest/asm/suppressions.rb +4 -4
  10. data/lib/sendgrid4r/rest/categories/categories.rb +1 -1
  11. data/lib/sendgrid4r/rest/contacts/custom_fields.rb +3 -3
  12. data/lib/sendgrid4r/rest/contacts/lists.rb +10 -10
  13. data/lib/sendgrid4r/rest/contacts/recipients.rb +10 -10
  14. data/lib/sendgrid4r/rest/contacts/segments.rb +5 -5
  15. data/lib/sendgrid4r/rest/ips/addresses.rb +3 -3
  16. data/lib/sendgrid4r/rest/ips/pools.rb +4 -4
  17. data/lib/sendgrid4r/rest/ips/warmup.rb +6 -6
  18. data/lib/sendgrid4r/rest/request.rb +2 -2
  19. data/lib/sendgrid4r/rest/subusers/subusers.rb +63 -3
  20. data/lib/sendgrid4r/rest/templates/templates.rb +14 -9
  21. data/lib/sendgrid4r/rest/templates/versions.rb +12 -10
  22. data/lib/sendgrid4r/rest/whitelabel/domains.rb +257 -0
  23. data/lib/sendgrid4r/rest/whitelabel/ips.rb +140 -0
  24. data/lib/sendgrid4r/rest/whitelabel/links.rb +185 -0
  25. data/lib/sendgrid4r/version.rb +1 -1
  26. data/sendgrid4r.gemspec +1 -1
  27. data/spec/client_spec.rb +93 -1
  28. data/spec/rest/api_keys/api_keys_spec.rb +23 -55
  29. data/spec/rest/asm/global_suppressions_spec.rb +40 -68
  30. data/spec/rest/asm/groups_spec.rb +31 -82
  31. data/spec/rest/asm/suppressions_spec.rb +33 -76
  32. data/spec/rest/categories/categories_spec.rb +8 -27
  33. data/spec/rest/contacts/custom_fields_spec.rb +18 -71
  34. data/spec/rest/contacts/lists_spec.rb +64 -187
  35. data/spec/rest/contacts/recipients_spec.rb +41 -196
  36. data/spec/rest/contacts/reserved_fields_spec.rb +2 -20
  37. data/spec/rest/contacts/segments_spec.rb +47 -33
  38. data/spec/rest/email_activity/email_activity_spec.rb +8 -21
  39. data/spec/rest/ips/addresses_spec.rb +18 -77
  40. data/spec/rest/ips/pools_spec.rb +21 -80
  41. data/spec/rest/ips/warmup_spec.rb +11 -58
  42. data/spec/rest/settings/enforced_tls_spec.rb +3 -40
  43. data/spec/rest/settings/mail_spec.rb +21 -294
  44. data/spec/rest/settings/partner_spec.rb +6 -79
  45. data/spec/rest/settings/tracking_spec.rb +10 -147
  46. data/spec/rest/stats/advanced_spec.rb +13 -135
  47. data/spec/rest/stats/category_spec.rb +5 -48
  48. data/spec/rest/stats/global_spec.rb +3 -5
  49. data/spec/rest/stats/parse_spec.rb +1 -24
  50. data/spec/rest/stats/subuser_spec.rb +6 -49
  51. data/spec/rest/subusers/subusers_spec.rb +156 -81
  52. data/spec/rest/templates/templates_spec.rb +32 -81
  53. data/spec/rest/templates/versions_spec.rb +50 -28
  54. data/spec/rest/whitelabel/domains_spec.rb +637 -0
  55. data/spec/rest/whitelabel/ips_spec.rb +231 -0
  56. data/spec/rest/whitelabel/links_spec.rb +359 -0
  57. metadata +22 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 564f7a655ea8602232bee0429bb54c57b9ddbc75
4
- data.tar.gz: 6ff6101f1f35683236bd613632ad0c0733dc725a
3
+ metadata.gz: 88a609c232531a4f0b6d1acac25b7f2e8ca56c01
4
+ data.tar.gz: 249e65cd6188c5280a64a13377a25595f8f31953
5
5
  SHA512:
6
- metadata.gz: ca1835713c3a05441b889827e5bc7bf9f1467369bed32fffd596d273f4a064cb583d99cb573dffbc7ac2d526cbc2473b63be6ab430db428b1781119b457e03a8
7
- data.tar.gz: 7b7537d0800a842fb0b2ca1a1eb7eb11e7fd3c91b1ae883f4226f762b55e643f079e98c52a4d9e83054bdf22b84c95de9dfc9d275a7d5c3899c355970779a3bc
6
+ metadata.gz: a9f3ffa6032f734c8b6aa5d80f740d72f1d57163e323e532d7fef561cb74de2e7af7316304ecc61c55ba7ea78d514bcee9e195c9516cff129caf003ef5738286
7
+ data.tar.gz: 82417181f37fcb1e45c3331bc0d23ff2b1ff4302719faf04013c3f63be07e2f6ae60a1f849cbe9067486aca3a587c114aa9dcc87b27b2da47e30a1feb1f73929
data/.env.example CHANGED
@@ -1,10 +1,8 @@
1
- SENDGRID_USERNAME=sendgrid username
2
- SENDGRID_PASSWORD=sendgrid_password
3
1
  API_KEY=apikey
4
- SILVER_SENDGRID_USERNAME=silver_sendgrid_username
5
- SILVER_SENDGRID_PASSWORD=silver_sendgird_password
6
- SILVER_SUBUSER=subusername
7
- SILVER_SUBUSER2=subusername
2
+ SILVER_API_KEY=apikey
8
3
  SUBUSER1=subusername
9
- SUBPASS1=password
10
- SUBMAIL1=email@email.com
4
+ SUBUSER2=subusername
5
+ SUBUSER3=subusername
6
+ PASS=password
7
+ MAIL=email@email.com
8
+ EVENT_URL=http://event.webhook/endpoint
data/.rubocop.yml CHANGED
@@ -9,7 +9,7 @@ MethodLength:
9
9
 
10
10
  # Change limitation of the number of params
11
11
  ParameterLists:
12
- Max: 7
12
+ Max: 8
13
13
  CountKeywordArgs: true
14
14
 
15
15
  # Change limitation of AbcSize
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Sendgrid4r
2
2
 
3
- **This gem is BETA yet. The interfaces will be changed often.**
4
-
5
3
  This gem allows you to quickly and easily access to SendGrid Web API v3 for Ruby.
6
4
  See [api reference](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) for more detail
7
5
 
@@ -30,6 +30,9 @@ require 'sendgrid4r/rest/contacts/segments'
30
30
  require 'sendgrid4r/rest/api_keys/api_keys'
31
31
  require 'sendgrid4r/rest/subusers/subusers'
32
32
  require 'sendgrid4r/rest/email_activity/email_activity'
33
+ require 'sendgrid4r/rest/whitelabel/domains'
34
+ require 'sendgrid4r/rest/whitelabel/ips'
35
+ require 'sendgrid4r/rest/whitelabel/links'
33
36
 
34
37
  module SendGrid4r
35
38
  module REST
@@ -65,6 +68,9 @@ module SendGrid4r
65
68
  include SendGrid4r::REST::ApiKeys
66
69
  include SendGrid4r::REST::Subusers
67
70
  include SendGrid4r::REST::EmailActivity
71
+ include SendGrid4r::REST::Whitelabel::Domains
72
+ include SendGrid4r::REST::Whitelabel::Ips
73
+ include SendGrid4r::REST::Whitelabel::Links
68
74
  end
69
75
  end
70
76
  end
@@ -44,21 +44,21 @@ module SendGrid4r
44
44
  SendGrid4r::REST::ApiKeys.create_api_keys(resp)
45
45
  end
46
46
 
47
- def post_api_key(name, &block)
47
+ def post_api_key(name:, &block)
48
48
  params = {}
49
49
  params['name'] = name
50
50
  resp = post(@auth, SendGrid4r::REST::ApiKeys.url, params, &block)
51
51
  SendGrid4r::REST::ApiKeys.create_api_key(resp)
52
52
  end
53
53
 
54
- def delete_api_key(api_key, &block)
55
- delete(@auth, SendGrid4r::REST::ApiKeys.url(api_key), &block)
54
+ def delete_api_key(api_key_id:, &block)
55
+ delete(@auth, SendGrid4r::REST::ApiKeys.url(api_key_id), &block)
56
56
  end
57
57
 
58
- def patch_api_key(api_key, name, &block)
58
+ def patch_api_key(api_key_id:, name:, &block)
59
59
  params = {}
60
60
  params['name'] = name
61
- endpoint = SendGrid4r::REST::ApiKeys.url(api_key)
61
+ endpoint = SendGrid4r::REST::ApiKeys.url(api_key_id)
62
62
  resp = patch(@auth, endpoint, params, &block)
63
63
  SendGrid4r::REST::ApiKeys.create_api_key(resp)
64
64
  end
@@ -18,21 +18,21 @@ module SendGrid4r
18
18
  url
19
19
  end
20
20
 
21
- def post_global_suppressed_emails(recipient_emails, &block)
21
+ def post_global_suppressed_emails(recipient_emails:, &block)
22
22
  params = { recipient_emails: recipient_emails }
23
23
  endpoint = SendGrid4r::REST::Asm::GlobalSuppressions.url
24
24
  resp = post(@auth, endpoint, params, &block)
25
25
  SendGrid4r::REST::Asm.create_recipient_emails(resp)
26
26
  end
27
27
 
28
- def get_global_suppressed_email(email_address, &block)
28
+ def get_global_suppressed_email(email_address:, &block)
29
29
  endpoint =
30
30
  SendGrid4r::REST::Asm::GlobalSuppressions.url(email_address)
31
31
  resp = get(@auth, endpoint, &block)
32
32
  SendGrid4r::REST::Asm.create_recipient_email(resp)
33
33
  end
34
34
 
35
- def delete_global_suppressed_email(email_address, &block)
35
+ def delete_global_suppressed_email(email_address:, &block)
36
36
  endpoint =
37
37
  SendGrid4r::REST::Asm::GlobalSuppressions.url(email_address)
38
38
  delete(@auth, endpoint, &block)
@@ -41,7 +41,7 @@ module SendGrid4r
41
41
  )
42
42
  end
43
43
 
44
- def post_group(name, description, &block)
44
+ def post_group(name:, description:, &block)
45
45
  params = { name: name, description: description }
46
46
  resp = post(@auth, SendGrid4r::REST::Asm::Groups.url, params, &block)
47
47
  SendGrid4r::REST::Asm::Groups.create_group(resp)
@@ -52,18 +52,18 @@ module SendGrid4r
52
52
  SendGrid4r::REST::Asm::Groups.create_groups(resp)
53
53
  end
54
54
 
55
- def get_group(group_id, &block)
55
+ def get_group(group_id:, &block)
56
56
  resp = get(@auth, SendGrid4r::REST::Asm::Groups.url(group_id), &block)
57
57
  SendGrid4r::REST::Asm::Groups.create_group(resp)
58
58
  end
59
59
 
60
- def patch_group(group_id, group, &block)
60
+ def patch_group(group_id:, group:, &block)
61
61
  endpoint = SendGrid4r::REST::Asm::Groups.url(group_id)
62
62
  resp = patch(@auth, endpoint, group.to_h, &block)
63
63
  SendGrid4r::REST::Asm::Groups.create_group(resp)
64
64
  end
65
65
 
66
- def delete_group(group_id, &block)
66
+ def delete_group(group_id:, &block)
67
67
  delete(@auth, SendGrid4r::REST::Asm::Groups.url(group_id), &block)
68
68
  end
69
69
  end
@@ -50,7 +50,7 @@ module SendGrid4r
50
50
  emails
51
51
  end
52
52
 
53
- def post_suppressed_emails(group_id, recipient_emails, &block)
53
+ def post_suppressed_emails(group_id:, recipient_emails:, &block)
54
54
  resp = post(
55
55
  @auth,
56
56
  SendGrid4r::REST::Asm::Suppressions.url(group_id),
@@ -60,19 +60,19 @@ module SendGrid4r
60
60
  SendGrid4r::REST::Asm.create_recipient_emails(resp)
61
61
  end
62
62
 
63
- def get_suppressed_emails(group_id, &block)
63
+ def get_suppressed_emails(group_id:, &block)
64
64
  endpoint = SendGrid4r::REST::Asm::Suppressions.url(group_id)
65
65
  resp = get(@auth, endpoint, &block)
66
66
  SendGrid4r::REST::Asm::Suppressions.create_emails(resp)
67
67
  end
68
68
 
69
- def get_suppressions(email_address, &block)
69
+ def get_suppressions(email_address:, &block)
70
70
  endpoint = "#{BASE_URL}/asm/suppressions/#{email_address}"
71
71
  resp = get(@auth, endpoint, &block)
72
72
  SendGrid4r::REST::Asm::Suppressions.create_suppressions(resp)
73
73
  end
74
74
 
75
- def delete_suppressed_email(group_id, email_address, &block)
75
+ def delete_suppressed_email(group_id:, email_address:, &block)
76
76
  delete(
77
77
  @auth,
78
78
  SendGrid4r::REST::Asm::Suppressions.url(group_id, email_address),
@@ -32,7 +32,7 @@ module SendGrid4r
32
32
  categories
33
33
  end
34
34
 
35
- def get_categories(category = nil, limit = nil, offset = nil, &block)
35
+ def get_categories(category: nil, limit: nil, offset: nil, &block)
36
36
  params = {}
37
37
  params['category'] = category unless category.nil?
38
38
  params['limit'] = limit unless limit.nil?
@@ -46,7 +46,7 @@ module SendGrid4r
46
46
  Fields.new(custom_fields)
47
47
  end
48
48
 
49
- def post_custom_field(name, type, &block)
49
+ def post_custom_field(name:, type:, &block)
50
50
  params = {}
51
51
  params['name'] = name
52
52
  params['type'] = type
@@ -63,7 +63,7 @@ module SendGrid4r
63
63
  SendGrid4r::REST::Contacts::CustomFields.create_fields(resp)
64
64
  end
65
65
 
66
- def get_custom_field(custom_field_id, &block)
66
+ def get_custom_field(custom_field_id:, &block)
67
67
  resp = get(
68
68
  @auth,
69
69
  SendGrid4r::REST::Contacts::CustomFields.url(custom_field_id),
@@ -72,7 +72,7 @@ module SendGrid4r
72
72
  SendGrid4r::REST::Contacts::CustomFields.create_field(resp)
73
73
  end
74
74
 
75
- def delete_custom_field(custom_field_id, &block)
75
+ def delete_custom_field(custom_field_id:, &block)
76
76
  delete(
77
77
  @auth,
78
78
  SendGrid4r::REST::Contacts::CustomFields.url(custom_field_id),
@@ -41,7 +41,7 @@ module SendGrid4r
41
41
  Lists.new(lists)
42
42
  end
43
43
 
44
- def post_list(name, &block)
44
+ def post_list(name:, &block)
45
45
  params = {}
46
46
  params['name'] = name
47
47
  resp = post(
@@ -55,14 +55,14 @@ module SendGrid4r
55
55
  SendGrid4r::REST::Contacts::Lists.create_lists(resp)
56
56
  end
57
57
 
58
- def get_list(list_id, &block)
58
+ def get_list(list_id:, &block)
59
59
  resp = get(
60
60
  @auth, SendGrid4r::REST::Contacts::Lists.url(list_id), &block
61
61
  )
62
62
  SendGrid4r::REST::Contacts::Lists.create_list(resp)
63
63
  end
64
64
 
65
- def patch_list(list_id, name, &block)
65
+ def patch_list(list_id:, name:, &block)
66
66
  params = {}
67
67
  params['name'] = name
68
68
  endpoint = SendGrid4r::REST::Contacts::Lists.url(list_id)
@@ -70,18 +70,18 @@ module SendGrid4r
70
70
  SendGrid4r::REST::Contacts::Lists.create_list(resp)
71
71
  end
72
72
 
73
- def delete_list(list_id, &block)
73
+ def delete_list(list_id:, &block)
74
74
  delete(@auth, SendGrid4r::REST::Contacts::Lists.url(list_id), &block)
75
75
  end
76
76
 
77
77
  # no bodies returned
78
- def post_recipients_to_list(list_id, recipients, &block)
78
+ def post_recipients_to_list(list_id:, recipients:, &block)
79
79
  url = SendGrid4r::REST::Contacts::Lists.url(list_id)
80
80
  endpoint = "#{url}/recipients_batch"
81
81
  post(@auth, endpoint, recipients, &block)
82
82
  end
83
83
 
84
- def get_recipients_from_list(list_id, limit = nil, offset = nil, &block)
84
+ def get_recipients_from_list(list_id:, limit: nil, offset: nil, &block)
85
85
  params = {}
86
86
  params['limit'] = limit unless limit.nil?
87
87
  params['offset'] = offset unless offset.nil?
@@ -90,23 +90,23 @@ module SendGrid4r
90
90
  SendGrid4r::REST::Contacts::Recipients.create_recipients(resp)
91
91
  end
92
92
 
93
- def post_recipient_to_list(list_id, recipient_id, &block)
93
+ def post_recipient_to_list(list_id:, recipient_id:, &block)
94
94
  endpoint = SendGrid4r::REST::Contacts::Lists.recipients_url(
95
95
  list_id, recipient_id
96
96
  )
97
97
  post(@auth, endpoint, &block)
98
98
  end
99
99
 
100
- def delete_recipient_from_list(list_id, recipient_id, &block)
100
+ def delete_recipient_from_list(list_id:, recipient_id:, &block)
101
101
  endpoint = SendGrid4r::REST::Contacts::Lists.recipients_url(
102
102
  list_id, recipient_id
103
103
  )
104
104
  delete(@auth, endpoint, &block)
105
105
  end
106
106
 
107
- def delete_lists(list_ids, &block)
107
+ def delete_lists(list_ids:, &block)
108
108
  endpoint = "#{BASE_URL}/contactdb/lists_batch"
109
- delete(@auth, endpoint, list_ids, &block)
109
+ delete(@auth, endpoint, nil, list_ids, &block)
110
110
  end
111
111
  end
112
112
  end
@@ -66,18 +66,18 @@ module SendGrid4r
66
66
  url
67
67
  end
68
68
 
69
- def post_recipient(params, &block)
69
+ def post_recipient(params:, &block)
70
70
  endpoint = SendGrid4r::REST::Contacts::Recipients.url
71
71
  resp = post(@auth, endpoint, params, &block)
72
72
  SendGrid4r::REST::Contacts::Recipients.create_recipient(resp)
73
73
  end
74
74
 
75
- def delete_recipients(emails, &block)
75
+ def delete_recipients(emails:, &block)
76
76
  endpoint = SendGrid4r::REST::Contacts::Recipients.url
77
- delete(@auth, endpoint, emails, &block)
77
+ delete(@auth, endpoint, nil, emails, &block)
78
78
  end
79
79
 
80
- def get_recipients(limit = nil, offset = nil, &block)
80
+ def get_recipients(limit: nil, offset: nil, &block)
81
81
  params = {}
82
82
  params['limit'] = limit unless limit.nil?
83
83
  params['offset'] = offset unless offset.nil?
@@ -86,7 +86,7 @@ module SendGrid4r
86
86
  SendGrid4r::REST::Contacts::Recipients.create_recipients(resp)
87
87
  end
88
88
 
89
- def get_recipients_by_id(recipient_ids, &block)
89
+ def get_recipients_by_id(recipient_ids:, &block)
90
90
  endpoint = "#{SendGrid4r::REST::Contacts::Recipients.url}/batch"
91
91
  resp = get(@auth, endpoint, nil, recipient_ids, &block)
92
92
  SendGrid4r::REST::Contacts::Recipients.create_recipients(resp)
@@ -98,24 +98,24 @@ module SendGrid4r
98
98
  resp['recipient_count'] unless resp.nil?
99
99
  end
100
100
 
101
- def search_recipients(params, &block)
101
+ def search_recipients(params:, &block)
102
102
  endpoint = "#{SendGrid4r::REST::Contacts::Recipients.url}/search"
103
103
  resp = get(@auth, endpoint, params, &block)
104
104
  SendGrid4r::REST::Contacts::Recipients.create_recipients(resp)
105
105
  end
106
106
 
107
- def get_recipient(recipient_id, &block)
107
+ def get_recipient(recipient_id:, &block)
108
108
  endpoint = SendGrid4r::REST::Contacts::Recipients.url(recipient_id)
109
109
  resp = get(@auth, endpoint, &block)
110
110
  SendGrid4r::REST::Contacts::Recipients.create_recipient(resp)
111
111
  end
112
112
 
113
- def delete_recipient(recipient_id, &block)
113
+ def delete_recipient(recipient_id:, &block)
114
114
  endpoint = SendGrid4r::REST::Contacts::Recipients.url(recipient_id)
115
115
  delete(@auth, endpoint, &block)
116
116
  end
117
117
 
118
- def get_lists_recipient_belong(recipient_id, &block)
118
+ def get_lists_recipient_belong(recipient_id:, &block)
119
119
  resp = get(
120
120
  @auth,
121
121
  "#{SendGrid4r::REST::Contacts::Recipients.url(recipient_id)}/lists",
@@ -124,7 +124,7 @@ module SendGrid4r
124
124
  SendGrid4r::REST::Contacts::Lists.create_lists(resp)
125
125
  end
126
126
 
127
- def post_recipients(recipients, &block)
127
+ def post_recipients(recipients:, &block)
128
128
  endpoint = "#{BASE_URL}/contactdb/recipients_batch"
129
129
  resp = post(@auth, endpoint, recipients, &block)
130
130
  SendGrid4r::REST::Contacts::Recipients.create_result(resp)
@@ -61,7 +61,7 @@ module SendGrid4r
61
61
  Segments.new(segments)
62
62
  end
63
63
 
64
- def post_segment(params, &block)
64
+ def post_segment(params:, &block)
65
65
  endpoint = SendGrid4r::REST::Contacts::Segments.url
66
66
  resp = post(@auth, endpoint, params.to_h, &block)
67
67
  SendGrid4r::REST::Contacts::Segments.create_segment(resp)
@@ -72,25 +72,25 @@ module SendGrid4r
72
72
  SendGrid4r::REST::Contacts::Segments.create_segments(resp)
73
73
  end
74
74
 
75
- def get_segment(segment_id, &block)
75
+ def get_segment(segment_id:, &block)
76
76
  endpoint = SendGrid4r::REST::Contacts::Segments.url(segment_id)
77
77
  resp = get(@auth, endpoint, &block)
78
78
  SendGrid4r::REST::Contacts::Segments.create_segment(resp)
79
79
  end
80
80
 
81
- def put_segment(segment_id, params, &block)
81
+ def put_segment(segment_id:, params:, &block)
82
82
  endpoint = SendGrid4r::REST::Contacts::Segments.url(segment_id)
83
83
  resp = put(@auth, endpoint, params, &block)
84
84
  SendGrid4r::REST::Contacts::Segments.create_segment(resp)
85
85
  end
86
86
 
87
- def delete_segment(segment_id, &block)
87
+ def delete_segment(segment_id:, &block)
88
88
  endpoint = SendGrid4r::REST::Contacts::Segments.url(segment_id)
89
89
  delete(@auth, endpoint, &block)
90
90
  end
91
91
 
92
92
  def get_recipients_from_segment(
93
- segment_id, limit = nil, offset = nil, &block
93
+ segment_id:, limit: nil, offset: nil, &block
94
94
  )
95
95
  params = {}
96
96
  params['limit'] = limit unless limit.nil?
@@ -46,7 +46,7 @@ module SendGrid4r
46
46
  url
47
47
  end
48
48
 
49
- def post_ip_to_pool(pool_name, ip, &block)
49
+ def post_ip_to_pool(pool_name:, ip:, &block)
50
50
  endpoint = SendGrid4r::REST::Ips::Pools.url(pool_name, 'ips')
51
51
  resp = post(@auth, endpoint, ip: ip, &block)
52
52
  SendGrid4r::REST::Ips::Addresses.create_address(resp)
@@ -63,13 +63,13 @@ module SendGrid4r
63
63
  SendGrid4r::REST::Ips::Addresses.create_addresses(resp)
64
64
  end
65
65
 
66
- def get_ip(ip, &block)
66
+ def get_ip(ip:, &block)
67
67
  endpoint = SendGrid4r::REST::Ips::Addresses.url(ip)
68
68
  resp = get(@auth, endpoint, &block)
69
69
  SendGrid4r::REST::Ips::Addresses.create_address(resp)
70
70
  end
71
71
 
72
- def delete_ip_from_pool(pool_name, ip, &block)
72
+ def delete_ip_from_pool(pool_name:, ip:, &block)
73
73
  endpoint = SendGrid4r::REST::Ips::Pools.url(pool_name, 'ips', ip)
74
74
  delete(@auth, endpoint, &block)
75
75
  end
@@ -41,7 +41,7 @@ module SendGrid4r
41
41
  url
42
42
  end
43
43
 
44
- def post_pool(name, &block)
44
+ def post_pool(name:, &block)
45
45
  endpoint = SendGrid4r::REST::Ips::Pools.url
46
46
  resp = post(@auth, endpoint, name: name, &block)
47
47
  SendGrid4r::REST::Ips::Pools.create_pool(resp)
@@ -52,19 +52,19 @@ module SendGrid4r
52
52
  SendGrid4r::REST::Ips::Pools.create_pools(resp)
53
53
  end
54
54
 
55
- def get_pool(name, &block)
55
+ def get_pool(name:, &block)
56
56
  endpoint = SendGrid4r::REST::Ips::Pools.url(name)
57
57
  resp = get(@auth, endpoint, &block)
58
58
  SendGrid4r::REST::Ips::Pools.create_pool(resp)
59
59
  end
60
60
 
61
- def put_pool(name, new_name, &block)
61
+ def put_pool(name:, new_name:, &block)
62
62
  endpoint = SendGrid4r::REST::Ips::Pools.url(name)
63
63
  resp = put(@auth, endpoint, name: new_name, &block)
64
64
  SendGrid4r::REST::Ips::Pools.create_pool(resp)
65
65
  end
66
66
 
67
- def delete_pool(name, &block)
67
+ def delete_pool(name:, &block)
68
68
  delete(@auth, SendGrid4r::REST::Ips::Pools.url(name), &block)
69
69
  end
70
70
  end
@@ -42,20 +42,20 @@ module SendGrid4r
42
42
  SendGrid4r::REST::Ips::Warmup.create_warmup_ips(resp)
43
43
  end
44
44
 
45
- def get_warmup_ip(ip_address, &block)
46
- endpoint = SendGrid4r::REST::Ips::Warmup.url(ip_address)
45
+ def get_warmup_ip(ip:, &block)
46
+ endpoint = SendGrid4r::REST::Ips::Warmup.url(ip)
47
47
  resp = get(@auth, endpoint, &block)
48
48
  SendGrid4r::REST::Ips::Warmup.create_warmup_ip(resp)
49
49
  end
50
50
 
51
- def post_warmup_ip(ip_address, &block)
51
+ def post_warmup_ip(ip:, &block)
52
52
  endpoint = SendGrid4r::REST::Ips::Warmup.url
53
- resp = post(@auth, endpoint, ip: ip_address, &block)
53
+ resp = post(@auth, endpoint, ip: ip, &block)
54
54
  SendGrid4r::REST::Ips::Warmup.create_warmup_ip(resp)
55
55
  end
56
56
 
57
- def delete_warmup_ip(ip_address, &block)
58
- endpoint = SendGrid4r::REST::Ips::Warmup.url(ip_address)
57
+ def delete_warmup_ip(ip:, &block)
58
+ endpoint = SendGrid4r::REST::Ips::Warmup.url(ip)
59
59
  delete(@auth, endpoint, &block)
60
60
  end
61
61
  end
@@ -29,8 +29,8 @@ module SendGrid4r
29
29
  execute(:put, auth, endpoint, nil, payload, &block)
30
30
  end
31
31
 
32
- def delete(auth, endpoint, payload = nil, &block)
33
- execute(:delete, auth, endpoint, nil, payload, &block)
32
+ def delete(auth, endpoint, params = nil, payload = nil, &block)
33
+ execute(:delete, auth, endpoint, params, payload, &block)
34
34
  end
35
35
 
36
36
  def execute(method, auth, endpoint, params, payload, &block)
@@ -44,6 +44,16 @@ module SendGrid4r
44
44
  )
45
45
  end
46
46
 
47
+ Monitor = Struct.new(:email, :frequency)
48
+
49
+ def self.create_monitor(resp)
50
+ return resp if resp.nil?
51
+ Monitor.new(
52
+ resp['email'],
53
+ resp['frequency']
54
+ )
55
+ end
56
+
47
57
  def get_subusers(limit: nil, offset: nil, username: nil, &block)
48
58
  params = {}
49
59
  params['limit'] = limit unless limit.nil?
@@ -63,19 +73,69 @@ module SendGrid4r
63
73
  SendGrid4r::REST::Subusers.create_subuser(resp)
64
74
  end
65
75
 
76
+ def patch_subuser(username:, disabled:, &block)
77
+ endpoint = SendGrid4r::REST::Subusers.url(username)
78
+ payload = {}
79
+ payload['disabled'] = disabled
80
+ resp = patch(@auth, endpoint, payload, &block)
81
+ SendGrid4r::REST::Subusers.create_subuser(resp)
82
+ end
83
+
84
+ def delete_subuser(username:, &block)
85
+ endpoint = SendGrid4r::REST::Subusers.url(username)
86
+ delete(@auth, endpoint, &block)
87
+ end
88
+
89
+ def get_subuser_monitor(username:, email:, frequency:, &block)
90
+ endpoint = SendGrid4r::REST::Subusers.url(username)
91
+ endpoint = "#{endpoint}/monitor"
92
+ payload = {}
93
+ payload['email'] = email
94
+ payload['frequency'] = frequency
95
+ resp = post(@auth, endpoint, payload, &block)
96
+ SendGrid4r::REST::Subusers.create_monitor(resp)
97
+ end
98
+
99
+ def post_subuser_monitor(username:, email:, frequency:, &block)
100
+ endpoint = SendGrid4r::REST::Subusers.url(username)
101
+ endpoint = "#{endpoint}/monitor"
102
+ payload = {}
103
+ payload['email'] = email
104
+ payload['frequency'] = frequency
105
+ resp = post(@auth, endpoint, payload, &block)
106
+ SendGrid4r::REST::Subusers.create_monitor(resp)
107
+ end
108
+
109
+ def put_subuser_monitor(username:, email:, frequency:, &block)
110
+ endpoint = SendGrid4r::REST::Subusers.url(username)
111
+ endpoint = "#{endpoint}/monitor"
112
+ payload = {}
113
+ payload['email'] = email
114
+ payload['frequency'] = frequency
115
+ resp = put(@auth, endpoint, payload, &block)
116
+ SendGrid4r::REST::Subusers.create_monitor(resp)
117
+ end
118
+
119
+ def delete_subuser_monitor(username:, &block)
120
+ endpoint = SendGrid4r::REST::Subusers.url(username)
121
+ endpoint = "#{endpoint}/monitor"
122
+ delete(@auth, endpoint, &block)
123
+ end
124
+
66
125
  def get_subuser_reputation(usernames:, &block)
67
126
  params = ''
68
127
  usernames.each do |username|
69
128
  params += "usernames=#{username}&"
70
129
  end
71
- endpoint = "#{SendGrid4r::REST::Subusers.url}/reputations?#{params}"
130
+ endpoint = SendGrid4r::REST::Subusers.url
131
+ endpoint = "#{endpoint}/reputations?#{params}"
72
132
  resp = get(@auth, endpoint, usernames, &block)
73
133
  SendGrid4r::REST::Subusers.create_subusers(resp)
74
134
  end
75
135
 
76
- def put_subuser_assigned_ips(username:, &block)
136
+ def put_subuser_assigned_ips(username:, ips:, &block)
77
137
  endpoint = "#{SendGrid4r::REST::Subusers.url(username)}/ips"
78
- resp = put(@auth, endpoint, nil, &block)
138
+ resp = put(@auth, endpoint, ips, &block)
79
139
  SendGrid4r::REST::Subusers.create_subuser(resp)
80
140
  end
81
141
  end
@@ -39,8 +39,9 @@ module SendGrid4r
39
39
  Template.new(resp['id'], resp['name'], vers)
40
40
  end
41
41
 
42
- def post_template(name, &block)
43
- resp = post(@auth, SendGrid4r::REST::Templates.url, name: name, &block)
42
+ def post_template(name:, &block)
43
+ endpoint = SendGrid4r::REST::Templates.url
44
+ resp = post(@auth, endpoint, name: name, &block)
44
45
  SendGrid4r::REST::Templates.create_template(resp)
45
46
  end
46
47
 
@@ -49,19 +50,23 @@ module SendGrid4r
49
50
  SendGrid4r::REST::Templates.create_templates(resp)
50
51
  end
51
52
 
52
- def get_template(temp_id, &block)
53
- resp = get(@auth, SendGrid4r::REST::Templates.url(temp_id), &block)
53
+ def get_template(template_id:, &block)
54
+ endpoint = SendGrid4r::REST::Templates.url(template_id)
55
+ resp = get(@auth, endpoint, &block)
54
56
  SendGrid4r::REST::Templates.create_template(resp)
55
57
  end
56
58
 
57
- def patch_template(temp_id, name, &block)
58
- resp = patch(
59
- @auth, SendGrid4r::REST::Templates.url(temp_id), name: name, &block)
59
+ def patch_template(template_id:, name:, &block)
60
+ endpoint = SendGrid4r::REST::Templates.url(template_id)
61
+ payload = {}
62
+ payload['name'] = name
63
+ resp = patch(@auth, endpoint, name: name, &block)
60
64
  SendGrid4r::REST::Templates.create_template(resp)
61
65
  end
62
66
 
63
- def delete_template(temp_id, &block)
64
- delete(@auth, SendGrid4r::REST::Templates.url(temp_id), &block)
67
+ def delete_template(template_id:, &block)
68
+ endpoint = SendGrid4r::REST::Templates.url(template_id)
69
+ delete(@auth, endpoint, &block)
65
70
  end
66
71
  end
67
72
  end