finix 0.10 → 0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Yzg5Y2E4MmY3NzNhYzJmMjcwNGNmOTdhOTk5ZTA5NzFkMjVkYTE5Zg==
4
+ Yjk4MjU3OGNmZDdjZmJiMmEzMTkwMDU5MjVlYmEwYzI3ZWI1YzI1OQ==
5
5
  data.tar.gz: !binary |-
6
- YTgyMjk3ZDA5NGU2OGYyMDFjODc3YzlkMWM0ODFiOTBlNGYyOWQwNQ==
6
+ MjM4NTEzZDFhNWFmYzhkZDVmZDJiOTcyNDdlM2VkNmM2Zjg4NWMzMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDg5Yzk1ZGYzYTU0YWFlMTZhNDE2MzFmZjYzYmExZWQ4NzI2YWZjYTYyNTY4
10
- NDgwNTBjMDEwOWM3M2IwNDI1MTZiNWZjNjYwYjZkODgwMWYwNDM4ZjFiNWRl
11
- OTlmM2U0NGNhYTY2N2YwMzA4OTE1N2NlZWJkN2RlYmNhNDQ3MjU=
9
+ YWQ5OTQxOGE2NjRlYmU3Mzk5YmEyZjY3YTc0YTg0ZDk3ZWQ0ODlkZDIxZDM2
10
+ NzY2ZDlkNmFhZjZlZTM0OWRiYTFjOTUxOGE1OWI0N2I1MTJkNjU3ZmQxNTFl
11
+ OGY1ODZmNTIwMjM4YjU4ZGY1OGFiYThhZDhmMDA4NThiNzU4Y2E=
12
12
  data.tar.gz: !binary |-
13
- ZTVmZDQ1MzNlNWE4N2Y2Mjc0OWNlODUyMTdjNDYxN2I3MDE4YTViMmYzYzVk
14
- ZTE0ZjJjZjVkN2E5YWZiMmU5ODllNzFiZjE2MTZmMzEzMGIxOTUwMTM2NGI5
15
- M2UzMjVkZmRjZTI5MjY3MDkxMDUxY2YzMzdjMjYyNWNiN2NjY2Y=
13
+ NzMwOTkyYTYwNTE1MTZiZTI2ZDEwYTFmNGU1OWQ2ZGU0ZmMwOTllYzAzMjA4
14
+ N2UxNjkxNGU3NzYyN2RhMmJkZWViODM0NmJlZjhmODhhYjJjNzY4OWIwOGY2
15
+ NThjMDk2Y2Y5YWJkZDkxYTNhNmZjZGJiZTUzNmQ5ZTg2YjJhNDI=
data/circle.yml CHANGED
@@ -20,11 +20,13 @@ test:
20
20
  post:
21
21
  - cp -Rf .report/ $CIRCLE_ARTIFACTS
22
22
 
23
- #deployment:
24
- # release:
25
- # tag: /v[0-9]+(\.[0-9]+)*/
26
- # owner: finix-payments
27
- # commands:
28
- # - echo "--\n:rubygems_api_key: ${RUBYGEMS_API_KEY}" > ~/.gem/credentials
29
- # - gem build *.gemspec
30
- # - gem push *.gem
23
+ deployment:
24
+ release:
25
+ tag: /v[0-9]+(\.[0-9]+)*/
26
+ owner: finix-payments
27
+ commands:
28
+ - |
29
+ curl -u ${rubygems_user}:${rubygems_password} https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials
30
+ - chmod 0600 ~/.gem/credentials
31
+ - gem build *.gemspec
32
+ - gem push *.gem
@@ -7,15 +7,26 @@ module Finix
7
7
  @client = nil
8
8
  @config = {:root_url => 'https://localhost/processing'}
9
9
  @hypermedia_registry = {}
10
+ @errors_registry = {
11
+ :unknown => Finix::ResourceErrors,
12
+ 400 => Finix::BadRequest,
13
+ 401 => Finix::Unauthorized,
14
+ 403 => Finix::Forbidden,
15
+ 404 => Finix::NotFound,
16
+ 405 => Finix::MethodNotAllowed,
17
+ 422 => Finix::UnprocessableEntity,
18
+ 500 => Finix::ServerError
19
+ }
10
20
 
11
21
  class << self
12
22
 
13
23
  attr_accessor :client
14
24
  attr_accessor :config
15
25
  attr_accessor :hypermedia_registry
26
+ attr_accessor :errors_registry
16
27
 
17
28
  def configure(options={})
18
- unless options[:root_url].nil? # reset us/pass as well if user update :root_url
29
+ unless options[:root_url].nil?
19
30
  @config = {}
20
31
  end
21
32
 
@@ -19,7 +19,7 @@ module Finix
19
19
  end
20
20
  end
21
21
 
22
- class ResourceError
22
+ class ResourceError < ::StandardError
23
23
  attr_reader :attributes
24
24
 
25
25
  def initialize(error = {})
@@ -42,4 +42,5 @@ module Finix
42
42
  class NotFound < ResourceErrors; end
43
43
  class MethodNotAllowed < ResourceErrors; end
44
44
  class UnprocessableEntity < ResourceErrors; end
45
+ class ServerError < ResourceErrors; end
45
46
  end
@@ -10,11 +10,15 @@ module Finix
10
10
  def hypermedia_subtype(response)
11
11
  unless response.nil?
12
12
  type = response['instrument_type'] || response['type']
13
+ name = self.name.sub! 'PaymentInstrument', 'PaymentCard'
14
+ self.instance_eval name
13
15
  if type == 'PAYMENT_CARD'
14
- return Finix::PaymentCard
16
+ name = self.name.sub! 'PaymentInstrument', 'PaymentCard'
15
17
  elsif type == 'BANK_ACCOUNT'
16
- return Finix::BankAccount
18
+ name = self.name.sub! 'PaymentInstrument', 'BankAccount'
17
19
  end
20
+
21
+ return self.instance_eval name unless name.nil?
18
22
  end
19
23
  self
20
24
  end
@@ -5,19 +5,10 @@ module Faraday
5
5
 
6
6
  class Response::RaiseApiError < Response::Middleware
7
7
 
8
- HTTP_STATUS_CODES = {
9
- 400 => Finix::BadRequest,
10
- 401 => Finix::Unauthorized,
11
- 403 => Finix::Forbidden,
12
- 404 => Finix::NotFound,
13
- 405 => Finix::MethodNotAllowed,
14
- 422 => Finix::UnprocessableEntity
15
- }
16
-
17
8
  def on_complete(response)
18
9
  status_code = response[:status].to_i
19
- error_class = HTTP_STATUS_CODES[status_code]
20
- raise Finix::ResourceErrors.new(response) if error_class.nil? and status_code >= 400
10
+ error_class = Finix.errors_registry[status_code]
11
+ raise Finix.errors_registry[:unknown].new(response) if error_class.nil? and status_code >= 400
21
12
  raise error_class.new(response) if error_class
22
13
  end
23
14
 
@@ -1,3 +1,3 @@
1
1
  module Finix
2
- VERSION = '0.10'
2
+ VERSION = '0.11'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finix
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.10'
4
+ version: '0.11'
5
5
  platform: ruby
6
6
  authors:
7
7
  - finix-payments