sendgrid4r 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.env.example +5 -0
  3. data/.rubocop.yml +8 -8
  4. data/README.md +2 -0
  5. data/lib/auth.rb +5 -2
  6. data/lib/client.rb +4 -2
  7. data/lib/sendgrid4r/factory/version_factory.rb +1 -1
  8. data/lib/sendgrid4r/rest/api.rb +4 -0
  9. data/lib/sendgrid4r/rest/api_keys/api_keys.rb +73 -0
  10. data/lib/sendgrid4r/rest/asm/asm.rb +28 -0
  11. data/lib/sendgrid4r/rest/asm/global_suppressions.rb +12 -8
  12. data/lib/sendgrid4r/rest/asm/groups.rb +29 -22
  13. data/lib/sendgrid4r/rest/asm/suppressions.rb +25 -15
  14. data/lib/sendgrid4r/rest/categories/categories.rb +19 -9
  15. data/lib/sendgrid4r/rest/contacts/custom_fields.rb +14 -8
  16. data/lib/sendgrid4r/rest/contacts/lists.rb +32 -20
  17. data/lib/sendgrid4r/rest/contacts/recipients.rb +42 -31
  18. data/lib/sendgrid4r/rest/contacts/reserved_fields.rb +6 -2
  19. data/lib/sendgrid4r/rest/contacts/segments.rb +22 -12
  20. data/lib/sendgrid4r/rest/ips/addresses.rb +36 -22
  21. data/lib/sendgrid4r/rest/ips/pools.rb +31 -16
  22. data/lib/sendgrid4r/rest/ips/warmup.rb +34 -15
  23. data/lib/sendgrid4r/rest/request.rb +33 -19
  24. data/lib/sendgrid4r/rest/settings/enforced_tls.rb +12 -5
  25. data/lib/sendgrid4r/rest/stats/advanced.rb +73 -25
  26. data/lib/sendgrid4r/rest/stats/category.rb +11 -6
  27. data/lib/sendgrid4r/rest/stats/global.rb +6 -4
  28. data/lib/sendgrid4r/rest/stats/parse.rb +10 -4
  29. data/lib/sendgrid4r/rest/stats/stats.rb +13 -18
  30. data/lib/sendgrid4r/rest/stats/subuser.rb +10 -6
  31. data/lib/sendgrid4r/rest/templates/templates.rb +23 -16
  32. data/lib/sendgrid4r/rest/templates/versions.rb +39 -36
  33. data/lib/sendgrid4r/version.rb +1 -1
  34. data/spec/api_keys/api_keys_spec.rb +152 -0
  35. data/spec/asm/asm_spec.rb +33 -0
  36. data/spec/asm/global_suppressions_spec.rb +111 -45
  37. data/spec/asm/groups_spec.rb +172 -48
  38. data/spec/asm/suppressions_spec.rb +180 -54
  39. data/spec/categories/categories_spec.rb +81 -25
  40. data/spec/client_spec.rb +11 -4
  41. data/spec/contacts/custom_fields_spec.rb +135 -44
  42. data/spec/contacts/lists_spec.rb +314 -84
  43. data/spec/contacts/recipients_spec.rb +337 -92
  44. data/spec/contacts/reserved_fields_spec.rb +80 -60
  45. data/spec/contacts/segments_spec.rb +219 -88
  46. data/spec/factory/condition_factory_spec.rb +12 -12
  47. data/spec/factory/segment_factory_spec.rb +19 -19
  48. data/spec/factory/version_factory_spec.rb +6 -6
  49. data/spec/ips/addresses_spec.rb +177 -84
  50. data/spec/ips/pools_spec.rb +190 -34
  51. data/spec/ips/warmup_spec.rb +106 -38
  52. data/spec/settings/enforced_tls_spec.rb +76 -18
  53. data/spec/stats/advanced_spec.rb +373 -196
  54. data/spec/stats/category_spec.rb +133 -71
  55. data/spec/stats/global_spec.rb +74 -47
  56. data/spec/stats/parse_spec.rb +46 -29
  57. data/spec/stats/stats_spec.rb +246 -0
  58. data/spec/stats/subuser_spec.rb +99 -54
  59. data/spec/templates/templates_spec.rb +219 -54
  60. data/spec/templates/versions_spec.rb +171 -67
  61. metadata +10 -2
