conekta 0.4.0 → 0.4.1
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/Gemfile +0 -1
- data/lib/conekta.rb +1 -2
- data/lib/conekta/method.rb +4 -0
- data/lib/conekta/payee.rb +26 -0
- data/lib/conekta/payout.rb +7 -0
- data/lib/conekta/payout_method.rb +16 -0
- data/lib/conekta/util.rb +39 -6
- data/lib/conekta/version.rb +1 -1
- data/lib/conekta/webhook_log.rb +4 -0
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmFlNDMyNzJhOGEwODI0NTVjM2I0ZmU2OWEyZjUwOGVlNDIxMjVjZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzM5NDk1ODM5ZmU1YjViMDJiNWQ2YTIxNmI4NDA3MDQ4NjlmZmQ2Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWNlM2JkNzllNGYyYWJlN2ExMGU4N2FmNzBjY2M0YjJhNTI4NjFiNzFmZDI3
|
10
|
+
NGU2YzQ4NjdlNWQ0NzBjYjUwZGJiMDkwYzllYTNjYjQwMmJhOTMwYThmMzcz
|
11
|
+
OGI3ZjE2NTkzNzY0YjZiYzlkZGRkYjYxZDc4M2RiZDZmNzQyNGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTIxZWZkYWFlYmJjYzI1YjM1YjE1YjAwYjE3OGY1YjllODQwMWMzNDU3Yzky
|
14
|
+
NjllYTJmZjUyYjE2N2I1MmNlMDc4Njc4NTk2Yzc3NWFkMDMyNDFlYmE2MDI4
|
15
|
+
MjdiYjlkZTM1OTI1MDJhZWE0NmRjZTY4NWVhYmFjOTU0MmQ1N2E=
|
data/Gemfile
CHANGED
data/lib/conekta.rb
CHANGED
@@ -30,8 +30,7 @@ require "conekta/method"
|
|
30
30
|
require "conekta/webhook_log"
|
31
31
|
|
32
32
|
module Conekta
|
33
|
-
|
34
|
-
@api_base = 'http://localhost:3000'
|
33
|
+
@api_base = 'https://api.conekta.io'
|
35
34
|
@api_version = '0.3.0'
|
36
35
|
def self.api_base
|
37
36
|
@api_base
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Conekta
|
2
|
+
class Payee < Resource
|
3
|
+
include Conekta::Operations::Find
|
4
|
+
include Conekta::Operations::Where
|
5
|
+
include Conekta::Operations::Create
|
6
|
+
include Conekta::Operations::Delete
|
7
|
+
include Conekta::Operations::Update
|
8
|
+
include Conekta::Operations::CustomAction
|
9
|
+
include Conekta::Operations::CreateMember
|
10
|
+
def load_from(response=nil)
|
11
|
+
if response
|
12
|
+
super
|
13
|
+
end
|
14
|
+
payee = self
|
15
|
+
self.payout_methods.each do |k,v|
|
16
|
+
if !v.respond_to? :deleted or !v.deleted
|
17
|
+
v.create_attr('payee', payee)
|
18
|
+
self.payout_methods.set_val(k,v)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def create_payout_method(params)
|
23
|
+
self.create_member('payout_methods', params)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Conekta
|
2
|
+
class PayoutMethod < Resource
|
3
|
+
include Conekta::Operations::Delete
|
4
|
+
include Conekta::Operations::Update
|
5
|
+
include Conekta::Operations::CustomAction
|
6
|
+
def url
|
7
|
+
if id == nil || id == ""
|
8
|
+
raise Error.new('Could not get the id of ' + self.class.class_name + ' instance.')
|
9
|
+
end
|
10
|
+
self.payee.url + self.class.url + "/" + id
|
11
|
+
end
|
12
|
+
def delete
|
13
|
+
self.delete_member('payee','payout_methods')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/conekta/util.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'active_support/inflector'
|
2
1
|
module Conekta
|
3
2
|
module Util
|
4
3
|
def self.types
|
@@ -27,12 +26,12 @@ module Conekta
|
|
27
26
|
instance.load_from(resp)
|
28
27
|
return instance
|
29
28
|
elsif name.instance_of? String
|
30
|
-
name = "event_data" if name
|
31
|
-
name = "obj" if name
|
32
|
-
if !Object.const_defined?(name
|
33
|
-
instance = Object.const_set(name
|
29
|
+
name = "event_data" if camelize(name) == "Data"
|
30
|
+
name = "obj" if camelize(name) == "Object"
|
31
|
+
if !Object.const_defined?(camelize(name))
|
32
|
+
instance = Object.const_set(camelize(name), Class.new(ConektaObject)).new
|
34
33
|
else
|
35
|
-
instance = name.
|
34
|
+
instance = constantize(camelize(name)).new
|
36
35
|
end
|
37
36
|
instance.load_from(resp)
|
38
37
|
return instance
|
@@ -52,5 +51,39 @@ module Conekta
|
|
52
51
|
end
|
53
52
|
return instance
|
54
53
|
end
|
54
|
+
protected
|
55
|
+
def self.camelize(str)
|
56
|
+
str.split('_').map{|e| e.capitalize}.join
|
57
|
+
end
|
58
|
+
def self.constantize(camel_cased_word)
|
59
|
+
names = camel_cased_word.split('::')
|
60
|
+
|
61
|
+
# Trigger a builtin NameError exception including the ill-formed constant in the message.
|
62
|
+
Object.const_get(camel_cased_word) if names.empty?
|
63
|
+
|
64
|
+
# Remove the first blank element in case of '::ClassName' notation.
|
65
|
+
names.shift if names.size > 1 && names.first.empty?
|
66
|
+
|
67
|
+
names.inject(Object) do |constant, name|
|
68
|
+
if constant == Object
|
69
|
+
constant.const_get(name)
|
70
|
+
else
|
71
|
+
candidate = constant.const_get(name)
|
72
|
+
next candidate if constant.const_defined?(name, false)
|
73
|
+
next candidate unless Object.const_defined?(name)
|
74
|
+
|
75
|
+
# Go down the ancestors to check it it's owned
|
76
|
+
# directly before we reach Object or the end of ancestors.
|
77
|
+
constant = constant.ancestors.inject do |const, ancestor|
|
78
|
+
break const if ancestor == Object
|
79
|
+
break ancestor if ancestor.const_defined?(name, false)
|
80
|
+
const
|
81
|
+
end
|
82
|
+
|
83
|
+
# owner is in Object, so raise
|
84
|
+
constant.const_get(name, false)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
55
88
|
end
|
56
89
|
end
|
data/lib/conekta/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MauricioMurga
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/conekta/customer.rb
|
116
116
|
- lib/conekta/error.rb
|
117
117
|
- lib/conekta/event.rb
|
118
|
+
- lib/conekta/method.rb
|
118
119
|
- lib/conekta/operations/create.rb
|
119
120
|
- lib/conekta/operations/create_member.rb
|
120
121
|
- lib/conekta/operations/custom_action.rb
|
@@ -122,7 +123,10 @@ files:
|
|
122
123
|
- lib/conekta/operations/find.rb
|
123
124
|
- lib/conekta/operations/update.rb
|
124
125
|
- lib/conekta/operations/where.rb
|
126
|
+
- lib/conekta/payee.rb
|
125
127
|
- lib/conekta/payment_method.rb
|
128
|
+
- lib/conekta/payout.rb
|
129
|
+
- lib/conekta/payout_method.rb
|
126
130
|
- lib/conekta/plan.rb
|
127
131
|
- lib/conekta/requestor.rb
|
128
132
|
- lib/conekta/resource.rb
|
@@ -130,6 +134,7 @@ files:
|
|
130
134
|
- lib/conekta/token.rb
|
131
135
|
- lib/conekta/util.rb
|
132
136
|
- lib/conekta/version.rb
|
137
|
+
- lib/conekta/webhook_log.rb
|
133
138
|
- lib/ssl_data/ca_bundle.crt
|
134
139
|
- spec/conekta_spec.rb
|
135
140
|
- spec/spec_helper.rb
|