phaxio 2.1.0.pre → 2.1.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/README.md +17 -17
- data/lib/phaxio/client.rb +2 -6
- data/lib/phaxio/config.rb +6 -4
- data/lib/phaxio/resource.rb +11 -5
- data/lib/phaxio/resources/account.rb +1 -1
- data/lib/phaxio/resources/ata.rb +85 -19
- data/lib/phaxio/resources/callback.rb +10 -56
- data/lib/phaxio/resources/fax.rb +11 -11
- data/lib/phaxio/resources/phax_code.rb +2 -2
- data/lib/phaxio/resources/phone_number.rb +31 -5
- data/lib/phaxio/resources/port_number.rb +42 -0
- data/lib/phaxio/resources/port_number_note.rb +51 -0
- data/lib/phaxio/resources/port_order.rb +172 -0
- data/lib/phaxio/resources/public/area_code.rb +1 -1
- data/lib/phaxio/resources/public/country.rb +1 -1
- data/lib/phaxio/resources/webhook.rb +65 -0
- data/lib/phaxio/version.rb +1 -1
- data/lib/phaxio.rb +12 -3
- data/spec/phaxio_spec.rb +7 -1
- data/spec/resources/account_spec.rb +1 -7
- data/spec/resources/ata_spec.rb +207 -0
- data/spec/resources/fax_spec.rb +35 -103
- data/spec/resources/phax_code_spec.rb +10 -44
- data/spec/resources/phone_number_spec.rb +19 -30
- data/spec/resources/port_number_note_spec.rb +33 -0
- data/spec/resources/port_number_spec.rb +32 -0
- data/spec/resources/port_order_spec.rb +76 -0
- data/spec/resources/public/area_code_spec.rb +1 -1
- data/spec/resources/public/country_spec.rb +1 -7
- data/spec/resources/{callback_spec.rb → webhook_spec.rb} +8 -8
- data/spec/spec_helper.rb +1 -0
- data/spec/support/{vcr_cassettes/resources/account/status.yml → cassettes/account/get.yml} +7 -9
- data/spec/support/cassettes/ata/add_phone_number.yml +89 -0
- data/spec/support/{vcr_cassettes/resources/fax/resend.yml → cassettes/ata/create.yml} +12 -13
- data/spec/support/cassettes/ata/delete.yml +86 -0
- data/spec/support/cassettes/ata/get.yml +87 -0
- data/spec/support/cassettes/ata/list.yml +67 -0
- data/spec/support/{vcr_cassettes/resources/phax_code/get_id.yml → cassettes/ata/provisioning_urls.yml} +10 -13
- data/spec/support/cassettes/ata/reference.yml +87 -0
- data/spec/support/cassettes/ata/regenerate.yml +89 -0
- data/spec/support/cassettes/ata/remove_phone_number.yml +130 -0
- data/spec/support/cassettes/ata/update.yml +89 -0
- data/spec/support/{vcr_cassettes/resources/fax/create_for_cancel.yml → cassettes/fax/cancel.yml} +51 -11
- data/spec/support/{vcr_cassettes/resources/fax/create_for_reference.yml → cassettes/fax/create.yml} +11 -13
- data/spec/support/{vcr_cassettes/resources/fax/create.yml → cassettes/fax/delete.yml} +49 -11
- data/spec/support/{vcr_cassettes/resources/fax/create_for_delete.yml → cassettes/fax/delete_file.yml} +49 -11
- data/spec/support/cassettes/fax/file.yml +93 -0
- data/spec/support/{vcr_cassettes/resources/fax/create_for_download_file.yml → cassettes/fax/get.yml} +49 -11
- data/spec/support/{vcr_cassettes/resources → cassettes}/fax/list.yml +5 -7
- data/spec/support/cassettes/fax/reference.yml +88 -0
- data/spec/support/{vcr_cassettes/resources/fax/create_for_delete_file.yml → cassettes/fax/resend.yml} +51 -11
- data/spec/support/{vcr_cassettes/resources → cassettes}/fax/test_receive.yml +7 -9
- data/spec/support/{vcr_cassettes/resources → cassettes}/phax_code/create.yml +8 -10
- data/spec/support/{vcr_cassettes/resources → cassettes}/phax_code/create_png.yml +8 -10
- data/spec/support/cassettes/phax_code/get_by_id.yml +86 -0
- data/spec/support/{vcr_cassettes/resources/phax_code/get.yml → cassettes/phax_code/get_default.yml} +8 -10
- data/spec/support/{vcr_cassettes/resources/phax_code/get_png.yml → cassettes/phax_code/get_default_png.yml} +8 -10
- data/spec/support/cassettes/phax_code/get_png_by_id.yml +90 -0
- data/spec/support/{vcr_cassettes/resources → cassettes}/phone_number/create.yml +8 -10
- data/spec/support/{vcr_cassettes/resources → cassettes}/phone_number/get.yml +10 -12
- data/spec/support/cassettes/phone_number/list.yml +72 -0
- data/spec/support/cassettes/phone_number/reference.yml +45 -0
- data/spec/support/cassettes/phone_number/release.yml +86 -0
- data/spec/support/cassettes/port_number/get.yml +88 -0
- data/spec/support/cassettes/port_number_note/list.yml +88 -0
- data/spec/support/cassettes/port_order/create.yml +48 -0
- data/spec/support/cassettes/port_order/get.yml +91 -0
- data/spec/support/cassettes/port_order/list.yml +52 -0
- data/spec/support/{vcr_cassettes/resources/public/area_codes → cassettes/public/area_code}/list.yml +15 -17
- data/spec/support/{vcr_cassettes/resources → cassettes}/public/country/list.yml +5 -7
- data/spec/support/vcr.rb +24 -6
- metadata +115 -41
- data/spec/support/credentials.rb +0 -7
- data/spec/support/vcr_cassettes/resources/fax/cancel.yml +0 -47
- data/spec/support/vcr_cassettes/resources/fax/create_for_get.yml +0 -50
- data/spec/support/vcr_cassettes/resources/fax/create_for_resend.yml +0 -50
- data/spec/support/vcr_cassettes/resources/fax/delete.yml +0 -45
- data/spec/support/vcr_cassettes/resources/fax/delete_file.yml +0 -45
- data/spec/support/vcr_cassettes/resources/fax/file.yml +0 -50
- data/spec/support/vcr_cassettes/resources/fax/get.yml +0 -45
- data/spec/support/vcr_cassettes/resources/fax/reference.yml +0 -45
- data/spec/support/vcr_cassettes/resources/phax_code/get_id_png.yml +0 -50
- data/spec/support/vcr_cassettes/resources/phone_number/list.yml +0 -60
- data/spec/support/vcr_cassettes/resources/phone_number/release.yml +0 -45
data/spec/resources/fax_spec.rb
CHANGED
@@ -2,19 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe Fax do
|
4
4
|
let(:test_file) { File.open test_file_path }
|
5
|
-
let(:test_file_path) { File.
|
6
|
-
let(:test_recipient_number) {
|
5
|
+
let(:test_file_path) { File.join File.expand_path('..', __dir__), 'support', 'files', 'test.pdf' }
|
6
|
+
let(:test_recipient_number) { TEST_NUMBER }
|
7
7
|
|
8
|
-
describe 'creating a fax' do
|
8
|
+
describe 'creating a fax', vcr: 'fax/create' do
|
9
9
|
let(:action) { Fax.create params }
|
10
10
|
let(:params) { {to: test_recipient_number, file: test_file} }
|
11
11
|
|
12
|
-
around(:each) do |example|
|
13
|
-
VCR.use_cassette('resources/fax/create') do
|
14
|
-
example.run
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
12
|
it 'makes the request to Phaxio' do
|
19
13
|
expect_api_request :post, 'faxes', to: test_recipient_number, file: test_file
|
20
14
|
action
|
@@ -27,21 +21,11 @@ RSpec.describe Fax do
|
|
27
21
|
end
|
28
22
|
end
|
29
23
|
|
30
|
-
describe 'retrieving a fax' do
|
24
|
+
describe 'retrieving a fax', vcr: 'fax/get' do
|
31
25
|
let(:action) { Fax.get fax_id, params }
|
32
|
-
let
|
33
|
-
VCR.use_cassette('resources/fax/create_for_get') do
|
34
|
-
Phaxio::Fax.create(to: test_recipient_number, file: test_file).id
|
35
|
-
end
|
36
|
-
}
|
26
|
+
let(:fax_id) { Fax.create(to: test_recipient_number, file: test_file).id }
|
37
27
|
let(:params) { {} }
|
38
28
|
|
39
|
-
around(:each) do |example|
|
40
|
-
VCR.use_cassette('resources/fax/get') do
|
41
|
-
example.run
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
29
|
it 'makes the request to Phaxio' do
|
46
30
|
expect_api_request :get, "faxes/#{fax_id}", params
|
47
31
|
action
|
@@ -54,20 +38,10 @@ RSpec.describe Fax do
|
|
54
38
|
end
|
55
39
|
end
|
56
40
|
|
57
|
-
describe 'cancelling a fax' do
|
41
|
+
describe 'cancelling a fax', vcr: 'fax/cancel' do
|
58
42
|
let(:action) { Fax.cancel fax_id, params }
|
43
|
+
let(:fax_id) { Fax.create(to: test_recipient_number, file: test_file).id }
|
59
44
|
let(:params) { {} }
|
60
|
-
let!(:fax_id) {
|
61
|
-
VCR.use_cassette('resources/fax/create_for_cancel') do
|
62
|
-
Phaxio::Fax.create(to: test_recipient_number, file: test_file).id
|
63
|
-
end
|
64
|
-
}
|
65
|
-
|
66
|
-
around(:each) do |example|
|
67
|
-
VCR.use_cassette('resources/fax/cancel') do
|
68
|
-
example.run
|
69
|
-
end
|
70
|
-
end
|
71
45
|
|
72
46
|
it 'makes the request to Phaxio' do
|
73
47
|
expect_api_request :post, "faxes/#{fax_id}/cancel", params
|
@@ -81,17 +55,11 @@ RSpec.describe Fax do
|
|
81
55
|
end
|
82
56
|
end
|
83
57
|
|
84
|
-
describe 'listing faxes' do
|
58
|
+
describe 'listing faxes', vcr: 'fax/list' do
|
85
59
|
let(:action) { Fax.list params }
|
86
60
|
let(:params) { {created_before: time} }
|
87
61
|
let(:time) { Time.new 2017, 10, 28, 0, 17, 0, 0 }
|
88
62
|
|
89
|
-
around do |example|
|
90
|
-
VCR.use_cassette('resources/fax/list') do
|
91
|
-
example.run
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
63
|
it 'sends the request to phaxio' do
|
96
64
|
expect_api_request :get, 'faxes', params
|
97
65
|
action
|
@@ -103,21 +71,15 @@ RSpec.describe Fax do
|
|
103
71
|
end
|
104
72
|
end
|
105
73
|
|
106
|
-
describe 'resending a fax' do
|
74
|
+
describe 'resending a fax', vcr: 'fax/resend' do
|
107
75
|
let(:action) { Fax.resend fax_id, params }
|
108
|
-
let
|
109
|
-
|
110
|
-
|
111
|
-
|
76
|
+
let(:fax_id) {
|
77
|
+
fax_id = Fax.create(to: test_recipient_number, file: test_file).id
|
78
|
+
sleep 30 if VCR.current_cassette.recording?
|
79
|
+
fax_id
|
112
80
|
}
|
113
81
|
let(:params) { {} }
|
114
82
|
|
115
|
-
around do |example|
|
116
|
-
VCR.use_cassette('resources/fax/resend') do
|
117
|
-
example.run
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
83
|
it 'makes the request to Phaxio' do
|
122
84
|
expect_api_request :post, "faxes/#{fax_id}/resend", params
|
123
85
|
action
|
@@ -130,21 +92,15 @@ RSpec.describe Fax do
|
|
130
92
|
end
|
131
93
|
end
|
132
94
|
|
133
|
-
describe 'deleting a fax' do
|
95
|
+
describe 'deleting a fax', vcr: 'fax/delete' do
|
134
96
|
let(:action) { Fax.delete fax_id, params }
|
135
|
-
let
|
136
|
-
|
137
|
-
|
138
|
-
|
97
|
+
let(:fax_id) {
|
98
|
+
fax_id = Fax.create(to: test_recipient_number, file: test_file).id
|
99
|
+
sleep 30 if VCR.current_cassette.recording?
|
100
|
+
fax_id
|
139
101
|
}
|
140
102
|
let(:params) { {} }
|
141
103
|
|
142
|
-
around do |example|
|
143
|
-
VCR.use_cassette('resources/fax/delete') do
|
144
|
-
example.run
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
104
|
it 'makes the request to Phaxio' do
|
149
105
|
expect_api_request :delete, "faxes/#{fax_id}", params
|
150
106
|
action
|
@@ -156,21 +112,15 @@ RSpec.describe Fax do
|
|
156
112
|
end
|
157
113
|
end
|
158
114
|
|
159
|
-
describe 'deleting a fax file' do
|
115
|
+
describe 'deleting a fax file', vcr: 'fax/delete_file' do
|
160
116
|
let(:action) { Fax.delete_file fax_id, params }
|
161
|
-
let
|
162
|
-
|
163
|
-
|
164
|
-
|
117
|
+
let(:fax_id) {
|
118
|
+
fax_id = Fax.create(to: test_recipient_number, file: test_file).id
|
119
|
+
sleep 30 if VCR.current_cassette.recording?
|
120
|
+
fax_id
|
165
121
|
}
|
166
122
|
let(:params) { {} }
|
167
123
|
|
168
|
-
around do |example|
|
169
|
-
VCR.use_cassette('resources/fax/delete_file') do
|
170
|
-
example.run
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
124
|
it 'makes the request to Phaxio' do
|
175
125
|
expect_api_request :delete, "faxes/#{fax_id}/file", params
|
176
126
|
action
|
@@ -182,21 +132,15 @@ RSpec.describe Fax do
|
|
182
132
|
end
|
183
133
|
end
|
184
134
|
|
185
|
-
describe 'downloading a fax file' do
|
135
|
+
describe 'downloading a fax file', vcr: 'fax/file' do
|
186
136
|
let(:action) { Fax.file fax_id, params }
|
187
|
-
let
|
188
|
-
|
189
|
-
|
190
|
-
|
137
|
+
let(:fax_id) {
|
138
|
+
fax_id = Fax.create(to: test_recipient_number, file: test_file).id
|
139
|
+
sleep 30 if VCR.current_cassette.recording?
|
140
|
+
fax_id
|
191
141
|
}
|
192
142
|
let(:params) { {} }
|
193
143
|
|
194
|
-
around do |example|
|
195
|
-
VCR.use_cassette('resources/fax/file') do
|
196
|
-
example.run
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
144
|
it 'makes the request to phaxio' do
|
201
145
|
expect_api_request :get, "faxes/#{fax_id}/file", params
|
202
146
|
action
|
@@ -208,16 +152,10 @@ RSpec.describe Fax do
|
|
208
152
|
end
|
209
153
|
end
|
210
154
|
|
211
|
-
describe 'receiving a test fax' do
|
155
|
+
describe 'receiving a test fax', vcr: 'fax/test_receive' do
|
212
156
|
let(:action) { Fax.test_receive params }
|
213
157
|
let(:params) { {file: test_file} }
|
214
158
|
|
215
|
-
around do |example|
|
216
|
-
VCR.use_cassette('resources/fax/test_receive') do
|
217
|
-
example.run
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
159
|
it 'makes the request to Phaxio' do
|
222
160
|
expect_api_request :post, 'faxes', {file: test_file, direction: 'received'}
|
223
161
|
action
|
@@ -229,20 +167,14 @@ RSpec.describe Fax do
|
|
229
167
|
end
|
230
168
|
end
|
231
169
|
|
232
|
-
describe Fax::Reference do
|
233
|
-
let
|
234
|
-
VCR.use_cassette('resources/fax/create_for_reference') do
|
235
|
-
Phaxio::Fax.create(to: test_recipient_number, file: test_file).id
|
236
|
-
end
|
237
|
-
}
|
170
|
+
describe Fax::Reference, vcr: 'fax/reference' do
|
171
|
+
let(:fax_id) { Fax.create(to: test_recipient_number, file: test_file).id }
|
238
172
|
|
239
173
|
it 'gets the full fax' do
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
expect(result.id).to eq(fax_id)
|
245
|
-
end
|
174
|
+
reference = Fax::Reference.new fax_id
|
175
|
+
result = reference.get
|
176
|
+
expect(result).to be_a(Fax)
|
177
|
+
expect(result.id).to eq(fax_id)
|
246
178
|
end
|
247
179
|
end
|
248
180
|
end
|
@@ -5,13 +5,7 @@ RSpec.describe PhaxCode do
|
|
5
5
|
let(:action) { PhaxCode.create params }
|
6
6
|
let(:params) { {metadata: 'This is a test PhaxCode'} }
|
7
7
|
|
8
|
-
context 'default type' do
|
9
|
-
around do |example|
|
10
|
-
VCR.use_cassette('resources/phax_code/create') do
|
11
|
-
example.run
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
8
|
+
context 'default type', vcr: 'phax_code/create' do
|
15
9
|
it 'makes the request to phaxio' do
|
16
10
|
expect_api_request :post, 'phax_codes', params
|
17
11
|
action
|
@@ -23,15 +17,9 @@ RSpec.describe PhaxCode do
|
|
23
17
|
end
|
24
18
|
end
|
25
19
|
|
26
|
-
context 'type is specified to be png' do
|
20
|
+
context 'type is specified to be png', vcr: 'phax_code/create_png' do
|
27
21
|
let(:params) { {metadata: 'This is a test PhaxCode', type: 'png'} }
|
28
22
|
|
29
|
-
around do |example|
|
30
|
-
VCR.use_cassette('resources/phax_code/create_png') do
|
31
|
-
example.run
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
23
|
it 'returns a png if type is specified to be png' do
|
36
24
|
result = action
|
37
25
|
expect(result).to be_a(File)
|
@@ -43,13 +31,7 @@ RSpec.describe PhaxCode do
|
|
43
31
|
let(:action) { PhaxCode.get params }
|
44
32
|
let(:params) { {} }
|
45
33
|
|
46
|
-
context 'default' do
|
47
|
-
around do |example|
|
48
|
-
VCR.use_cassette('resources/phax_code/get') do
|
49
|
-
example.run
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
34
|
+
context 'default', vcr: 'phax_code/get_default' do
|
53
35
|
it 'makes the request to Phaxio' do
|
54
36
|
expect_api_request :get, 'phax_code', params
|
55
37
|
action
|
@@ -63,29 +45,18 @@ RSpec.describe PhaxCode do
|
|
63
45
|
end
|
64
46
|
end
|
65
47
|
|
66
|
-
context 'getting the default phax code with png type specified' do
|
48
|
+
context 'getting the default phax code with png type specified', vcr: 'phax_code/get_default_png' do
|
67
49
|
let(:params) { {type: 'png'} }
|
68
50
|
|
69
|
-
around do |example|
|
70
|
-
VCR.use_cassette('resources/phax_code/get_png') do
|
71
|
-
example.run
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
51
|
it 'returns a file' do
|
76
52
|
result = action
|
77
53
|
expect(result).to be_a(File)
|
78
54
|
end
|
79
55
|
end
|
80
56
|
|
81
|
-
context 'getting a particular phax code with no type specified' do
|
82
|
-
let(:params) { {identifier:
|
83
|
-
|
84
|
-
around do |example|
|
85
|
-
VCR.use_cassette('resources/phax_code/get_id') do
|
86
|
-
example.run
|
87
|
-
end
|
88
|
-
end
|
57
|
+
context 'getting a particular phax code with no type specified', vcr: 'phax_code/get_by_id' do
|
58
|
+
let(:params) { {identifier: phax_code_identifier} }
|
59
|
+
let(:phax_code_identifier) { PhaxCode.create(metadata: 'Test Phax Code').identifier }
|
89
60
|
|
90
61
|
it 'returns a PhaxCode instance' do
|
91
62
|
result = action
|
@@ -93,14 +64,9 @@ RSpec.describe PhaxCode do
|
|
93
64
|
end
|
94
65
|
end
|
95
66
|
|
96
|
-
context 'getting a particular phax code with png type specified' do
|
97
|
-
let(:params) { {identifier:
|
98
|
-
|
99
|
-
around do |example|
|
100
|
-
VCR.use_cassette('resources/phax_code/get_id_png') do
|
101
|
-
example.run
|
102
|
-
end
|
103
|
-
end
|
67
|
+
context 'getting a particular phax code with png type specified', vcr: 'phax_code/get_png_by_id' do
|
68
|
+
let(:params) { {identifier: phax_code_identifier, type: 'png'} }
|
69
|
+
let(:phax_code_identifier) { PhaxCode.create(metadata: 'Test Phax Code').identifier }
|
104
70
|
|
105
71
|
it 'returns a file' do
|
106
72
|
result = action
|
@@ -1,15 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe PhoneNumber do
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
describe PhoneNumber::Reference, vcr: 'phone_number/reference' do
|
5
|
+
describe '#get' do
|
6
|
+
it 'returns information about the referenced number' do
|
7
|
+
reference = PhoneNumber::Reference.new TEST_NUMBER
|
8
|
+
result = reference.get
|
9
|
+
expect(result).to be_a(PhoneNumber)
|
10
|
+
expect(result.phone_number).to eq(TEST_NUMBER)
|
11
11
|
end
|
12
12
|
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'provisioning a number', vcr: 'phone_number/create' do
|
16
|
+
let(:action) { PhoneNumber.create params }
|
17
|
+
let(:params) { {country_code: 1, area_code: 225} }
|
13
18
|
|
14
19
|
it 'makes the request to Phaxio' do
|
15
20
|
expect_api_request :post, 'phone_numbers', params
|
@@ -22,17 +27,11 @@ RSpec.describe PhoneNumber do
|
|
22
27
|
end
|
23
28
|
end
|
24
29
|
|
25
|
-
describe 'getting information about a number' do
|
30
|
+
describe 'getting information about a number', vcr: 'phone_number/get' do
|
26
31
|
let(:action) { PhoneNumber.get phone_number, params }
|
27
|
-
let(:phone_number) {
|
32
|
+
let(:phone_number) { TEST_NUMBER }
|
28
33
|
let(:params) { {} }
|
29
34
|
|
30
|
-
around do |example|
|
31
|
-
VCR.use_cassette('resources/phone_number/get') do
|
32
|
-
example.run
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
35
|
it 'makes the request to Phaxio' do
|
37
36
|
expect_api_request :get, "phone_numbers/#{phone_number}"
|
38
37
|
action
|
@@ -44,16 +43,10 @@ RSpec.describe PhoneNumber do
|
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
|
-
describe 'listing numbers' do
|
46
|
+
describe 'listing numbers', vcr: 'phone_number/list' do
|
48
47
|
let(:action) { PhoneNumber.list params }
|
49
48
|
let(:params) { {} }
|
50
49
|
|
51
|
-
around do |example|
|
52
|
-
VCR.use_cassette('resources/phone_number/list') do
|
53
|
-
example.run
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
50
|
it 'makes the request to Phaxio' do
|
58
51
|
expect_api_request :get, 'phone_numbers', params
|
59
52
|
action
|
@@ -65,17 +58,13 @@ RSpec.describe PhoneNumber do
|
|
65
58
|
end
|
66
59
|
end
|
67
60
|
|
68
|
-
describe 'releasing a number' do
|
61
|
+
describe 'releasing a number', vcr: 'phone_number/release' do
|
69
62
|
let(:action) { PhoneNumber.release phone_number, params }
|
70
|
-
let(:phone_number) {
|
63
|
+
let(:phone_number) {
|
64
|
+
PhoneNumber.provision(country_code: 1, area_code: 225).phone_number
|
65
|
+
}
|
71
66
|
let(:params) { {} }
|
72
67
|
|
73
|
-
around do |example|
|
74
|
-
VCR.use_cassette('resources/phone_number/release') do
|
75
|
-
example.run
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
68
|
it 'sends the request to Phaxio' do
|
80
69
|
expect_api_request :delete, "phone_numbers/#{phone_number}", params
|
81
70
|
action
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe PortNumberNote do
|
4
|
+
describe 'getting a list of notes', vcr: 'port_number_note/list' do
|
5
|
+
let(:action) { PortNumberNote.list port_number_id, params }
|
6
|
+
let(:port_number_id) {
|
7
|
+
PortOrder.create(
|
8
|
+
port_numbers: [TEST_NUMBER],
|
9
|
+
contact_number: TEST_NUMBER,
|
10
|
+
contact_email: 'julien@phaxio.com',
|
11
|
+
account_identifier: '1234',
|
12
|
+
name_on_account: 'THIS IS A TEST',
|
13
|
+
provider_name: 'DO NOT PORT --Julien',
|
14
|
+
has_bill: true,
|
15
|
+
legal_agreement: true,
|
16
|
+
port_type: 'residential',
|
17
|
+
esig: 'NOT A VALID SIGNATURE'
|
18
|
+
).port_numbers[0].id
|
19
|
+
}
|
20
|
+
|
21
|
+
let(:params) { {} }
|
22
|
+
|
23
|
+
it 'makes the request to phaxio' do
|
24
|
+
expect_api_request :get, "port_numbers/#{port_number_id}/notes", params
|
25
|
+
action
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns a collection of port number note objects' do
|
29
|
+
result = action
|
30
|
+
expect(result).to be_a(Phaxio::Resource::Collection)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe PortNumber do
|
4
|
+
describe 'getting information about a number', vcr: 'port_number/get' do
|
5
|
+
let(:action) { PortNumber.get id, params }
|
6
|
+
let(:id) {
|
7
|
+
PortOrder.create(
|
8
|
+
port_numbers: [TEST_NUMBER],
|
9
|
+
contact_number: TEST_NUMBER,
|
10
|
+
contact_email: 'julien@phaxio.com',
|
11
|
+
account_identifier: '1234',
|
12
|
+
name_on_account: 'THIS IS A TEST',
|
13
|
+
provider_name: 'DO NOT PORT --Julien',
|
14
|
+
has_bill: true,
|
15
|
+
legal_agreement: true,
|
16
|
+
port_type: 'residential',
|
17
|
+
esig: 'NOT A VALID SIGNATURE'
|
18
|
+
).port_numbers[0].id
|
19
|
+
}
|
20
|
+
let(:params) { {} }
|
21
|
+
|
22
|
+
it 'makes the request to phaxio' do
|
23
|
+
expect_api_request :get, "port_numbers/#{id}", params
|
24
|
+
action
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns a port number object' do
|
28
|
+
result = action
|
29
|
+
expect(result).to be_a(PortNumber)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe PortOrder do
|
4
|
+
describe 'creating an order', vcr: 'port_order/create' do
|
5
|
+
let(:action) { PortOrder.create params }
|
6
|
+
let(:params) {
|
7
|
+
{
|
8
|
+
port_numbers: [TEST_NUMBER],
|
9
|
+
contact_number: TEST_NUMBER,
|
10
|
+
contact_email: 'julien@phaxio.com',
|
11
|
+
account_identifier: '1234',
|
12
|
+
name_on_account: 'THIS IS A TEST',
|
13
|
+
provider_name: 'DO NOT PORT --Julien',
|
14
|
+
has_bill: true,
|
15
|
+
legal_agreement: true,
|
16
|
+
port_type: 'residential',
|
17
|
+
esig: 'NOT A VALID SIGNATURE'
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
it 'makes the request to Phaxio' do
|
22
|
+
expect_api_request :post, 'port_orders', params
|
23
|
+
action
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns a port order object' do
|
27
|
+
result = action
|
28
|
+
expect(result).to be_a(PortOrder)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'getting information about an order', vcr: 'port_order/get' do
|
33
|
+
let(:action) { PortOrder.get id, params }
|
34
|
+
let(:id) {
|
35
|
+
PortOrder.create(
|
36
|
+
port_numbers: [TEST_NUMBER],
|
37
|
+
contact_number: TEST_NUMBER,
|
38
|
+
contact_email: 'julien@phaxio.com',
|
39
|
+
account_identifier: '1234',
|
40
|
+
name_on_account: 'THIS IS A TEST',
|
41
|
+
provider_name: 'DO NOT PORT --Julien',
|
42
|
+
has_bill: true,
|
43
|
+
legal_agreement: true,
|
44
|
+
port_type: 'residential',
|
45
|
+
esig: 'NOT A VALID SIGNATURE'
|
46
|
+
).id
|
47
|
+
}
|
48
|
+
let(:params) { {} }
|
49
|
+
|
50
|
+
it 'makes the request to Phaxio' do
|
51
|
+
expect_api_request :get, "port_orders/#{id}", params
|
52
|
+
action
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'returns a port order object' do
|
56
|
+
result = action
|
57
|
+
expect(result).to be_a(PortOrder)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'listing port orders', vcr: 'port_order/list' do
|
62
|
+
let(:action) { PortOrder.list params }
|
63
|
+
let(:params) { {} }
|
64
|
+
|
65
|
+
it 'makes the request to Phaxio' do
|
66
|
+
expect_api_request :get, 'port_orders', params
|
67
|
+
action
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'returns a collection of port order objects' do
|
71
|
+
result = action
|
72
|
+
expect(result).to be_a(Phaxio::Resource::Collection)
|
73
|
+
expect(result.first).to be_a(PortOrder)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Public::AreaCode do
|
4
|
-
describe 'listing area codes available for purchasing numbers' do
|
4
|
+
describe 'listing area codes available for purchasing numbers', vcr: 'public/area_code/list' do
|
5
5
|
let(:action) { Public::AreaCode.list params }
|
6
6
|
let(:params) { {} }
|
7
7
|
|
@@ -1,16 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Public::Country do
|
4
|
-
describe 'getting a list of supported countries' do
|
4
|
+
describe 'getting a list of supported countries', vcr: 'public/country/list' do
|
5
5
|
let(:action) { Public::Country.list }
|
6
6
|
let(:params) { {} }
|
7
7
|
|
8
|
-
around do |example|
|
9
|
-
VCR.use_cassette('resources/public/country/list') do
|
10
|
-
example.run
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
8
|
it 'makes the request to Phaxio' do
|
15
9
|
expect_api_request :get, 'public/countries', params
|
16
10
|
action
|
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe
|
4
|
-
describe 'validating a
|
5
|
-
let(:action) {
|
6
|
-
let(:signature) { '
|
3
|
+
RSpec.describe Webhook do
|
4
|
+
describe 'validating a webhook signature' do
|
5
|
+
let(:action) { Webhook.valid_signature? signature, url, params, files }
|
6
|
+
let(:signature) { '64a735ef0c47a0ae671e381c046648f0966deb29' }
|
7
7
|
let(:url) { 'example.com' }
|
8
8
|
let(:params) { {test: true} }
|
9
9
|
let(:files) { [] }
|
10
10
|
|
11
|
-
it 'raises an error if Phaxio::Config.
|
12
|
-
Phaxio.
|
11
|
+
it 'raises an error if Phaxio::Config.webhook_token is unset' do
|
12
|
+
Phaxio.webhook_token = nil
|
13
13
|
expect {
|
14
14
|
action
|
15
|
-
}.to raise_error(Phaxio::Error::PhaxioError, 'No
|
15
|
+
}.to raise_error(Phaxio::Error::PhaxioError, 'No webhook token has been set')
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'signature matches' do
|
@@ -31,4 +31,4 @@ RSpec.describe Callback do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,10 +7,10 @@ http_interactions:
|
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
9
9
|
headers:
|
10
|
-
Authorization:
|
11
|
-
- Basic dGVzdC1hcGkta2V5OnRlc3QtYXBpLXNlY3JldA==
|
12
10
|
User-Agent:
|
13
11
|
- Faraday v1.3.0
|
12
|
+
Authorization:
|
13
|
+
- "<AUTH_HEADER>"
|
14
14
|
response:
|
15
15
|
status:
|
16
16
|
code: 200
|
@@ -21,25 +21,23 @@ http_interactions:
|
|
21
21
|
content-type:
|
22
22
|
- application/json; charset=utf-8
|
23
23
|
date:
|
24
|
-
-
|
24
|
+
- Thu, 04 Nov 2021 21:07:44 GMT
|
25
25
|
etag:
|
26
|
-
- W/"
|
26
|
+
- W/"ec3c8a9d370f99638f5670ec4ac6fc00"
|
27
27
|
server:
|
28
28
|
- nginx
|
29
29
|
strict-transport-security:
|
30
30
|
- max-age=15768000; preload
|
31
31
|
x-request-id:
|
32
|
-
-
|
32
|
+
- e9708d49-deff-443c-92cb-2d89a3ef7272
|
33
33
|
x-robots-tag:
|
34
34
|
- noindex, nofollow, nosnippet, noarchive
|
35
|
-
x-runtime:
|
36
|
-
- '0.022529'
|
37
35
|
content-length:
|
38
36
|
- '171'
|
39
37
|
connection:
|
40
38
|
- keep-alive
|
41
39
|
body:
|
42
40
|
encoding: UTF-8
|
43
|
-
string: '{"success":true,"message":"Account status retrieved successfully","data":{"balance":
|
44
|
-
recorded_at:
|
41
|
+
string: '{"success":true,"message":"Account status retrieved successfully","data":{"balance":1076,"faxes_today":{"sent":0,"received":0},"faxes_this_month":{"sent":0,"received":0}}}'
|
42
|
+
recorded_at: Thu, 04 Nov 2021 21:08:25 GMT
|
45
43
|
recorded_with: VCR 6.0.0
|