@@ -1,66 +1,231 @@
1
1
  # encoding: utf-8
2
2
  require File.dirname(__FILE__) + '/../spec_helper'
3
3
 
4
- describe 'SendGrid4r::REST::Templates' do
5
- before :all do
6
- Dotenv.load
7
- @client = SendGrid4r::Client.new(
8
- ENV['SENDGRID_USERNAME'], ENV['SENDGRID_PASSWORD']
9
- )
10
- @template_name = 'template_test'
11
- @template_edit = 'template_edit'
12
- end
4
+ describe SendGrid4r::REST::Templates do
5
+ describe 'integration test' do
6
+ before do
7
+ begin
8
+ Dotenv.load
9
+ @client = SendGrid4r::Client.new(
10
+ username: ENV['SENDGRID_USERNAME'],
11
+ password: ENV['SENDGRID_PASSWORD'])
12
+ @template_name1 = 'template_test1'
13
+ @template_name2 = 'template_test2'
14
+ @template_edit1 = 'template_edit1'
15
+
16
+ # celan up test env
17
+ tmps = @client.get_templates
18
+ tmps.templates.each do |tmp|
19
+ @client.delete_template(tmp.id) if tmp.name == @template_name1
20
+ @client.delete_template(tmp.id) if tmp.name == @template_name2
21
+ @client.delete_template(tmp.id) if tmp.name == @template_edit1
22
+ end
23
+ # post a template
24
+ @template1 = @client.post_template(@template_name1)
25
+ rescue => e
26
+ puts e.inspect
27
+ raise e
28
+ end
29
+ end
13
30
 
14
- context 'always' do
15
- it 'is normal' do
16
- # celan up test env
17
- tmps = @client.get_templates
18
- expect(tmps.length >= 0).to eq(true)
19
- tmps.each do |tmp|
20
- if tmp.name == @template_name || tmp.name == @template_edit
21
- @client.delete_template(tmp.id)
31
+ context 'without block call' do
32
+ it '#post_template' do
33
+ begin
34
+ new_template = @client.post_template(@template_name2)
35
+ expect(new_template.id).to be_a(String)
36
+ expect(new_template.name).to eq(@template_name2)
37
+ expect(new_template.versions).to be_a(Array)
38
+ rescue => e
39
+ puts e.inspect
40
+ raise e
22
41
  end
23
42
  end
24
- # post a template
25
- new_template = @client.post_template(@template_name)
26
- expect(@template_name).to eq(new_template.name)
27
- expect([]).to eq(new_template.versions)
28
- # get all templates
29
- tmps = @client.get_templates
30
- tmps.each do |tmp|
31
- expect(false).to eq(tmp.id.nil?)
32
- expect(false).to eq(tmp.name.nil?)
33
- expect(true).to eq(tmp.versions.is_a?(Array))
34
- tmp.versions.each do |ver|
35
- expect(false).to eq(ver.id.nil?)
36
- expect(false).to eq(ver.template_id.nil?)
37
- expect(false).to eq(ver.active.nil?)
38
- expect(false).to eq(ver.name.nil?)
39
- expect(false).to eq(ver.updated_at.nil?)
43
+
44
+ it '#get_templates' do
45
+ begin
46
+ tmps = @client.get_templates
47
+ tmps.templates.each do |tmp|
48
+ expect(tmp.id).to be_a(String)
49
+ expect(tmp.name).to be_a(String)
50
+ expect(tmp.versions).to be_a(Array)
51
+ tmp.versions.each do |ver|
52
+ expect(ver.id).to be_a(String)
53
+ expect(ver.template_id).to be_a(String)
54
+ expect(ver.active).to be_a(Fixnum)
55
+ expect(ver.name).to be_a(String)
56
+ expect(ver.updated_at).to be_a(String)
57
+ end
58
+ end
59
+ rescue => e
60
+ puts e.inspect
61
+ raise e
62
+ end
63
+ end
64
+
65
+ it '#patch_template' do
66
+ begin
67
+ tmp = @client.patch_template(@template1.id, @template_edit1)
68
+ expect(tmp.id).to be_a(String)
69
+ expect(tmp.name).to be_a(String)
70
+ expect(tmp.versions).to be_a(Array)
71
+ tmp.versions.each do |ver|
72
+ expect(ver.id).to be_a(String)
73
+ expect(ver.template_id).to be_a(String)
74
+ expect(ver.active).to be_a(Fixnum)
75
+ expect(ver.name).to be_a(String)
76
+ expect(ver.updated_at).to be_a(String)
77
+ end
78
+ rescue => e
79
+ puts e.inspect
80
+ raise e
81
+ end
82
+ end
83
+
84
+ it '#get_template' do
85
+ begin
86
+ tmp = @client.get_template(@template1.id)
87
+ expect(tmp.id).to eq(@template1.id)
88
+ expect(tmp.versions).to eq(@template1.versions)
89
+ rescue => e
90
+ puts e.inspect
91
+ raise e
92
+ end
93
+ end
94
+
95
+ it '#delete_template' do
96
+ begin
97
+ @client.delete_template(@template1.id)
98
+ rescue => e
99
+ puts e.inspect
100
+ raise e
101
+ end
102
+ end
103
+ end
104
+
105
+ context 'with block call' do
106
+ it '#post_template' do
107
+ @client.post_template(@template_name2) do |resp, req, res|
108
+ resp =
109
+ SendGrid4r::REST::Templates.create_template(
110
+ JSON.parse(resp)
111
+ )
112
+ expect(resp).to be_a(SendGrid4r::REST::Templates::Template)
113
+ expect(req).to be_a(RestClient::Request)
114
+ expect(res).to be_a(Net::HTTPCreated)
40
115
  end
