finix 0.10 → 0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/circle.yml +10 -8
- data/lib/finix.rb +12 -1
- data/lib/finix/error.rb +2 -1
- data/lib/finix/resources/payment_instrument.rb +6 -2
- data/lib/finix/response/finix_error_middleware.rb +2 -11
- data/lib/finix/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Yjk4MjU3OGNmZDdjZmJiMmEzMTkwMDU5MjVlYmEwYzI3ZWI1YzI1OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjM4NTEzZDFhNWFmYzhkZDVmZDJiOTcyNDdlM2VkNmM2Zjg4NWMzMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWQ5OTQxOGE2NjRlYmU3Mzk5YmEyZjY3YTc0YTg0ZDk3ZWQ0ODlkZDIxZDM2
|
10
|
+
NzY2ZDlkNmFhZjZlZTM0OWRiYTFjOTUxOGE1OWI0N2I1MTJkNjU3ZmQxNTFl
|
11
|
+
OGY1ODZmNTIwMjM4YjU4ZGY1OGFiYThhZDhmMDA4NThiNzU4Y2E=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
data/lib/finix.rb
CHANGED
@@ -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?
|
29
|
+
unless options[:root_url].nil?
|
19
30
|
@config = {}
|
20
31
|
end
|
21
32
|
|
data/lib/finix/error.rb
CHANGED
@@ -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
|
-
|
16
|
+
name = self.name.sub! 'PaymentInstrument', 'PaymentCard'
|
15
17
|
elsif type == 'BANK_ACCOUNT'
|
16
|
-
|
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 =
|
20
|
-
raise Finix
|
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
|
|
data/lib/finix/version.rb
CHANGED