sendgrid4r 0.3.0 → 0.4.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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.env.example +4 -1
  3. data/.travis.yml +1 -1
  4. data/lib/client.rb +0 -2
  5. data/lib/sendgrid4r/rest/api.rb +4 -0
  6. data/lib/sendgrid4r/rest/api_keys/api_keys.rb +4 -10
  7. data/lib/sendgrid4r/rest/asm/global_suppressions.rb +9 -16
  8. data/lib/sendgrid4r/rest/asm/groups.rb +3 -7
  9. data/lib/sendgrid4r/rest/asm/suppressions.rb +25 -18
  10. data/lib/sendgrid4r/rest/categories/categories.rb +1 -3
  11. data/lib/sendgrid4r/rest/contacts/custom_fields.rb +1 -1
  12. data/lib/sendgrid4r/rest/contacts/lists.rb +15 -37
  13. data/lib/sendgrid4r/rest/contacts/recipients.rb +19 -44
  14. data/lib/sendgrid4r/rest/contacts/reserved_fields.rb +1 -5
  15. data/lib/sendgrid4r/rest/contacts/segments.rb +9 -16
  16. data/lib/sendgrid4r/rest/email_activity/email_activity.rb +84 -0
  17. data/lib/sendgrid4r/rest/ips/addresses.rb +9 -18
  18. data/lib/sendgrid4r/rest/ips/pools.rb +7 -12
  19. data/lib/sendgrid4r/rest/ips/warmup.rb +7 -17
  20. data/lib/sendgrid4r/rest/request.rb +7 -1
  21. data/lib/sendgrid4r/rest/settings/enforced_tls.rb +5 -12
  22. data/lib/sendgrid4r/rest/stats/advanced.rb +10 -32
  23. data/lib/sendgrid4r/rest/stats/category.rb +4 -11
  24. data/lib/sendgrid4r/rest/stats/global.rb +3 -2
  25. data/lib/sendgrid4r/rest/stats/parse.rb +4 -6
  26. data/lib/sendgrid4r/rest/stats/subuser.rb +4 -11
  27. data/lib/sendgrid4r/rest/subusers/subusers.rb +83 -0
  28. data/lib/sendgrid4r/rest/templates/templates.rb +1 -1
  29. data/lib/sendgrid4r/rest/templates/versions.rb +3 -2
  30. data/lib/sendgrid4r/version.rb +1 -1
  31. data/spec/client_spec.rb +17 -4
  32. data/spec/factory/condition_factory_spec.rb +1 -1
  33. data/spec/factory/segment_factory_spec.rb +1 -1
  34. data/spec/factory/version_factory_spec.rb +1 -1
  35. data/spec/{api_keys → rest/api_keys}/api_keys_spec.rb +52 -18
  36. data/spec/{asm → rest/asm}/asm_spec.rb +23 -17
  37. data/spec/{asm → rest/asm}/global_suppressions_spec.rb +45 -2
  38. data/spec/{asm → rest/asm}/groups_spec.rb +76 -7
  39. data/spec/{asm → rest/asm}/suppressions_spec.rb +95 -20
  40. data/spec/{categories → rest/categories}/categories_spec.rb +27 -7
  41. data/spec/{contacts → rest/contacts}/custom_fields_spec.rb +49 -15
  42. data/spec/{contacts → rest/contacts}/lists_spec.rb +138 -15
  43. data/spec/{contacts → rest/contacts}/recipients_spec.rb +141 -26
  44. data/spec/{contacts → rest/contacts}/reserved_fields_spec.rb +29 -13
  45. data/spec/{contacts → rest/contacts}/segments_spec.rb +108 -31
  46. data/spec/rest/email_activity/email_activity_spec.rb +192 -0
  47. data/spec/{ips → rest/ips}/addresses_spec.rb +58 -18
  48. data/spec/{ips → rest/ips}/pools_spec.rb +80 -45
  49. data/spec/{ips → rest/ips}/warmup_spec.rb +50 -7
  50. data/spec/{settings → rest/settings}/enforced_tls_spec.rb +32 -7
  51. data/spec/{stats → rest/stats}/advanced_spec.rb +2 -2
  52. data/spec/{stats → rest/stats}/category_spec.rb +2 -2
  53. data/spec/{stats → rest/stats}/global_spec.rb +2 -2
  54. data/spec/{stats → rest/stats}/parse_spec.rb +2 -2
  55. data/spec/{stats → rest/stats}/stats_spec.rb +2 -2
  56. data/spec/{stats → rest/stats}/subuser_spec.rb +2 -2
  57. data/spec/rest/subusers/subusers_spec.rb +246 -0
  58. data/spec/{templates → rest/templates}/templates_spec.rb +55 -15
  59. data/spec/{templates → rest/templates}/versions_spec.rb +44 -7
  60. metadata +54 -48