41
116
  end
42
- # pach the template
43
- edit_template = @client.patch_template(new_template.id, @template_edit)
44
- expect(false).to eq(edit_template.id.nil?)
45
- expect(false).to eq(edit_template.name.nil?)
46
- expect(true).to eq(edit_template.versions.is_a?(Array))
47
- edit_template.versions.each do |ver|
48
- expect(false).to eq(ver.id.nil?)
49
- expect(false).to eq(ver.template_id.nil?)
50
- expect(false).to eq(ver.active.nil?)
51
- expect(false).to eq(ver.name.nil?)
52
- expect(false).to eq(ver.updated_at.nil?)
117
+
118
+ it '#get_templates' do
119
+ @client.get_templates do |resp, req, res|
120
+ resp =
121
+ SendGrid4r::REST::Templates.create_templates(
122
+ JSON.parse(resp)
123
+ )
124
+ expect(resp).to be_a(SendGrid4r::REST::Templates::Templates)
125
+ expect(req).to be_a(RestClient::Request)
126
+ expect(res).to be_a(Net::HTTPOK)
127
+ end
128
+ end
129
+
130
+ it '#get_template' do
131
+ @client.get_template(@template1.id) do |resp, req, res|
132
+ resp =
133
+ SendGrid4r::REST::Templates.create_template(
134
+ JSON.parse(resp)
135
+ )
136
+ expect(resp).to be_a(SendGrid4r::REST::Templates::Template)
137
+ expect(req).to be_a(RestClient::Request)
138
+ expect(res).to be_a(Net::HTTPOK)
139
+ end
140
+ end
141
+
142
+ it '#patch_template' do
143
+ @client.patch_template(
144
+ @template1.id, @template_edit1
145
+ ) do |resp, req, res|
146
+ resp =
147
+ SendGrid4r::REST::Templates.create_template(
148
+ JSON.parse(resp)
149
+ )
150
+ expect(resp).to be_a(SendGrid4r::REST::Templates::Template)
151
+ expect(req).to be_a(RestClient::Request)
152
+ expect(res).to be_a(Net::HTTPOK)
153
+ end
154
+ end
155
+
156
+ it '#delete_template' do
157
+ @client.delete_template(@template1.id) do |resp, req, res|
158
+ expect(resp).to eq('')
159
+ expect(req).to be_a(RestClient::Request)
160
+ expect(res).to be_a(Net::HTTPNoContent)
161
+ end
162
+ end
163
+ end
164
+ end
165
+
166
+ describe 'unit test' do
167
+ it 'creates template instance' do
168
+ json =
169
+ '{'\
170
+ '"id": "733ba07f-ead1-41fc-933a-3976baa23716",'\
171
+ '"name": "example_name",'\
172
+ '"versions": []'\
173
+ '}'
174
+ hash = JSON.parse(json)
175
+ actual = SendGrid4r::REST::Templates.create_template(hash)
176
+ expect(actual).to be_a(SendGrid4r::REST::Templates::Template)
177
+ expect(actual.id).to eq('733ba07f-ead1-41fc-933a-3976baa23716')
178
+ expect(actual.name).to eq('example_name')
179
+ expect(actual.versions).to be_a(Array)
180
+ end
181
+
182
+ it 'creates templates instance' do
183
+ json =
184
+ '{'\
185
+ '"templates": ['\
186
+ '{'\
187
+ '"id": "e8ac01d5-a07a-4a71-b14c-4721136fe6aa",'\
188
+ '"name": "example template name",'\
189
+ '"versions": ['\
190
+ '{'\
191
+ '"id": "de37d11b-082a-42c0-9884-c0c143015a47",'\
192
+ '"user_id": 1234,'\
193
+ '"template_id": "d51480ba-ca3f-465c-bc3e-ceb71d73c38d",'\
194
+ '"active": 1,'\
195
+ '"name": "example version",'\
196
+ '"html_content": "<%body%><strong>Click to Reset</strong>",'\
197
+ '"plain_content": "Click to Reset<%body%>",'\
198
+ '"subject": "<%subject%>",'\
199
+ '"updated_at": "2014-05-22 20:05:21"'\
200
+ '}'\
201
+ ']'\
202
+ '}'\
203
+ ']'\
204
+ '}'
205
+ hash = JSON.parse(json)
206
+ actual = SendGrid4r::REST::Templates.create_templates(hash)
207
+ expect(actual).to be_a(SendGrid4r::REST::Templates::Templates)
208
+ expect(actual.templates).to be_a(Array)
209
+ actual.templates.each do |template|
210
+ expect(template.id).to eq('e8ac01d5-a07a-4a71-b14c-4721136fe6aa')
211
+ expect(template.name).to eq('example template name')
212
+ expect(template.versions).to be_a(Array)
213
+ template.versions do |version|
214
+ expect(version.id).to eq('de37d11b-082a-42c0-9884-c0c143015a47')
215
+ expect(version.user_id).to eq(1234)
216
+ expect(version.template_id).to eq(
217
+ 'd51480ba-ca3f-465c-bc3e-ceb71d73c38d'
218
+ )
219
+ expect(version.active).to eq(1)
220
+ expect(version.name).to eq('example version')
221
+ expect(version.html_content).to eq(
222
+ '<%body%><strong>Click to Reset</strong>'
223
+ )
224
+ expect(version.plain_content).to eq('Click to Reset<%body%>')
225
+ expect(version.subject).to eq('<%subject%>')
226
+ expect(version.updated_at).to eq('2014-05-22 20:05:21')
227
+ end
53
228
  end
