conekta 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG +4 -0
- data/Gemfile +1 -0
- data/lib/conekta.rb +9 -0
- data/lib/conekta/error.rb +12 -9
- data/lib/conekta/requestor.rb +4 -2
- data/lib/conekta/resource.rb +1 -1
- data/lib/conekta/version.rb +1 -1
- data/locales/en.yml +7 -0
- data/locales/es.yml +7 -0
- data/spec/conekta_spec.rb +0 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTA3YmQzYTliZWM5MDdjY2ZkZWRmZTNjMDgwOWJlYWIyNzYzOGU1MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDE0MzUyMTdiMWZmMDc2ZDE5MmM4ZWY1NWVjYzc1OGQyNDU4NTAwZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2M5MGVjOTY5Mzc3YzZiMDBlNmU4MjBmMzZlYzkzMTJlNjdmNmMxMzU2MWM5
|
10
|
+
YmI2YzkxZTdjNjQzYzg4NmRjMTQxZTE4NjQ3YTZiZTNkMDMxZWU0ZTgxODE1
|
11
|
+
NDQ2NTI2ZWE2NTc1NDAyZjlhZWNjOGM5NDkxYjFmMTk3YTIyNjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWNkNzA5MGQ4ZDA3OWEwNGIxNjQzYTIyNmQyMTI5ZDY0NDEyZDg0NTc2ZTgz
|
14
|
+
ZmExZWY1OWYzMWUyNGVjMDVjNDhkYTIzMTRmOWU5ZDQyMDg4ZmYxZTY3NjQ0
|
15
|
+
OTBhMDAxMzc2ODdmZDlmMzdkMTAwNTlmMjM4YzFlYTFlYmRmMjY=
|
data/CHANGELOG
CHANGED
data/Gemfile
CHANGED
data/lib/conekta.rb
CHANGED
@@ -28,10 +28,13 @@ require "conekta/payout"
|
|
28
28
|
require "conekta/payout_method"
|
29
29
|
require "conekta/method"
|
30
30
|
require "conekta/webhook_log"
|
31
|
+
require "i18n"
|
31
32
|
|
32
33
|
module Conekta
|
34
|
+
I18n.load_path = Dir[File.join(File.expand_path('../..', __FILE__), 'locales', '*.{rb,yml}').to_s]
|
33
35
|
@api_base = 'https://api.conekta.io'
|
34
36
|
@api_version = '0.3.0'
|
37
|
+
@locale = 'es'
|
35
38
|
def self.api_base
|
36
39
|
@api_base
|
37
40
|
end
|
@@ -50,4 +53,10 @@ module Conekta
|
|
50
53
|
def self.api_key=(api_key)
|
51
54
|
@api_key = api_key
|
52
55
|
end
|
56
|
+
def self.locale
|
57
|
+
@locale
|
58
|
+
end
|
59
|
+
def self.locale=(locale)
|
60
|
+
@locale = locale
|
61
|
+
end
|
53
62
|
end
|
data/lib/conekta/error.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
module Conekta
|
2
2
|
class Error < Exception
|
3
3
|
attr_reader :message
|
4
|
+
attr_reader :message_to_purchaser
|
4
5
|
attr_reader :type
|
5
6
|
attr_reader :code
|
6
7
|
attr_reader :param
|
7
8
|
|
8
|
-
def initialize(message=nil, type=nil, code=nil, param=nil)
|
9
|
+
def initialize(message=nil, message_to_purchaser=nil, type=nil, code=nil, param=nil)
|
9
10
|
@message = message
|
11
|
+
@message_to_purchaser = message_to_purchaser
|
10
12
|
@type = type
|
11
13
|
@code = code
|
12
14
|
@param = param
|
@@ -17,28 +19,29 @@ module Conekta
|
|
17
19
|
def self.error_handler(resp, code)
|
18
20
|
if resp.instance_of?(Hash)
|
19
21
|
@message = resp["message"] if resp.has_key?('message')
|
22
|
+
@message_to_purchaser = resp["message_to_purchaser"] if resp.has_key?('message_to_purchaser')
|
20
23
|
@type = resp["type"] if resp.has_key?('type')
|
21
24
|
@code = resp["code"] if resp.has_key?('code')
|
22
25
|
@param = resp["param"] if resp.has_key?('param')
|
23
26
|
end
|
24
27
|
if code == nil or code == 0 or code == nil or code == ""
|
25
|
-
raise NoConnectionError.new(
|
28
|
+
raise NoConnectionError.new(I18n.t('error.requestor.connection', {base: Conekta.api_base, locale: :en}), I18n.t('error.requestor.connection', {base: Conekta.api_base, locale: Conekta.locale.to_sym}))
|
26
29
|
end
|
27
30
|
case code
|
28
31
|
when 400
|
29
|
-
raise MalformedRequestError.new(@message, @type, @code, @params)
|
32
|
+
raise MalformedRequestError.new(@message, @message_to_purchaser, @type, @code, @params)
|
30
33
|
when 401
|
31
|
-
raise AuthenticationError.new(@message, @type, @code, @params)
|
34
|
+
raise AuthenticationError.new(@message, @message_to_purchaser, @type, @code, @params)
|
32
35
|
when 402
|
33
|
-
raise ProcessingError.new(@message, @type, @code, @params)
|
36
|
+
raise ProcessingError.new(@message, @message_to_purchaser, @type, @code, @params)
|
34
37
|
when 404
|
35
|
-
raise ResourceNotFoundError.new(@message, @type, @code, @params)
|
38
|
+
raise ResourceNotFoundError.new(@message, @message_to_purchaser, @type, @code, @params)
|
36
39
|
when 422
|
37
|
-
raise ParameterValidationError.new(@message, @type, @code, @params)
|
40
|
+
raise ParameterValidationError.new(@message, @message_to_purchaser, @type, @code, @params)
|
38
41
|
when 500
|
39
|
-
raise ApiError.new(@message, @type, @code, @params)
|
42
|
+
raise ApiError.new(@message, @message_to_purchaser, @type, @code, @params)
|
40
43
|
else
|
41
|
-
raise Error.new(@message, @type, @code, @params)
|
44
|
+
raise Error.new(@message, @message_to_purchaser, @type, @code, @params)
|
42
45
|
end
|
43
46
|
end
|
44
47
|
end
|
data/lib/conekta/requestor.rb
CHANGED
@@ -18,7 +18,8 @@ module Conekta
|
|
18
18
|
begin
|
19
19
|
conn = Faraday.new(:ssl => {
|
20
20
|
:ca_file => File.dirname(__FILE__) + '/../ssl_data/ca_bundle.crt'
|
21
|
-
}
|
21
|
+
}
|
22
|
+
) do |faraday|
|
22
23
|
faraday.adapter Faraday.default_adapter
|
23
24
|
end
|
24
25
|
response = conn.method(meth).call do |req|
|
@@ -27,6 +28,7 @@ module Conekta
|
|
27
28
|
req.headers['X-Conekta-Client-User-Agent'] = set_headers.to_json
|
28
29
|
req.headers['User-Agent'] = 'Conekta/v1 RubyBindings/' + Conekta::VERSION
|
29
30
|
req.headers['Accept'] = "application/vnd.conekta-v#{Conekta.api_version}+json"
|
31
|
+
req.headers['Accept-Language'] = Conekta.locale
|
30
32
|
req.headers['Authorization'] = "Basic #{ Base64.encode64("#{self.api_key}" + ':')}"
|
31
33
|
if params
|
32
34
|
req.headers['Content-Type'] = 'application/json'
|
@@ -34,7 +36,7 @@ module Conekta
|
|
34
36
|
end
|
35
37
|
end
|
36
38
|
rescue Exception => e
|
37
|
-
Error.error_handler(e
|
39
|
+
Error.error_handler(e, "")
|
38
40
|
end
|
39
41
|
if response.status != 200
|
40
42
|
Error.error_handler(JSON.parse(response.body), response.status)
|
data/lib/conekta/resource.rb
CHANGED
@@ -5,7 +5,7 @@ module Conekta
|
|
5
5
|
end
|
6
6
|
def url
|
7
7
|
if id == nil || id == ""
|
8
|
-
raise Error.new('
|
8
|
+
raise Error.new(I18n.t('error.resource.id', {resource: self.class.class_name, locale: :en}), I18n.t('error.resource.id', {resource: self.class.class_name, locale: Conekta.locale.to_sym}))
|
9
9
|
end
|
10
10
|
self.class.url + "/" + id
|
11
11
|
end
|
data/lib/conekta/version.rb
CHANGED
data/locales/en.yml
ADDED
data/locales/es.yml
ADDED
data/spec/conekta_spec.rb
CHANGED
@@ -15,7 +15,6 @@ describe :conekta_tests do
|
|
15
15
|
bank: {
|
16
16
|
account_number: '032180000118359719',
|
17
17
|
account_holder: 'J D - Radcorp',
|
18
|
-
bank: 'Banorte',
|
19
18
|
description: 'Conekta To JD',
|
20
19
|
statement_description: 'Conekta To JD 111111111',
|
21
20
|
statement_reference: '111111111'
|
@@ -57,7 +56,6 @@ describe :conekta_tests do
|
|
57
56
|
payout.method.account_number.should eq('032180000118359719')
|
58
57
|
payout.method.account_holder.should eq('J D - Radcorp')
|
59
58
|
payout.method.bank.should eq('ixe')
|
60
|
-
# payout.payout_transaction_id.should_not eq(nil)
|
61
59
|
payout.transactions.count.should eq(0)
|
62
60
|
end
|
63
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conekta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MauricioMurga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,6 +136,8 @@ files:
|
|
136
136
|
- lib/conekta/version.rb
|
137
137
|
- lib/conekta/webhook_log.rb
|
138
138
|
- lib/ssl_data/ca_bundle.crt
|
139
|
+
- locales/en.yml
|
140
|
+
- locales/es.yml
|
139
141
|
- spec/conekta_spec.rb
|
140
142
|
- spec/spec_helper.rb
|
141
143
|
homepage: https://www.conekta.io
|