@@ -41,18 +41,14 @@ module SendGrid4r
41
41
  end
42
42
 
43
43
  def self.url(ip = nil)
44
- url = "#{SendGrid4r::Client::BASE_URL}/ips"
44
+ url = "#{BASE_URL}/ips"
45
45
  url = "#{url}/#{ip}" unless ip.nil?
46
46
  url
47
47
  end
48
48
 
49
49
  def post_ip_to_pool(pool_name, ip, &block)
50
- resp = post(
51
- @auth,
52
- SendGrid4r::REST::Ips::Pools.url(pool_name, 'ips'),
53
- ip: ip,
54
- &block
55
- )
50
+ endpoint = SendGrid4r::REST::Ips::Pools.url(pool_name, 'ips')
51
+ resp = post(@auth, endpoint, ip: ip, &block)
56
52
  SendGrid4r::REST::Ips::Addresses.create_address(resp)
57
53
  end
58
54
 
@@ -62,25 +58,20 @@ module SendGrid4r
62
58
  end
63
59
 
64
60
  def get_ips_assigned(&block)
65
- resp = get(
66
- @auth, SendGrid4r::REST::Ips::Addresses.url('assigned'), &block
67
- )
61
+ endpoint = SendGrid4r::REST::Ips::Addresses.url('assigned')
62
+ resp = get(@auth, endpoint, &block)
68
63
  SendGrid4r::REST::Ips::Addresses.create_addresses(resp)
69
64
  end
70
65
 
71
66
  def get_ip(ip, &block)
72
- resp = get(
73
- @auth, SendGrid4r::REST::Ips::Addresses.url(ip), &block
74
- )
67
+ endpoint = SendGrid4r::REST::Ips::Addresses.url(ip)
68
+ resp = get(@auth, endpoint, &block)
75
69
  SendGrid4r::REST::Ips::Addresses.create_address(resp)
76
70
  end
77
71
 
78
72
  def delete_ip_from_pool(pool_name, ip, &block)
79
- delete(
80
- @auth,
81
- SendGrid4r::REST::Ips::Pools.url(pool_name, 'ips', ip),
82
- &block
83
- )
73
+ endpoint = SendGrid4r::REST::Ips::Pools.url(pool_name, 'ips', ip)
74
+ delete(@auth, endpoint, &block)
84
75
  end
85
76
  end
86
77
  end
@@ -34,7 +34,7 @@ module SendGrid4r
34
34
  end
35
35
 
36
36
  def self.url(name = nil, ips = nil, ip = nil)
37
- url = "#{SendGrid4r::Client::BASE_URL}/ips/pools"
37
+ url = "#{BASE_URL}/ips/pools"
38
38
  url = "#{url}/#{name}" unless name.nil?
39
39
  url = "#{url}/#{ips}" unless ips.nil?
40
40
  url = "#{url}/#{ip}" unless ip.nil?
@@ -42,9 +42,8 @@ module SendGrid4r
42
42
  end
43
43
 
44
44
  def post_pool(name, &block)
45
- resp = post(
46
- @auth, SendGrid4r::REST::Ips::Pools.url, name: name, &block
47
- )
45
+ endpoint = SendGrid4r::REST::Ips::Pools.url
46
+ resp = post(@auth, endpoint, name: name, &block)
48
47
  SendGrid4r::REST::Ips::Pools.create_pool(resp)
49
48
  end
50
49
 
@@ -54,18 +53,14 @@ module SendGrid4r
54
53
  end
55
54
 
56
55
  def get_pool(name, &block)