54
- # get the template
55
- edit_template = @client.get_template(new_template.id)
56
- expect(new_template.id).to eq(edit_template.id)
57
- expect(@template_edit).to eq(edit_template.name)
58
- expect(new_template.versions).to eq(edit_template.versions)
59
- # delete the template
60
- @client.delete_template(edit_template.id)
61
- expect do
62
- @client.get_template(edit_template.id)
63
- end.to raise_error(RestClient::ResourceNotFound)
64
229
  end
65
230
  end
66
231
  end
@@ -1,89 +1,193 @@
1
1
  # encoding: utf-8
2
2
  require File.dirname(__FILE__) + '/../spec_helper'
3
3
 
4
- describe 'SendGrid4r::REST::Templates::Versions' do
5
- before :all do
6
- Dotenv.load
7
- @client = SendGrid4r::Client.new(
8
- ENV['SENDGRID_USERNAME'], ENV['SENDGRID_PASSWORD']
9
- )
10
- @template_edit = 'version_test'
11
- @version1_name = 'version1_test'
12
- @version2_name = 'version2_test'
13
- end
14
-
15
- context 'always' do
16
- it 'is normal' do
4
+ describe SendGrid4r::REST::Templates::Versions do
5
+ describe 'integration test' do
6
+ before do
17
7
  begin
