sfax 0.2.0 → 0.3.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.rb +1 -0
- data/lib/sfax/client.rb +3 -5
- data/lib/sfax/errors.rb +16 -0
- data/lib/sfax/version.rb +1 -1
- data/spec/sfax/errors_spec.rb +33 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eec66efe4f81cba14622f07b75517a1749ddc56b
|
4
|
+
data.tar.gz: e30e25d9bb3c84e7664f559bac45b43bf5c9d9c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a5a9b9a5bee104c31ac823225c2044ea1f1da22eda4c68e2d89a08aa50c13f1d7d6dd9e5227f38aab941d92f68f974d94b833e93e12041f5e2ea4a5b0cff830
|
7
|
+
data.tar.gz: 79c2b10cf033095caed2908e6838880bf8082b6c7328b0fb40e50685910e32ce5a2bc24e4cde2047c8270a696ed3098eb5ae4d763ab63a391f5b9eb70f51c312
|
data/lib/sfax.rb
CHANGED
data/lib/sfax/client.rb
CHANGED
@@ -7,6 +7,7 @@ require 'json'
|
|
7
7
|
module SFax
|
8
8
|
class Client
|
9
9
|
include Constants
|
10
|
+
include Errors
|
10
11
|
|
11
12
|
def initialize(username:, api_key:, encryption_key:)
|
12
13
|
@username = username
|
@@ -44,8 +45,8 @@ module SFax
|
|
44
45
|
end
|
45
46
|
|
46
47
|
response_object.tap do |o|
|
47
|
-
raise SendFaxError
|
48
|
-
raise SendFaxError
|
48
|
+
raise SendFaxError.new(message: o.message, response: o) unless o.success?
|
49
|
+
raise SendFaxError.new(message: o.message, response: o) if o.fax_id.to_s == SEND_FAX_QUEUE_ID_ERROR_VALUE
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -74,8 +75,5 @@ module SFax
|
|
74
75
|
raise InvalidFaxNumberError, "Expected an 11 digit fax number. Got: #{number}"
|
75
76
|
end
|
76
77
|
end
|
77
|
-
|
78
|
-
InvalidFaxNumberError = Class.new(StandardError)
|
79
|
-
SendFaxError = Class.new(StandardError)
|
80
78
|
end
|
81
79
|
end
|
data/lib/sfax/errors.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
module SFax
|
3
|
+
module Errors
|
4
|
+
class SendFaxError < StandardError
|
5
|
+
attr_reader :response
|
6
|
+
DEFAULT_MESSAGE = 'An error occurred while submitting the fax for sending.'.freeze
|
7
|
+
|
8
|
+
def initialize(message: DEFAULT_MESSAGE, response: nil)
|
9
|
+
@response = response
|
10
|
+
super(message)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
InvalidFaxNumberError = Class.new(StandardError)
|
15
|
+
end
|
16
|
+
end
|
data/lib/sfax/version.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe SFax::Errors do
|
4
|
+
let(:message) { SecureRandom.hex }
|
5
|
+
let(:response) do
|
6
|
+
{
|
7
|
+
'isSuccess' => false,
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'SendFaxError' do
|
12
|
+
specify do
|
13
|
+
error = described_class::SendFaxError.new
|
14
|
+
|
15
|
+
expect(error.message).to eq('An error occurred while submitting the fax for sending.')
|
16
|
+
expect(error.response).to eq(nil)
|
17
|
+
end
|
18
|
+
|
19
|
+
specify do
|
20
|
+
error = described_class::SendFaxError.new(message: message)
|
21
|
+
|
22
|
+
expect(error.message).to eq(message)
|
23
|
+
expect(error.response).to eq(nil)
|
24
|
+
end
|
25
|
+
|
26
|
+
specify do
|
27
|
+
error = described_class::SendFaxError.new(message: message, response: response)
|
28
|
+
|
29
|
+
expect(error.message).to eq(message)
|
30
|
+
expect(error.response).to eq(response)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
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.3.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: 2017-02-
|
11
|
+
date: 2017-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -97,8 +97,10 @@ files:
|
|
97
97
|
- lib/sfax/client.rb
|
98
98
|
- lib/sfax/constants.rb
|
99
99
|
- lib/sfax/encryptor.rb
|
100
|
+
- lib/sfax/errors.rb
|
100
101
|
- lib/sfax/version.rb
|
101
102
|
- sfax.gemspec
|
103
|
+
- spec/sfax/errors_spec.rb
|
102
104
|
- spec/sfax_client_spec.rb
|
103
105
|
- spec/sfax_encryptor_spec.rb
|
104
106
|
- spec/sfax_spec.rb
|
@@ -128,6 +130,7 @@ signing_key:
|
|
128
130
|
specification_version: 4
|
129
131
|
summary: Ruby client for SFax API
|
130
132
|
test_files:
|
133
|
+
- spec/sfax/errors_spec.rb
|
131
134
|
- spec/sfax_client_spec.rb
|
132
135
|
- spec/sfax_encryptor_spec.rb
|
133
136
|
- spec/sfax_spec.rb
|