57
- resp = get(
58
- @auth, SendGrid4r::REST::Ips::Pools.url(name), &block
59
- )
56
+ endpoint = SendGrid4r::REST::Ips::Pools.url(name)
57
+ resp = get(@auth, endpoint, &block)
60
58
  SendGrid4r::REST::Ips::Pools.create_pool(resp)
61
59
  end
62
60
 
63
61
  def put_pool(name, new_name, &block)
64
- resp = put(
65
- @auth,
66
- SendGrid4r::REST::Ips::Pools.url(name),
67
- name: new_name,
68
- &block)
62
+ endpoint = SendGrid4r::REST::Ips::Pools.url(name)
63
+ resp = put(@auth, endpoint, name: new_name, &block)
69
64
  SendGrid4r::REST::Ips::Pools.create_pool(resp)
70
65
  end
71
66
 
@@ -32,7 +32,7 @@ module SendGrid4r
32
32
  end
33
33
 
34
34
  def self.url(ip_address = nil)
35
- url = "#{SendGrid4r::Client::BASE_URL}/ips/warmup"
35
+ url = "#{BASE_URL}/ips/warmup"
36
36
  url = "#{url}/#{ip_address}" unless ip_address.nil?
37
37
  url
38
38
  end
@@ -43,30 +43,20 @@ module SendGrid4r
43
43
  end
44
44
 
45
45
  def get_warmup_ip(ip_address, &block)
46
- resp = get(
47
- @auth,
48
- SendGrid4r::REST::Ips::Warmup.url(ip_address),
49
- &block
50
- )
46
+ endpoint = SendGrid4r::REST::Ips::Warmup.url(ip_address)
47
+ resp = get(@auth, endpoint, &block)
51
48
  SendGrid4r::REST::Ips::Warmup.create_warmup_ip(resp)
52
49
  end
53
50
 
54
51
  def post_warmup_ip(ip_address, &block)
55
- resp = post(
56
- @auth,
57
- SendGrid4r::REST::Ips::Warmup.url,
58
- ip: ip_address,
59
- &block
60
- )
52
+ endpoint = SendGrid4r::REST::Ips::Warmup.url
53
+ resp = post(@auth, endpoint, ip: ip_address, &block)
61
54
  SendGrid4r::REST::Ips::Warmup.create_warmup_ip(resp)
62
55
  end
63
56
 
64
57
  def delete_warmup_ip(ip_address, &block)
65
- delete(
66
- @auth,
67
- SendGrid4r::REST::Ips::Warmup.url(ip_address),
68
- &block
69
- )
58
+ endpoint = SendGrid4r::REST::Ips::Warmup.url(ip_address)
59
+ delete(@auth, endpoint, &block)
70
60
  end
71
61
  end
72
62
  end
@@ -11,6 +11,8 @@ module SendGrid4r
11
11
  # SendGrid Web API v3 Request
12
12
  #
13
13
  module Request
14
+ BASE_URL = 'https://api.sendgrid.com/v3'
15
+
14
16
  def get(auth, endpoint, params = nil, payload = nil, &block)
15
17
  execute(:get, auth, endpoint, params, payload, &block)
16
18
  end
@@ -67,11 +69,15 @@ module SendGrid4r
67
69
  endpoint
68
70
  else
69
71
  query_string = params.collect do |k, v|
70
- "#{k}=#{CGI.escape(v.to_s)}"
72
+ "#{k}=#{CGI.escape(process_array_params(v))}"
71
73
  end.join('&')
72
74
  endpoint + "?#{query_string}"
73
75
  end
74
76
  end
77
+
78
+ def process_array_params(v)
79
+ v.is_a?(Array) ? v.join(',') : v.to_s
80
+ end
75
81
  end
76
82
  end
77
83
  end
@@ -19,25 +19,18 @@ module SendGrid4r
19
19
  end
20
20
 
21
21
  def self.url
22
- "#{SendGrid4r::Client::BASE_URL}/user/settings/enforced_tls"
22
+ "#{BASE_URL}/user/settings/enforced_tls"
23
23
  end
24
24
 
25
25
  def get_enforced_tls(&block)
