Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order Endpoint #9

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
language: ruby

rvm:
- 2.0.0
- 2.1.0
- 2.2.0
- 2.3.0
- 2.4.0
- 2.2.7
- 2.3.4
- 2.4.1

notifications:
email:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.0.8 04-09-2017
* Use Culqi module to scope operations
* Use interpolation to concatenate strings

### 0.0.7 08-04-2017
* Add update method to Customer

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Biblioteca de CULQI para el lenguaje Ruby, pagos simples en tu sitio web. Consum

| Versión actual|Culqi API|
|----|----|
| [0.0.7](https://rubygems.org/gems/culqi-ruby) (2017-04-08) |[v2](https://culqi.com/api)|
| [0.0.8](https://rubygems.org/gems/culqi-ruby) (2017-09-04) |[v2](https://culqi.com/api)|

## Requisitos

- Ruby >= 2.0.0
- Credenciales de comercio en Culqi (1).
- Credenciales de comercio en Culqi [1](https://www.culqi.com/docs/#/cuenta/cuenta).


## Ejemplos
Expand Down Expand Up @@ -191,4 +191,4 @@ Willy Aguirre ([@marti1125](https://github.com/marti1125) - Team Culqi)

## Licencia

El código fuente de culqi-python está distribuido bajo MIT License, revisar el archivo [LICENSE](https://github.com/culqi/culqi-ruby/blob/master/LICENSE).
El código fuente de culqi-ruby está distribuido bajo MIT License, revisar el archivo [LICENSE](https://github.com/culqi/culqi-ruby/blob/master/LICENSE).
2 changes: 1 addition & 1 deletion culqi-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require 'culqi/version'
Gem::Specification.new do |s|
s.name = 'culqi-ruby'
s.version = Culqi::VERSION
s.date = '2017-04-08'
s.date = '2017-09-04'
s.summary = "Culqi Ruby"
s.description = "Biblioteca de Culqi en Ruby API v2"
s.authors = ["Willy Aguirre"]
Expand Down
4 changes: 2 additions & 2 deletions i.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sudo gem uninstall culqi-ruby-0.0.7.gem
sudo gem uninstall culqi-ruby-0.0.8.gem
gem build culqi-ruby.gemspec
sudo gem install culqi-ruby-0.0.7.gem
sudo gem install culqi-ruby-0.0.8.gem
1 change: 1 addition & 0 deletions lib/culqi-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
require 'culqi/subscription'
require 'culqi/refund'
require 'culqi/transfer'
require 'culqi/order'

module Culqi

Expand Down
2 changes: 1 addition & 1 deletion lib/culqi/charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Charge
@url = URL

def self.capture(id)
response = Culqi.connect(URL+id+"/capture/", Culqi.secret_key, nil, "post", Culqi::READ_TIMEOUT)
response = Culqi.connect("#{@url}#{id}/capture/", Culqi.secret_key, nil, "post", Culqi::READ_TIMEOUT)
return response.read_body
end

Expand Down
14 changes: 14 additions & 0 deletions lib/culqi/order.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Culqi

class Order

extend Post

URL = '/orders/'

@url = URL

end

end

2 changes: 1 addition & 1 deletion lib/culqi/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Culqi
VERSION = "0.0.7"
VERSION = "0.0.8"
end
4 changes: 2 additions & 2 deletions lib/operation/delete.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require 'util/connect'

module Delete
module Culqi::Delete

def initialize
@url = ''
end

def delete(id)
response = Culqi.connect(@url+id+'/', Culqi.secret_key, nil, 'delete', Culqi::READ_TIMEOUT)
response = Culqi.connect("#{@url}#{id}/", Culqi.secret_key, nil, 'delete', Culqi::READ_TIMEOUT)
return response.read_body
end

Expand Down
4 changes: 2 additions & 2 deletions lib/operation/get.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require 'util/connect'

module Get
module Culqi::Get

def initialize
@url = ''
end

def get(id)
response = Culqi.connect(@url+id+'/', Culqi.secret_key, nil, 'get', Culqi::READ_TIMEOUT)
response = Culqi.connect("#{@url}#{id}/", Culqi.secret_key, nil, 'get', Culqi::READ_TIMEOUT)
return response.read_body
end

Expand Down
2 changes: 1 addition & 1 deletion lib/operation/list.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'util/connect'

module List
module Culqi::List

def initialize
@url = ''
Expand Down
2 changes: 1 addition & 1 deletion lib/operation/post.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'util/connect'

module Post
module Culqi::Post

def initialize
@url = ''
Expand Down
6 changes: 3 additions & 3 deletions lib/operation/update.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
require 'util/connect'

module Update
module Culqi::Update

def initialize
@url = ''
end

def update(id, params={})
response = Culqi.connect(@url+id+'/', Culqi.secret_key, params, 'patch', Culqi::READ_TIMEOUT)
response = Culqi.connect("#{@url}#{id}/", Culqi.secret_key, params, 'patch', Culqi::READ_TIMEOUT)
return response.read_body
end

end
end
2 changes: 1 addition & 1 deletion lib/util/connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Culqi

def self.connect(url, api_key, data, type, time_out)

url = URI(Culqi::API_BASE+"#{url}")
url = URI("#{Culqi::API_BASE}#{url}")

http = Net::HTTP.new(url.host, url.port)
http.read_timeout = time_out
Expand Down
25 changes: 19 additions & 6 deletions test/test_culqi-ruby.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
gem 'minitest'
require 'minitest/autorun'
require 'test_helper'
require 'securerandom'
require 'culqi-ruby'

class CulqiTest < Minitest::Test

Culqi.public_key = ENV['LLAVE_PUBLICA']
Culqi.secret_key = ENV['LLAVE_SECRETA']

def getToken

token = Culqi::Token.create(
Expand Down Expand Up @@ -112,6 +107,24 @@ def getRefund
return JSON.parse(refund)
end

def getOrder
order = Culqi::Order.create(
:amount => 1000,
:currency_code => 'PEN',
:description => 'Venta de prueba',
:order_number => 'prueba-999',
:client_details => ({
:first_name => 'Richard',
:last_name => 'Meza',
:email => 'test'+SecureRandom.uuid+'@culqi.com',
:phone_number => 998989789
}),
:expiration_date => 2323423432,
:confirm => false
)
return JSON.parse(order)
end

def test_1_token
assert_equal 'token', getToken['object']
end
Expand Down
5 changes: 5 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'minitest/autorun'
require 'culqi-ruby'

Culqi.public_key = ENV['PUBLIC_KEY']
Culqi.secret_key = ENV['SECRET_KEY']
12 changes: 2 additions & 10 deletions test/test_list.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
gem 'minitest'
require 'minitest/autorun'
require 'culqi-ruby'
require 'test_helper'

class TestList < Minitest::Test

Culqi.secret_key = ENV['LLAVE_SECRETA']

def test_tokens
assert_operator JSON.parse(Culqi::Token.list())['data'].count, :>=, 0
end
Expand All @@ -26,10 +22,6 @@ def test_cards
assert_operator JSON.parse(Culqi::Card.list())['data'].count, :>=, 0
end

def test_subscriptions
assert_operator JSON.parse(Culqi::Subscription.list())['data'].count, :>=, 0
end

def test_refunds
assert_operator JSON.parse(Culqi::Refund.list())['data'].count, :>=, 0
end
Expand All @@ -42,4 +34,4 @@ def test_transfers
assert_operator JSON.parse(Culqi::Transfer.list())['data'].count, :>=, 0
end

end
end