conekta 0.5.6 → 0.5.7

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
- NjdiOWRmMGMxNDQxZWMwY2U1ZGM1MDZjMmFlMzEwMGZjOGFlNjU1Zg==
4
+ NzE0ZDk3OGI5ODI0YzllNmZiNzM2YjU4NDhjZDk5YWVjZGQ0ZmJmZA==
5
5
  data.tar.gz: !binary |-
6
- YmE4OTUxMmU0ZWM3ZWE2MjhmZDA0ZDRlZjNlYjYxNDYxMmJlOGUyMg==
6
+ ZmJmYjlmYzY2NzA0NTkwMDQ5ZTA3ZDQ5MTY1ZTdjZmVkODQ4ZDA2Yg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDAwZWFiMTYxMzNhZDhmNDU1NmYxOTFiNWYzZDZhMTJhZTFhMTkzNmZmZjY5
10
- MjE0ZjMwYTgwNTNkNGExZDgyYTlhZmVhMjVlNDU3MmIxYzIzNzcyNTFkNWI1
11
- MjkxMWMzMjc2YWFhMTViNTFmNDQ3ZTc1MTdjM2U1ZWJkY2E1MGI=
9
+ ZWZlY2MzNDhjNTg0NzZiZGJlZjc1Nzc0NDk2ZGE1ZjI5Mzk4YTMxMjdjYTA1
10
+ OTA5MWRhY2QxZWU5YmE1YTIzZDkzMGYzZWYxMDI1MTdhNDBiNWI2NzAwYzQ5
11
+ YmM4ZDQyZDliZGQyYzNhM2E5NzQ1ZGUyMmNiOTUyZjU5NTU2ZmE=
12
12
  data.tar.gz: !binary |-
13
- N2Q4MjgxNjBiYTNiMGJhNTM3MWIyYTRkNzg1OGYyMGZlZWQzOWU1NzRiOWZj
14
- ODc3OGYzZjA0MzhhNjI3ODAwOWRkNWE4YjUxZDAyNmY1MTRkNGJiODMzMDRm
15
- MzZiNDVjYzdmNDc3MzhlNTViMTY4Y2U0NTZjZWVjYzA5YmYwNTc=
13
+ MmFjODM4NWE1ODBlZDAxY2NlYzg1Y2QwNDVlYzJhN2M2ZTFjMjY5YzQzMzA2
14
+ ZGYzOGJiMmM5ZDNmYzg0YzUzYTNmNGZhZWQ4MzNjY2MxMTQ1OWRkMzU0MWY2
15
+ NWFiMGE5N2M4NzVjNjQ3MzU0NjVmZWNiMjgxZGIxMmUyODMxNWI=
data/CHANGELOG CHANGED
@@ -67,4 +67,8 @@
67
67
 
68
68
  == 0.5.6 2015-12-29
69
69
 
70
- * Change parameter serialization using request body instead of connection params.
70
+ * Change parameter serialization using request body instead of connection params.
71
+
72
+ == 0.5.7 2016-07-19
73
+
74
+ * Fix parameter handling for get requests.
@@ -0,0 +1,44 @@
1
+ FROM ubuntu:14.04
2
+
3
+ MAINTAINER Leo Fischer
4
+
5
+ RUN apt-get update
6
+ RUN apt-get install -y vim git wget curl
7
+
8
+ #setup test_user user
9
+ RUN useradd -ms /bin/bash test_user
10
+ RUN echo "test_user:sudo" | chpasswd
11
+ RUN usermod -aG sudo test_user
12
+ RUN mkdir -p /data/db/
13
+ RUN chown test_user /data/db
14
+ RUN sudo echo "test_user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
15
+
16
+ USER test_user
17
+ ENV HOME /home/test_user
18
+
19
+ RUN echo "set tabstop=2" >> ~/.vimrc
20
+ RUN echo "set shiftwidth=2" >> ~/.vimrc
21
+ RUN echo "set softtabstop=2" >> ~/.vimrc
22
+
23
+ #install RVM and Ruby
24
+ RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
25
+ RUN \curl -sSL https://get.rvm.io | sudo bash -s stable
26
+ RUN sudo usermod -a -G rvm test_user
27
+ RUN /bin/bash -l -c "rvm requirements"
28
+ RUN /bin/bash -l -c "rvm install 1.9.3"
29
+ RUN /bin/bash -l -c "rvm install 2.1.9"
30
+ RUN /bin/bash -l -c "rvm install 2.2.4"
31
+ RUN /bin/bash -l -c "rvm install 2.3.0"
32
+
33
+ #configure external fs links
34
+ WORKDIR $HOME
35
+
36
+ #One Time Staging Steps
37
+ RUN git clone https://github.com/conekta/conekta-ruby
38
+
39
+ WORKDIR $HOME/conekta-ruby
40
+
41
+ RUN /bin/bash -l -c "rvm use 1.9.3 && gem install bundle && bundle install"
42
+ RUN /bin/bash -l -c "rvm use 2.1.9 && gem install bundle && bundle install"
43
+ RUN /bin/bash -l -c "rvm use 2.2.4 && gem install bundle && bundle install"
44
+ RUN /bin/bash -l -c "rvm use 2.3.0 && gem install bundle && bundle install"
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ![alt tag](https://raw.github.com/conekta/conekta-ruby/master/readme_files/cover.png)
2
2
 
3
- # Conekta Ruby v.0.5.6
3
+ # Conekta Ruby v.0.5.7
4
4
 
5
5
  This is a ruby library that allows interaction with https://api.conekta.io API.
6
6
 
@@ -89,6 +89,22 @@ License
89
89
  -------
90
90
  Developed by [Conekta](https://www.conekta.io). Available with [MIT License](LICENSE).
91
91
 
92
+ Development and Testing
93
+ -----------------------
94
+ Feel free to play with our library and make pull requests if you find any bugs. You can run the test suite with rspec from the library's root directory:
95
+
96
+ ```shell
97
+ bundle exec rspec
98
+ ```
99
+
100
+ To facilitate the development and testing process you can use one our ruby docker, docker preloaded with rvm and ruby versions 1.9.3, 2.1.9, 2.2.4 and 2.3.0:
101
+
102
+ ```shell
103
+ docker pull conekta/conekta-ruby
104
+
105
+ docker run -ti conekta/conekta-ruby /bin/bash --login
106
+ ```
107
+
92
108
  We are hiring
93
109
  -------------
94
110
 
@@ -16,18 +16,20 @@ require "conekta/resource"
16
16
  require "conekta/requestor"
17
17
  require "conekta/util"
18
18
  require "conekta/error"
19
- require "conekta/payment_method"
19
+
20
+ require "conekta/event"
20
21
  require "conekta/charge"
21
22
  require "conekta/customer"
22
23
  require "conekta/card"
23
- require "conekta/subscription"
24
- require "conekta/plan"
25
- require "conekta/token"
26
- require "conekta/event"
24
+ require "conekta/log"
25
+ require "conekta/method"
26
+ require "conekta/payment_method"
27
27
  require "conekta/payee"
28
28
  require "conekta/payout"
29
29
  require "conekta/payout_method"
30
- require "conekta/method"
30
+ require "conekta/plan"
31
+ require "conekta/subscription"
32
+ require "conekta/token"
31
33
  require "conekta/webhook"
32
34
  require "conekta/webhook_log"
33
35
 
@@ -3,11 +3,11 @@ module Conekta
3
3
  include Conekta::Operations::Delete
4
4
  include Conekta::Operations::Update
5
5
  include Conekta::Operations::CustomAction
6
- def url
6
+ def _url
7
7
  raise Error.new(
8
8
  I18n.t('error.resource.id', { resource: self.class.class_name, locale: :en }),
9
9
  I18n.t('error.resource.id_purchaser', { locale: Conekta.locale.to_sym })) if (id.nil? || id.empty?)
10
- self.customer.url + self.class.url + "/" + id
10
+ self.customer._url + self.class._url + "/" + id
11
11
  end
12
12
  def delete
13
13
  self.delete_member('customer','cards')
@@ -53,17 +53,17 @@ module Conekta
53
53
  self.class.name.split('::')[-1]
54
54
  end
55
55
  def create_attr(k,v)
56
- # Conflict with Resource Class Url
57
- k = "webhook_url" if k.to_s == "url"
58
- # Conflict with Resource Class Url
56
+ # Conflict with Resource Class Url
57
+ if ! k.to_s.match(/-/) and ! k.to_s.match(/^[0-9]+/)
59
58
  create_method( "#{k}=".to_sym ) { |val|
60
59
  instance_variable_set( "@" + k, val)
61
60
  }
62
61
  self.send("#{k}=".to_sym, v)
63
62
  self.class.send(:remove_method, "#{k}=".to_sym)
64
63
  create_method( k.to_sym ) {
65
- instance_variable_get( "@" + k )
64
+ instance_variable_get( "@" + k )
66
65
  }
66
+ end
67
67
  end
68
68
  protected
69
69
  def to_hash
@@ -0,0 +1,6 @@
1
+ module Conekta
2
+ class Log < Resource
3
+ include Conekta::Operations::Where
4
+ include Conekta::Operations::Find
5
+ end
6
+ end
@@ -3,8 +3,8 @@ module Conekta
3
3
  module Create
4
4
  module ClassMethods
5
5
  def create(params)
6
- url = Util.types[self.class_name.downcase].url
7
- response = Requestor.new.request(:post, url, params)
6
+ _url = Util.types[self.class_name.downcase]._url
7
+ response = Requestor.new.request(:post, _url, params)
8
8
  instance = self.new
9
9
  instance.load_from(response)
10
10
  instance
@@ -2,9 +2,9 @@ module Conekta
2
2
  module Operations
3
3
  module CreateMember
4
4
  def create_member(member, params)
5
- url = [self.url, member].join('/')
5
+ _url = [self._url, member].join('/')
6
6
  member = member.to_sym
7
- response = Requestor.new.request(:post, url, params)
7
+ response = Requestor.new.request(:post, _url, params)
8
8
 
9
9
  if self.method(member).call and self.method(member).call.class.class_name == "ConektaObject"
10
10
  arr = []
@@ -2,8 +2,8 @@ module Conekta
2
2
  module Operations
3
3
  module CustomAction
4
4
  def custom_action(method, action=nil, params=nil)
5
- url = action ? [self.url, action].join('/') : self.url
6
- response = Requestor.new.request(method, url, params)
5
+ _url = action ? [self._url, action].join('/') : self._url
6
+ response = Requestor.new.request(method, _url, params)
7
7
 
8
8
  self.load_from(response)
9
9
  self
@@ -4,7 +4,7 @@ module Conekta
4
4
  module ClassMethods
5
5
  def find(id)
6
6
  instance = self.new(id)
7
- response = Requestor.new.request(:get, instance.url)
7
+ response = Requestor.new.request(:get, instance._url)
8
8
  instance.load_from(response)
9
9
  instance
10
10
  end
@@ -2,7 +2,7 @@ module Conekta
2
2
  module Operations
3
3
  module Update
4
4
  def update(params)
5
- response = Requestor.new.request(:put, self.url, params)
5
+ response = Requestor.new.request(:put, self._url, params)
6
6
  self.load_from(response)
7
7
  self
8
8
  end
@@ -4,8 +4,8 @@ module Conekta
4
4
  module ClassMethods
5
5
  def where(params=nil)
6
6
  instance = ConektaObject.new
7
- url = Util.types[self.class_name.downcase].url
8
- response = Requestor.new.request(:get, url,params)
7
+ _url = Util.types[self.class_name.downcase]._url
8
+ response = Requestor.new.request(:get, _url, params)
9
9
  instance.load_from(response)
10
10
  instance
11
11
  end
@@ -3,11 +3,11 @@ module Conekta
3
3
  include Conekta::Operations::Delete
4
4
  include Conekta::Operations::Update
5
5
  include Conekta::Operations::CustomAction
6
- def url
6
+ def _url
7
7
  raise Error.new(
8
8
  I18n.t('error.resource.id', { resource: self.class.class_name, locale: :en }),
9
9
  I18n.t('error.resource.id_purchaser', { locale: Conekta.locale.to_sym })) if (id.nil? || id.empty?)
10
- self.payee.url + self.class.url + "/" + id
10
+ self.payee._url + self.class._url + "/" + id
11
11
  end
12
12
  def delete
13
13
  self.delete_member('payee','payout_methods')
@@ -12,19 +12,19 @@ module Conekta
12
12
  @api_key = Conekta.api_key
13
13
  end
14
14
 
15
- def api_url(url='')
15
+ def api_url(_url='')
16
16
  api_base = Conekta.api_base
17
- api_base + url
17
+ api_base + _url
18
18
  end
19
19
 
20
- def request(meth, url, params=nil)
21
- url = self.api_url(url)
20
+ def request(meth, _url, params = nil)
21
+ _url = self.api_url(_url)
22
22
  meth = meth.downcase
23
23
 
24
24
  begin
25
- connection = build_connection(url, params)
25
+ connection = build_connection(_url, params)
26
26
  response = connection.method(meth).call do |req|
27
- req.body = params.to_json if params
27
+ (if meth == :get then req.params = params else req.body = params.to_json end) if params
28
28
  end
29
29
  rescue Exception => e
30
30
  Error.error_handler(e, "")
@@ -36,9 +36,9 @@ module Conekta
36
36
 
37
37
  private
38
38
 
39
- def build_connection(url, params = nil)
39
+ def build_connection(_url, params = nil)
40
40
  connection = Faraday.new(
41
- :url => url,
41
+ :url => _url,
42
42
  :ssl => { :ca_file=> File.dirname(__FILE__) + '/../ssl_data/ca_bundle.crt'}
43
43
  ) do |faraday|
44
44
  faraday.adapter Faraday.default_adapter
@@ -68,4 +68,4 @@ module Conekta
68
68
  }
69
69
  end
70
70
  end
71
- end
71
+ end
@@ -1,14 +1,14 @@
1
1
  module Conekta
2
2
  class Resource < ConektaObject
3
- def self.url()
3
+ def self._url()
4
4
  "/#{CGI.escape(self.class_name.downcase)}s"
5
5
  end
6
- def url
6
+ def _url
7
7
  raise Error.new(
8
8
  I18n.t('error.resource.id', { resource: self.class.class_name, locale: :en }),
9
9
  I18n.t('error.resource.id_purchaser', { locale: Conekta.locale.to_sym })) if (id.nil? || id.empty?)
10
10
 
11
- return [self.class.url, id].join('/')
11
+ return [self.class._url, id].join('/')
12
12
  end
13
13
  end
14
14
  end
@@ -2,11 +2,11 @@ module Conekta
2
2
  class Subscription < Resource
3
3
  include Conekta::Operations::Update
4
4
  include Conekta::Operations::CustomAction
5
- def url
5
+ def _url
6
6
  raise Error.new(
7
7
  I18n.t('error.resource.id', { resource: self.class.class_name, locale: :en }),
8
8
  I18n.t('error.resource.id_purchaser', { locale: Conekta.locale.to_sym })) if (id.nil? || id.empty?)
9
- self.customer.url + "/subscription"
9
+ self.customer._url + "/subscription"
10
10
  end
11
11
  def pause
12
12
  custom_action(:post, 'pause')
@@ -2,22 +2,23 @@ module Conekta
2
2
  module Util
3
3
  def self.types
4
4
  @types ||= {
5
- 'webhook' => Webhook,
6
- 'webhook_log' => WebhookLog,
7
- 'bank_transfer_payout_method' => Method,
8
- 'payout' => Payout,
9
- 'payee' => Payee,
10
- 'payout_method' => PayoutMethod,
11
5
  'bank_transfer_payment' => PaymentMethod,
6
+ 'bank_transfer_payout_method' => Method,
7
+ 'card' => Card,
12
8
  'card_payment' => PaymentMethod,
13
9
  'cash_payment' => PaymentMethod,
14
10
  'charge' => Charge,
15
11
  'customer' => Customer,
16
- 'card' => Card,
17
- 'subscription' => Subscription,
12
+ 'event' => Event,
13
+ 'log' => Log,
14
+ 'payee' => Payee,
15
+ 'payout' => Payout,
16
+ 'payout_method' => PayoutMethod,
18
17
  'plan' => Plan,
18
+ 'subscription' => Subscription,
19
19
  'token' => Token,
20
- 'event' => Event
20
+ 'webhook' => Webhook,
21
+ 'webhook_log' => WebhookLog,
21
22
  }
22
23
  end
23
24
  def self.convert_to_conekta_object(name,resp)
@@ -1,3 +1,3 @@
1
1
  module Conekta
2
- VERSION = '0.5.6'.freeze
2
+ VERSION = '0.5.7'.freeze
3
3
  end
@@ -3,14 +3,46 @@ require 'spec_helper'
3
3
  describe Conekta::Charge do
4
4
  let(:payment_method) do
5
5
  {
6
- amount: 2000, currency: 'mxn', description: 'Some desc'
6
+ amount: 2000,
7
+ currency: 'mxn',
8
+ description: 'Some desc',
9
+ details: {
10
+ name: "Wolverine",
11
+ email: "logan.thomas@xmen.org",
12
+ phone: "403-342-0642",
13
+ line_items: [{
14
+ name: "Shades",
15
+ description: "Imported From Mex.",
16
+ unit_price: 20000,
17
+ quantity: 1,
18
+ sku: "cohb_s1",
19
+ category: "eyewear"
20
+ }]
21
+ }
7
22
  }
8
23
  end
24
+
9
25
  let(:invalid_payment_method) do
10
26
  {
11
- amount: 10, currency: 'mxn', description: 'Some desc'
27
+ amount: 10,
28
+ currency: 'mxn',
29
+ description: 'Some desc',
30
+ details: {
31
+ name: "Wolverine",
32
+ email: "logan.thomas@xmen.org",
33
+ phone: "403-342-0642",
34
+ line_items: [{
35
+ name: "Shades",
36
+ description: "Imported From Mex.",
37
+ unit_price: 20000,
38
+ quantity: 1,
39
+ sku: "cohb_s1",
40
+ category: "eyewear"
41
+ }]
42
+ }
12
43
  }
13
44
  end
45
+
14
46
  let(:card) { { card: 'tok_test_visa_4242' } }
15
47
 
16
48
  context "get" do
@@ -26,6 +58,18 @@ describe Conekta::Charge do
26
58
  charge = charges.first
27
59
  expect(charge).to be_a(Conekta::Charge)
28
60
  end
61
+ it "test succesful where status 'pending_payment'" do
62
+ charges = Conekta::Charge.where({status: 'pending_payment'})
63
+ charges.map{|index, charge|
64
+ expect(charge.status).to eq("pending_payment")
65
+ }
66
+ end
67
+ it "test succesful where status 'paid'" do
68
+ charges = Conekta::Charge.where({status: 'paid'})
69
+ charges.map{|index, charge|
70
+ expect(charge.status).to eq("paid")
71
+ }
72
+ end
29
73
  end
30
74
 
31
75
  context "creating charges" do
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conekta::Log do
4
+ it "test successful where" do
5
+ events = Conekta::Log.where
6
+ expect(events.class_name).to eq("ConektaObject")
7
+ expect(events[0].class_name).to eq("Log")
8
+ end
9
+
10
+ it "test successful find" do
11
+ events = Conekta::Log.where
12
+ e = events.first
13
+
14
+ event = Conekta::Log.find(e.id)
15
+
16
+ expect(event).to be_a(Conekta::Log)
17
+ expect(event.class_name).to eq("Log")
18
+ end
19
+ end
@@ -21,13 +21,15 @@ describe Conekta::Webhook do
21
21
  end
22
22
  let(:url) { { url: "http://localhost:3000/my_listener" } }
23
23
 
24
- it "succesfully gets charge" do
25
- webhook = Conekta::Webhook.create(url.merge(events))
26
- expect(webhook.webhook_url).to eq(url[:url])
27
- webhook = Conekta::Webhook.find(webhook.id)
28
- expect(webhook.webhook_url).to eq(url[:url])
29
- webhook.update({url: "http://localhost:2000/my_listener"})
30
- expect(webhook.webhook_url).to eq("http://localhost:2000/my_listener")
31
- webhook.delete
32
- end
24
+ # This spec was commented to avoid webhook creation saturation.
25
+ #
26
+ # it "succesfully gets charge" do
27
+ # webhook = Conekta::Webhook.create(url.merge(events))
28
+ # expect(webhook.url).to eq(url[:url])
29
+ # webhook = Conekta::Webhook.find(webhook.id)
30
+ # expect(webhook.url).to eq(url[:url])
31
+ # webhook.update({url: "http://localhost:2000/my_listener"})
32
+ # expect(webhook.url).to eq("http://localhost:2000/my_listener")
33
+ # webhook.delete
34
+ # end
33
35
  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.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - MauricioMurga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-29 00:00:00.000000000 Z
11
+ date: 2016-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -118,6 +118,7 @@ files:
118
118
  - .gitignore
119
119
  - .rspec
120
120
  - CHANGELOG
121
+ - Dockerfile
121
122
  - Gemfile
122
123
  - LICENSE.txt
123
124
  - README.md
@@ -130,6 +131,7 @@ files:
130
131
  - lib/conekta/customer.rb
131
132
  - lib/conekta/error.rb
132
133
  - lib/conekta/event.rb
134
+ - lib/conekta/log.rb
133
135
  - lib/conekta/method.rb
134
136
  - lib/conekta/operations/create.rb
135
137
  - lib/conekta/operations/create_member.rb
@@ -159,6 +161,7 @@ files:
159
161
  - spec/conekta/customer_spec.rb
160
162
  - spec/conekta/error_spec.rb
161
163
  - spec/conekta/event_spec.rb
164
+ - spec/conekta/log_spec.rb
162
165
  - spec/conekta/payee_spec.rb
163
166
  - spec/conekta/payout_spec.rb
164
167
  - spec/conekta/plan_spec.rb
@@ -195,6 +198,7 @@ test_files:
195
198
  - spec/conekta/customer_spec.rb
196
199
  - spec/conekta/error_spec.rb
197
200
  - spec/conekta/event_spec.rb
201
+ - spec/conekta/log_spec.rb
198
202
  - spec/conekta/payee_spec.rb
199
203
  - spec/conekta/payout_spec.rb
200
204
  - spec/conekta/plan_spec.rb