sfax 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sfax/client.rb +10 -1
- data/lib/sfax/constants.rb +2 -0
- data/lib/sfax/version.rb +1 -1
- data/spec/sfax_client_spec.rb +18 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fdaa7dc60428262e6a5e7329b1472404011e5ac
|
4
|
+
data.tar.gz: 15ff36354f2180a0a85179f22ec134a30f093378
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fa0aad3bfb66aed503049d66802e23133fbd21231fe18b64069d414254061caa223eca4be737a806b5c9d81c3225782e931ae26f86062c423e434d253cd3692
|
7
|
+
data.tar.gz: d0d558856c8f2a9dcb4b6fd4973fcacf9b8c280f760c6115ec787df6e5f8cd3c8f85e5b1645f55f14519fd3cb6aefeae301eae9bdf9767040ed2189c17d1bad7
|
data/lib/sfax/client.rb
CHANGED
@@ -35,8 +35,17 @@ module SFax
|
|
35
35
|
fetch('SendFaxQueueId')
|
36
36
|
end
|
37
37
|
|
38
|
+
def response_object.success?
|
39
|
+
fetch('isSuccess')
|
40
|
+
end
|
41
|
+
|
42
|
+
def response_object.message
|
43
|
+
fetch('message')
|
44
|
+
end
|
45
|
+
|
38
46
|
response_object.tap do |o|
|
39
|
-
raise SendFaxError
|
47
|
+
raise SendFaxError, o.message unless o.success?
|
48
|
+
raise SendFaxError, o.message if o.fax_id.to_s == SEND_FAX_QUEUE_ID_ERROR_VALUE
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
data/lib/sfax/constants.rb
CHANGED
data/lib/sfax/version.rb
CHANGED
data/spec/sfax_client_spec.rb
CHANGED
@@ -17,7 +17,9 @@ RSpec.describe SFax::Client do
|
|
17
17
|
let(:file) { StringIO.new('data') }
|
18
18
|
let(:recipient_name) { nil }
|
19
19
|
let(:token) { SecureRandom.hex }
|
20
|
+
let(:message) { SecureRandom.hex }
|
20
21
|
let(:send_fax_queue_id) { rand(1_000_000) }
|
22
|
+
let(:is_success) { true }
|
21
23
|
let!(:send_fax_request) do
|
22
24
|
stub_request(:post, 'https://api.sfaxme.com/api/sendfax').with(query: {
|
23
25
|
'token' => token,
|
@@ -26,6 +28,8 @@ RSpec.describe SFax::Client do
|
|
26
28
|
'RecipientName' => recipient_name,
|
27
29
|
}).and_return(body: {
|
28
30
|
'SendFaxQueueId' => send_fax_queue_id,
|
31
|
+
'isSuccess' => is_success,
|
32
|
+
'message' => message,
|
29
33
|
}.to_json)
|
30
34
|
end
|
31
35
|
|
@@ -50,12 +54,24 @@ RSpec.describe SFax::Client do
|
|
50
54
|
end
|
51
55
|
|
52
56
|
context 'send_fax_queue_id is -1' do
|
53
|
-
let(:send_fax_queue_id) { -1 }
|
57
|
+
let(:send_fax_queue_id) { '-1' }
|
54
58
|
|
55
59
|
specify do
|
56
60
|
expect {
|
57
61
|
subject.send_fax(fax_number: fax_number, file: file, recipient_name: recipient_name)
|
58
|
-
}.to raise_error(described_class::SendFaxError)
|
62
|
+
}.to raise_error(described_class::SendFaxError, message)
|
63
|
+
|
64
|
+
expect(send_fax_request).to have_been_requested
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'isSuccess is false' do
|
69
|
+
let(:is_success) { false }
|
70
|
+
|
71
|
+
specify do
|
72
|
+
expect {
|
73
|
+
subject.send_fax(fax_number: fax_number, file: file, recipient_name: recipient_name)
|
74
|
+
}.to raise_error(described_class::SendFaxError, message)
|
59
75
|
|
60
76
|
expect(send_fax_request).to have_been_requested
|
61
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sfax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Schneider
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|