phaxio 2.1.0.pre → 2.1.1
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 +14 -12
- data/lib/phaxio/config.rb +6 -4
- data/lib/phaxio/error.rb +1 -0
- 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/client_spec.rb +17 -0
- 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
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Ata do
|
|
4
|
+
describe Ata::Reference, vcr: 'ata/reference' do
|
|
5
|
+
let(:reference) { Ata::Reference.new ata_id }
|
|
6
|
+
let(:ata_id) { Ata.create(name: 'Test ATA').id }
|
|
7
|
+
|
|
8
|
+
describe '#get' do
|
|
9
|
+
it 'returns information about the referenced ATA' do
|
|
10
|
+
result = reference.get
|
|
11
|
+
expect(result).to be_a(Ata)
|
|
12
|
+
expect(result.name).to eq('Test ATA')
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe Ata::ProvisioningURLs, vcr: 'ata/provisioning_urls' do
|
|
18
|
+
let(:provisioning_urls) { Ata.provisioning_urls }
|
|
19
|
+
|
|
20
|
+
describe '#urls' do
|
|
21
|
+
it 'returns the full hash of provisioning URLS' do
|
|
22
|
+
expect(provisioning_urls.urls).to be_a(Hash)
|
|
23
|
+
expect(provisioning_urls.urls.keys).to match_array([
|
|
24
|
+
'OBi',
|
|
25
|
+
'Grandstream',
|
|
26
|
+
'Netgen',
|
|
27
|
+
])
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '#grandstream' do
|
|
32
|
+
it 'returns the grandstream provisioning URL' do
|
|
33
|
+
url = provisioning_urls.urls['Grandstream']
|
|
34
|
+
expect(provisioning_urls.grandstream).to eq(url)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe '#obi' do
|
|
39
|
+
it 'returns the obi provisioning URL' do
|
|
40
|
+
url = provisioning_urls.urls['OBi']
|
|
41
|
+
expect(provisioning_urls.obi).to eq(url)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe '#netgen' do
|
|
46
|
+
it 'returns the netgen provisioning url' do
|
|
47
|
+
url = provisioning_urls.urls['Netgen']
|
|
48
|
+
expect(provisioning_urls.netgen).to eq(url)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe 'getting a list of ATAs', vcr: 'ata/list' do
|
|
54
|
+
let(:action) { Ata.list params }
|
|
55
|
+
let(:params) { {} }
|
|
56
|
+
|
|
57
|
+
it 'sends the request to phaxio' do
|
|
58
|
+
expect_api_request :get, 'atas', params
|
|
59
|
+
action
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'returns a collection of ATAs' do
|
|
63
|
+
result = action
|
|
64
|
+
expect(result).to be_a(Ata::Collection)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe 'creating an ATA', vcr: 'ata/create' do
|
|
69
|
+
let(:action) { Ata.create params }
|
|
70
|
+
let(:params) { {name: 'Test ATA'} }
|
|
71
|
+
|
|
72
|
+
it 'sends the request to phaxio' do
|
|
73
|
+
expect_api_request :post, 'atas', name: 'Test ATA'
|
|
74
|
+
action
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'returns information about the created ATA' do
|
|
78
|
+
result = action
|
|
79
|
+
expect(result).to be_a(Ata)
|
|
80
|
+
expect(result.name).to eq('Test ATA')
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe 'getting information about an ATA', vcr: 'ata/get' do
|
|
85
|
+
let(:action) { Ata.get ata_id, params }
|
|
86
|
+
let(:ata_id) { Ata.create(name: 'Test ATA').id }
|
|
87
|
+
let(:params) { {} }
|
|
88
|
+
|
|
89
|
+
it 'sends the request to phaxio' do
|
|
90
|
+
expect_api_request :get, "atas/#{ata_id}", params
|
|
91
|
+
action
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'returns information about the ATA' do
|
|
95
|
+
result = action
|
|
96
|
+
expect(result).to be_a(Ata)
|
|
97
|
+
expect(result.name).to eq('Test ATA')
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
describe 'updating an ATA', vcr: 'ata/update' do
|
|
102
|
+
let(:action) { Ata.update ata_id, params }
|
|
103
|
+
let(:ata_id) { Ata.create(name: 'Test ATA').id }
|
|
104
|
+
let(:params) { {name: 'New Name'} }
|
|
105
|
+
|
|
106
|
+
it 'sends the request to phaxio' do
|
|
107
|
+
expect_api_request :patch, "atas/#{ata_id}", params
|
|
108
|
+
action
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it 'returns information about the updated ATA' do
|
|
112
|
+
result = action
|
|
113
|
+
expect(result).to be_a(Ata)
|
|
114
|
+
expect(result.name).to eq('New Name')
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe 'regenerating ATA credentials', vcr: 'ata/regenerate' do
|
|
119
|
+
let(:action) { Ata.regenerate_credentials ata_id, params }
|
|
120
|
+
let(:ata) { Ata.create(name: 'Test ATA') }
|
|
121
|
+
let(:ata_id) { ata.id }
|
|
122
|
+
let(:params) { {} }
|
|
123
|
+
|
|
124
|
+
it 'sends the request to phaxio' do
|
|
125
|
+
expect_api_request :patch, "atas/#{ata_id}/regenerate_credentials", params
|
|
126
|
+
action
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it 'returns information about the ATA' do
|
|
130
|
+
original_username = ata.username
|
|
131
|
+
# some actions don't return full creds; creation does, but run a sanity check just in case
|
|
132
|
+
expect(original_username).to_not be_nil
|
|
133
|
+
result = action
|
|
134
|
+
expect(result).to be_a(Ata)
|
|
135
|
+
expect(result.username).to_not eq(original_username)
|
|
136
|
+
expect(result.username).to_not be_nil
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
describe 'deleting an ATA', vcr: 'ata/delete' do
|
|
141
|
+
let(:action) { Ata.delete ata_id, params }
|
|
142
|
+
let(:ata_id) { Ata.create(name: 'Test ATA').id }
|
|
143
|
+
let(:params) { {} }
|
|
144
|
+
|
|
145
|
+
it 'sends the request to phaxio' do
|
|
146
|
+
expect_api_request :delete, "atas/#{ata_id}", params
|
|
147
|
+
action
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
it 'returns a reference to the deleted ATA' do
|
|
151
|
+
result = action
|
|
152
|
+
expect(result).to be_a(Ata::Reference)
|
|
153
|
+
expect(result.id).to eq(ata_id)
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
describe 'adding a phone number to an ATA', vcr: 'ata/add_phone_number' do
|
|
158
|
+
let(:action) { Ata.add_phone_number ata_id, TEST_NUMBER, params }
|
|
159
|
+
let(:ata_id) { Ata.create(name: 'Test ATA').id }
|
|
160
|
+
let(:params) { {} }
|
|
161
|
+
|
|
162
|
+
it 'sends the request to phaxio' do
|
|
163
|
+
expect_api_request :post, "atas/#{ata_id}/phone_numbers/#{TEST_NUMBER}", params
|
|
164
|
+
action
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it 'returns a reference to the added phone number' do
|
|
168
|
+
result = action
|
|
169
|
+
expect(result).to be_a(PhoneNumber::Reference)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
describe 'removing a phone number from an ATA', vcr: 'ata/remove_phone_number' do
|
|
174
|
+
let(:action) { Ata.remove_phone_number ata_id, TEST_NUMBER, params }
|
|
175
|
+
let(:ata_id) { Ata.create(name: 'Test ATA').id }
|
|
176
|
+
let(:params) { {} }
|
|
177
|
+
|
|
178
|
+
before do
|
|
179
|
+
Ata.add_phone_number ata_id, TEST_NUMBER
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it 'sends the request to phaxio' do
|
|
183
|
+
expect_api_request :delete, "atas/#{ata_id}/phone_numbers/#{TEST_NUMBER}", params
|
|
184
|
+
action
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
it 'returns a reference to the removed phone number' do
|
|
188
|
+
result = action
|
|
189
|
+
expect(result).to be_a(PhoneNumber::Reference)
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
describe 'listing provisioning URLs for an ATA', vcr: 'ata/provisioning_urls' do
|
|
194
|
+
let(:action) { Ata.provisioning_urls params }
|
|
195
|
+
let(:params) { {} }
|
|
196
|
+
|
|
197
|
+
it 'sends the request to phaxio' do
|
|
198
|
+
expect_api_request :get, "atas/provisioning_urls", params
|
|
199
|
+
action
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it 'returns a set of provisioning URLs' do
|
|
203
|
+
response = action
|
|
204
|
+
expect(response).to be_a(Ata::ProvisioningURLs)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
end
|
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
|