tpaga 0.0.3 → 0.0.4

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.
@@ -1,370 +1,128 @@
1
1
  require "uri"
2
2
 
3
3
  module Tpaga
4
- class CustomerAPI
5
- basePath = "https://api.tpaga.co.local:8443/api"
6
- # apiInvoker = APIInvoker
4
+ class CustomerApi
5
+ basePath = "https://sandbox.tpaga.co/api"
6
+ # apiInvoker = APIInvoker
7
7
 
8
- def self.escapeString(string)
9
- URI.encode(string.to_s)
10
- end
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
- end
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
- required_options = {
172
- :'id' => id}
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
- # Deletes a Customer by ID
210
- # Deletes a Customer when ID is `customer_token_id_delete` or anything else will simulate API error conditions. Only available when the customer does not have associated payment methods.
211
- # @param id Identificaiton of customer that needs to be deleted
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
- # verify existence of params
217
- raise "id is required" if id.nil?
218
- # set default values and merge with input
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
- required_options = {
223
- :'id' => id}
36
+ # form parameters
37
+ form_params = {}
224
38
 
225
- options.merge!(required_options)
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
- # pull querystring keys from options
233
- queryopts = options.select do |key,value|
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
- # header parameter
238
- headers = {}
239
- # additional http headers
240
- headers['Accept'] = 'application/json'
241
- headers['Content-Type'] = 'application/x-www-form-urlencoded'
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
- # http body
244
- post_body = nil
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
- # authentication setting
251
- require_auth = true
59
+ # resource path
60
+ path = "/customer/{id}".sub('{format}', 'json').sub('{' + 'id' + '}', id.to_s)
252
61
 
253
- Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :form_params => form_parameter_hash, :body=>post_body, :require_auth => require_auth }).make
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
- # Find a `CreditCard` by ID
261
- # Returns a CreditCard when ID is `credit_card_token` or anything else will simulate API error conditions
262
- # @param customer_id Identificaiton of `Customer` associated with the card
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
- # verify existence of params
269
- raise "customer_id is required" if customer_id.nil?
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
- required_options = {
276
- :'customer_id' => customer_id,
277
- :'card_id' => card_id}
79
+ # http body (model)
80
+ post_body = nil
278
81
 
279
- options.merge!(required_options)
280
82
 
281
- #resource path
282
- path = "/customer/{customer_id}/credit_card/{card_id}".sub('{' + 'customer_id' + '}', escapeString(customer_id))
283
- .sub('{' + 'card_id' + '}', escapeString(card_id))
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
- # header parameter
293
- headers = {}
294
- # additional http headers
295
- headers['Accept'] = 'application/json'
296
- headers['Content-Type'] = 'application/x-www-form-urlencoded'
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
- response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :form_params => form_parameter_hash, :body=>post_body, :require_auth => require_auth }).make.body
309
- CreditCard.new(response)
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
- # Deletes a Credit Card by ID
316
- # Deletes a `CreditCard` when ID is `credit_card_token_delete` or anything else will simulate API error conditions. Only available when the CreditCard does not have associated Charges.
317
- # @param customer_id Identificaiton token of `Customer` associated with the card
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
- # verify existence of params
324
- raise "customer_id is required" if customer_id.nil?
325
- raise "card_id is required" if card_id.nil?
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
- required_options = {
331
- :'customer_id' => customer_id,
332
- :'card_id' => card_id}
116
+ # form parameters
117
+ form_params = {}
333
118
 
334
- options.merge!(required_options)
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
- # pull querystring keys from options
343
- queryopts = options.select do |key,value|
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
-