8
+ Dotenv.load
9
+ @client = SendGrid4r::Client.new(
10
+ username: ENV['SENDGRID_USERNAME'],
11
+ password: ENV['SENDGRID_PASSWORD'])
12
+ @template_name = 'version_test'
13
+ @version1_name = 'version_name1'
14
+ @version2_name = 'version_name2'
15
+ @factory = SendGrid4r::Factory::VersionFactory.new
16
+
18
17
  # celan up test env
19
18
  tmps = @client.get_templates
20
- tmps.each do |tmp|
21
- next if tmp.name != @template_edit
19
+ tmps.templates.each do |tmp|
20
+ next if tmp.name != @template_name
22
21
  tmp.versions.each do |ver|
23
22
  @client.delete_version(tmp.id, ver.id)
24
23
  end
25
24
  @client.delete_template(tmp.id)
26
25
  end
27
26
  # post a template
28
- new_template = @client.post_template(@template_edit)
29
- expect(@template_edit).to eq(new_template.name)
27
+ @template = @client.post_template(@template_name)
30
28
  # post a version
31
- factory = SendGrid4r::Factory::VersionFactory.new
32
- ver1 = factory.create(name: @version1_name)
33
- ver1 = @client.post_version(new_template.id, ver1)
34
- # get the version
35
- actual = @client.get_version(new_template.id, ver1.id)
36
- expect(ver1.template_id).to eq(actual.template_id)
37
- expect(ver1.active).to eq(actual.active)
38
- expect(ver1.name).to eq(actual.name)
39
- expect(ver1.html_content).to eq(actual.html_content)
40
- expect(ver1.plain_content).to eq(actual.plain_content)
41
- expect(ver1.subject).to eq(actual.subject)
42
- # edit the version
43
- edit_ver1 = actual.dup
29
+ ver1 = @factory.create(name: @version1_name)
30
+ @version1 = @client.post_version(@template.id, ver1)
31
+ rescue => e
32
+ puts e.inspect
33
+ raise e
34
+ end
35
+ end
36
+
37
+ context 'without block call' do
38
+ it '#post_version' do
39
+ begin
40
+ ver2 = @factory.create(name: @version2_name)
41
+ version2 = @client.post_version(@template.id, ver2)
42
+ expect(version2.name).to eq(@version2_name)
43
+ rescue => e
44
+ puts e.inspect
45
+ raise e
46
+ end
47
+ end
48
+
49
+ it '#activate_version' do
50
+ begin
51
+ actual = @client.activate_version(@template.id, @version1.id)
52
+ expect(actual.active).to eq(1)
53
+ rescue => e
54
+ puts e.inspect
55
+ raise e
56
+ end
57
+ end
58
+
59
+ it '#get_version' do
60
+ begin
61
+ actual = @client.get_version(@template.id, @version1.id)
62
+ expect(actual.template_id).to eq(@version1.template_id)
63
+ expect(actual.active).to be_a(Fixnum)
64
+ expect(actual.name).to eq(@version1.name)
65
+ expect(actual.html_content).to eq(@version1.html_content)
66
+ expect(actual.plain_content).to eq(@version1.plain_content)
67
+ expect(actual.subject).to eq(@version1.subject)
68
+ rescue => e
69
+ puts e.inspect
70
+ raise e
71
+ end
72
+ end
73
+
74
+ it '#patch_version' do
75
+ begin
76
+ edit_ver1 = @version1.dup
77
+ edit_ver1.name = 'edit_version'
78
+ edit_ver1.subject = 'edit<%subject%>edit'
79
+ edit_ver1.html_content = 'edit<%body%>edit'
80
+ edit_ver1.plain_content = 'edit<%body%>edit'
81
+ edit_ver1.active = 0
82
+ @client.patch_version(@template.id, @version1.id, edit_ver1)
83
+ rescue => e
84
+ puts e.inspect
85
+ raise e
86
+ end
87
+ end
88
+
89
+ it '#delete_version' do
90
+ begin
91
+ @client.delete_version(@template.id, @version1.id)
92
+ rescue => e
93
+ puts e.inspect
94
+ raise e
95
+ end
96
+ end
97
+ end
98
+
99
+ context 'with block call' do
100
+ it '#post_version' do
101
+ ver2 = @factory.create(name: @version2_name)
102
+ @client.post_version(@template.id, ver2) do |resp, req, res|
103
+ resp =
104
+ SendGrid4r::REST::Templates::Versions.create_version(
105
+ JSON.parse(resp)
106
+ )
107
+ expect(resp).to be_a(SendGrid4r::REST::Templates::Versions::Version)
108
+ expect(req).to be_a(RestClient::Request)
109
+ expect(res).to be_a(Net::HTTPCreated)
110
+ end
111
+ end
112
+
113
+ it '#activate_version' do
114
+ @client.activate_version(@template.id, @version1.id) do |resp, req, res|
115
+ resp =
116
+ SendGrid4r::REST::Templates::Versions.create_version(
117
+ JSON.parse(resp)
118
+ )
119
+ expect(resp).to be_a(SendGrid4r::REST::Templates::Versions::Version)
120
+ expect(req).to be_a(RestClient::Request)
121
+ expect(res).to be_a(Net::HTTPOK)
122
+ end
123
+ end
124
+
125
+ it '#get_version' do
126
+ @client.get_version(@template.id, @version1.id) do |resp, req, res|
127
+ resp =
128
+ SendGrid4r::REST::Templates::Versions.create_version(
129
+ JSON.parse(resp)
130
+ )
131
+ expect(resp).to be_a(SendGrid4r::REST::Templates::Versions::Version)
132
+ expect(req).to be_a(RestClient::Request)
133
+ expect(res).to be_a(Net::HTTPOK)
134
+ end
135
+ end
136
+
137
+ it '#patch_version' do
138
+ edit_ver1 = @version1.dup
44
139
  edit_ver1.name = 'edit_version'
