payfort_start 0.0.3 → 0.0.4

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: 5c695a731adfd0f2e3341a812c6679f2882e3da9
4
- data.tar.gz: f8ebd8dbdfb9f1a5e45f0237db91d222187856e5
3
+ metadata.gz: 33b0bfdca559a9ca3276432bdf7cde6a479fa080
4
+ data.tar.gz: fdb8087d4461755e61a7ab0313ef6075dea73ba1
5
5
  SHA512:
6
- metadata.gz: d0d8c40bf5711a070266fb56a3626dbef58e1d2fd69e40c69e255097000c4322605c5b3cb04ca34fd274c42c3f35a3f835b9fcdec87ebc71aedf29b825b40721
7
- data.tar.gz: a76f1ac3662c00369398c980408ec261995ae6979094c04d82ffc2b8255295e13c69b9bab4e4f2d44cbd44c4dbedfd6d1b6a2088a6911a5b32f88469b4828138
6
+ metadata.gz: 0bcdb5efc99c2aedd93028aabc690247658340c957f45cc4d19e45a9c2e8dd9eeb7082de92c1f1fefd6d8eee7f8176676b352c509b0aa49d93ca1cf92ac9803a
7
+ data.tar.gz: b00f6da8ca8a47450c562f6ca717335d82ce1e59351a3b274b5e7c90e2e3c609e980b39ebebbabd8dab89afa42e260c478ca4d9b43ee8aee2ff3e57bdfbdeaf4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- payfort_start (0.0.2)
4
+ payfort_start (0.0.3)
5
5
  httparty (~> 0.13)
6
6
  json (~> 1.8)
7
7
 
@@ -25,23 +25,13 @@ module Start
25
25
  return body
26
26
  end
27
27
 
28
- # There was an error .. check the response
29
- case body['error']['type']
30
- when 'banking'
31
- raise Start::BankingError.new(body['error']['message'], body['error']['code'], response.code)
28
+ exception_class = if ['banking', 'authentication', 'processing', 'request'].include?(body['error']['type'])
29
+ Object.const_get "Start::#{body['error']['type'].capitalize}Error"
30
+ else
31
+ StartError
32
+ end
32
33
 
33
- when 'authentication'
34
- raise Start::AuthenticationError.new(body['error']['message'], body['error']['code'], response.code)
35
-
36
- when 'processing'
37
- raise Start::ProcessingError.new(body['error']['message'], body['error']['code'], response.code)
38
-
39
- when 'request'
40
- raise Start::RequestError.new(body['error']['message'], body['error']['code'], response.code)
41
- end
42
-
43
- # Otherwise, raise a General error
44
- raise Start::StartError.new(body['error']['message'], body['error']['code'], response.code)
34
+ raise exception_class.new(body['error']['message'], body['error']['code'], response.code, body['error']['extras'])
45
35
  end
46
36
  end
47
37
  end
@@ -1,13 +1,12 @@
1
1
  module Start
2
2
  class StartError < StandardError
3
- attr_reader :message
4
- attr_reader :code
5
- attr_reader :http_status
3
+ attr_reader :message, :code, :http_status, :extras
6
4
 
7
- def initialize(message=nil, code=nil, http_status=nil)
5
+ def initialize(message = nil, code = nil, http_status = nil, extras = {})
8
6
  @message = message
9
7
  @code = code
10
8
  @http_status = http_status
9
+ @extras = extras
11
10
  end
12
11
 
13
12
  def to_s
@@ -1,3 +1,3 @@
1
1
  module Start
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -21,6 +21,7 @@ describe Start::BankingError do
21
21
  rescue Start::BankingError => e
22
22
  expect(e.code).to eq('card_declined')
23
23
  expect(e.http_status).to eq(402)
24
+ expect(e.extras).to include('charge')
24
25
  end
25
26
  end
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payfort_start
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Gabriel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-22 00:00:00.000000000 Z
12
+ date: 2015-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty