processout 2.20.0 → 2.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +52 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Dockerfile +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/Makefile +4 -0
- data/README.md +12 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/processout/activity.rb +206 -0
- data/lib/processout/addon.rb +401 -0
- data/lib/processout/alternative_merchant_certificate.rb +115 -0
- data/lib/processout/api_request.rb +295 -0
- data/lib/processout/api_version.rb +92 -0
- data/lib/processout/apple_pay_alternative_merchant_certificates.rb +121 -0
- data/lib/processout/balance.rb +92 -0
- data/lib/processout/balances.rb +111 -0
- data/lib/processout/card.rb +503 -0
- data/lib/processout/card_information.rb +164 -0
- data/lib/processout/coupon.rb +352 -0
- data/lib/processout/customer.rb +755 -0
- data/lib/processout/customer_action.rb +81 -0
- data/lib/processout/discount.rb +360 -0
- data/lib/processout/dunning_action.rb +81 -0
- data/lib/processout/errors/authentication_error.rb +9 -0
- data/lib/processout/errors/generic_error.rb +9 -0
- data/lib/processout/errors/internal_error.rb +9 -0
- data/lib/processout/errors/notfound_error.rb +9 -0
- data/lib/processout/errors/validation_error.rb +9 -0
- data/lib/processout/event.rb +237 -0
- data/lib/processout/gateway.rb +210 -0
- data/lib/processout/gateway_configuration.rb +346 -0
- data/lib/processout/gateway_request.rb +26 -0
- data/lib/processout/invoice.rb +984 -0
- data/lib/processout/invoice_detail.rb +235 -0
- data/lib/processout/invoice_device.rb +92 -0
- data/lib/processout/invoice_external_fraud_tools.rb +70 -0
- data/lib/processout/invoice_risk.rb +81 -0
- data/lib/processout/invoice_shipping.rb +202 -0
- data/lib/processout/invoice_tax.rb +81 -0
- data/lib/processout/networking/request.rb +102 -0
- data/lib/processout/networking/response.rb +67 -0
- data/lib/processout/payment_data_network_authentication.rb +70 -0
- data/lib/processout/payment_data_three_ds_authentication.rb +70 -0
- data/lib/processout/payment_data_three_ds_request.rb +103 -0
- data/lib/processout/payout.rb +379 -0
- data/lib/processout/payout_item.rb +238 -0
- data/lib/processout/plan.rb +368 -0
- data/lib/processout/product.rb +368 -0
- data/lib/processout/project.rb +353 -0
- data/lib/processout/refund.rb +277 -0
- data/lib/processout/subscription.rb +910 -0
- data/lib/processout/three_ds.rb +158 -0
- data/lib/processout/token.rb +493 -0
- data/lib/processout/transaction.rb +905 -0
- data/lib/processout/transaction_operation.rb +418 -0
- data/lib/processout/version.rb +3 -0
- data/lib/processout/webhook.rb +237 -0
- data/lib/processout/webhook_endpoint.rb +149 -0
- data/lib/processout.rb +263 -0
- data/processout.gemspec +26 -0
- metadata +66 -3
@@ -0,0 +1,503 @@
|
|
1
|
+
# The content of this file was automatically generated
|
2
|
+
|
3
|
+
require "cgi"
|
4
|
+
require "json"
|
5
|
+
require "processout/networking/request"
|
6
|
+
require "processout/networking/response"
|
7
|
+
|
8
|
+
module ProcessOut
|
9
|
+
class Card
|
10
|
+
|
11
|
+
attr_reader :id
|
12
|
+
attr_reader :project
|
13
|
+
attr_reader :project_id
|
14
|
+
attr_reader :token
|
15
|
+
attr_reader :scheme
|
16
|
+
attr_reader :co_scheme
|
17
|
+
attr_reader :preferred_scheme
|
18
|
+
attr_reader :type
|
19
|
+
attr_reader :bank_name
|
20
|
+
attr_reader :brand
|
21
|
+
attr_reader :category
|
22
|
+
attr_reader :iin
|
23
|
+
attr_reader :last_4_digits
|
24
|
+
attr_reader :exp_month
|
25
|
+
attr_reader :exp_year
|
26
|
+
attr_reader :cvc_check
|
27
|
+
attr_reader :avs_check
|
28
|
+
attr_reader :name
|
29
|
+
attr_reader :address1
|
30
|
+
attr_reader :address2
|
31
|
+
attr_reader :city
|
32
|
+
attr_reader :state
|
33
|
+
attr_reader :zip
|
34
|
+
attr_reader :country_code
|
35
|
+
attr_reader :ip_address
|
36
|
+
attr_reader :fingerprint
|
37
|
+
attr_reader :token_type
|
38
|
+
attr_reader :metadata
|
39
|
+
attr_reader :expires_soon
|
40
|
+
attr_reader :sandbox
|
41
|
+
attr_reader :created_at
|
42
|
+
|
43
|
+
|
44
|
+
def id=(val)
|
45
|
+
@id = val
|
46
|
+
end
|
47
|
+
|
48
|
+
def project=(val)
|
49
|
+
if val.nil?
|
50
|
+
@project = val
|
51
|
+
return
|
52
|
+
end
|
53
|
+
|
54
|
+
if val.instance_of? Project
|
55
|
+
@project = val
|
56
|
+
else
|
57
|
+
obj = Project.new(@client)
|
58
|
+
obj.fill_with_data(val)
|
59
|
+
@project = obj
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
def project_id=(val)
|
65
|
+
@project_id = val
|
66
|
+
end
|
67
|
+
|
68
|
+
def token=(val)
|
69
|
+
if val.nil?
|
70
|
+
@token = val
|
71
|
+
return
|
72
|
+
end
|
73
|
+
|
74
|
+
if val.instance_of? Token
|
75
|
+
@token = val
|
76
|
+
else
|
77
|
+
obj = Token.new(@client)
|
78
|
+
obj.fill_with_data(val)
|
79
|
+
@token = obj
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
def scheme=(val)
|
85
|
+
@scheme = val
|
86
|
+
end
|
87
|
+
|
88
|
+
def co_scheme=(val)
|
89
|
+
@co_scheme = val
|
90
|
+
end
|
91
|
+
|
92
|
+
def preferred_scheme=(val)
|
93
|
+
@preferred_scheme = val
|
94
|
+
end
|
95
|
+
|
96
|
+
def type=(val)
|
97
|
+
@type = val
|
98
|
+
end
|
99
|
+
|
100
|
+
def bank_name=(val)
|
101
|
+
@bank_name = val
|
102
|
+
end
|
103
|
+
|
104
|
+
def brand=(val)
|
105
|
+
@brand = val
|
106
|
+
end
|
107
|
+
|
108
|
+
def category=(val)
|
109
|
+
@category = val
|
110
|
+
end
|
111
|
+
|
112
|
+
def iin=(val)
|
113
|
+
@iin = val
|
114
|
+
end
|
115
|
+
|
116
|
+
def last_4_digits=(val)
|
117
|
+
@last_4_digits = val
|
118
|
+
end
|
119
|
+
|
120
|
+
def exp_month=(val)
|
121
|
+
@exp_month = val
|
122
|
+
end
|
123
|
+
|
124
|
+
def exp_year=(val)
|
125
|
+
@exp_year = val
|
126
|
+
end
|
127
|
+
|
128
|
+
def cvc_check=(val)
|
129
|
+
@cvc_check = val
|
130
|
+
end
|
131
|
+
|
132
|
+
def avs_check=(val)
|
133
|
+
@avs_check = val
|
134
|
+
end
|
135
|
+
|
136
|
+
def name=(val)
|
137
|
+
@name = val
|
138
|
+
end
|
139
|
+
|
140
|
+
def address1=(val)
|
141
|
+
@address1 = val
|
142
|
+
end
|
143
|
+
|
144
|
+
def address2=(val)
|
145
|
+
@address2 = val
|
146
|
+
end
|
147
|
+
|
148
|
+
def city=(val)
|
149
|
+
@city = val
|
150
|
+
end
|
151
|
+
|
152
|
+
def state=(val)
|
153
|
+
@state = val
|
154
|
+
end
|
155
|
+
|
156
|
+
def zip=(val)
|
157
|
+
@zip = val
|
158
|
+
end
|
159
|
+
|
160
|
+
def country_code=(val)
|
161
|
+
@country_code = val
|
162
|
+
end
|
163
|
+
|
164
|
+
def ip_address=(val)
|
165
|
+
@ip_address = val
|
166
|
+
end
|
167
|
+
|
168
|
+
def fingerprint=(val)
|
169
|
+
@fingerprint = val
|
170
|
+
end
|
171
|
+
|
172
|
+
def token_type=(val)
|
173
|
+
@token_type = val
|
174
|
+
end
|
175
|
+
|
176
|
+
def metadata=(val)
|
177
|
+
@metadata = val
|
178
|
+
end
|
179
|
+
|
180
|
+
def expires_soon=(val)
|
181
|
+
@expires_soon = val
|
182
|
+
end
|
183
|
+
|
184
|
+
def sandbox=(val)
|
185
|
+
@sandbox = val
|
186
|
+
end
|
187
|
+
|
188
|
+
def created_at=(val)
|
189
|
+
@created_at = val
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
# Initializes the Card object
|
194
|
+
# Params:
|
195
|
+
# +client+:: +ProcessOut+ client instance
|
196
|
+
# +data+:: data that can be used to fill the object
|
197
|
+
def initialize(client, data = {})
|
198
|
+
@client = client
|
199
|
+
|
200
|
+
self.id = data.fetch(:id, nil)
|
201
|
+
self.project = data.fetch(:project, nil)
|
202
|
+
self.project_id = data.fetch(:project_id, nil)
|
203
|
+
self.token = data.fetch(:token, nil)
|
204
|
+
self.scheme = data.fetch(:scheme, nil)
|
205
|
+
self.co_scheme = data.fetch(:co_scheme, nil)
|
206
|
+
self.preferred_scheme = data.fetch(:preferred_scheme, nil)
|
207
|
+
self.type = data.fetch(:type, nil)
|
208
|
+
self.bank_name = data.fetch(:bank_name, nil)
|
209
|
+
self.brand = data.fetch(:brand, nil)
|
210
|
+
self.category = data.fetch(:category, nil)
|
211
|
+
self.iin = data.fetch(:iin, nil)
|
212
|
+
self.last_4_digits = data.fetch(:last_4_digits, nil)
|
213
|
+
self.exp_month = data.fetch(:exp_month, nil)
|
214
|
+
self.exp_year = data.fetch(:exp_year, nil)
|
215
|
+
self.cvc_check = data.fetch(:cvc_check, nil)
|
216
|
+
self.avs_check = data.fetch(:avs_check, nil)
|
217
|
+
self.name = data.fetch(:name, nil)
|
218
|
+
self.address1 = data.fetch(:address1, nil)
|
219
|
+
self.address2 = data.fetch(:address2, nil)
|
220
|
+
self.city = data.fetch(:city, nil)
|
221
|
+
self.state = data.fetch(:state, nil)
|
222
|
+
self.zip = data.fetch(:zip, nil)
|
223
|
+
self.country_code = data.fetch(:country_code, nil)
|
224
|
+
self.ip_address = data.fetch(:ip_address, nil)
|
225
|
+
self.fingerprint = data.fetch(:fingerprint, nil)
|
226
|
+
self.token_type = data.fetch(:token_type, nil)
|
227
|
+
self.metadata = data.fetch(:metadata, nil)
|
228
|
+
self.expires_soon = data.fetch(:expires_soon, nil)
|
229
|
+
self.sandbox = data.fetch(:sandbox, nil)
|
230
|
+
self.created_at = data.fetch(:created_at, nil)
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
# Create a new Card using the current client
|
235
|
+
def new(data = {})
|
236
|
+
Card.new(@client, data)
|
237
|
+
end
|
238
|
+
|
239
|
+
# Overrides the JSON marshaller to only send the fields we want
|
240
|
+
def to_json(options)
|
241
|
+
{
|
242
|
+
"id": self.id,
|
243
|
+
"project": self.project,
|
244
|
+
"project_id": self.project_id,
|
245
|
+
"token": self.token,
|
246
|
+
"scheme": self.scheme,
|
247
|
+
"co_scheme": self.co_scheme,
|
248
|
+
"preferred_scheme": self.preferred_scheme,
|
249
|
+
"type": self.type,
|
250
|
+
"bank_name": self.bank_name,
|
251
|
+
"brand": self.brand,
|
252
|
+
"category": self.category,
|
253
|
+
"iin": self.iin,
|
254
|
+
"last_4_digits": self.last_4_digits,
|
255
|
+
"exp_month": self.exp_month,
|
256
|
+
"exp_year": self.exp_year,
|
257
|
+
"cvc_check": self.cvc_check,
|
258
|
+
"avs_check": self.avs_check,
|
259
|
+
"name": self.name,
|
260
|
+
"address1": self.address1,
|
261
|
+
"address2": self.address2,
|
262
|
+
"city": self.city,
|
263
|
+
"state": self.state,
|
264
|
+
"zip": self.zip,
|
265
|
+
"country_code": self.country_code,
|
266
|
+
"ip_address": self.ip_address,
|
267
|
+
"fingerprint": self.fingerprint,
|
268
|
+
"token_type": self.token_type,
|
269
|
+
"metadata": self.metadata,
|
270
|
+
"expires_soon": self.expires_soon,
|
271
|
+
"sandbox": self.sandbox,
|
272
|
+
"created_at": self.created_at,
|
273
|
+
}.to_json
|
274
|
+
end
|
275
|
+
|
276
|
+
# Fills the object with data coming from the API
|
277
|
+
# Params:
|
278
|
+
# +data+:: +Hash+ of data coming from the API
|
279
|
+
def fill_with_data(data)
|
280
|
+
if data.nil?
|
281
|
+
return self
|
282
|
+
end
|
283
|
+
if data.include? "id"
|
284
|
+
self.id = data["id"]
|
285
|
+
end
|
286
|
+
if data.include? "project"
|
287
|
+
self.project = data["project"]
|
288
|
+
end
|
289
|
+
if data.include? "project_id"
|
290
|
+
self.project_id = data["project_id"]
|
291
|
+
end
|
292
|
+
if data.include? "token"
|
293
|
+
self.token = data["token"]
|
294
|
+
end
|
295
|
+
if data.include? "scheme"
|
296
|
+
self.scheme = data["scheme"]
|
297
|
+
end
|
298
|
+
if data.include? "co_scheme"
|
299
|
+
self.co_scheme = data["co_scheme"]
|
300
|
+
end
|
301
|
+
if data.include? "preferred_scheme"
|
302
|
+
self.preferred_scheme = data["preferred_scheme"]
|
303
|
+
end
|
304
|
+
if data.include? "type"
|
305
|
+
self.type = data["type"]
|
306
|
+
end
|
307
|
+
if data.include? "bank_name"
|
308
|
+
self.bank_name = data["bank_name"]
|
309
|
+
end
|
310
|
+
if data.include? "brand"
|
311
|
+
self.brand = data["brand"]
|
312
|
+
end
|
313
|
+
if data.include? "category"
|
314
|
+
self.category = data["category"]
|
315
|
+
end
|
316
|
+
if data.include? "iin"
|
317
|
+
self.iin = data["iin"]
|
318
|
+
end
|
319
|
+
if data.include? "last_4_digits"
|
320
|
+
self.last_4_digits = data["last_4_digits"]
|
321
|
+
end
|
322
|
+
if data.include? "exp_month"
|
323
|
+
self.exp_month = data["exp_month"]
|
324
|
+
end
|
325
|
+
if data.include? "exp_year"
|
326
|
+
self.exp_year = data["exp_year"]
|
327
|
+
end
|
328
|
+
if data.include? "cvc_check"
|
329
|
+
self.cvc_check = data["cvc_check"]
|
330
|
+
end
|
331
|
+
if data.include? "avs_check"
|
332
|
+
self.avs_check = data["avs_check"]
|
333
|
+
end
|
334
|
+
if data.include? "name"
|
335
|
+
self.name = data["name"]
|
336
|
+
end
|
337
|
+
if data.include? "address1"
|
338
|
+
self.address1 = data["address1"]
|
339
|
+
end
|
340
|
+
if data.include? "address2"
|
341
|
+
self.address2 = data["address2"]
|
342
|
+
end
|
343
|
+
if data.include? "city"
|
344
|
+
self.city = data["city"]
|
345
|
+
end
|
346
|
+
if data.include? "state"
|
347
|
+
self.state = data["state"]
|
348
|
+
end
|
349
|
+
if data.include? "zip"
|
350
|
+
self.zip = data["zip"]
|
351
|
+
end
|
352
|
+
if data.include? "country_code"
|
353
|
+
self.country_code = data["country_code"]
|
354
|
+
end
|
355
|
+
if data.include? "ip_address"
|
356
|
+
self.ip_address = data["ip_address"]
|
357
|
+
end
|
358
|
+
if data.include? "fingerprint"
|
359
|
+
self.fingerprint = data["fingerprint"]
|
360
|
+
end
|
361
|
+
if data.include? "token_type"
|
362
|
+
self.token_type = data["token_type"]
|
363
|
+
end
|
364
|
+
if data.include? "metadata"
|
365
|
+
self.metadata = data["metadata"]
|
366
|
+
end
|
367
|
+
if data.include? "expires_soon"
|
368
|
+
self.expires_soon = data["expires_soon"]
|
369
|
+
end
|
370
|
+
if data.include? "sandbox"
|
371
|
+
self.sandbox = data["sandbox"]
|
372
|
+
end
|
373
|
+
if data.include? "created_at"
|
374
|
+
self.created_at = data["created_at"]
|
375
|
+
end
|
376
|
+
|
377
|
+
self
|
378
|
+
end
|
379
|
+
|
380
|
+
# Prefills the object with the data passed as parameters
|
381
|
+
# Params:
|
382
|
+
# +data+:: +Hash+ of data
|
383
|
+
def prefill(data)
|
384
|
+
if data.nil?
|
385
|
+
return self
|
386
|
+
end
|
387
|
+
self.id = data.fetch(:id, self.id)
|
388
|
+
self.project = data.fetch(:project, self.project)
|
389
|
+
self.project_id = data.fetch(:project_id, self.project_id)
|
390
|
+
self.token = data.fetch(:token, self.token)
|
391
|
+
self.scheme = data.fetch(:scheme, self.scheme)
|
392
|
+
self.co_scheme = data.fetch(:co_scheme, self.co_scheme)
|
393
|
+
self.preferred_scheme = data.fetch(:preferred_scheme, self.preferred_scheme)
|
394
|
+
self.type = data.fetch(:type, self.type)
|
395
|
+
self.bank_name = data.fetch(:bank_name, self.bank_name)
|
396
|
+
self.brand = data.fetch(:brand, self.brand)
|
397
|
+
self.category = data.fetch(:category, self.category)
|
398
|
+
self.iin = data.fetch(:iin, self.iin)
|
399
|
+
self.last_4_digits = data.fetch(:last_4_digits, self.last_4_digits)
|
400
|
+
self.exp_month = data.fetch(:exp_month, self.exp_month)
|
401
|
+
self.exp_year = data.fetch(:exp_year, self.exp_year)
|
402
|
+
self.cvc_check = data.fetch(:cvc_check, self.cvc_check)
|
403
|
+
self.avs_check = data.fetch(:avs_check, self.avs_check)
|
404
|
+
self.name = data.fetch(:name, self.name)
|
405
|
+
self.address1 = data.fetch(:address1, self.address1)
|
406
|
+
self.address2 = data.fetch(:address2, self.address2)
|
407
|
+
self.city = data.fetch(:city, self.city)
|
408
|
+
self.state = data.fetch(:state, self.state)
|
409
|
+
self.zip = data.fetch(:zip, self.zip)
|
410
|
+
self.country_code = data.fetch(:country_code, self.country_code)
|
411
|
+
self.ip_address = data.fetch(:ip_address, self.ip_address)
|
412
|
+
self.fingerprint = data.fetch(:fingerprint, self.fingerprint)
|
413
|
+
self.token_type = data.fetch(:token_type, self.token_type)
|
414
|
+
self.metadata = data.fetch(:metadata, self.metadata)
|
415
|
+
self.expires_soon = data.fetch(:expires_soon, self.expires_soon)
|
416
|
+
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
417
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
418
|
+
|
419
|
+
self
|
420
|
+
end
|
421
|
+
|
422
|
+
# Get all the cards.
|
423
|
+
# Params:
|
424
|
+
# +options+:: +Hash+ of options
|
425
|
+
def all(options = {})
|
426
|
+
self.prefill(options)
|
427
|
+
|
428
|
+
request = Request.new(@client)
|
429
|
+
path = "/cards"
|
430
|
+
data = {
|
431
|
+
|
432
|
+
}
|
433
|
+
|
434
|
+
response = Response.new(request.get(path, data, options))
|
435
|
+
return_values = Array.new
|
436
|
+
|
437
|
+
a = Array.new
|
438
|
+
body = response.body
|
439
|
+
for v in body['cards']
|
440
|
+
tmp = Card.new(@client)
|
441
|
+
tmp.fill_with_data(v)
|
442
|
+
a.push(tmp)
|
443
|
+
end
|
444
|
+
|
445
|
+
return_values.push(a)
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
return_values[0]
|
450
|
+
end
|
451
|
+
|
452
|
+
# Find a card by its ID.
|
453
|
+
# Params:
|
454
|
+
# +card_id+:: ID of the card
|
455
|
+
# +options+:: +Hash+ of options
|
456
|
+
def find(card_id, options = {})
|
457
|
+
self.prefill(options)
|
458
|
+
|
459
|
+
request = Request.new(@client)
|
460
|
+
path = "/cards/" + CGI.escape(card_id) + ""
|
461
|
+
data = {
|
462
|
+
|
463
|
+
}
|
464
|
+
|
465
|
+
response = Response.new(request.get(path, data, options))
|
466
|
+
return_values = Array.new
|
467
|
+
|
468
|
+
body = response.body
|
469
|
+
body = body["card"]
|
470
|
+
|
471
|
+
|
472
|
+
obj = Card.new(@client)
|
473
|
+
return_values.push(obj.fill_with_data(body))
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
return_values[0]
|
478
|
+
end
|
479
|
+
|
480
|
+
# Anonymize the card.
|
481
|
+
# Params:
|
482
|
+
# +options+:: +Hash+ of options
|
483
|
+
def anonymize(options = {})
|
484
|
+
self.prefill(options)
|
485
|
+
|
486
|
+
request = Request.new(@client)
|
487
|
+
path = "/cards/" + CGI.escape(@id) + ""
|
488
|
+
data = {
|
489
|
+
|
490
|
+
}
|
491
|
+
|
492
|
+
response = Response.new(request.delete(path, data, options))
|
493
|
+
return_values = Array.new
|
494
|
+
|
495
|
+
return_values.push(response.success)
|
496
|
+
|
497
|
+
|
498
|
+
return_values[0]
|
499
|
+
end
|
500
|
+
|
501
|
+
|
502
|
+
end
|
503
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
# The content of this file was automatically generated
|
2
|
+
|
3
|
+
require "cgi"
|
4
|
+
require "json"
|
5
|
+
require "processout/networking/request"
|
6
|
+
require "processout/networking/response"
|
7
|
+
|
8
|
+
module ProcessOut
|
9
|
+
class CardInformation
|
10
|
+
|
11
|
+
attr_reader :iin
|
12
|
+
attr_reader :scheme
|
13
|
+
attr_reader :type
|
14
|
+
attr_reader :bank_name
|
15
|
+
attr_reader :brand
|
16
|
+
attr_reader :category
|
17
|
+
attr_reader :country
|
18
|
+
|
19
|
+
|
20
|
+
def iin=(val)
|
21
|
+
@iin = val
|
22
|
+
end
|
23
|
+
|
24
|
+
def scheme=(val)
|
25
|
+
@scheme = val
|
26
|
+
end
|
27
|
+
|
28
|
+
def type=(val)
|
29
|
+
@type = val
|
30
|
+
end
|
31
|
+
|
32
|
+
def bank_name=(val)
|
33
|
+
@bank_name = val
|
34
|
+
end
|
35
|
+
|
36
|
+
def brand=(val)
|
37
|
+
@brand = val
|
38
|
+
end
|
39
|
+
|
40
|
+
def category=(val)
|
41
|
+
@category = val
|
42
|
+
end
|
43
|
+
|
44
|
+
def country=(val)
|
45
|
+
@country = val
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
# Initializes the CardInformation object
|
50
|
+
# Params:
|
51
|
+
# +client+:: +ProcessOut+ client instance
|
52
|
+
# +data+:: data that can be used to fill the object
|
53
|
+
def initialize(client, data = {})
|
54
|
+
@client = client
|
55
|
+
|
56
|
+
self.iin = data.fetch(:iin, nil)
|
57
|
+
self.scheme = data.fetch(:scheme, nil)
|
58
|
+
self.type = data.fetch(:type, nil)
|
59
|
+
self.bank_name = data.fetch(:bank_name, nil)
|
60
|
+
self.brand = data.fetch(:brand, nil)
|
61
|
+
self.category = data.fetch(:category, nil)
|
62
|
+
self.country = data.fetch(:country, nil)
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
# Create a new CardInformation using the current client
|
67
|
+
def new(data = {})
|
68
|
+
CardInformation.new(@client, data)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Overrides the JSON marshaller to only send the fields we want
|
72
|
+
def to_json(options)
|
73
|
+
{
|
74
|
+
"iin": self.iin,
|
75
|
+
"scheme": self.scheme,
|
76
|
+
"type": self.type,
|
77
|
+
"bank_name": self.bank_name,
|
78
|
+
"brand": self.brand,
|
79
|
+
"category": self.category,
|
80
|
+
"country": self.country,
|
81
|
+
}.to_json
|
82
|
+
end
|
83
|
+
|
84
|
+
# Fills the object with data coming from the API
|
85
|
+
# Params:
|
86
|
+
# +data+:: +Hash+ of data coming from the API
|
87
|
+
def fill_with_data(data)
|
88
|
+
if data.nil?
|
89
|
+
return self
|
90
|
+
end
|
91
|
+
if data.include? "iin"
|
92
|
+
self.iin = data["iin"]
|
93
|
+
end
|
94
|
+
if data.include? "scheme"
|
95
|
+
self.scheme = data["scheme"]
|
96
|
+
end
|
97
|
+
if data.include? "type"
|
98
|
+
self.type = data["type"]
|
99
|
+
end
|
100
|
+
if data.include? "bank_name"
|
101
|
+
self.bank_name = data["bank_name"]
|
102
|
+
end
|
103
|
+
if data.include? "brand"
|
104
|
+
self.brand = data["brand"]
|
105
|
+
end
|
106
|
+
if data.include? "category"
|
107
|
+
self.category = data["category"]
|
108
|
+
end
|
109
|
+
if data.include? "country"
|
110
|
+
self.country = data["country"]
|
111
|
+
end
|
112
|
+
|
113
|
+
self
|
114
|
+
end
|
115
|
+
|
116
|
+
# Prefills the object with the data passed as parameters
|
117
|
+
# Params:
|
118
|
+
# +data+:: +Hash+ of data
|
119
|
+
def prefill(data)
|
120
|
+
if data.nil?
|
121
|
+
return self
|
122
|
+
end
|
123
|
+
self.iin = data.fetch(:iin, self.iin)
|
124
|
+
self.scheme = data.fetch(:scheme, self.scheme)
|
125
|
+
self.type = data.fetch(:type, self.type)
|
126
|
+
self.bank_name = data.fetch(:bank_name, self.bank_name)
|
127
|
+
self.brand = data.fetch(:brand, self.brand)
|
128
|
+
self.category = data.fetch(:category, self.category)
|
129
|
+
self.country = data.fetch(:country, self.country)
|
130
|
+
|
131
|
+
self
|
132
|
+
end
|
133
|
+
|
134
|
+
# Fetch card information from the IIN.
|
135
|
+
# Params:
|
136
|
+
# +iin+:: IIN of the card (first 6 digits)
|
137
|
+
# +options+:: +Hash+ of options
|
138
|
+
def fetch(iin, options = {})
|
139
|
+
self.prefill(options)
|
140
|
+
|
141
|
+
request = Request.new(@client)
|
142
|
+
path = "/iins/" + CGI.escape(iin) + ""
|
143
|
+
data = {
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
response = Response.new(request.get(path, data, options))
|
148
|
+
return_values = Array.new
|
149
|
+
|
150
|
+
body = response.body
|
151
|
+
body = body["card_information"]
|
152
|
+
|
153
|
+
|
154
|
+
obj = CardInformation.new(@client)
|
155
|
+
return_values.push(obj.fill_with_data(body))
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
return_values[0]
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
end
|
164
|
+
end
|