26
- resp = get(
27
- @auth,
28
- SendGrid4r::REST::Settings::EnforcedTls.url,
29
- &block
30
- )
26
+ endpoint = SendGrid4r::REST::Settings::EnforcedTls.url
27
+ resp = get(@auth, endpoint, &block)
31
28
  SendGrid4r::REST::Settings::EnforcedTls.create_enforced_tls(resp)
32
29
  end
33
30
 
34
31
  def patch_enforced_tls(params, &block)
35
- resp = patch(
36
- @auth,
37
- SendGrid4r::REST::Settings::EnforcedTls.url,
38
- params.to_h,
39
- &block
40
- )
32
+ endpoint = SendGrid4r::REST::Settings::EnforcedTls.url
33
+ resp = patch(@auth, endpoint, params.to_h, &block)
41
34
  SendGrid4r::REST::Settings::EnforcedTls.create_enforced_tls(resp)
42
35
  end
43
36
  end
@@ -10,6 +10,8 @@ module SendGrid4r
10
10
  # SendGrid Web API v3 Stats - Advanced
11
11
  #
12
12
  module Advanced
13
+ include SendGrid4r::REST::Request
14
+
13
15
  def get_geo_stats(
14
16
  start_date:,
15
17
  end_date: nil,
@@ -23,8 +25,7 @@ module SendGrid4r
23
25
  aggregated_by: aggregated_by,
24
26
  country: country
25
27
  }
26
- resp = get(
27
- @auth, "#{SendGrid4r::Client::BASE_URL}/geo/stats", params, &block)
28
+ resp = get(@auth, "#{BASE_URL}/geo/stats", params, &block)
28
29
  SendGrid4r::REST::Stats.create_top_stats(resp)
29
30
  end
30
31
 
@@ -39,12 +40,7 @@ module SendGrid4r
39
40
  end_date: end_date,
40
41
  aggregated_by: aggregated_by
41
42
  }
42
- resp = get(
43
- @auth,
44
- "#{SendGrid4r::Client::BASE_URL}/devices/stats",
45
- params,
46
- &block
47
- )
43
+ resp = get(@auth, "#{BASE_URL}/devices/stats", params, &block)
48
44
  SendGrid4r::REST::Stats.create_top_stats(resp)
49
45
  end
50
46
 
@@ -59,12 +55,7 @@ module SendGrid4r
59
55
  end_date: end_date,
60
56
  aggregated_by: aggregated_by
61
57
  }
62
- resp = get(
63
- @auth,
64
- "#{SendGrid4r::Client::BASE_URL}/clients/stats",
65
- params,
66
- &block
67
- )
58
+ resp = get(@auth, "#{BASE_URL}/clients/stats", params, &block)
68
59
  SendGrid4r::REST::Stats.create_top_stats(resp)
69
60
  end
70
61
 
@@ -81,12 +72,8 @@ module SendGrid4r
81
72
  aggregated_by: aggregated_by,
82
73
  client_type: client_type
83
74
  }
84
- resp = get(
85
- @auth,
86
- "#{SendGrid4r::Client::BASE_URL}/clients/#{client_type}/stats",
87
- params,
88
- &block
89
- )
75
+ endpoint = "#{BASE_URL}/clients/#{client_type}/stats"
76
+ resp = get(@auth, endpoint, params, &block)
90
77
  SendGrid4r::REST::Stats.create_top_stats(resp)
91
78
  end
92
79
 
@@ -103,12 +90,8 @@ module SendGrid4r
103
90
  aggregated_by: aggregated_by,
104
91
  esps: esps
105
92
  }
106
- resp = get(
107
- @auth,
108
- "#{SendGrid4r::Client::BASE_URL}/mailbox_providers/stats",
109
- params,
110
- &block
111
- )
93
+ endpoint = "#{BASE_URL}/mailbox_providers/stats"
94
+ resp = get(@auth, endpoint, params, &block)
112
95
  SendGrid4r::REST::Stats.create_top_stats(resp)
113
96
  end
114
97
 
@@ -125,12 +108,7 @@ module SendGrid4r
125
108
  aggregated_by: aggregated_by,
126
109
  browsers: browsers
127
110
  }
