ebanx 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/CONTRIBUTORS +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +27 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/VERSION +1 -0
- data/ebanx.gemspec +25 -0
- data/lib/ebanx.rb +61 -0
- data/lib/ebanx/command/cancel.rb +16 -0
- data/lib/ebanx/command/capture.rb +16 -0
- data/lib/ebanx/command/command.rb +29 -0
- data/lib/ebanx/command/exchange.rb +16 -0
- data/lib/ebanx/command/print_html.rb +16 -0
- data/lib/ebanx/command/query.rb +16 -0
- data/lib/ebanx/command/refund.rb +26 -0
- data/lib/ebanx/command/refund_or_cancel.rb +17 -0
- data/lib/ebanx/command/request.rb +21 -0
- data/lib/ebanx/version.rb +3 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f6199e3f2a9c361e756af0826fca2bbc2a48f11b
|
4
|
+
data.tar.gz: 95dfdfde61a1d96da9e15187cb17d3f05be0c051
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 65245844edf359c97ae313f59ab19eff89959f4e28b46fd4ad972f063f2bf630b7d36cf42a261fb743bf5852e24dd5f2ffab2dffa1f1ce97c15ca61a5ba0cc51
|
7
|
+
data.tar.gz: f16ca6ad24dc33081e58c12f4f143270745cb2903ac27e8acf947da9962eaff9e4ba02acc87044828b76699e9407d50ac2ec100e6fbf72268e393447b75187e7
|
data/.gitignore
ADDED
data/CONTRIBUTORS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gustavo Henrique Mascarenhas Machado <guhemama@gmail.com>
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2014, EBANX Tecnologia da Informação Ltda.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
* Neither the name of EBANX nor the names of its
|
15
|
+
contributors may be used to endorse or promote products derived from
|
16
|
+
this software without specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
22
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
23
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
24
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
26
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Ebanx
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ebanx'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ebanx
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/ebanx.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ebanx/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ebanx"
|
8
|
+
spec.version = Ebanx::VERSION
|
9
|
+
spec.authors = ["Gustavo Henrique Mascarenhas Machado"]
|
10
|
+
spec.email = ["guhemama@gmail.com"]
|
11
|
+
spec.summary = "Ruby bindings for the EBANX API"
|
12
|
+
spec.description = "EBANX is the market leader in e-commerce payment solutions for International Merchants selling online to Brazil"
|
13
|
+
spec.homepage = "https://www.ebanx.com"
|
14
|
+
spec.license = "BSD"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency('rest-client', '~> 1.5')
|
25
|
+
end
|
data/lib/ebanx.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require_relative 'ebanx/version'
|
5
|
+
require_relative 'ebanx/command/command'
|
6
|
+
require_relative 'ebanx/command/cancel'
|
7
|
+
require_relative 'ebanx/command/capture'
|
8
|
+
require_relative 'ebanx/command/exchange'
|
9
|
+
require_relative 'ebanx/command/print_html'
|
10
|
+
require_relative 'ebanx/command/query'
|
11
|
+
require_relative 'ebanx/command/refund'
|
12
|
+
require_relative 'ebanx/command/refund_or_cancel'
|
13
|
+
require_relative 'ebanx/command/request'
|
14
|
+
|
15
|
+
|
16
|
+
module Ebanx
|
17
|
+
@test_mode = false
|
18
|
+
|
19
|
+
class << self
|
20
|
+
attr_accessor :integration_key, :test_mode
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.base_uri
|
24
|
+
if @test_mode
|
25
|
+
'https://www.ebanx.com/test/ws/'
|
26
|
+
else
|
27
|
+
'https://www.ebanx.com/pay/ws/'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.run_command(method, params)
|
32
|
+
klass = get_command_class method
|
33
|
+
|
34
|
+
params = params[0].merge! integration_key: @integration_key
|
35
|
+
command = klass.new params
|
36
|
+
|
37
|
+
command.valid?
|
38
|
+
|
39
|
+
request command
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.request(command)
|
43
|
+
uri = Ebanx::base_uri + command.request_action
|
44
|
+
result = RestClient.send command.request_method, uri, params: command.params, content_type: command.response_type
|
45
|
+
JSON.parse result
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.method_missing(method, *args, &block)
|
49
|
+
if method.to_s =~ /^do_[a-z]+/
|
50
|
+
run_command method.to_s, args
|
51
|
+
else
|
52
|
+
super
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.get_command_class(method)
|
57
|
+
method = method.gsub /^do_/, ''
|
58
|
+
class_name = 'Ebanx::Command::' + method.split('_').map { |w| w.capitalize }.join
|
59
|
+
Object.const_get class_name
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ebanx
|
2
|
+
module Command
|
3
|
+
class Cancel < Command
|
4
|
+
def initialize(params)
|
5
|
+
@params = params
|
6
|
+
@request_method = :post
|
7
|
+
@request_action = 'cancel'
|
8
|
+
@response_type = :json
|
9
|
+
end
|
10
|
+
|
11
|
+
def validate
|
12
|
+
validate_presence :hash
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ebanx
|
2
|
+
module Command
|
3
|
+
class Capture < Command
|
4
|
+
def initialize(params)
|
5
|
+
@params = params
|
6
|
+
@request_method = :get
|
7
|
+
@request_action = 'capture'
|
8
|
+
@response_type = :json
|
9
|
+
end
|
10
|
+
|
11
|
+
def validate
|
12
|
+
validate_presence_or :hash, :merchant_payment_code
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Ebanx
|
2
|
+
module Command
|
3
|
+
class Command
|
4
|
+
attr_accessor :params, :request_method, :request_action, :response_type
|
5
|
+
|
6
|
+
def valid?
|
7
|
+
validate
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
def validate
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
14
|
+
|
15
|
+
def validate_presence(name)
|
16
|
+
raise ArgumentError unless @params.include? name
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def validate_presence_or(name1, name2)
|
21
|
+
unless @params.include?(name1) || @params.include?(name2)
|
22
|
+
raise ArgumentError
|
23
|
+
end
|
24
|
+
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ebanx
|
2
|
+
module Command
|
3
|
+
class Exchange < Command
|
4
|
+
def initialize(params)
|
5
|
+
@params = params
|
6
|
+
@request_method = :get
|
7
|
+
@request_action = 'exchange'
|
8
|
+
@response_type = :json
|
9
|
+
end
|
10
|
+
|
11
|
+
def validate
|
12
|
+
validate_presence :currency_code
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ebanx
|
2
|
+
module Command
|
3
|
+
class PrintHtml < Command
|
4
|
+
def initialize(params)
|
5
|
+
@params = params
|
6
|
+
@request_method = :get
|
7
|
+
@request_action = 'boleto/printHTML'
|
8
|
+
@response_type = 'text/html'
|
9
|
+
end
|
10
|
+
|
11
|
+
def validate
|
12
|
+
validate_presence :hash
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ebanx
|
2
|
+
module Command
|
3
|
+
class Query < Command
|
4
|
+
def initialize(params)
|
5
|
+
@params = params
|
6
|
+
@request_method = :get
|
7
|
+
@request_action = 'query'
|
8
|
+
@response_type = :json
|
9
|
+
end
|
10
|
+
|
11
|
+
def validate
|
12
|
+
validate_presence :hash
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Ebanx
|
2
|
+
module Command
|
3
|
+
class Refund < Command
|
4
|
+
def initialize(params)
|
5
|
+
@params = params
|
6
|
+
@request_method = :post
|
7
|
+
@request_action = 'refund'
|
8
|
+
@response_type = :json
|
9
|
+
end
|
10
|
+
|
11
|
+
def validate
|
12
|
+
validate_presence :operation
|
13
|
+
|
14
|
+
# Validation for a new refund request
|
15
|
+
if @params[:operation] == 'request'
|
16
|
+
validate_presence :hash
|
17
|
+
validate_presence :amount
|
18
|
+
validate_presence :description
|
19
|
+
#Validation for a refund cancel request
|
20
|
+
else
|
21
|
+
validate_presence_or :merchant_refund_code, :refund_id
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Ebanx
|
2
|
+
module Command
|
3
|
+
class RefundOrCancel < Command
|
4
|
+
def initialize(params)
|
5
|
+
@params = params
|
6
|
+
@request_method = :post
|
7
|
+
@request_action = 'refundOrCancel'
|
8
|
+
@response_type = :json
|
9
|
+
end
|
10
|
+
|
11
|
+
def validate
|
12
|
+
validate_presence :hash
|
13
|
+
validate_presence :description
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ebanx
|
2
|
+
module Command
|
3
|
+
class Request < Command
|
4
|
+
def initialize(params)
|
5
|
+
@params = params
|
6
|
+
@request_method = :post
|
7
|
+
@request_action = 'request'
|
8
|
+
@response_type = :json
|
9
|
+
end
|
10
|
+
|
11
|
+
def validate
|
12
|
+
validate_presence :currency_code
|
13
|
+
validate_presence :amount
|
14
|
+
validate_presence :merchant_payment_code
|
15
|
+
validate_presence :name
|
16
|
+
validate_presence :email
|
17
|
+
validate_presence :payment_type_code
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ebanx
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gustavo Henrique Mascarenhas Machado
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rest-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
description: EBANX is the market leader in e-commerce payment solutions for International
|
56
|
+
Merchants selling online to Brazil
|
57
|
+
email:
|
58
|
+
- guhemama@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- CONTRIBUTORS
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- VERSION
|
70
|
+
- ebanx.gemspec
|
71
|
+
- lib/ebanx.rb
|
72
|
+
- lib/ebanx/command/cancel.rb
|
73
|
+
- lib/ebanx/command/capture.rb
|
74
|
+
- lib/ebanx/command/command.rb
|
75
|
+
- lib/ebanx/command/exchange.rb
|
76
|
+
- lib/ebanx/command/print_html.rb
|
77
|
+
- lib/ebanx/command/query.rb
|
78
|
+
- lib/ebanx/command/refund.rb
|
79
|
+
- lib/ebanx/command/refund_or_cancel.rb
|
80
|
+
- lib/ebanx/command/request.rb
|
81
|
+
- lib/ebanx/version.rb
|
82
|
+
homepage: https://www.ebanx.com
|
83
|
+
licenses:
|
84
|
+
- BSD
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.1.11
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Ruby bindings for the EBANX API
|
106
|
+
test_files: []
|