45
140
  edit_ver1.subject = 'edit<%subject%>edit'
46
141
  edit_ver1.html_content = 'edit<%body%>edit'
47
142
  edit_ver1.plain_content = 'edit<%body%>edit'
48
143
  edit_ver1.active = 0
49
- @client.patch_version(new_template.id, ver1.id, edit_ver1)
50
- # get the version
51
- actual = @client.get_version(new_template.id, ver1.id)
52
- expect(new_template.id).to eq(actual.template_id)
53
- expect(edit_ver1.active).to eq(actual.active)
54
- expect(edit_ver1.name).to eq(actual.name)
55
- expect(edit_ver1.html_content).to eq(actual.html_content)
56
- expect(edit_ver1.plain_content).to eq(actual.plain_content)
57
- expect(edit_ver1.subject).to eq(actual.subject)
58
- # post a version 2
59
- ver2 = factory.create(
60
- name: @version2_name,
61
- subject: '<%subject%>',
62
- html_content: '<%body%>',
63
- plain_content: '<%body%>'
64
- )
65
- ver2 = @client.post_version(new_template.id, ver2)
66
- # activate version 2
67
- @client.activate_version(new_template.id, ver2.id)
68
- actual_ver1 = @client.get_version(new_template.id, ver1.id)
69
- actual_ver2 = @client.get_version(new_template.id, ver2.id)
70
- expect(0).to eq(actual_ver1.active)
71
- expect(1).to eq(actual_ver2.active)
72
- # delete the version
73
- @client.delete_version(new_template.id, actual_ver1.id)
74
- @client.delete_version(new_template.id, actual_ver2.id)
75
- expect do
76
- @client.get_version(new_template.id, actual_ver1.id)
77
- end.to raise_error(RestClient::ResourceNotFound)
78
- expect do
79
- @client.get_version(new_template.id, actual_ver2.id)
80
- end.to raise_error(RestClient::ResourceNotFound)
81
- # delete the template
82
- @client.delete_template(new_template.id)
83
- rescue => e
84
- puts e.inspect
85
- raise e
144
+ @client.patch_version(
145
+ @template.id, @version1.id, edit_ver1
146
+ ) do |resp, req, res|
147
+ resp =
148
+ SendGrid4r::REST::Templates::Versions.create_version(
149
+ JSON.parse(resp)
150
+ )
151
+ expect(resp).to be_a(SendGrid4r::REST::Templates::Versions::Version)
152
+ expect(req).to be_a(RestClient::Request)
153
+ expect(res).to be_a(Net::HTTPOK)
154
+ end
86
155
  end