128
- resp = get(
129
- @auth,
130
- "#{SendGrid4r::Client::BASE_URL}/browsers/stats",
131
- params,
132
- &block
133
- )
111
+ resp = get(@auth, "#{BASE_URL}/browsers/stats", params, &block)
134
112
  SendGrid4r::REST::Stats.create_top_stats(resp)
135
113
  end
136
114
  end
@@ -10,6 +10,8 @@ module SendGrid4r
10
10
  # SendGrid Web API v3 Stats - Category
11
11
  #
12
12
  module Category
13
+ include SendGrid4r::REST::Request
14
+
13
15
  def get_categories_stats(
14
16
  start_date:, end_date: nil, aggregated_by: nil, categories:, &block)
15
17
  params = {
@@ -18,12 +20,7 @@ module SendGrid4r
18
20
  aggregated_by: aggregated_by,
19
21
  categories: categories
20
22
  }
21
- resp = get(
22
- @auth,
23
- "#{SendGrid4r::Client::BASE_URL}/categories/stats",
24
- params,
25
- &block
26
- )
23
+ resp = get(@auth, "#{BASE_URL}/categories/stats", params, &block)
27
24
  SendGrid4r::REST::Stats.create_top_stats(resp)
28
25
  end
29
26
 
@@ -38,11 +35,7 @@ module SendGrid4r
38
35
  limit: limit,
39
36
  offset: offset
40
37
  }
41
- resp = get(
42
- @auth,
43
- "#{SendGrid4r::Client::BASE_URL}/categories/stats/sums",
44
- params,
45
- &block)
38
+ resp = get(@auth, "#{BASE_URL}/categories/stats/sums", params, &block)
46
39
  SendGrid4r::REST::Stats.create_top_stat(resp)
47
40
  end
48
41
  end
@@ -10,6 +10,8 @@ module SendGrid4r
10
10
  # SendGrid Web API v3 Stats - Global
11
11
  #
12
12
  module Global
13
+ include SendGrid4r::REST::Request
14
+
13
15
  def get_global_stats(
14
16
  start_date:, end_date: nil, aggregated_by: nil, &block
15
17
  )
@@ -18,8 +20,7 @@ module SendGrid4r
18
20
  end_date: end_date,
19
21
  aggregated_by: aggregated_by
20
22
  }
21
- resp = get(
22
- @auth, "#{SendGrid4r::Client::BASE_URL}/stats", params, &block)
23
+ resp = get(@auth, "#{BASE_URL}/stats", params, &block)
23
24
  SendGrid4r::REST::Stats.create_top_stats(resp)
24
25
  end
25
26
  end
@@ -10,6 +10,8 @@ module SendGrid4r
10
10
  # SendGrid Web API v3 Stats - Parse
11
11
  #
12
12
  module Parse
13
+ include SendGrid4r::REST::Request
14
+
13
15
  def get_parse_stats(
14
16
  start_date:, end_date: nil, aggregated_by: nil, &block
15
17
  )
@@ -18,12 +20,8 @@ module SendGrid4r
18
20
  end_date: end_date,
19
21
  aggregated_by: aggregated_by
20
22
  }
21
- resp = get(
22
- @auth,
23
- "#{SendGrid4r::Client::BASE_URL}/user/webhooks/parse/stats",
24
- params,
25
- &block
26
- )
23
+ endpoint = "#{BASE_URL}/user/webhooks/parse/stats"
24
+ resp = get(@auth, endpoint, params, &block)
27
25
  SendGrid4r::REST::Stats.create_top_stats(resp)
28
26
  end
29
27
  end
@@ -10,6 +10,8 @@ module SendGrid4r
10
10
  # SendGrid Web API v3 Stats - Subuser
11
11
  #
12
12
  module Subuser
13
+ include SendGrid4r::REST::Request
14
+
13
15
  def get_subusers_stats(
14
16
  start_date:, end_date: nil, aggregated_by: nil, subusers:, &block)
15
17
  params = {
@@ -18,11 +20,7 @@ module SendGrid4r
18
20
  aggregated_by: aggregated_by,
19
21
  subusers: subusers
20
22
  }
21
- resp = get(
22
- @auth,
23
- "#{SendGrid4r::Client::BASE_URL}/subusers/stats",
24
- params,
25
- &block)
23
+ resp = get(@auth, "#{BASE_URL}/subusers/stats", params, &block)
26
24
  SendGrid4r::REST::Stats.create_top_stats(resp)
