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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fdaa7dc60428262e6a5e7329b1472404011e5ac
4
- data.tar.gz: 15ff36354f2180a0a85179f22ec134a30f093378
3
+ metadata.gz: eec66efe4f81cba14622f07b75517a1749ddc56b
4
+ data.tar.gz: e30e25d9bb3c84e7664f559bac45b43bf5c9d9c8
5
5
  SHA512:
6
- metadata.gz: 2fa0aad3bfb66aed503049d66802e23133fbd21231fe18b64069d414254061caa223eca4be737a806b5c9d81c3225782e931ae26f86062c423e434d253cd3692
7
- data.tar.gz: d0d558856c8f2a9dcb4b6fd4973fcacf9b8c280f760c6115ec787df6e5f8cd3c8f85e5b1645f55f14519fd3cb6aefeae301eae9bdf9767040ed2189c17d1bad7
6
+ metadata.gz: 6a5a9b9a5bee104c31ac823225c2044ea1f1da22eda4c68e2d89a08aa50c13f1d7d6dd9e5227f38aab941d92f68f974d94b833e93e12041f5e2ea4a5b0cff830
7
+ data.tar.gz: 79c2b10cf033095caed2908e6838880bf8082b6c7328b0fb40e50685910e32ce5a2bc24e4cde2047c8270a696ed3098eb5ae4d763ab63a391f5b9eb70f51c312
@@ -1,3 +1,4 @@
1
+ require 'sfax/errors'
1
2
  require 'sfax/client'
2
3
  require 'sfax/encryptor'
3
4
  require 'sfax/version'
@@ -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, o.message unless o.success?
48
- raise SendFaxError, o.message if o.fax_id.to_s == SEND_FAX_QUEUE_ID_ERROR_VALUE
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module SFax
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -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.2.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-19 00:00:00.000000000 Z
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