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,370 +1,128 @@
|
|
1
1
|
require "uri"
|
2
2
|
|
3
3
|
module Tpaga
|
4
|
-
class
|
5
|
-
|
6
|
-
|
4
|
+
class CustomerApi
|
5
|
+
basePath = "https://sandbox.tpaga.co/api"
|
6
|
+
# apiInvoker = APIInvoker
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# Add a new Customer to the Merchant
|
15
|
-
# Creates a new `Customer` associated to the Merchant
|
16
|
-
# @param body Customer object that needs to be added to the Merchant
|
17
|
-
# @return Customer
|
18
|
-
def self.add_customer (body,opts={})
|
19
|
-
query_param_keys = []
|
20
|
-
|
21
|
-
# verify existence of params
|
22
|
-
raise "body is required" if body.nil?
|
23
|
-
# set default values and merge with input
|
24
|
-
options = {
|
25
|
-
}.merge(opts)
|
26
|
-
|
27
|
-
required_options = {
|
28
|
-
:'body' => body}
|
29
|
-
|
30
|
-
options.merge!(required_options)
|
31
|
-
|
32
|
-
#resource path
|
33
|
-
path = "/customer"
|
34
|
-
|
35
|
-
|
36
|
-
# pull querystring keys from options
|
37
|
-
queryopts = options.select do |key,value|
|
38
|
-
query_param_keys.include? key
|
39
|
-
end
|
40
|
-
|
41
|
-
# header parameter
|
42
|
-
headers = {}
|
43
|
-
# additional http headers
|
44
|
-
headers['Accept'] = 'application/json'
|
45
|
-
headers['Content-Type'] = 'application/json'
|
46
|
-
|
47
|
-
# http body
|
48
|
-
post_body = nil
|
49
|
-
if body != nil
|
50
|
-
if body.is_a?(Array)
|
51
|
-
array = Array.new
|
52
|
-
body.each do |item|
|
53
|
-
if item.respond_to?("to_body".to_sym)
|
54
|
-
array.push item.to_body
|
55
|
-
else
|
56
|
-
array.push item
|
57
|
-
end
|
58
|
-
end
|
59
|
-
post_body = array
|
60
|
-
|
61
|
-
else
|
62
|
-
if body.respond_to?("to_body".to_sym)
|
63
|
-
post_body = body.to_body
|
64
|
-
else
|
65
|
-
post_body = body
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
# form parameter
|
70
|
-
form_parameter_hash = {}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
# authentication setting
|
75
|
-
require_auth = true
|
76
|
-
|
77
|
-
response = Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :form_params => form_parameter_hash, :body=>post_body, :require_auth => require_auth }).make.body
|
78
|
-
Customer.new(response)
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
# Add a new Credit Card payment method to the Customer
|
85
|
-
# Creates a new `CreditCard` and associated to the `Customer`
|
86
|
-
# @param customer_id Identificaiton of `Customer` to associate the new `CreditCard`
|
87
|
-
# @param body CreditCard object that needs to be added to the Customer
|
88
|
-
# @return CreditCard
|
89
|
-
def self.add_credit_card (customer_id,body,opts={})
|
90
|
-
query_param_keys = []
|
91
|
-
|
92
|
-
# verify existence of params
|
93
|
-
raise "customer_id is required" if customer_id.nil?
|
94
|
-
raise "body is required" if body.nil?
|
95
|
-
# set default values and merge with input
|
96
|
-
options = {
|
97
|
-
}.merge(opts)
|
98
|
-
|
99
|
-
required_options = {
|
100
|
-
:'customer_id' => customer_id,
|
101
|
-
:'body' => body}
|
102
|
-
|
103
|
-
options.merge!(required_options)
|
104
|
-
|
105
|
-
#resource path
|
106
|
-
path = "/customer/{customer_id}/credit_card".sub('{' + 'customer_id' + '}', escapeString(customer_id))
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
# pull querystring keys from options
|
111
|
-
queryopts = options.select do |key,value|
|
112
|
-
query_param_keys.include? key
|
113
|
-
end
|
114
|
-
|
115
|
-
# header parameter
|
116
|
-
headers = {}
|
117
|
-
# additional http headers
|
118
|
-
headers['Accept'] = 'application/json'
|
119
|
-
headers['Content-Type'] = 'application/json'
|
120
|
-
|
121
|
-
# http body
|
122
|
-
post_body = nil
|
123
|
-
if body != nil
|
124
|
-
if body.is_a?(Array)
|
125
|
-
array = Array.new
|
126
|
-
body.each do |item|
|
127
|
-
if item.respond_to?("to_body".to_sym)
|
128
|
-
array.push item.to_body
|
129
|
-
else
|
130
|
-
array.push item
|
131
|
-
end
|
132
|
-
end
|
133
|
-
post_body = array
|
134
|
-
|
135
|
-
else
|
136
|
-
if body.respond_to?("to_body".to_sym)
|
137
|
-
post_body = body.to_body
|
138
|
-
else
|
139
|
-
post_body = body
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
# form parameter
|
144
|
-
form_parameter_hash = {}
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
# authentication setting
|
149
|
-
require_auth = true
|
150
|
-
|
151
|
-
response = Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :form_params => form_parameter_hash, :body=>post_body, :require_auth => require_auth }).make.body
|
152
|
-
CreditCard.new(response)
|
8
|
+
# Add a new Customer to the Merchant
|
9
|
+
# Creates a new `Customer` associated to the Merchant. There are no mandatory parameters to create the `Customer`, but filling all the fields is highly recomended.
|
10
|
+
# @param body Customer object to be added to the Merchant, it has the following fields\n- **id** its the id of the `Customer` thats going to be generated after creation.\n- **firstName** which is the `Customer`'s first name.\n- **lastName** which is the `Customer`'s last name.\n- **gender** of the `Customer` which can be Male (M), Female (F) or Not Available (N/A)\n- **address** which is the `Customer`'s home address.\n- **email** which is the `Customer`'s e-mail address with proper formatting ( i. e. email@example.com)\n- **phone** which is the `Customer`'s phone number
|
11
|
+
# @param [Hash] opts the optional parameters
|
12
|
+
# @return [Customer]
|
13
|
+
def self.create_customer(body, opts = {})
|
153
14
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
# Find a Customer by ID
|
159
|
-
# Returns a `Customer` when ID is `customer_token_id` or anything else will simulate API error conditions
|
160
|
-
# @param id Identification of `Customer` that needs to be fetched
|
161
|
-
# @return Customer
|
162
|
-
def self.get_customer_by_id (id,opts={})
|
163
|
-
query_param_keys = []
|
15
|
+
# verify the required parameter 'body' is set
|
16
|
+
raise "Missing the required parameter 'body' when calling create_customer" if body.nil?
|
164
17
|
|
165
|
-
# verify existence of params
|
166
|
-
raise "id is required" if id.nil?
|
167
|
-
# set default values and merge with input
|
168
|
-
options = {
|
169
|
-
}.merge(opts)
|
170
18
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
options.merge!(required_options)
|
175
|
-
|
176
|
-
#resource path
|
177
|
-
path = "/customer/{id}".sub('{' + 'id' + '}', escapeString(id))
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
# pull querystring keys from options
|
182
|
-
queryopts = options.select do |key,value|
|
183
|
-
query_param_keys.include? key
|
184
|
-
end
|
185
|
-
|
186
|
-
# header parameter
|
187
|
-
headers = {}
|
188
|
-
# additional http headers
|
189
|
-
headers['Accept'] = 'application/json'
|
190
|
-
headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
191
|
-
|
192
|
-
# http body
|
193
|
-
post_body = nil
|
194
|
-
# form parameter
|
195
|
-
form_parameter_hash = {}
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
# authentication setting
|
200
|
-
require_auth = true
|
201
|
-
|
202
|
-
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :form_params => form_parameter_hash, :body=>post_body, :require_auth => require_auth }).make.body
|
203
|
-
Customer.new(response)
|
204
|
-
|
205
|
-
end
|
19
|
+
# resource path
|
20
|
+
path = "/customer".sub('{format}', 'json')
|
206
21
|
|
22
|
+
# query parameters
|
23
|
+
query_params = {}
|
207
24
|
|
25
|
+
# header parameters
|
26
|
+
header_params = {}
|
208
27
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
# @return void
|
213
|
-
def self.delete_customer_by_id (id,opts={})
|
214
|
-
query_param_keys = []
|
28
|
+
# HTTP header 'Accept' (if needed)
|
29
|
+
_header_accept = []
|
30
|
+
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
215
31
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
options = {
|
220
|
-
}.merge(opts)
|
32
|
+
# HTTP header 'Content-Type'
|
33
|
+
_header_content_type = []
|
34
|
+
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
221
35
|
|
222
|
-
|
223
|
-
|
36
|
+
# form parameters
|
37
|
+
form_params = {}
|
224
38
|
|
225
|
-
|
39
|
+
# http body (model)
|
40
|
+
post_body = Swagger::Request.object_to_http_body(body)
|
226
41
|
|
227
|
-
#resource path
|
228
|
-
path = "/customer/{id}".sub('{' + 'id' + '}', escapeString(id))
|
229
|
-
|
230
42
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
query_param_keys.include? key
|
43
|
+
auth_names = ['api_key']
|
44
|
+
response = Swagger::Request.new(:POST, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body
|
45
|
+
obj = Customer.new() and obj.build_from_hash(response)
|
235
46
|
end
|
236
47
|
|
237
|
-
#
|
238
|
-
|
239
|
-
#
|
240
|
-
|
241
|
-
|
48
|
+
# Retrieve a Customer by ID
|
49
|
+
# Get the details of an existing `Customer`. This method only requires an unique `Customer` identifier `id` that was returned upon `Customer` creation.
|
50
|
+
# @param id Identification of `Customer` to be retrieved
|
51
|
+
# @param [Hash] opts the optional parameters
|
52
|
+
# @return [Customer]
|
53
|
+
def self.get_customer_by_id(id, opts = {})
|
242
54
|
|
243
|
-
|
244
|
-
|
245
|
-
# form parameter
|
246
|
-
form_parameter_hash = {}
|
247
|
-
|
55
|
+
# verify the required parameter 'id' is set
|
56
|
+
raise "Missing the required parameter 'id' when calling get_customer_by_id" if id.nil?
|
248
57
|
|
249
58
|
|
250
|
-
|
251
|
-
|
59
|
+
# resource path
|
60
|
+
path = "/customer/{id}".sub('{format}', 'json').sub('{' + 'id' + '}', id.to_s)
|
252
61
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
end
|
62
|
+
# query parameters
|
63
|
+
query_params = {}
|
257
64
|
|
65
|
+
# header parameters
|
66
|
+
header_params = {}
|
258
67
|
|
68
|
+
# HTTP header 'Accept' (if needed)
|
69
|
+
_header_accept = []
|
70
|
+
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
259
71
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
# @param card_id Identification of `CreditCard` that needs to be fetched
|
264
|
-
# @return CreditCard
|
265
|
-
def self.get_credit_card_by_id (customer_id,card_id,opts={})
|
266
|
-
query_param_keys = []
|
72
|
+
# HTTP header 'Content-Type'
|
73
|
+
_header_content_type = []
|
74
|
+
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
267
75
|
|
268
|
-
|
269
|
-
|
270
|
-
raise "card_id is required" if card_id.nil?
|
271
|
-
# set default values and merge with input
|
272
|
-
options = {
|
273
|
-
}.merge(opts)
|
76
|
+
# form parameters
|
77
|
+
form_params = {}
|
274
78
|
|
275
|
-
|
276
|
-
|
277
|
-
:'card_id' => card_id}
|
79
|
+
# http body (model)
|
80
|
+
post_body = nil
|
278
81
|
|
279
|
-
options.merge!(required_options)
|
280
82
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
# pull querystring keys from options
|
288
|
-
queryopts = options.select do |key,value|
|
289
|
-
query_param_keys.include? key
|
83
|
+
auth_names = ['api_key']
|
84
|
+
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body
|
85
|
+
obj = Customer.new() and obj.build_from_hash(response)
|
290
86
|
end
|
291
87
|
|
292
|
-
#
|
293
|
-
|
294
|
-
#
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
# http body
|
299
|
-
post_body = nil
|
300
|
-
# form parameter
|
301
|
-
form_parameter_hash = {}
|
302
|
-
|
88
|
+
# Deletes a Customer by ID
|
89
|
+
# Deletes a `Customer` when its `id` matches the parameter. Only available when `Customer` does not have associated payment methods.
|
90
|
+
# @param id Identification of customer to be deleted
|
91
|
+
# @param [Hash] opts the optional parameters
|
92
|
+
# @return [nil]
|
93
|
+
def self.delete_customer_by_id(id, opts = {})
|
303
94
|
|
95
|
+
# verify the required parameter 'id' is set
|
96
|
+
raise "Missing the required parameter 'id' when calling delete_customer_by_id" if id.nil?
|
304
97
|
|
305
|
-
# authentication setting
|
306
|
-
require_auth = true
|
307
98
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
end
|
99
|
+
# resource path
|
100
|
+
path = "/customer/{id}".sub('{format}', 'json').sub('{' + 'id' + '}', id.to_s)
|
312
101
|
|
102
|
+
# query parameters
|
103
|
+
query_params = {}
|
313
104
|
|
105
|
+
# header parameters
|
106
|
+
header_params = {}
|
314
107
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
# @param card_id Identification token of `CreditCard` that needs to be deleted
|
319
|
-
# @return void
|
320
|
-
def self.delete_credit_card_by_id (customer_id,card_id,opts={})
|
321
|
-
query_param_keys = []
|
108
|
+
# HTTP header 'Accept' (if needed)
|
109
|
+
_header_accept = []
|
110
|
+
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
322
111
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
# set default values and merge with input
|
327
|
-
options = {
|
328
|
-
}.merge(opts)
|
112
|
+
# HTTP header 'Content-Type'
|
113
|
+
_header_content_type = []
|
114
|
+
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
329
115
|
|
330
|
-
|
331
|
-
|
332
|
-
:'card_id' => card_id}
|
116
|
+
# form parameters
|
117
|
+
form_params = {}
|
333
118
|
|
334
|
-
|
119
|
+
# http body (model)
|
120
|
+
post_body = nil
|
335
121
|
|
336
|
-
#resource path
|
337
|
-
path = "/customer/{customer_id}/credit_card/{card_id}".sub('{' + 'customer_id' + '}', escapeString(customer_id))
|
338
|
-
.sub('{' + 'card_id' + '}', escapeString(card_id))
|
339
|
-
|
340
122
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
query_param_keys.include? key
|
123
|
+
auth_names = ['api_key']
|
124
|
+
Swagger::Request.new(:DELETE, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make
|
125
|
+
nil
|
345
126
|
end
|
346
|
-
|
347
|
-
# header parameter
|
348
|
-
headers = {}
|
349
|
-
# additional http headers
|
350
|
-
headers['Accept'] = 'application/json'
|
351
|
-
headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
352
|
-
|
353
|
-
# http body
|
354
|
-
post_body = nil
|
355
|
-
# form parameter
|
356
|
-
form_parameter_hash = {}
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
# authentication setting
|
361
|
-
require_auth = true
|
362
|
-
|
363
|
-
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :form_params => form_parameter_hash, :body=>post_body, :require_auth => require_auth }).make
|
364
|
-
|
365
|
-
|
366
127
|
end
|
367
|
-
|
368
|
-
end
|
369
128
|
end
|
370
|
-
|