27
25
  end
28
26
 
@@ -37,12 +35,7 @@ module SendGrid4r
37
35
  limit: limit,
38
36
  offset: offset
39
37
  }
40
- resp = get(
41
- @auth,
42
- "#{SendGrid4r::Client::BASE_URL}/subusers/stats/sums",
43
- params,
44
- &block
45
- )
38
+ resp = get(@auth, "#{BASE_URL}/subusers/stats/sums", params, &block)
46
39
  SendGrid4r::REST::Stats.create_top_stat(resp)
47
40
  end
48
41
  end
@@ -0,0 +1,83 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'sendgrid4r/rest/request'
5
+
6
+ module SendGrid4r
7
+ module REST
8
+ #
9
+ # SendGrid Web API v3 Subusers
10
+ #
11
+ module Subusers
12
+ include SendGrid4r::REST::Request
13
+
14
+ Subuser = Struct.new(
15
+ :id, :username, :email, :password, :ips, :reputation, :disabled
16
+ )
17
+ Ips = Struct.new(:ips)
18
+
19
+ def self.url(subuser_name = nil)
20
+ url = "#{BASE_URL}/subusers"
21
+ url = "#{url}/#{subuser_name}" unless subuser_name.nil?
22
+ url
23
+ end
24
+
25
+ def self.create_subusers(resp)
26
+ return resp if resp.nil?
27
+ subusers = []
28
+ resp.each do |subuser|
29
+ subusers.push(SendGrid4r::REST::Subusers.create_subuser(subuser))
30
+ end
31
+ subusers
32
+ end
33
+
34
+ def self.create_subuser(resp)
35
+ return resp if resp.nil?
36
+ Subuser.new(
37
+ resp['id'],
38
+ resp['username'],
39
+ resp['email'],
40
+ resp['password'],
41
+ resp['ips'],
42
+ resp['reputation'],
43
+ resp['disabled']
44
+ )
45
+ end
46
+
47
+ def get_subusers(limit: nil, offset: nil, username: nil, &block)
48
+ params = {}
49
+ params['limit'] = limit unless limit.nil?
50
+ params['offset'] = offset unless offset.nil?
51
+ params['username'] = username unless username.nil?
52
+ resp = get(@auth, SendGrid4r::REST::Subusers.url, params, &block)
53
+ SendGrid4r::REST::Subusers.create_subusers(resp)
54
+ end
55
+
56
+ def post_subuser(username:, email:, password:, ips:, &block)
57
+ params = {}
58
+ params['username'] = username
59
+ params['email'] = email
60
+ params['password'] = password
61
+ params['ips'] = ips
62
+ resp = post(@auth, SendGrid4r::REST::Subusers.url, params, &block)
63
+ SendGrid4r::REST::Subusers.create_subuser(resp)
64
+ end
65
+
66
+ def get_subuser_reputation(usernames:, &block)
67
+ params = ''
68
+ usernames.each do |username|
69
+ params += "usernames=#{username}&"
70
+ end
71
+ endpoint = "#{SendGrid4r::REST::Subusers.url}/reputations?#{params}"
72
+ resp = get(@auth, endpoint, usernames, &block)
73
+ SendGrid4r::REST::Subusers.create_subusers(resp)
74
+ end
75
+
76
+ def put_subuser_assigned_ips(username:, &block)
77
+ endpoint = "#{SendGrid4r::REST::Subusers.url(username)}/ips"
78
+ resp = put(@auth, endpoint, nil, &block)
79
+ SendGrid4r::REST::Subusers.create_subuser(resp)
80
+ end
81
+ end
82
+ end
83
+ end
@@ -16,7 +16,7 @@ module SendGrid4r
16
16
  Template = Struct.new(:id, :name, :versions)
17
17
 
18
18
  def self.url(temp_id = nil)
19
- url = "#{SendGrid4r::Client::BASE_URL}/templates"
19
+ url = "#{BASE_URL}/templates"
20
20
  url = "#{url}/#{temp_id}" unless temp_id.nil?
21
21
  url
22
22
  end
@@ -34,15 +34,16 @@ module SendGrid4r
34
34
  end