156
+
157
+ it '#delete_version' do
158
+ @client.delete_version(@template.id, @version1.id) do |resp, req, res|
159
+ expect(resp).to eq('')
160
+ expect(req).to be_a(RestClient::Request)
161
+ expect(res).to be_a(Net::HTTPNoContent)
162
+ end
163
+ end
164
+ end
165
+ end
166
+
167
+ describe 'unit test' do
168
+ it 'creates version instance' do
169
+ json =
170
+ '{'\
171
+ '"id": "8aefe0ee-f12b-4575-b5b7-c97e21cb36f3",'\
172
+ '"template_id": "ddb96bbc-9b92-425e-8979-99464621b543",'\
173
+ '"active": 1,'\
174
+ '"name": "example_version_name",'\
175
+ '"html_content": "<%body%>",'\
176
+ '"plain_content": "<%body%>",'\
177
+ '"subject": "<%subject%>",'\
178
+ '"updated_at": "2014-03-19 18:56:33"'\
179
+ '}'
180
+ hash = JSON.parse(json)
181
+ actual = SendGrid4r::REST::Templates::Versions.create_version(hash)
182
+ expect(actual).to be_a(SendGrid4r::REST::Templates::Versions::Version)
183
+ expect(actual.id).to eq('8aefe0ee-f12b-4575-b5b7-c97e21cb36f3')
184
+ expect(actual.template_id).to eq('ddb96bbc-9b92-425e-8979-99464621b543')
185
+ expect(actual.active).to eq(1)
186
+ expect(actual.name).to eq('example_version_name')
187
+ expect(actual.html_content).to eq('<%body%>')
188
+ expect(actual.plain_content).to eq('<%body%>')
189
+ expect(actual.subject).to eq('<%subject%>')
190
+ expect(actual.updated_at).to eq('2014-03-19 18:56:33')
87
191
  end
88
192
  end
89
193
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sendgrid4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - awwa500@gmail.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-05 00:00:00.000000000 Z
11
+ date: 2015-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -120,6 +120,8 @@ files:
120
120
  - lib/sendgrid4r/factory/segment_factory.rb
121
121
  - lib/sendgrid4r/factory/version_factory.rb
122
122
  - lib/sendgrid4r/rest/api.rb
123
+ - lib/sendgrid4r/rest/api_keys/api_keys.rb
124
+ - lib/sendgrid4r/rest/asm/asm.rb
123
125
  - lib/sendgrid4r/rest/asm/global_suppressions.rb
124
126
  - lib/sendgrid4r/rest/asm/groups.rb
125
127
  - lib/sendgrid4r/rest/asm/suppressions.rb
@@ -144,6 +146,8 @@ files:
144
146
  - lib/sendgrid4r/rest/templates/versions.rb
145
147
  - lib/sendgrid4r/version.rb
146
148
  - sendgrid4r.gemspec
149
+ - spec/api_keys/api_keys_spec.rb
150
+ - spec/asm/asm_spec.rb
147
151
  - spec/asm/global_suppressions_spec.rb
148
152
  - spec/asm/groups_spec.rb
149
153
  - spec/asm/suppressions_spec.rb
@@ -166,6 +170,7 @@ files:
166
170
  - spec/stats/category_spec.rb
167
171
  - spec/stats/global_spec.rb
168
172
  - spec/stats/parse_spec.rb
173
+ - spec/stats/stats_spec.rb
169
174
  - spec/stats/subuser_spec.rb
170
175
  - spec/templates/templates_spec.rb
171
176
  - spec/templates/versions_spec.rb
@@ -194,6 +199,8 @@ signing_key:
194
199
  specification_version: 4
195
200
  summary: SendGrid Web API v3 module
196
201
  test_files:
202
+ - spec/api_keys/api_keys_spec.rb
203
+ - spec/asm/asm_spec.rb
197
204
  - spec/asm/global_suppressions_spec.rb
198
205
  - spec/asm/groups_spec.rb
199
206
  - spec/asm/suppressions_spec.rb
@@ -216,6 +223,7 @@ test_files:
216
223
  - spec/stats/category_spec.rb
217
224
  - spec/stats/global_spec.rb
218
225
  - spec/stats/parse_spec.rb
226
+ - spec/stats/stats_spec.rb
219
227
  - spec/stats/subuser_spec.rb
220
228
  - spec/templates/templates_spec.rb
221
229
  - spec/templates/versions_spec.rb