processout 2.19.0 → 2.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +4 -67
- data/.gitignore +0 -52
- data/.rspec +0 -2
- data/.travis.yml +0 -5
- data/Dockerfile +0 -7
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -21
- data/Makefile +0 -4
- data/README.md +0 -12
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/processout/activity.rb +0 -206
- data/lib/processout/addon.rb +0 -401
- data/lib/processout/alternative_merchant_certificate.rb +0 -94
- data/lib/processout/api_request.rb +0 -295
- data/lib/processout/api_version.rb +0 -92
- data/lib/processout/apple_pay_alternative_merchant_certificates.rb +0 -110
- data/lib/processout/balance.rb +0 -81
- data/lib/processout/balances.rb +0 -111
- data/lib/processout/card.rb +0 -503
- data/lib/processout/card_information.rb +0 -164
- data/lib/processout/coupon.rb +0 -352
- data/lib/processout/customer.rb +0 -755
- data/lib/processout/customer_action.rb +0 -81
- data/lib/processout/discount.rb +0 -360
- data/lib/processout/dunning_action.rb +0 -81
- data/lib/processout/errors/authentication_error.rb +0 -9
- data/lib/processout/errors/generic_error.rb +0 -9
- data/lib/processout/errors/internal_error.rb +0 -9
- data/lib/processout/errors/notfound_error.rb +0 -9
- data/lib/processout/errors/validation_error.rb +0 -9
- data/lib/processout/event.rb +0 -237
- data/lib/processout/gateway.rb +0 -210
- data/lib/processout/gateway_configuration.rb +0 -346
- data/lib/processout/gateway_request.rb +0 -26
- data/lib/processout/invoice.rb +0 -945
- data/lib/processout/invoice_detail.rb +0 -235
- data/lib/processout/invoice_device.rb +0 -92
- data/lib/processout/invoice_external_fraud_tools.rb +0 -70
- data/lib/processout/invoice_risk.rb +0 -81
- data/lib/processout/invoice_shipping.rb +0 -191
- data/lib/processout/invoice_tax.rb +0 -81
- data/lib/processout/networking/request.rb +0 -102
- data/lib/processout/networking/response.rb +0 -67
- data/lib/processout/payment_data_network_authentication.rb +0 -70
- data/lib/processout/payment_data_three_ds_authentication.rb +0 -70
- data/lib/processout/payment_data_three_ds_request.rb +0 -103
- data/lib/processout/payout.rb +0 -379
- data/lib/processout/payout_item.rb +0 -238
- data/lib/processout/plan.rb +0 -368
- data/lib/processout/product.rb +0 -368
- data/lib/processout/project.rb +0 -353
- data/lib/processout/refund.rb +0 -277
- data/lib/processout/subscription.rb +0 -910
- data/lib/processout/three_ds.rb +0 -158
- data/lib/processout/token.rb +0 -493
- data/lib/processout/transaction.rb +0 -905
- data/lib/processout/transaction_operation.rb +0 -418
- data/lib/processout/version.rb +0 -3
- data/lib/processout/webhook.rb +0 -237
- data/lib/processout/webhook_endpoint.rb +0 -149
- data/lib/processout.rb +0 -263
- data/processout.gemspec +0 -26
data/lib/processout/customer.rb
DELETED
@@ -1,755 +0,0 @@
|
|
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 Customer
|
10
|
-
|
11
|
-
attr_reader :id
|
12
|
-
attr_reader :project
|
13
|
-
attr_reader :project_id
|
14
|
-
attr_reader :default_token
|
15
|
-
attr_reader :default_token_id
|
16
|
-
attr_reader :tokens
|
17
|
-
attr_reader :subscriptions
|
18
|
-
attr_reader :transactions
|
19
|
-
attr_reader :balance
|
20
|
-
attr_reader :currency
|
21
|
-
attr_reader :email
|
22
|
-
attr_reader :first_name
|
23
|
-
attr_reader :last_name
|
24
|
-
attr_reader :address1
|
25
|
-
attr_reader :address2
|
26
|
-
attr_reader :city
|
27
|
-
attr_reader :state
|
28
|
-
attr_reader :zip
|
29
|
-
attr_reader :country_code
|
30
|
-
attr_reader :ip_address
|
31
|
-
attr_reader :phone_number
|
32
|
-
attr_reader :legal_document
|
33
|
-
attr_reader :sex
|
34
|
-
attr_reader :is_business
|
35
|
-
attr_reader :metadata
|
36
|
-
attr_reader :sandbox
|
37
|
-
attr_reader :created_at
|
38
|
-
attr_reader :registered_at
|
39
|
-
attr_reader :date_of_birth
|
40
|
-
|
41
|
-
|
42
|
-
def id=(val)
|
43
|
-
@id = val
|
44
|
-
end
|
45
|
-
|
46
|
-
def project=(val)
|
47
|
-
if val.nil?
|
48
|
-
@project = val
|
49
|
-
return
|
50
|
-
end
|
51
|
-
|
52
|
-
if val.instance_of? Project
|
53
|
-
@project = val
|
54
|
-
else
|
55
|
-
obj = Project.new(@client)
|
56
|
-
obj.fill_with_data(val)
|
57
|
-
@project = obj
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
def project_id=(val)
|
63
|
-
@project_id = val
|
64
|
-
end
|
65
|
-
|
66
|
-
def default_token=(val)
|
67
|
-
if val.nil?
|
68
|
-
@default_token = val
|
69
|
-
return
|
70
|
-
end
|
71
|
-
|
72
|
-
if val.instance_of? Token
|
73
|
-
@default_token = val
|
74
|
-
else
|
75
|
-
obj = Token.new(@client)
|
76
|
-
obj.fill_with_data(val)
|
77
|
-
@default_token = obj
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
def default_token_id=(val)
|
83
|
-
@default_token_id = val
|
84
|
-
end
|
85
|
-
|
86
|
-
def tokens=(val)
|
87
|
-
if val.nil?
|
88
|
-
@tokens = []
|
89
|
-
return
|
90
|
-
end
|
91
|
-
|
92
|
-
if val.length > 0 and val[0].instance_of? Token
|
93
|
-
@tokens = val
|
94
|
-
else
|
95
|
-
l = Array.new
|
96
|
-
for v in val
|
97
|
-
obj = Token.new(@client)
|
98
|
-
obj.fill_with_data(v)
|
99
|
-
l.push(obj)
|
100
|
-
end
|
101
|
-
@tokens = l
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
def subscriptions=(val)
|
107
|
-
if val.nil?
|
108
|
-
@subscriptions = []
|
109
|
-
return
|
110
|
-
end
|
111
|
-
|
112
|
-
if val.length > 0 and val[0].instance_of? Subscription
|
113
|
-
@subscriptions = val
|
114
|
-
else
|
115
|
-
l = Array.new
|
116
|
-
for v in val
|
117
|
-
obj = Subscription.new(@client)
|
118
|
-
obj.fill_with_data(v)
|
119
|
-
l.push(obj)
|
120
|
-
end
|
121
|
-
@subscriptions = l
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
125
|
-
|
126
|
-
def transactions=(val)
|
127
|
-
if val.nil?
|
128
|
-
@transactions = []
|
129
|
-
return
|
130
|
-
end
|
131
|
-
|
132
|
-
if val.length > 0 and val[0].instance_of? Transaction
|
133
|
-
@transactions = val
|
134
|
-
else
|
135
|
-
l = Array.new
|
136
|
-
for v in val
|
137
|
-
obj = Transaction.new(@client)
|
138
|
-
obj.fill_with_data(v)
|
139
|
-
l.push(obj)
|
140
|
-
end
|
141
|
-
@transactions = l
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
145
|
-
|
146
|
-
def balance=(val)
|
147
|
-
@balance = val
|
148
|
-
end
|
149
|
-
|
150
|
-
def currency=(val)
|
151
|
-
@currency = val
|
152
|
-
end
|
153
|
-
|
154
|
-
def email=(val)
|
155
|
-
@email = val
|
156
|
-
end
|
157
|
-
|
158
|
-
def first_name=(val)
|
159
|
-
@first_name = val
|
160
|
-
end
|
161
|
-
|
162
|
-
def last_name=(val)
|
163
|
-
@last_name = val
|
164
|
-
end
|
165
|
-
|
166
|
-
def address1=(val)
|
167
|
-
@address1 = val
|
168
|
-
end
|
169
|
-
|
170
|
-
def address2=(val)
|
171
|
-
@address2 = val
|
172
|
-
end
|
173
|
-
|
174
|
-
def city=(val)
|
175
|
-
@city = val
|
176
|
-
end
|
177
|
-
|
178
|
-
def state=(val)
|
179
|
-
@state = val
|
180
|
-
end
|
181
|
-
|
182
|
-
def zip=(val)
|
183
|
-
@zip = val
|
184
|
-
end
|
185
|
-
|
186
|
-
def country_code=(val)
|
187
|
-
@country_code = val
|
188
|
-
end
|
189
|
-
|
190
|
-
def ip_address=(val)
|
191
|
-
@ip_address = val
|
192
|
-
end
|
193
|
-
|
194
|
-
def phone_number=(val)
|
195
|
-
@phone_number = val
|
196
|
-
end
|
197
|
-
|
198
|
-
def legal_document=(val)
|
199
|
-
@legal_document = val
|
200
|
-
end
|
201
|
-
|
202
|
-
def sex=(val)
|
203
|
-
@sex = val
|
204
|
-
end
|
205
|
-
|
206
|
-
def is_business=(val)
|
207
|
-
@is_business = val
|
208
|
-
end
|
209
|
-
|
210
|
-
def metadata=(val)
|
211
|
-
@metadata = val
|
212
|
-
end
|
213
|
-
|
214
|
-
def sandbox=(val)
|
215
|
-
@sandbox = val
|
216
|
-
end
|
217
|
-
|
218
|
-
def created_at=(val)
|
219
|
-
@created_at = val
|
220
|
-
end
|
221
|
-
|
222
|
-
def registered_at=(val)
|
223
|
-
@registered_at = val
|
224
|
-
end
|
225
|
-
|
226
|
-
def date_of_birth=(val)
|
227
|
-
@date_of_birth = val
|
228
|
-
end
|
229
|
-
|
230
|
-
|
231
|
-
# Initializes the Customer object
|
232
|
-
# Params:
|
233
|
-
# +client+:: +ProcessOut+ client instance
|
234
|
-
# +data+:: data that can be used to fill the object
|
235
|
-
def initialize(client, data = {})
|
236
|
-
@client = client
|
237
|
-
|
238
|
-
self.id = data.fetch(:id, nil)
|
239
|
-
self.project = data.fetch(:project, nil)
|
240
|
-
self.project_id = data.fetch(:project_id, nil)
|
241
|
-
self.default_token = data.fetch(:default_token, nil)
|
242
|
-
self.default_token_id = data.fetch(:default_token_id, nil)
|
243
|
-
self.tokens = data.fetch(:tokens, nil)
|
244
|
-
self.subscriptions = data.fetch(:subscriptions, nil)
|
245
|
-
self.transactions = data.fetch(:transactions, nil)
|
246
|
-
self.balance = data.fetch(:balance, nil)
|
247
|
-
self.currency = data.fetch(:currency, nil)
|
248
|
-
self.email = data.fetch(:email, nil)
|
249
|
-
self.first_name = data.fetch(:first_name, nil)
|
250
|
-
self.last_name = data.fetch(:last_name, nil)
|
251
|
-
self.address1 = data.fetch(:address1, nil)
|
252
|
-
self.address2 = data.fetch(:address2, nil)
|
253
|
-
self.city = data.fetch(:city, nil)
|
254
|
-
self.state = data.fetch(:state, nil)
|
255
|
-
self.zip = data.fetch(:zip, nil)
|
256
|
-
self.country_code = data.fetch(:country_code, nil)
|
257
|
-
self.ip_address = data.fetch(:ip_address, nil)
|
258
|
-
self.phone_number = data.fetch(:phone_number, nil)
|
259
|
-
self.legal_document = data.fetch(:legal_document, nil)
|
260
|
-
self.sex = data.fetch(:sex, nil)
|
261
|
-
self.is_business = data.fetch(:is_business, nil)
|
262
|
-
self.metadata = data.fetch(:metadata, nil)
|
263
|
-
self.sandbox = data.fetch(:sandbox, nil)
|
264
|
-
self.created_at = data.fetch(:created_at, nil)
|
265
|
-
self.registered_at = data.fetch(:registered_at, nil)
|
266
|
-
self.date_of_birth = data.fetch(:date_of_birth, nil)
|
267
|
-
|
268
|
-
end
|
269
|
-
|
270
|
-
# Create a new Customer using the current client
|
271
|
-
def new(data = {})
|
272
|
-
Customer.new(@client, data)
|
273
|
-
end
|
274
|
-
|
275
|
-
# Overrides the JSON marshaller to only send the fields we want
|
276
|
-
def to_json(options)
|
277
|
-
{
|
278
|
-
"id": self.id,
|
279
|
-
"project": self.project,
|
280
|
-
"project_id": self.project_id,
|
281
|
-
"default_token": self.default_token,
|
282
|
-
"default_token_id": self.default_token_id,
|
283
|
-
"tokens": self.tokens,
|
284
|
-
"subscriptions": self.subscriptions,
|
285
|
-
"transactions": self.transactions,
|
286
|
-
"balance": self.balance,
|
287
|
-
"currency": self.currency,
|
288
|
-
"email": self.email,
|
289
|
-
"first_name": self.first_name,
|
290
|
-
"last_name": self.last_name,
|
291
|
-
"address1": self.address1,
|
292
|
-
"address2": self.address2,
|
293
|
-
"city": self.city,
|
294
|
-
"state": self.state,
|
295
|
-
"zip": self.zip,
|
296
|
-
"country_code": self.country_code,
|
297
|
-
"ip_address": self.ip_address,
|
298
|
-
"phone_number": self.phone_number,
|
299
|
-
"legal_document": self.legal_document,
|
300
|
-
"sex": self.sex,
|
301
|
-
"is_business": self.is_business,
|
302
|
-
"metadata": self.metadata,
|
303
|
-
"sandbox": self.sandbox,
|
304
|
-
"created_at": self.created_at,
|
305
|
-
"registered_at": self.registered_at,
|
306
|
-
"date_of_birth": self.date_of_birth,
|
307
|
-
}.to_json
|
308
|
-
end
|
309
|
-
|
310
|
-
# Fills the object with data coming from the API
|
311
|
-
# Params:
|
312
|
-
# +data+:: +Hash+ of data coming from the API
|
313
|
-
def fill_with_data(data)
|
314
|
-
if data.nil?
|
315
|
-
return self
|
316
|
-
end
|
317
|
-
if data.include? "id"
|
318
|
-
self.id = data["id"]
|
319
|
-
end
|
320
|
-
if data.include? "project"
|
321
|
-
self.project = data["project"]
|
322
|
-
end
|
323
|
-
if data.include? "project_id"
|
324
|
-
self.project_id = data["project_id"]
|
325
|
-
end
|
326
|
-
if data.include? "default_token"
|
327
|
-
self.default_token = data["default_token"]
|
328
|
-
end
|
329
|
-
if data.include? "default_token_id"
|
330
|
-
self.default_token_id = data["default_token_id"]
|
331
|
-
end
|
332
|
-
if data.include? "tokens"
|
333
|
-
self.tokens = data["tokens"]
|
334
|
-
end
|
335
|
-
if data.include? "subscriptions"
|
336
|
-
self.subscriptions = data["subscriptions"]
|
337
|
-
end
|
338
|
-
if data.include? "transactions"
|
339
|
-
self.transactions = data["transactions"]
|
340
|
-
end
|
341
|
-
if data.include? "balance"
|
342
|
-
self.balance = data["balance"]
|
343
|
-
end
|
344
|
-
if data.include? "currency"
|
345
|
-
self.currency = data["currency"]
|
346
|
-
end
|
347
|
-
if data.include? "email"
|
348
|
-
self.email = data["email"]
|
349
|
-
end
|
350
|
-
if data.include? "first_name"
|
351
|
-
self.first_name = data["first_name"]
|
352
|
-
end
|
353
|
-
if data.include? "last_name"
|
354
|
-
self.last_name = data["last_name"]
|
355
|
-
end
|
356
|
-
if data.include? "address1"
|
357
|
-
self.address1 = data["address1"]
|
358
|
-
end
|
359
|
-
if data.include? "address2"
|
360
|
-
self.address2 = data["address2"]
|
361
|
-
end
|
362
|
-
if data.include? "city"
|
363
|
-
self.city = data["city"]
|
364
|
-
end
|
365
|
-
if data.include? "state"
|
366
|
-
self.state = data["state"]
|
367
|
-
end
|
368
|
-
if data.include? "zip"
|
369
|
-
self.zip = data["zip"]
|
370
|
-
end
|
371
|
-
if data.include? "country_code"
|
372
|
-
self.country_code = data["country_code"]
|
373
|
-
end
|
374
|
-
if data.include? "ip_address"
|
375
|
-
self.ip_address = data["ip_address"]
|
376
|
-
end
|
377
|
-
if data.include? "phone_number"
|
378
|
-
self.phone_number = data["phone_number"]
|
379
|
-
end
|
380
|
-
if data.include? "legal_document"
|
381
|
-
self.legal_document = data["legal_document"]
|
382
|
-
end
|
383
|
-
if data.include? "sex"
|
384
|
-
self.sex = data["sex"]
|
385
|
-
end
|
386
|
-
if data.include? "is_business"
|
387
|
-
self.is_business = data["is_business"]
|
388
|
-
end
|
389
|
-
if data.include? "metadata"
|
390
|
-
self.metadata = data["metadata"]
|
391
|
-
end
|
392
|
-
if data.include? "sandbox"
|
393
|
-
self.sandbox = data["sandbox"]
|
394
|
-
end
|
395
|
-
if data.include? "created_at"
|
396
|
-
self.created_at = data["created_at"]
|
397
|
-
end
|
398
|
-
if data.include? "registered_at"
|
399
|
-
self.registered_at = data["registered_at"]
|
400
|
-
end
|
401
|
-
if data.include? "date_of_birth"
|
402
|
-
self.date_of_birth = data["date_of_birth"]
|
403
|
-
end
|
404
|
-
|
405
|
-
self
|
406
|
-
end
|
407
|
-
|
408
|
-
# Prefills the object with the data passed as parameters
|
409
|
-
# Params:
|
410
|
-
# +data+:: +Hash+ of data
|
411
|
-
def prefill(data)
|
412
|
-
if data.nil?
|
413
|
-
return self
|
414
|
-
end
|
415
|
-
self.id = data.fetch(:id, self.id)
|
416
|
-
self.project = data.fetch(:project, self.project)
|
417
|
-
self.project_id = data.fetch(:project_id, self.project_id)
|
418
|
-
self.default_token = data.fetch(:default_token, self.default_token)
|
419
|
-
self.default_token_id = data.fetch(:default_token_id, self.default_token_id)
|
420
|
-
self.tokens = data.fetch(:tokens, self.tokens)
|
421
|
-
self.subscriptions = data.fetch(:subscriptions, self.subscriptions)
|
422
|
-
self.transactions = data.fetch(:transactions, self.transactions)
|
423
|
-
self.balance = data.fetch(:balance, self.balance)
|
424
|
-
self.currency = data.fetch(:currency, self.currency)
|
425
|
-
self.email = data.fetch(:email, self.email)
|
426
|
-
self.first_name = data.fetch(:first_name, self.first_name)
|
427
|
-
self.last_name = data.fetch(:last_name, self.last_name)
|
428
|
-
self.address1 = data.fetch(:address1, self.address1)
|
429
|
-
self.address2 = data.fetch(:address2, self.address2)
|
430
|
-
self.city = data.fetch(:city, self.city)
|
431
|
-
self.state = data.fetch(:state, self.state)
|
432
|
-
self.zip = data.fetch(:zip, self.zip)
|
433
|
-
self.country_code = data.fetch(:country_code, self.country_code)
|
434
|
-
self.ip_address = data.fetch(:ip_address, self.ip_address)
|
435
|
-
self.phone_number = data.fetch(:phone_number, self.phone_number)
|
436
|
-
self.legal_document = data.fetch(:legal_document, self.legal_document)
|
437
|
-
self.sex = data.fetch(:sex, self.sex)
|
438
|
-
self.is_business = data.fetch(:is_business, self.is_business)
|
439
|
-
self.metadata = data.fetch(:metadata, self.metadata)
|
440
|
-
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
441
|
-
self.created_at = data.fetch(:created_at, self.created_at)
|
442
|
-
self.registered_at = data.fetch(:registered_at, self.registered_at)
|
443
|
-
self.date_of_birth = data.fetch(:date_of_birth, self.date_of_birth)
|
444
|
-
|
445
|
-
self
|
446
|
-
end
|
447
|
-
|
448
|
-
# Get the subscriptions belonging to the customer.
|
449
|
-
# Params:
|
450
|
-
# +options+:: +Hash+ of options
|
451
|
-
def fetch_subscriptions(options = {})
|
452
|
-
self.prefill(options)
|
453
|
-
|
454
|
-
request = Request.new(@client)
|
455
|
-
path = "/customers/" + CGI.escape(@id) + "/subscriptions"
|
456
|
-
data = {
|
457
|
-
|
458
|
-
}
|
459
|
-
|
460
|
-
response = Response.new(request.get(path, data, options))
|
461
|
-
return_values = Array.new
|
462
|
-
|
463
|
-
a = Array.new
|
464
|
-
body = response.body
|
465
|
-
for v in body['subscriptions']
|
466
|
-
tmp = Subscription.new(@client)
|
467
|
-
tmp.fill_with_data(v)
|
468
|
-
a.push(tmp)
|
469
|
-
end
|
470
|
-
|
471
|
-
return_values.push(a)
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
return_values[0]
|
476
|
-
end
|
477
|
-
|
478
|
-
# Get the customer's tokens.
|
479
|
-
# Params:
|
480
|
-
# +options+:: +Hash+ of options
|
481
|
-
def fetch_tokens(options = {})
|
482
|
-
self.prefill(options)
|
483
|
-
|
484
|
-
request = Request.new(@client)
|
485
|
-
path = "/customers/" + CGI.escape(@id) + "/tokens"
|
486
|
-
data = {
|
487
|
-
|
488
|
-
}
|
489
|
-
|
490
|
-
response = Response.new(request.get(path, data, options))
|
491
|
-
return_values = Array.new
|
492
|
-
|
493
|
-
a = Array.new
|
494
|
-
body = response.body
|
495
|
-
for v in body['tokens']
|
496
|
-
tmp = Token.new(@client)
|
497
|
-
tmp.fill_with_data(v)
|
498
|
-
a.push(tmp)
|
499
|
-
end
|
500
|
-
|
501
|
-
return_values.push(a)
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
return_values[0]
|
506
|
-
end
|
507
|
-
|
508
|
-
# Find a customer's token by its ID.
|
509
|
-
# Params:
|
510
|
-
# +token_id+:: ID of the token
|
511
|
-
# +options+:: +Hash+ of options
|
512
|
-
def find_token(token_id, options = {})
|
513
|
-
self.prefill(options)
|
514
|
-
|
515
|
-
request = Request.new(@client)
|
516
|
-
path = "/customers/" + CGI.escape(@id) + "/tokens/" + CGI.escape(token_id) + ""
|
517
|
-
data = {
|
518
|
-
|
519
|
-
}
|
520
|
-
|
521
|
-
response = Response.new(request.get(path, data, options))
|
522
|
-
return_values = Array.new
|
523
|
-
|
524
|
-
body = response.body
|
525
|
-
body = body["token"]
|
526
|
-
token = Token.new(@client)
|
527
|
-
return_values.push(token.fill_with_data(body))
|
528
|
-
|
529
|
-
|
530
|
-
return_values[0]
|
531
|
-
end
|
532
|
-
|
533
|
-
# Delete a customer's token by its ID.
|
534
|
-
# Params:
|
535
|
-
# +token_id+:: ID of the token
|
536
|
-
# +options+:: +Hash+ of options
|
537
|
-
def delete_token(token_id, options = {})
|
538
|
-
self.prefill(options)
|
539
|
-
|
540
|
-
request = Request.new(@client)
|
541
|
-
path = "/customers/" + CGI.escape(@id) + "/tokens/" + CGI.escape(token_id) + ""
|
542
|
-
data = {
|
543
|
-
|
544
|
-
}
|
545
|
-
|
546
|
-
response = Response.new(request.delete(path, data, options))
|
547
|
-
return_values = Array.new
|
548
|
-
|
549
|
-
return_values.push(response.success)
|
550
|
-
|
551
|
-
|
552
|
-
return_values[0]
|
553
|
-
end
|
554
|
-
|
555
|
-
# Get the transactions belonging to the customer.
|
556
|
-
# Params:
|
557
|
-
# +options+:: +Hash+ of options
|
558
|
-
def fetch_transactions(options = {})
|
559
|
-
self.prefill(options)
|
560
|
-
|
561
|
-
request = Request.new(@client)
|
562
|
-
path = "/customers/" + CGI.escape(@id) + "/transactions"
|
563
|
-
data = {
|
564
|
-
|
565
|
-
}
|
566
|
-
|
567
|
-
response = Response.new(request.get(path, data, options))
|
568
|
-
return_values = Array.new
|
569
|
-
|
570
|
-
a = Array.new
|
571
|
-
body = response.body
|
572
|
-
for v in body['transactions']
|
573
|
-
tmp = Transaction.new(@client)
|
574
|
-
tmp.fill_with_data(v)
|
575
|
-
a.push(tmp)
|
576
|
-
end
|
577
|
-
|
578
|
-
return_values.push(a)
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
return_values[0]
|
583
|
-
end
|
584
|
-
|
585
|
-
# Get all the customers.
|
586
|
-
# Params:
|
587
|
-
# +options+:: +Hash+ of options
|
588
|
-
def all(options = {})
|
589
|
-
self.prefill(options)
|
590
|
-
|
591
|
-
request = Request.new(@client)
|
592
|
-
path = "/customers"
|
593
|
-
data = {
|
594
|
-
|
595
|
-
}
|
596
|
-
|
597
|
-
response = Response.new(request.get(path, data, options))
|
598
|
-
return_values = Array.new
|
599
|
-
|
600
|
-
a = Array.new
|
601
|
-
body = response.body
|
602
|
-
for v in body['customers']
|
603
|
-
tmp = Customer.new(@client)
|
604
|
-
tmp.fill_with_data(v)
|
605
|
-
a.push(tmp)
|
606
|
-
end
|
607
|
-
|
608
|
-
return_values.push(a)
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
return_values[0]
|
613
|
-
end
|
614
|
-
|
615
|
-
# Create a new customer.
|
616
|
-
# Params:
|
617
|
-
# +options+:: +Hash+ of options
|
618
|
-
def create(options = {})
|
619
|
-
self.prefill(options)
|
620
|
-
|
621
|
-
request = Request.new(@client)
|
622
|
-
path = "/customers"
|
623
|
-
data = {
|
624
|
-
"balance" => @balance,
|
625
|
-
"currency" => @currency,
|
626
|
-
"email" => @email,
|
627
|
-
"first_name" => @first_name,
|
628
|
-
"last_name" => @last_name,
|
629
|
-
"address1" => @address1,
|
630
|
-
"address2" => @address2,
|
631
|
-
"city" => @city,
|
632
|
-
"state" => @state,
|
633
|
-
"zip" => @zip,
|
634
|
-
"country_code" => @country_code,
|
635
|
-
"ip_address" => @ip_address,
|
636
|
-
"phone_number" => @phone_number,
|
637
|
-
"legal_document" => @legal_document,
|
638
|
-
"date_of_birth" => @date_of_birth,
|
639
|
-
"is_business" => @is_business,
|
640
|
-
"sex" => @sex,
|
641
|
-
"metadata" => @metadata,
|
642
|
-
"id" => @id,
|
643
|
-
"registered_at" => @registered_at
|
644
|
-
}
|
645
|
-
|
646
|
-
response = Response.new(request.post(path, data, options))
|
647
|
-
return_values = Array.new
|
648
|
-
|
649
|
-
body = response.body
|
650
|
-
body = body["customer"]
|
651
|
-
|
652
|
-
|
653
|
-
return_values.push(self.fill_with_data(body))
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
return_values[0]
|
658
|
-
end
|
659
|
-
|
660
|
-
# Find a customer by its ID.
|
661
|
-
# Params:
|
662
|
-
# +customer_id+:: ID of the customer
|
663
|
-
# +options+:: +Hash+ of options
|
664
|
-
def find(customer_id, options = {})
|
665
|
-
self.prefill(options)
|
666
|
-
|
667
|
-
request = Request.new(@client)
|
668
|
-
path = "/customers/" + CGI.escape(customer_id) + ""
|
669
|
-
data = {
|
670
|
-
|
671
|
-
}
|
672
|
-
|
673
|
-
response = Response.new(request.get(path, data, options))
|
674
|
-
return_values = Array.new
|
675
|
-
|
676
|
-
body = response.body
|
677
|
-
body = body["customer"]
|
678
|
-
|
679
|
-
|
680
|
-
obj = Customer.new(@client)
|
681
|
-
return_values.push(obj.fill_with_data(body))
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
return_values[0]
|
686
|
-
end
|
687
|
-
|
688
|
-
# Save the updated customer attributes.
|
689
|
-
# Params:
|
690
|
-
# +options+:: +Hash+ of options
|
691
|
-
def save(options = {})
|
692
|
-
self.prefill(options)
|
693
|
-
|
694
|
-
request = Request.new(@client)
|
695
|
-
path = "/customers/" + CGI.escape(@id) + ""
|
696
|
-
data = {
|
697
|
-
"balance" => @balance,
|
698
|
-
"default_token_id" => @default_token_id,
|
699
|
-
"email" => @email,
|
700
|
-
"first_name" => @first_name,
|
701
|
-
"last_name" => @last_name,
|
702
|
-
"address1" => @address1,
|
703
|
-
"address2" => @address2,
|
704
|
-
"city" => @city,
|
705
|
-
"state" => @state,
|
706
|
-
"zip" => @zip,
|
707
|
-
"country_code" => @country_code,
|
708
|
-
"ip_address" => @ip_address,
|
709
|
-
"phone_number" => @phone_number,
|
710
|
-
"legal_document" => @legal_document,
|
711
|
-
"date_of_birth" => @date_of_birth,
|
712
|
-
"is_business" => @is_business,
|
713
|
-
"sex" => @sex,
|
714
|
-
"metadata" => @metadata,
|
715
|
-
"registered_at" => @registered_at
|
716
|
-
}
|
717
|
-
|
718
|
-
response = Response.new(request.put(path, data, options))
|
719
|
-
return_values = Array.new
|
720
|
-
|
721
|
-
body = response.body
|
722
|
-
body = body["customer"]
|
723
|
-
|
724
|
-
|
725
|
-
return_values.push(self.fill_with_data(body))
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
return_values[0]
|
730
|
-
end
|
731
|
-
|
732
|
-
# Delete the customer.
|
733
|
-
# Params:
|
734
|
-
# +options+:: +Hash+ of options
|
735
|
-
def delete(options = {})
|
736
|
-
self.prefill(options)
|
737
|
-
|
738
|
-
request = Request.new(@client)
|
739
|
-
path = "/customers/" + CGI.escape(@id) + ""
|
740
|
-
data = {
|
741
|
-
|
742
|
-
}
|
743
|
-
|
744
|
-
response = Response.new(request.delete(path, data, options))
|
745
|
-
return_values = Array.new
|
746
|
-
|
747
|
-
return_values.push(response.success)
|
748
|
-
|
749
|
-
|
750
|
-
return_values[0]
|
751
|
-
end
|
752
|
-
|
753
|
-
|
754
|
-
end
|
755
|
-
end
|