35
35
 
36
36
  def self.url(temp_id, ver_id = nil)
37
- url = "#{SendGrid4r::Client::BASE_URL}/templates/#{temp_id}/versions"
37
+ url = "#{BASE_URL}/templates/#{temp_id}/versions"
38
38
  url = "#{url}/#{ver_id}" unless ver_id.nil?
39
39
  url
40
40
  end
41
41
 
42
42
  def post_version(temp_id, version, &block)
43
+ endpoint = SendGrid4r::REST::Templates::Versions.url(temp_id)
43
44
  resp = post(
44
45
  @auth,
45
- SendGrid4r::REST::Templates::Versions.url(temp_id),
46
+ endpoint,
46
47
  remove_uneditable_keys(version.to_h),
47
48
  &block
48
49
  )
@@ -2,5 +2,5 @@
2
2
  # SendGrid API v3 wrapper implementation.
3
3
  #
4
4
  module SendGrid4r
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
6
6
  end
data/spec/client_spec.rb CHANGED
@@ -6,21 +6,34 @@ describe SendGrid4r::Client do
6
6
  Dotenv.load
7
7
  end
8
8
 
9
- context 'always' do
10
- before :all do
9
+ describe 'unit test', :ut do
10
+ before do
11
11
  @client = SendGrid4r::Client.new(
12
12
  username: 'username',
13
13
  password: 'password')
14
14
  end
15
15
 
16
16
  describe '#initialize' do
17
- it 'create instance' do
17
+ it 'create instance with username and password' do
18
+ @client = SendGrid4r::Client.new(
19
+ username: 'username',
20
+ password: 'password')
21
+ expect(@client.class).to eq(SendGrid4r::Client)
22
+ end
23
+
24
+ it 'create instance with apikey' do
25
+ @client = SendGrid4r::Client.new(api_key: 'api_key')
18
26
  expect(@client.class).to eq(SendGrid4r::Client)
19
27
  end
20
28
  end
21
29
 
22
30
  describe 'methods' do
23
31
  it 'available' do
32
+ # Subusers
33
+ expect(@client.respond_to?('get_subusers')).to eq(true)
34
+ expect(@client.respond_to?('post_subuser')).to eq(true)
35
+ expect(@client.respond_to?('get_subuser_reputation')).to eq(true)
36
+ expect(@client.respond_to?('put_subuser_assigned_ips')).to eq(true)
24
37
  # Api Keys
25
38
  expect(@client.respond_to?('get_api_keys')).to eq(true)
26
39
  expect(@client.respond_to?('post_api_key')).to eq(true)
@@ -136,7 +149,7 @@ describe SendGrid4r::Client do
136
149
 
137
150
  describe 'VERSION' do
138
151
  it 'returns VERSION value' do
139
- expect(SendGrid4r::VERSION).to eq('0.3.0')
152
+ expect(SendGrid4r::VERSION).to eq('0.4.0')
140
153
  end
141
154
  end
142
155
  end
@@ -2,7 +2,7 @@
2
2
  require File.dirname(__FILE__) + '/../spec_helper'
3
3
 
4
4
  describe SendGrid4r::Factory::ConditionFactory do
5
- describe 'unit test' do
5
+ describe 'unit test', :ut do
6
6
  before do
7
7
  Dotenv.load
8
8
  @factory = SendGrid4r::Factory::ConditionFactory.new
@@ -2,7 +2,7 @@
2
2
  require File.dirname(__FILE__) + '/../spec_helper'
3
3
 
4
4
  describe SendGrid4r::Factory::SegmentFactory do
5
- describe 'unit test' do
5
+ describe 'unit test', :ut do
6
6
  before do
7
7
  Dotenv.load
8
8
  @segment_factory = SendGrid4r::Factory::SegmentFactory.new
@@ -2,7 +2,7 @@
2
2
  require File.dirname(__FILE__) + '/../spec_helper'
3
3
 
4
4
  describe SendGrid4r::Factory::VersionFactory do
5
- describe 'unit test' do
5
+ describe 'unit test', :ut do
6
6
  before do
7
7
  Dotenv.load
8
8
  @factory = SendGrid4r::Factory::VersionFactory.new