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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODc3YTc5NTUzOGQxMjgzMTk3YTNlMjA1NzJiOGIxODFjMDRjNjNjYw==
4
+ ZmFlNDMyNzJhOGEwODI0NTVjM2I0ZmU2OWEyZjUwOGVlNDIxMjVjZg==
5
5
  data.tar.gz: !binary |-
6
- NDllYzQyYWU4YTAyZWRjMmNlMDU0YjE3M2E1ZTFmYmMwMjIyZTg1ZA==
6
+ MzM5NDk1ODM5ZmU1YjViMDJiNWQ2YTIxNmI4NDA3MDQ4NjlmZmQ2Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjdlYzNjMWJhZWExNTllZTEzZDM3OGMxZTE5YjcwOGZiMTFlZWMyY2RmNDdj
10
- OTIxYjNiZWRjODA3NGNkNTMxODIxYWIzOTc0YmUzMWZiMDVkZjkzZGZiMWE3
11
- ZmM1YzJiZGMxZTcwYjhjZmRlYzc5MzFhZDEyMzIzZDhkNGUwMGE=
9
+ OWNlM2JkNzllNGYyYWJlN2ExMGU4N2FmNzBjY2M0YjJhNTI4NjFiNzFmZDI3
10
+ NGU2YzQ4NjdlNWQ0NzBjYjUwZGJiMDkwYzllYTNjYjQwMmJhOTMwYThmMzcz
11
+ OGI3ZjE2NTkzNzY0YjZiYzlkZGRkYjYxZDc4M2RiZDZmNzQyNGI=
12
12
  data.tar.gz: !binary |-
13
- ZGMwYmNhM2FhZWM3YzlhYjUxZGE4ZDg4MTJjMmIyZmU3MjNkNGNhMzUwODY0
14
- M2RmOGFiZDhhMjY2YjBmZmFjY2JiZDBhMjM5NzI2N2FlYzQ5MTc5NGZlNDU0
15
- NjE2ZjFlMTViNTY1ZjE5MmY4MTRlMmVlMGQ5ZDEyOTg0MGU1ZWI=
13
+ OTIxZWZkYWFlYmJjYzI1YjM1YjE1YjAwYjE3OGY1YjllODQwMWMzNDU3Yzky
14
+ NjllYTJmZjUyYjE2N2I1MmNlMDc4Njc4NTk2Yzc3NWFkMDMyNDFlYmE2MDI4
15
+ MjdiYjlkZTM1OTI1MDJhZWE0NmRjZTY4NWVhYmFjOTU0MmQ1N2E=
data/Gemfile CHANGED
@@ -3,6 +3,5 @@ gem 'sys-uname'
3
3
  gem 'rspec'
4
4
  gem 'faraday'
5
5
  gem 'json'
6
- gem 'active_support'
7
6
  # Specify your gem's dependencies in conekta.gemspec
8
7
  gemspec
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
- # @api_base = 'https://api.conekta.io'
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,4 @@
1
+ module Conekta
2
+ class Method < Resource
3
+ end
4
+ end
@@ -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,7 @@
1
+ module Conekta
2
+ class Payout < Resource
3
+ include Conekta::Operations::Find
4
+ include Conekta::Operations::Where
5
+ include Conekta::Operations::Create
6
+ end
7
+ 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.camelize == "Data"
31
- name = "obj" if name.camelize == "Object"
32
- if !Object.const_defined?(name.camelize)
33
- instance = Object.const_set(name.camelize, Class.new(ConektaObject)).new
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.camelize.constantize.new
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
@@ -1,3 +1,3 @@
1
1
  module Conekta
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -0,0 +1,4 @@
1
+ module Conekta
2
+ class WebhookLog < Resource
3
+ end
4
+ end
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.0
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