tpaga 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tpaga.rb +28 -21
- data/lib/tpaga/api/charge_api.rb +133 -100
- data/lib/tpaga/api/chargeback_api.rb +88 -0
- data/lib/tpaga/api/credit_card_api.rb +220 -0
- data/lib/tpaga/api/customer_api.rb +84 -326
- data/lib/tpaga/api/davi_plata_api.rb +340 -0
- data/lib/tpaga/models/address.rb +47 -54
- data/lib/tpaga/models/api_error.rb +38 -0
- data/lib/tpaga/models/api_errors_item.rb +60 -0
- data/lib/tpaga/models/base_object.rb +85 -0
- data/lib/tpaga/models/billing_address.rb +76 -0
- data/lib/tpaga/models/city.rb +40 -51
- data/lib/tpaga/models/credit_card.rb +148 -0
- data/lib/tpaga/models/credit_card_charge.rb +116 -0
- data/lib/tpaga/models/credit_card_create.rb +76 -0
- data/lib/tpaga/models/customer.rb +68 -63
- data/lib/tpaga/models/davi_plata.rb +92 -0
- data/lib/tpaga/models/davi_plata_charge.rb +108 -0
- data/lib/tpaga/models/davi_plata_chargeback.rb +60 -0
- data/lib/tpaga/models/davi_plata_verification.rb +44 -0
- data/lib/tpaga/monkey.rb +1 -1
- data/lib/tpaga/swagger.rb +64 -87
- data/lib/tpaga/swagger/configuration.rb +24 -27
- data/lib/tpaga/swagger/request.rb +247 -192
- data/lib/tpaga/swagger/response.rb +52 -53
- data/lib/tpaga/swagger/version.rb +3 -4
- data/tpaga.gemspec +8 -9
- metadata +20 -12
- data/lib/tpaga/models/billingaddress.rb +0 -75
- data/lib/tpaga/models/charge.rb +0 -91
- data/lib/tpaga/models/creditcard.rb +0 -107
- data/lib/tpaga/models/creditcardcreate.rb +0 -75
@@ -1,71 +1,70 @@
|
|
1
1
|
module Tpaga
|
2
|
-
module Swagger
|
2
|
+
module Swagger
|
3
|
+
class Response
|
4
|
+
require 'json'
|
3
5
|
|
4
|
-
|
5
|
-
require 'json'
|
6
|
+
attr_accessor :raw
|
6
7
|
|
7
|
-
|
8
|
+
def initialize(raw)
|
9
|
+
self.raw = raw
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
+
case self.code
|
12
|
+
when 500..510 then raise(ServerError, self.error_message)
|
13
|
+
when 299..426 then raise(ClientError, self.error_message)
|
14
|
+
end
|
15
|
+
end
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
when 299..426 then raise ClientError.new(self.error_message, raw)
|
17
|
+
def code
|
18
|
+
raw.code
|
15
19
|
end
|
16
|
-
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
"#{raw.code} - #{raw.status_message}"
|
25
|
-
end
|
21
|
+
# Account for error messages that take different forms...
|
22
|
+
def error_message
|
23
|
+
body['message']
|
24
|
+
rescue
|
25
|
+
body
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
# If body is JSON, parse it
|
29
|
+
# Otherwise return raw string
|
30
|
+
def body
|
31
|
+
JSON.parse(raw.body, :symbolize_names => true)
|
32
|
+
rescue
|
33
|
+
raw.body
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
# `headers_hash` is a Typhoeus-specific extension of Hash,
|
37
|
+
# so simplify it back into a regular old Hash.
|
38
|
+
def headers
|
39
|
+
h = {}
|
40
|
+
raw.headers_hash.each {|k,v| h[k] = v }
|
41
|
+
h
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
# Extract the response format from the header hash
|
45
|
+
# e.g. {'Content-Type' => 'application/json'}
|
46
|
+
def format
|
47
|
+
headers['Content-Type'].split("/").last.downcase
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
def json?
|
51
|
+
format == 'json'
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
def xml?
|
55
|
+
format == 'xml'
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
def pretty_body
|
59
|
+
return unless body.present?
|
60
|
+
case format
|
61
|
+
when 'json' then JSON.pretty_generate(body).gsub(/\n/, '<br/>')
|
62
|
+
end
|
61
63
|
end
|
62
|
-
end
|
63
64
|
|
64
|
-
|
65
|
-
|
65
|
+
def pretty_headers
|
66
|
+
JSON.pretty_generate(headers).gsub(/\n/, '<br/>')
|
67
|
+
end
|
66
68
|
end
|
67
|
-
|
68
69
|
end
|
69
70
|
end
|
70
|
-
end
|
71
|
-
|
data/tpaga.gemspec
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "tpaga/swagger/version"
|
3
4
|
|
4
5
|
Gem::Specification.new do |s|
|
5
6
|
s.name = "tpaga"
|
6
|
-
s.date = "2015-
|
7
|
-
s.version =
|
7
|
+
s.date = "2015-06-26"
|
8
|
+
s.version = Tpaga::Swagger::VERSION
|
8
9
|
s.platform = Gem::Platform::RUBY
|
9
10
|
s.authors = ["Sebastian Ortiz V."]
|
10
|
-
s.email = ["
|
11
|
+
s.email = ["sebastian@tpaga.co"]
|
11
12
|
s.homepage = "https://tpaga.co"
|
12
13
|
s.summary = %q{TPaga API Ruby Bindings powered by Swagger}
|
13
14
|
s.description = %q{TPaga Payment Gateway API
|
14
15
|
|
15
16
|
[Learn about TPaga](https://tpaga.co)
|
16
17
|
|
17
|
-
[More information about this library](http://
|
18
|
+
[More information about this library] (http://docs.tpaga.co)
|
18
19
|
}
|
19
|
-
s.license = 'Apache License, Version 2.0'
|
20
|
-
|
21
20
|
s.add_runtime_dependency 'typhoeus', '~> 0.2', '>= 0.2.1'
|
22
21
|
s.add_runtime_dependency 'addressable', '~> 2.2', '>= 2.2.4'
|
23
22
|
s.add_runtime_dependency 'json', '~> 1.4', '>= 1.4.6'
|
24
23
|
|
25
|
-
s.files = `find *`.split("
|
26
|
-
|
24
|
+
s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }
|
25
|
+
s.test_files = `find spec/*`.split("\n")
|
27
26
|
s.executables = []
|
28
|
-
s.require_paths = ["lib"
|
27
|
+
s.require_paths = ["lib"]
|
29
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tpaga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Ortiz V.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -75,23 +75,33 @@ description: |
|
|
75
75
|
|
76
76
|
[Learn about TPaga](https://tpaga.co)
|
77
77
|
|
78
|
-
[More information about this library](http://
|
78
|
+
[More information about this library] (http://docs.tpaga.co)
|
79
79
|
email:
|
80
|
-
-
|
80
|
+
- sebastian@tpaga.co
|
81
81
|
executables: []
|
82
82
|
extensions: []
|
83
83
|
extra_rdoc_files: []
|
84
84
|
files:
|
85
85
|
- lib/tpaga.rb
|
86
86
|
- lib/tpaga/api/charge_api.rb
|
87
|
+
- lib/tpaga/api/chargeback_api.rb
|
88
|
+
- lib/tpaga/api/credit_card_api.rb
|
87
89
|
- lib/tpaga/api/customer_api.rb
|
90
|
+
- lib/tpaga/api/davi_plata_api.rb
|
88
91
|
- lib/tpaga/models/address.rb
|
89
|
-
- lib/tpaga/models/
|
90
|
-
- lib/tpaga/models/
|
92
|
+
- lib/tpaga/models/api_error.rb
|
93
|
+
- lib/tpaga/models/api_errors_item.rb
|
94
|
+
- lib/tpaga/models/base_object.rb
|
95
|
+
- lib/tpaga/models/billing_address.rb
|
91
96
|
- lib/tpaga/models/city.rb
|
92
|
-
- lib/tpaga/models/
|
93
|
-
- lib/tpaga/models/
|
97
|
+
- lib/tpaga/models/credit_card.rb
|
98
|
+
- lib/tpaga/models/credit_card_charge.rb
|
99
|
+
- lib/tpaga/models/credit_card_create.rb
|
94
100
|
- lib/tpaga/models/customer.rb
|
101
|
+
- lib/tpaga/models/davi_plata.rb
|
102
|
+
- lib/tpaga/models/davi_plata_charge.rb
|
103
|
+
- lib/tpaga/models/davi_plata_chargeback.rb
|
104
|
+
- lib/tpaga/models/davi_plata_verification.rb
|
95
105
|
- lib/tpaga/monkey.rb
|
96
106
|
- lib/tpaga/swagger.rb
|
97
107
|
- lib/tpaga/swagger/configuration.rb
|
@@ -100,14 +110,12 @@ files:
|
|
100
110
|
- lib/tpaga/swagger/version.rb
|
101
111
|
- tpaga.gemspec
|
102
112
|
homepage: https://tpaga.co
|
103
|
-
licenses:
|
104
|
-
- Apache License, Version 2.0
|
113
|
+
licenses: []
|
105
114
|
metadata: {}
|
106
115
|
post_install_message:
|
107
116
|
rdoc_options: []
|
108
117
|
require_paths:
|
109
118
|
- lib
|
110
|
-
- models
|
111
119
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
120
|
requirements:
|
113
121
|
- - ">="
|
@@ -120,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
128
|
version: '0'
|
121
129
|
requirements: []
|
122
130
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.4.
|
131
|
+
rubygems_version: 2.4.6
|
124
132
|
signing_key:
|
125
133
|
specification_version: 4
|
126
134
|
summary: TPaga API Ruby Bindings powered by Swagger
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
|
3
|
-
module Tpaga
|
4
|
-
class BillingAddress
|
5
|
-
attr_accessor :addressLine1, :addressLine2, :city, :country, :postalCode, :state
|
6
|
-
|
7
|
-
# :internal => :external
|
8
|
-
def self.attribute_map
|
9
|
-
{
|
10
|
-
:addressLine1 => :'addressLine1',
|
11
|
-
:addressLine2 => :'addressLine2',
|
12
|
-
:city => :'city',
|
13
|
-
:country => :'country',
|
14
|
-
:postalCode => :'postalCode',
|
15
|
-
:state => :'state'
|
16
|
-
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
def initialize(attributes = {})
|
21
|
-
return if attributes.empty?
|
22
|
-
|
23
|
-
# convert hash key from symbol to string
|
24
|
-
# and convert object to hash
|
25
|
-
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_s] = Swagger.to_body(v); memo}
|
26
|
-
|
27
|
-
# Morph attribute keys into undescored rubyish style
|
28
|
-
if self.class.attribute_map[:"addressLine1"]
|
29
|
-
@addressLine1 = attributes["addressLine1"]
|
30
|
-
end
|
31
|
-
if self.class.attribute_map[:"addressLine2"]
|
32
|
-
@addressLine2 = attributes["addressLine2"]
|
33
|
-
end
|
34
|
-
if self.class.attribute_map[:"city"]
|
35
|
-
@city = attributes["city"]
|
36
|
-
end
|
37
|
-
if self.class.attribute_map[:"country"]
|
38
|
-
@country = attributes["country"]
|
39
|
-
end
|
40
|
-
if self.class.attribute_map[:"postalCode"]
|
41
|
-
@postalCode = attributes["postalCode"]
|
42
|
-
end
|
43
|
-
if self.class.attribute_map[:"state"]
|
44
|
-
@state = attributes["state"]
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
def to_body
|
51
|
-
body = {}
|
52
|
-
self.class.attribute_map.each_pair do |key, value|
|
53
|
-
next if self.send(key).nil?
|
54
|
-
|
55
|
-
if self.send(key).respond_to? :to_body
|
56
|
-
body[value] = self.send(key).to_body
|
57
|
-
elsif self.send(key).kind_of?(Array)
|
58
|
-
body[value] = []
|
59
|
-
self.send(key).each do |arr|
|
60
|
-
if arr.respond_to? :to_body
|
61
|
-
body[value] << arr.to_body
|
62
|
-
else
|
63
|
-
body[value] << arr
|
64
|
-
end
|
65
|
-
end
|
66
|
-
else
|
67
|
-
body[value] = self.send(key)
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
body
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
data/lib/tpaga/models/charge.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
|
3
|
-
module Tpaga
|
4
|
-
class Charge
|
5
|
-
attr_accessor :amount, :creditCard, :currency, :customer, :description, :id, :orderId, :paid, :paymentTransaction, :taxAmount
|
6
|
-
|
7
|
-
# :internal => :external
|
8
|
-
def self.attribute_map
|
9
|
-
{
|
10
|
-
:amount => :'amount',
|
11
|
-
:creditCard => :'creditCard',
|
12
|
-
:currency => :'currency',
|
13
|
-
:customer => :'customer',
|
14
|
-
:description => :'description',
|
15
|
-
:id => :'id',
|
16
|
-
:orderId => :'orderId',
|
17
|
-
:paid => :'paid',
|
18
|
-
:paymentTransaction => :'paymentTransaction',
|
19
|
-
:taxAmount => :'taxAmount'
|
20
|
-
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
def initialize(attributes = {})
|
25
|
-
return if attributes.empty?
|
26
|
-
|
27
|
-
# convert hash key from symbol to string
|
28
|
-
# and convert object to hash
|
29
|
-
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_s] = Swagger.to_body(v); memo}
|
30
|
-
|
31
|
-
# Morph attribute keys into undescored rubyish style
|
32
|
-
if self.class.attribute_map[:"amount"]
|
33
|
-
@amount = attributes["amount"]
|
34
|
-
end
|
35
|
-
if self.class.attribute_map[:"creditCard"]
|
36
|
-
@creditCard = attributes["creditCard"]
|
37
|
-
end
|
38
|
-
if self.class.attribute_map[:"currency"]
|
39
|
-
@currency = attributes["currency"]
|
40
|
-
end
|
41
|
-
if self.class.attribute_map[:"customer"]
|
42
|
-
@customer = attributes["customer"]
|
43
|
-
end
|
44
|
-
if self.class.attribute_map[:"description"]
|
45
|
-
@description = attributes["description"]
|
46
|
-
end
|
47
|
-
if self.class.attribute_map[:"id"]
|
48
|
-
@id = attributes["id"]
|
49
|
-
end
|
50
|
-
if self.class.attribute_map[:"orderId"]
|
51
|
-
@orderId = attributes["orderId"]
|
52
|
-
end
|
53
|
-
if self.class.attribute_map[:"paid"]
|
54
|
-
@paid = attributes["paid"]
|
55
|
-
end
|
56
|
-
if self.class.attribute_map[:"paymentTransaction"]
|
57
|
-
@paymentTransaction = attributes["paymentTransaction"]
|
58
|
-
end
|
59
|
-
if self.class.attribute_map[:"taxAmount"]
|
60
|
-
@taxAmount = attributes["taxAmount"]
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
def to_body
|
67
|
-
body = {}
|
68
|
-
self.class.attribute_map.each_pair do |key, value|
|
69
|
-
next if self.send(key).nil?
|
70
|
-
|
71
|
-
if self.send(key).respond_to? :to_body
|
72
|
-
body[value] = self.send(key).to_body
|
73
|
-
elsif self.send(key).kind_of?(Array)
|
74
|
-
body[value] = []
|
75
|
-
self.send(key).each do |arr|
|
76
|
-
if arr.respond_to? :to_body
|
77
|
-
body[value] << arr.to_body
|
78
|
-
else
|
79
|
-
body[value] << arr
|
80
|
-
end
|
81
|
-
end
|
82
|
-
else
|
83
|
-
body[value] = self.send(key)
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
body
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
@@ -1,107 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
|
3
|
-
module Tpaga
|
4
|
-
class CreditCard
|
5
|
-
attr_accessor :addressCity, :addressCountry, :addressLine1, :addressLine2, :addressPostalCode, :addressState, :bin, :cardHolderName, :customer, :expirationMonth, :expirationYear, :id, :lastFour, :type
|
6
|
-
|
7
|
-
# :internal => :external
|
8
|
-
def self.attribute_map
|
9
|
-
{
|
10
|
-
:addressCity => :'addressCity',
|
11
|
-
:addressCountry => :'addressCountry',
|
12
|
-
:addressLine1 => :'addressLine1',
|
13
|
-
:addressLine2 => :'addressLine2',
|
14
|
-
:addressPostalCode => :'addressPostalCode',
|
15
|
-
:addressState => :'addressState',
|
16
|
-
:bin => :'bin',
|
17
|
-
:cardHolderName => :'cardHolderName',
|
18
|
-
:customer => :'customer',
|
19
|
-
:expirationMonth => :'expirationMonth',
|
20
|
-
:expirationYear => :'expirationYear',
|
21
|
-
:id => :'id',
|
22
|
-
:lastFour => :'lastFour',
|
23
|
-
:type => :'type'
|
24
|
-
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
def initialize(attributes = {})
|
29
|
-
return if attributes.empty?
|
30
|
-
|
31
|
-
# convert hash key from symbol to string
|
32
|
-
# and convert object to hash
|
33
|
-
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_s] = Swagger.to_body(v); memo}
|
34
|
-
|
35
|
-
# Morph attribute keys into undescored rubyish style
|
36
|
-
if self.class.attribute_map[:"addressCity"]
|
37
|
-
@addressCity = attributes["addressCity"]
|
38
|
-
end
|
39
|
-
if self.class.attribute_map[:"addressCountry"]
|
40
|
-
@addressCountry = attributes["addressCountry"]
|
41
|
-
end
|
42
|
-
if self.class.attribute_map[:"addressLine1"]
|
43
|
-
@addressLine1 = attributes["addressLine1"]
|
44
|
-
end
|
45
|
-
if self.class.attribute_map[:"addressLine2"]
|
46
|
-
@addressLine2 = attributes["addressLine2"]
|
47
|
-
end
|
48
|
-
if self.class.attribute_map[:"addressPostalCode"]
|
49
|
-
@addressPostalCode = attributes["addressPostalCode"]
|
50
|
-
end
|
51
|
-
if self.class.attribute_map[:"addressState"]
|
52
|
-
@addressState = attributes["addressState"]
|
53
|
-
end
|
54
|
-
if self.class.attribute_map[:"bin"]
|
55
|
-
@bin = attributes["bin"]
|
56
|
-
end
|
57
|
-
if self.class.attribute_map[:"cardHolderName"]
|
58
|
-
@cardHolderName = attributes["cardHolderName"]
|
59
|
-
end
|
60
|
-
if self.class.attribute_map[:"customer"]
|
61
|
-
@customer = attributes["customer"]
|
62
|
-
end
|
63
|
-
if self.class.attribute_map[:"expirationMonth"]
|
64
|
-
@expirationMonth = attributes["expirationMonth"]
|
65
|
-
end
|
66
|
-
if self.class.attribute_map[:"expirationYear"]
|
67
|
-
@expirationYear = attributes["expirationYear"]
|
68
|
-
end
|
69
|
-
if self.class.attribute_map[:"id"]
|
70
|
-
@id = attributes["id"]
|
71
|
-
end
|
72
|
-
if self.class.attribute_map[:"lastFour"]
|
73
|
-
@lastFour = attributes["lastFour"]
|
74
|
-
end
|
75
|
-
if self.class.attribute_map[:"type"]
|
76
|
-
@type = attributes["type"]
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
def to_body
|
83
|
-
body = {}
|
84
|
-
self.class.attribute_map.each_pair do |key, value|
|
85
|
-
next if self.send(key).nil?
|
86
|
-
|
87
|
-
if self.send(key).respond_to? :to_body
|
88
|
-
body[value] = self.send(key).to_body
|
89
|
-
elsif self.send(key).kind_of?(Array)
|
90
|
-
body[value] = []
|
91
|
-
self.send(key).each do |arr|
|
92
|
-
if arr.respond_to? :to_body
|
93
|
-
body[value] << arr.to_body
|
94
|
-
else
|
95
|
-
body[value] << arr
|
96
|
-
end
|
97
|
-
end
|
98
|
-
else
|
99
|
-
body[value] = self.send(key)
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
body
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|