paypal-sdk-rest 0.7.3 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e759a6fc42d56bd24b8e8467472c8fd4e323121d
4
- data.tar.gz: 68343766a40d693a959a0b6291efa662077d6426
3
+ metadata.gz: 50c4b6c303398d0616d50cca9ea5425372504ad6
4
+ data.tar.gz: 64101a28702aeb06650d5b4043e432b270df0706
5
5
  SHA512:
6
- metadata.gz: 08a94b1a3afa4574868b984f474102233cae7760703eb1faafc8170a8dc598e2123aa6437474a7e49dd6a1b856c67baea7b06a41305e1a6737bd8932986d96a1
7
- data.tar.gz: e139b81398da7712b2dd4e29047344c45a2953a223059435131ced027cec72d052c4eaf37091ba4bd24441950a63f87185a4f039c1cee83daf19959b3326c84a
6
+ metadata.gz: b6ed80f9ad8cd1456ea216c3a4c88843a66bbcccd394c81dc77f9a4aba62bdaff2b53cfcb6bd788fe638c6644f6eba7dd6a046a7566e1d476d2958505145bd1d
7
+ data.tar.gz: 5547cde29565746be4709da67471ab14e7e683bf5b10d3716aadfee44c9ffce9139e3acbcb2e0ca16176b9fcd4e9be9990f4dc2131b4a9dad0e98b49faf92c4a
@@ -12,7 +12,7 @@ module PayPal
12
12
 
13
13
  class << self
14
14
  def user_agent
15
- @user_agent ||= "PayPalSDK/rest-sdk-ruby #{VERSION} (#{sdk_library_details})"
15
+ @user_agent ||= "PayPalSDK/PayPal-Ruby-SDK #{VERSION} (#{sdk_library_details})"
16
16
  end
17
17
  end
18
18
 
@@ -1,1138 +1,1659 @@
1
- require 'paypal-sdk-core'
2
- require 'uuidtools'
3
-
4
- module PayPal::SDK
5
- module REST
6
- module DataTypes
7
- class Base < Core::API::DataTypes::Base
8
- attr_accessor :error
9
- attr_writer :header, :request_id
10
-
11
- def header
12
- @header ||= {}
13
- end
14
-
15
- def request_id
16
- @request_id ||= UUIDTools::UUID.random_create.to_s
17
- end
18
-
19
- def http_header
20
- { "PayPal-Request-Id" => request_id.to_s }.merge(header)
21
- end
22
-
23
- def success?
24
- @error.nil?
25
- end
26
-
27
- def merge!(values)
28
- @error = nil
29
- super
30
- end
31
-
32
- def self.load_members
33
- end
34
-
35
- class Number < Float
36
- end
37
- end
38
-
39
- class PaymentHistory < Base
40
-
41
- def self.load_members
42
- array_of :payments, Payment
43
- object_of :count, Integer
44
- object_of :next_id, String
45
- end
46
-
47
- end
48
- class Payment < Base
49
-
50
- def self.load_members
51
- object_of :id, String
52
- object_of :create_time, DateTime
53
- object_of :update_time, DateTime
54
- object_of :intent, String
55
- object_of :payer, Payer
56
- array_of :transactions, Transaction
57
- object_of :state, String
58
- object_of :redirect_urls, RedirectUrls
59
- array_of :links, Links
60
- end
61
-
62
- include RequestDataType
63
-
64
- def create()
65
- path = "v1/payments/payment"
66
- response = api.post(path, self.to_hash, http_header)
67
- self.merge!(response)
68
- success?
69
- end
70
-
71
- class << self
72
- def find(resource_id)
73
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
74
- path = "v1/payments/payment/#{resource_id}"
75
- self.new(api.get(path))
76
- end
77
- end
78
-
79
- def execute(payment_execution)
80
- payment_execution = PaymentExecution.new(payment_execution) unless payment_execution.is_a? PaymentExecution
81
- path = "v1/payments/payment/#{self.id}/execute"
82
- response = api.post(path, payment_execution.to_hash, http_header)
83
- self.merge!(response)
84
- success?
85
- end
86
-
87
- class << self
88
- def all(options = {})
89
- path = "v1/payments/payment"
90
- PaymentHistory.new(api.get(path, options))
91
- end
92
- end
93
-
94
- end
95
- class Payer < Base
96
-
97
- def self.load_members
98
- object_of :payment_method, String
99
- object_of :status, String
100
- array_of :funding_instruments, FundingInstrument
101
- object_of :payer_info, PayerInfo
102
- end
103
-
104
- end
105
- class FundingInstrument < Base
106
-
107
- def self.load_members
108
- object_of :credit_card, CreditCard
109
- object_of :credit_card_token, CreditCardToken
110
- end
111
-
112
- end
113
- class CreditCard < Base
114
-
115
- def self.load_members
116
- object_of :id, String
117
- object_of :number, String
118
- object_of :type, String
119
- object_of :expire_month, Integer
120
- object_of :expire_year, Integer
121
- object_of :cvv2, String
122
- object_of :first_name, String
123
- object_of :last_name, String
124
- object_of :billing_address, Address
125
- object_of :payer_id, String
126
- object_of :state, String
127
- object_of :valid_until, String
128
- object_of :create_time, String
129
- object_of :update_time, String
130
- array_of :links, Links
131
- end
132
-
133
- include RequestDataType
134
-
135
- def create()
136
- path = "v1/vault/credit-card"
137
- response = api.post(path, self.to_hash, http_header)
138
- self.merge!(response)
139
- success?
140
- end
141
-
142
- class << self
143
- def find(resource_id)
144
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
145
- path = "v1/vault/credit-card/#{resource_id}"
146
- self.new(api.get(path))
147
- end
148
- end
149
-
150
- def delete()
151
- path = "v1/vault/credit-card/#{self.id}"
152
- response = api.delete(path, {})
153
- self.merge!(response)
154
- success?
155
- end
156
-
157
- def update()
158
- path = "v1/vault/credit-card/#{self.id}"
159
- response = api.patch(path, self.to_hash, http_header)
160
- self.merge!(response)
161
- success?
162
- end
163
-
164
- class << self
165
- def all(options = {})
166
- path = "v1/vault/credit-card"
167
- CreditCardHistory.new(api.get(path, options))
168
- end
169
- end
170
-
171
- end
172
- class Address < Base
173
-
174
- def self.load_members
175
- object_of :recipient_name, String
176
- object_of :line1, String
177
- object_of :line2, String
178
- object_of :city, String
179
- object_of :country_code, String
180
- object_of :postal_code, String
181
- object_of :state, String
182
- object_of :phone, String
183
- end
184
-
185
- end
186
- class Links < Base
187
-
188
- def self.load_members
189
- object_of :href, String
190
- object_of :rel, String
191
- object_of :targetSchema, HyperSchema
192
- object_of :method, String
193
- object_of :enctype, String
194
- object_of :schema, HyperSchema
195
- end
196
-
197
- end
198
- class HyperSchema < Base
199
-
200
- def self.load_members
201
- array_of :links, Links
202
- object_of :fragmentResolution, String
203
- object_of :readonly, Boolean
204
- object_of :contentEncoding, String
205
- object_of :pathStart, String
206
- object_of :mediaType, String
207
- end
208
-
209
- end
210
- class CreditCardToken < Base
211
-
212
- def self.load_members
213
- object_of :credit_card_id, String
214
- object_of :payer_id, String
215
- object_of :last4, String
216
- object_of :type, String
217
- object_of :expire_month, Integer
218
- object_of :expire_year, Integer
219
- end
220
-
221
- end
222
- class PayerInfo < Base
223
-
224
- def self.load_members
225
- object_of :email, String
226
- object_of :first_name, String
227
- object_of :last_name, String
228
- object_of :payer_id, String
229
- object_of :phone, String
230
- object_of :shipping_address, Address
231
- end
232
-
233
- end
234
- class Transaction < Base
235
-
236
- def self.load_members
237
- object_of :amount, Amount
238
- object_of :payee, Payee
239
- object_of :description, String
240
- object_of :invoice_number, String
241
- object_of :custom, String
242
- object_of :soft_descriptor, String
243
- object_of :item_list, ItemList
244
- array_of :related_resources, RelatedResources
245
- array_of :transactions, Transaction
246
- end
247
-
248
- end
249
- class Amount < Base
250
-
251
- def self.load_members
252
- object_of :currency, String
253
- object_of :total, String
254
- object_of :details, Details
255
- end
256
-
257
- end
258
- class Details < Base
259
-
260
- def self.load_members
261
- object_of :shipping, String
262
- object_of :subtotal, String
263
- object_of :tax, String
264
- object_of :fee, String
265
- end
266
-
267
- end
268
- class Payee < Base
269
-
270
- def self.load_members
271
- object_of :email, String
272
- object_of :merchant_id, String
273
- object_of :phone, String
274
- end
275
-
276
- end
277
- class Item < Base
278
-
279
- def self.load_members
280
- object_of :quantity, String
281
- object_of :name, String
282
- object_of :price, String
283
- object_of :currency, String
284
- object_of :sku, String
285
- end
286
-
287
- end
288
- class ShippingAddress < Address
289
-
290
- def self.load_members
291
- object_of :recipient_name, String
292
- end
293
-
294
- end
295
- class ItemList < Base
296
-
297
- def self.load_members
298
- array_of :items, Item
299
- object_of :shipping_address, ShippingAddress
300
- end
301
-
302
- end
303
- class RelatedResources < Base
304
-
305
- def self.load_members
306
- object_of :order, Order
307
- object_of :sale, Sale
308
- object_of :authorization, Authorization
309
- object_of :capture, Capture
310
- object_of :refund, Refund
311
- end
312
-
313
- end
314
- class Order < Base
315
-
316
- def self.load_members
317
- object_of :id, String
318
- object_of :create_time, DateTime
319
- object_of :update_time, DateTime
320
- object_of :state, String
321
- object_of :amount, Amount
322
- object_of :parent_payment, String
323
- object_of :reason_code, String
324
- array_of :links, Links
325
- end
326
-
327
- end
328
- class Sale < Base
329
-
330
- def self.load_members
331
- object_of :id, String
332
- object_of :create_time, DateTime
333
- object_of :update_time, DateTime
334
- object_of :amount, Amount
335
- object_of :state, String
336
- object_of :parent_payment, String
337
- object_of :payment_mode, String
338
- object_of :protection_eligibility, String
339
- object_of :protection_eligibility_type, String
340
- array_of :links, Links
341
- end
342
-
343
- include RequestDataType
344
-
345
- class << self
346
- def find(resource_id)
347
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
348
- path = "v1/payments/sale/#{resource_id}"
349
- self.new(api.get(path))
350
- end
351
- end
352
-
353
- def refund(refund)
354
- refund = Refund.new(refund) unless refund.is_a? Refund
355
- path = "v1/payments/sale/#{self.id}/refund"
356
- response = api.post(path, refund.to_hash, http_header)
357
- Refund.new(response)
358
- end
359
-
360
- end
361
- class Authorization < Base
362
-
363
- def self.load_members
364
- object_of :id, String
365
- object_of :create_time, DateTime
366
- object_of :update_time, DateTime
367
- object_of :amount, Amount
368
- object_of :state, String
369
- object_of :parent_payment, String
370
- object_of :valid_until, String
371
- object_of :protection_eligibility, String
372
- object_of :payment_mode, String
373
- array_of :links, Links
374
- end
375
-
376
- include RequestDataType
377
-
378
- class << self
379
- def find(resource_id)
380
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
381
- path = "v1/payments/authorization/#{resource_id}"
382
- self.new(api.get(path))
383
- end
384
- end
385
-
386
- def capture(capture)
387
- capture = Capture.new(capture) unless capture.is_a? Capture
388
- path = "v1/payments/authorization/#{self.id}/capture"
389
- response = api.post(path, capture.to_hash, http_header)
390
- Capture.new(response)
391
- end
392
-
393
- def void()
394
- path = "v1/payments/authorization/#{self.id}/void"
395
- response = api.post(path, {}, http_header)
396
- self.merge!(response)
397
- success?
398
- end
399
-
400
- def reauthorize()
401
- path = "v1/payments/authorization/#{self.id}/reauthorize"
402
- response = api.post(path, self.to_hash, http_header)
403
- self.merge!(response)
404
- success?
405
- end
406
-
407
- end
408
- class Capture < Base
409
-
410
- def self.load_members
411
- object_of :id, String
412
- object_of :create_time, DateTime
413
- object_of :update_time, DateTime
414
- object_of :amount, Amount
415
- object_of :is_final_capture, Boolean
416
- object_of :state, String
417
- object_of :parent_payment, String
418
- array_of :links, Links
419
- end
420
-
421
- include RequestDataType
422
-
423
- class << self
424
- def find(resource_id)
425
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
426
- path = "v1/payments/capture/#{resource_id}"
427
- self.new(api.get(path))
428
- end
429
- end
430
-
431
- def refund(refund)
432
- refund = Refund.new(refund) unless refund.is_a? Refund
433
- path = "v1/payments/capture/#{self.id}/refund"
434
- response = api.post(path, refund.to_hash, http_header)
435
- Refund.new(response)
436
- end
437
-
438
- end
439
- class Refund < Base
440
-
441
- def self.load_members
442
- object_of :id, String
443
- object_of :create_time, DateTime
444
- object_of :update_time, DateTime
445
- object_of :amount, Amount
446
- object_of :state, String
447
- object_of :sale_id, String
448
- object_of :capture_id, String
449
- object_of :parent_payment, String
450
- array_of :links, Links
451
- end
452
-
453
- include RequestDataType
454
-
455
- class << self
456
- def find(resource_id)
457
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
458
- path = "v1/payments/refund/#{resource_id}"
459
- self.new(api.get(path))
460
- end
461
- end
462
-
463
- end
464
- class RedirectUrls < Base
465
-
466
- def self.load_members
467
- object_of :return_url, String
468
- object_of :cancel_url, String
469
- end
470
-
471
- end
472
- class PaymentExecution < Base
473
-
474
- def self.load_members
475
- object_of :payer_id, String
476
- array_of :transactions, Transactions
477
- end
478
-
479
- end
480
- class Transactions < Base
481
-
482
- def self.load_members
483
- object_of :amount, Amount
484
- end
485
-
486
- end
487
- class CreditCardHistory < Base
488
-
489
- def self.load_members
490
- array_of :"credit-cards", CreditCard
491
- object_of :count, Integer
492
- object_of :next_id, String
493
- end
494
-
495
- end
496
- class Error < Base
497
-
498
- def self.load_members
499
- object_of :name, String
500
- object_of :debug_id, String
501
- object_of :message, String
502
- object_of :information_link, String
503
- array_of :details, ErrorDetails
504
- end
505
-
506
- end
507
- class Invoice < Base
508
-
509
- def self.load_members
510
- object_of :id, String
511
- object_of :number, String
512
- object_of :uri, String
513
- object_of :status, String
514
- object_of :merchant_info, MerchantInfo
515
- array_of :billing_info, BillingInfo
516
- object_of :shipping_info, ShippingInfo
517
- array_of :items, InvoiceItem
518
- object_of :invoice_date, String
519
- object_of :payment_term, PaymentTerm
520
- object_of :discount, Cost
521
- object_of :shipping_cost, ShippingCost
522
- object_of :custom, CustomAmount
523
- object_of :tax_calculated_after_discount, Boolean
524
- object_of :tax_inclusive, Boolean
525
- object_of :terms, String
526
- object_of :note, String
527
- object_of :merchant_memo, String
528
- object_of :logo_url, String
529
- object_of :total_amount, Currency
530
- array_of :payment_details, PaymentDetail
531
- array_of :refund_details, RefundDetail
532
- object_of :metadata, Metadata
533
- end
534
-
535
- include RequestDataType
536
-
537
- def create()
538
- path = "v1/invoicing/invoices"
539
- response = api.post(path, self.to_hash, http_header)
540
- self.merge!(response)
541
- success?
542
- end
543
-
544
- class << self
545
- def self.search(options)
546
- path = "v1/invoicing/search"
547
- response = api.post(path, options)
548
- Invoices.new(response)
549
- end
550
- end
551
-
552
- def send_invoice()
553
- path = "v1/invoicing/invoices/#{self.id}/send"
554
- response = api.post(path, {}, http_header)
555
- self.merge!(response)
556
- success?
557
- end
558
-
559
- def remind(notification)
560
- notification = Notification.new(notification) unless notification.is_a? Notification
561
- path = "v1/invoicing/invoices/#{self.id}/remind"
562
- response = api.post(path, notification.to_hash, http_header)
563
- self.merge!(response)
564
- success?
565
- end
566
-
567
- def cancel(cancel_notification)
568
- cancel_notification = CancelNotification.new(cancel_notification) unless cancel_notification.is_a? CancelNotification
569
- path = "v1/invoicing/invoices/#{self.id}/cancel"
570
- response = api.post(path, cancel_notification.to_hash, http_header)
571
- self.merge!(response)
572
- success?
573
- end
574
-
575
- def record_payment(payment_detail)
576
- payment_detail = PaymentDetail.new(payment_detail) unless payment_detail.is_a? PaymentDetail
577
- path = "v1/invoicing/invoices/#{self.id}/record-payment"
578
- response = api.post(path, payment_detail.to_hash, http_header)
579
- self.merge!(response)
580
- success?
581
- end
582
-
583
- def record_refund(refund_detail)
584
- refund_detail = RefundDetail.new(refund_detail) unless refund_detail.is_a? RefundDetail
585
- path = "v1/invoicing/invoices/#{self.id}/record-refund"
586
- response = api.post(path, refund_detail.to_hash, http_header)
587
- self.merge!(response)
588
- success?
589
- end
590
-
591
- class << self
592
- def find(resource_id)
593
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
594
- path = "v1/invoicing/invoices/#{resource_id}"
595
- self.new(api.get(path))
596
- end
597
- end
598
-
599
- class << self
600
- def get_all(options = {})
601
- path = "v1/invoicing/invoices/"
602
- Invoices.new(api.get(path, options))
603
- end
604
- end
605
-
606
- def update()
607
- path = "v1/invoicing/invoices/#{self.id}"
608
- response = api.put(path, self.to_hash, http_header)
609
- self.merge!(response)
610
- success?
611
- end
612
-
613
- def delete()
614
- path = "v1/invoicing/invoices/#{self.id}"
615
- response = api.delete(path, {})
616
- self.merge!(response)
617
- success?
618
- end
619
-
620
- end
621
- class Invoices < Base
622
-
623
- def self.load_members
624
- object_of :total_count, Integer
625
- array_of :invoices, Invoice
626
- end
627
-
628
- end
629
- class InvoiceItem < Base
630
-
631
- def self.load_members
632
- object_of :name, String
633
- object_of :description, String
634
- object_of :quantity, Number
635
- object_of :unit_price, Currency
636
- object_of :tax, Tax
637
- object_of :date, String
638
- object_of :discount, Cost
639
- end
640
-
641
- end
642
- class MerchantInfo < Base
643
-
644
- def self.load_members
645
- object_of :email, String
646
- object_of :first_name, String
647
- object_of :last_name, String
648
- object_of :address, Address
649
- object_of :business_name, String
650
- object_of :phone, Phone
651
- object_of :fax, Phone
652
- object_of :website, String
653
- object_of :tax_id, String
654
- object_of :additional_info, String
655
- end
656
-
657
- end
658
- class BillingInfo < Base
659
-
660
- def self.load_members
661
- object_of :email, String
662
- object_of :first_name, String
663
- object_of :last_name, String
664
- object_of :business_name, String
665
- object_of :address, Address
666
- object_of :language, String
667
- object_of :additional_info, String
668
- end
669
-
670
- end
671
- class ShippingInfo < Base
672
-
673
- def self.load_members
674
- object_of :first_name, String
675
- object_of :last_name, String
676
- object_of :business_name, String
677
- object_of :address, Address
678
- end
679
-
680
- end
681
- class InvoicingNotification < Base
682
-
683
- def self.load_members
684
- object_of :subject, String
685
- object_of :note, String
686
- object_of :send_to_merchant, Boolean
687
- end
688
-
689
- end
690
- class InvoicingMetaData < Base
691
-
692
- def self.load_members
693
- object_of :created_date, String
694
- object_of :created_by, String
695
- object_of :cancelled_date, String
696
- object_of :cancelled_by, String
697
- object_of :last_updated_date, String
698
- object_of :last_updated_by, String
699
- object_of :first_sent_date, String
700
- object_of :last_sent_date, String
701
- object_of :last_sent_by, String
702
- end
703
-
704
- end
705
- class InvoicingPaymentDetail < Base
706
-
707
- def self.load_members
708
- object_of :type, String
709
- object_of :transaction_id, String
710
- object_of :transaction_type, String
711
- object_of :date, String
712
- object_of :method, String
713
- object_of :note, String
714
- end
715
-
716
- end
717
- class InvoicingRefundDetail < Base
718
-
719
- def self.load_members
720
- object_of :type, String
721
- object_of :date, String
722
- object_of :note, String
723
- end
724
-
725
- end
726
- class InvoicingSearch < Base
727
-
728
- def self.load_members
729
- object_of :email, String
730
- object_of :recipient_first_name, String
731
- object_of :recipient_last_name, String
732
- object_of :recipient_business_name, String
733
- object_of :number, String
734
- object_of :status, String
735
- object_of :lower_total_amount, Currency
736
- object_of :upper_total_amount, Currency
737
- object_of :start_invoice_date, String
738
- object_of :end_invoice_date, String
739
- object_of :start_due_date, String
740
- object_of :end_due_date, String
741
- object_of :start_payment_date, String
742
- object_of :end_payment_date, String
743
- object_of :start_creation_date, String
744
- object_of :end_creation_date, String
745
- object_of :page, Number
746
- object_of :page_size, Number
747
- object_of :total_count_required, Boolean
748
- end
749
-
750
- end
751
- class ErrorDetails < Base
752
-
753
- def self.load_members
754
- object_of :field, String
755
- object_of :issue, String
756
- end
757
-
758
- end
759
- class PaymentTerm < Base
760
-
761
- def self.load_members
762
- object_of :term_type, String
763
- object_of :due_date, String
764
- end
765
-
766
- end
767
- class Cost < Base
768
-
769
- def self.load_members
770
- object_of :percent, Number
771
- object_of :amount, Currency
772
- end
773
-
774
- end
775
- class Currency < Base
776
-
777
- def self.load_members
778
- object_of :currency, String
779
- object_of :value, String
780
- end
781
-
782
- end
783
- class ShippingCost < Base
784
-
785
- def self.load_members
786
- object_of :amount, Currency
787
- object_of :tax, Tax
788
- end
789
-
790
- end
791
- class Tax < Base
792
-
793
- def self.load_members
794
- object_of :id, String
795
- object_of :name, String
796
- object_of :percent, Number
797
- object_of :amount, Currency
798
- end
799
-
800
- end
801
- class CustomAmount < Base
802
-
803
- def self.load_members
804
- object_of :label, String
805
- object_of :amount, Currency
806
- end
807
-
808
- end
809
- class PaymentDetail < Base
810
-
811
- def self.load_members
812
- object_of :type, String
813
- object_of :transaction_id, String
814
- object_of :transaction_type, String
815
- object_of :date, String
816
- object_of :method, String
817
- object_of :note, String
818
- end
819
-
820
- end
821
- class RefundDetail < Base
822
-
823
- def self.load_members
824
- object_of :type, String
825
- object_of :date, String
826
- object_of :note, String
827
- end
828
-
829
- end
830
- class Metadata < Base
831
-
832
- def self.load_members
833
- object_of :created_date, String
834
- object_of :created_by, String
835
- object_of :cancelled_date, String
836
- object_of :cancelled_by, String
837
- object_of :last_updated_date, String
838
- object_of :last_updated_by, String
839
- object_of :first_sent_date, String
840
- object_of :last_sent_date, String
841
- object_of :last_sent_by, String
842
- end
843
-
844
- end
845
- class Phone < Base
846
-
847
- def self.load_members
848
- object_of :country_code, String
849
- object_of :national_number, String
850
- end
851
-
852
- end
853
- class Notification < Base
854
-
855
- def self.load_members
856
- object_of :subject, String
857
- object_of :note, String
858
- object_of :send_to_merchant, Boolean
859
- end
860
-
861
- end
862
- class Search < Base
863
-
864
- def self.load_members
865
- object_of :email, String
866
- object_of :recipient_first_name, String
867
- object_of :recipient_last_name, String
868
- object_of :recipient_business_name, String
869
- object_of :number, String
870
- object_of :status, String
871
- object_of :lower_total_amount, Currency
872
- object_of :upper_total_amount, Currency
873
- object_of :start_invoice_date, String
874
- object_of :end_invoice_date, String
875
- object_of :start_due_date, String
876
- object_of :end_due_date, String
877
- object_of :start_payment_date, String
878
- object_of :end_payment_date, String
879
- object_of :start_creation_date, String
880
- object_of :end_creation_date, String
881
- object_of :page, Number
882
- object_of :page_size, Number
883
- object_of :total_count_required, Boolean
884
- end
885
-
886
- end
887
- class CancelNotification < Base
888
-
889
- def self.load_members
890
- object_of :subject, String
891
- object_of :note, String
892
- object_of :send_to_merchant, Boolean
893
- object_of :send_to_payer, Boolean
894
- end
895
-
896
- end
897
- class FuturePayment < Payment
898
-
899
- def self.exch_token(auth_code)
900
- if auth_code
901
- token = PayPal::SDK::Core::API::REST.new.token(auth_code)
902
- token
903
- end
904
- end
905
-
906
- def create(correlation_id=nil)
907
- path = "v1/payments/payment"
908
- if correlation_id != nil
909
- header = http_header
910
- header = header.merge({
911
- "PAYPAL-CLIENT-METADATA-ID" => correlation_id})
912
- end
913
- response = api.post(path, self.to_hash, http_header)
914
- self.merge!(response)
915
- success?
916
- end
917
-
918
- end
919
- class Plan < Base
920
-
921
- def self.load_members
922
- array_of :links, Links
923
- array_of :payment_definitions, PaymentDefinition
924
- array_of :terms, Terms
925
- object_of :create_time, String
926
- object_of :description, String
927
- object_of :id, String
928
- object_of :merchant_preferences, MerchantPreferences
929
- object_of :name, String
930
- object_of :payee, Payee
931
- object_of :state, String
932
- object_of :type, String
933
- object_of :update_time, String
934
- end
935
-
936
- include RequestDataType
937
-
938
- def create()
939
- path = "v1/payments/billing-plans"
940
- response = api.post(path, self.to_hash, http_header)
941
- self.merge!(response)
942
- success?
943
- end
944
-
945
- class << self
946
- def find(resource_id)
947
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
948
- path = "v1/payments/billing-plans/#{resource_id}"
949
- self.new(api.get(path))
950
- end
951
- end
952
-
953
- def update(value)
954
- path = "v1/payments/billing-plans/#{self.id}"
955
- params = [{
956
- "path" => "/",
957
- "value" => value,
958
- "op" => "replace"
959
- }]
960
- response = api.patch(path, params, http_header)
961
- success?
962
- end
963
-
964
- class << self
965
- def all(options = {})
966
- path = "v1/payments/billing-plans"
967
- PlanHistory.new(api.get(path, options))
968
- end
969
- end
970
-
971
- end
972
- class PlanHistory < Base
973
-
974
- def self.load_members
975
- array_of :plans, Plan
976
- array_of :links, Links
977
- end
978
-
979
- end
980
- class PaymentDefinition < Base
981
-
982
- def self.load_members
983
- object_of :id, String
984
- object_of :name, String
985
- object_of :type, String
986
- object_of :frequency_interval, String
987
- object_of :frequency, String
988
- object_of :cycles, String
989
- object_of :amount, Currency
990
- array_of :charge_models, ChargeModels
991
- end
992
-
993
- end
994
- class ChargeModels < Base
995
-
996
- def self.load_members
997
- object_of :id, String
998
- object_of :type, String
999
- object_of :amount, Currency
1000
- end
1001
-
1002
- end
1003
- class MerchantPreferences < Base
1004
-
1005
- def self.load_members
1006
- object_of :id, String
1007
- object_of :setup_fee, Currency
1008
- object_of :cancel_url, String
1009
- object_of :return_url, String
1010
- object_of :notify_url, String
1011
- object_of :max_fail_attempts, String
1012
- object_of :auto_bill_amount, String
1013
- object_of :initial_fail_amount_action, String
1014
- object_of :accepted_payment_type, String
1015
- object_of :char_set, String
1016
- end
1017
-
1018
- end
1019
- class Terms < Base
1020
-
1021
- def self.load_members
1022
- object_of :id, String
1023
- object_of :type, String
1024
- object_of :max_billing_amount, Currency
1025
- object_of :occurrences, String
1026
- object_of :amount_range, Currency
1027
- object_of :buyer_editable, String
1028
- end
1029
-
1030
- end
1031
- class Agreement < Base
1032
-
1033
- def self.load_members
1034
- object_of :id, String
1035
- object_of :name, String
1036
- object_of :state, String
1037
- object_of :description, String
1038
- object_of :start_date, String
1039
- object_of :payer, Payer
1040
- object_of :shipping_address, Address
1041
- object_of :override_merchant_preferences, MerchantPreferences
1042
- array_of :override_charge_models, OverrideChargeModel
1043
- object_of :plan, Plan
1044
- object_of :create_time, String
1045
- object_of :update_time, String
1046
- array_of :links, Links
1047
- object_of :agreement_details, AgreementDetails
1048
- end
1049
-
1050
- include RequestDataType
1051
-
1052
- def create()
1053
- path = "v1/payments/billing-agreements"
1054
- response = api.post(path, self.to_hash, http_header)
1055
- self.merge!(response)
1056
- success?
1057
- end
1058
-
1059
- class << self
1060
- def find(resource_id)
1061
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
1062
- path = "v1/payments/billing-agreements/#{resource_id}"
1063
- self.new(api.get(path))
1064
- end
1065
- end
1066
-
1067
- class << self
1068
- def execute(token)
1069
- raise ArgumentError.new("token required") if token.to_s.strip.empty?
1070
- path = "v1/payments/billing-agreements/#{token}/agreement-execute"
1071
- response = api.post(path)
1072
- self.new(response)
1073
- end
1074
- end
1075
-
1076
- def suspend(note)
1077
- note = Note.new(note) unless note.is_a? Note
1078
- path = "v1/payments/billing-agreements/#{self.id}/suspend"
1079
- response = api.post(path, note.to_hash, http_header)
1080
- self.merge!(response)
1081
- success?
1082
- end
1083
-
1084
- def reactivate(note)
1085
- note = Note.new(note) unless note.is_a? Note
1086
- path = "v1/payments/billing-agreements/#{self.id}/re-activate"
1087
- response = api.post(path, note.to_hash, http_header)
1088
- self.merge!(response)
1089
- success?
1090
- end
1091
-
1092
- def cancel(note)
1093
- note = Note.new(note) unless note.is_a? Note
1094
- path = "v1/payments/billing-agreements/#{self.id}/cancel"
1095
- response = api.post(path, note.to_hash, http_header)
1096
- self.merge!(response)
1097
- success?
1098
- end
1099
-
1100
- end
1101
- class AgreementDetails < Base
1102
-
1103
- def self.load_members
1104
- object_of :outstanding_balance, Currency
1105
- object_of :cycles_remaining, String
1106
- object_of :cycles_completed, String
1107
- object_of :final_payment_date, DateTime
1108
- object_of :failed_payment_count, String
1109
- object_of :next_billing_date, DateTime
1110
- object_of :last_payment_date, DateTime
1111
- object_of :last_payment_amount, Currency
1112
- end
1113
-
1114
- end
1115
- class Note < Base
1116
-
1117
- def self.load_members
1118
- object_of :note, String
1119
- end
1120
-
1121
- end
1122
- class OverrideChargeModel < Base
1123
-
1124
- def self.load_members
1125
- object_of :charge_id, String
1126
- object_of :amount, Currency
1127
- end
1128
-
1129
- end
1130
-
1131
- constants.each do |data_type_klass|
1132
- data_type_klass = const_get(data_type_klass)
1133
- data_type_klass.load_members if defined? data_type_klass.load_members
1134
- end
1135
-
1136
- end
1137
- end
1138
- end
1
+ require 'paypal-sdk-core'
2
+ require 'uuidtools'
3
+
4
+ module PayPal::SDK
5
+ module REST
6
+ module DataTypes
7
+ class Base < Core::API::DataTypes::Base
8
+ attr_accessor :error
9
+ attr_writer :header, :request_id
10
+
11
+ def header
12
+ @header ||= {}
13
+ end
14
+
15
+ def request_id
16
+ @request_id ||= UUIDTools::UUID.random_create.to_s
17
+ end
18
+
19
+ def http_header
20
+ { "PayPal-Request-Id" => request_id.to_s }.merge(header)
21
+ end
22
+
23
+ def success?
24
+ @error.nil?
25
+ end
26
+
27
+ def merge!(values)
28
+ @error = nil
29
+ super
30
+ end
31
+
32
+ def self.load_members
33
+ end
34
+
35
+ class Number < Float
36
+ end
37
+ end
38
+
39
+ class Payment < Base
40
+
41
+ def self.load_members
42
+ object_of :id, String
43
+ object_of :intent, String
44
+ object_of :payer, Payer
45
+ object_of :cart, String
46
+ array_of :transactions, Transaction
47
+ array_of :failed_transactions, Error
48
+ object_of :payment_instruction, PaymentInstruction
49
+ object_of :state, String
50
+ object_of :experience_profile_id, String
51
+ object_of :redirect_urls, RedirectUrls
52
+ object_of :create_time, String
53
+ object_of :update_time, String
54
+ array_of :links, Links
55
+ end
56
+
57
+ include RequestDataType
58
+
59
+ def create()
60
+ path = "v1/payments/payment"
61
+ response = api.post(path, self.to_hash, http_header)
62
+ self.merge!(response)
63
+ success?
64
+ end
65
+
66
+ class << self
67
+ def find(resource_id)
68
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
69
+ path = "v1/payments/payment/#{resource_id}"
70
+ self.new(api.get(path))
71
+ end
72
+ end
73
+
74
+ def update(patch_request)
75
+ patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
76
+ path = "v1/payments/payment/#{self.id}"
77
+ response = api.patch(path, patch_request.to_hash, http_header)
78
+ object.new(response)
79
+ end
80
+
81
+ def execute(payment_execution)
82
+ payment_execution = PaymentExecution.new(payment_execution) unless payment_execution.is_a? PaymentExecution
83
+ path = "v1/payments/payment/#{self.id}/execute"
84
+ response = api.post(path, payment_execution.to_hash, http_header)
85
+ self.merge!(response)
86
+ success?
87
+ end
88
+
89
+ class << self
90
+ def all(options = {})
91
+ path = "v1/payments/payment"
92
+ PaymentHistory.new(api.get(path, options))
93
+ end
94
+ end
95
+
96
+ end
97
+ class Payer < Base
98
+
99
+ def self.load_members
100
+ object_of :payment_method, String
101
+ object_of :status, String
102
+ array_of :funding_instruments, FundingInstrument
103
+ object_of :funding_option_id, String
104
+ object_of :funding_option, FundingOption
105
+ object_of :related_funding_option, FundingOption
106
+ object_of :payer_info, PayerInfo
107
+ end
108
+
109
+ end
110
+ class FundingInstrument < Base
111
+
112
+ def self.load_members
113
+ object_of :credit_card, CreditCard
114
+ object_of :credit_card_token, CreditCardToken
115
+ end
116
+
117
+ end
118
+ class CreditCard < Base
119
+
120
+ def self.load_members
121
+ object_of :id, String
122
+ object_of :number, String
123
+ object_of :type, String
124
+ object_of :expire_month, Integer
125
+ object_of :expire_year, Integer
126
+ object_of :cvv2, String
127
+ object_of :first_name, String
128
+ object_of :last_name, String
129
+ object_of :billing_address, Address
130
+ object_of :external_customer_id, String
131
+ object_of :state, String
132
+ object_of :valid_until, String
133
+ object_of :create_time, String
134
+ object_of :update_time, String
135
+ array_of :links, Links
136
+ end
137
+
138
+ include RequestDataType
139
+
140
+ def create()
141
+ path = "v1/vault/credit-card"
142
+ response = api.post(path, self.to_hash, http_header)
143
+ self.merge!(response)
144
+ success?
145
+ end
146
+
147
+ class << self
148
+ def find(resource_id)
149
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
150
+ path = "v1/vault/credit-card/#{resource_id}"
151
+ self.new(api.get(path))
152
+ end
153
+ end
154
+
155
+ def delete()
156
+ path = "v1/vault/credit-card/#{self.id}"
157
+ response = api.delete(path, {})
158
+ self.merge!(response)
159
+ success?
160
+ end
161
+
162
+ def update()
163
+ path = "v1/vault/credit-card/#{self.id}"
164
+ response = api.patch(path, self.to_hash, http_header)
165
+ self.merge!(response)
166
+ success?
167
+ end
168
+
169
+ end
170
+ class Address < Base
171
+
172
+ def self.load_members
173
+ object_of :line1, String
174
+ object_of :line2, String
175
+ object_of :city, String
176
+ object_of :country_code, String
177
+ object_of :postal_code, String
178
+ object_of :state, String
179
+ object_of :phone, String
180
+ object_of :normalization_status, String
181
+ end
182
+
183
+ end
184
+ class OneOf < Base
185
+
186
+ def self.load_members
187
+ object_of :phone, Phone
188
+ end
189
+
190
+ end
191
+ class CreditCardToken < Base
192
+
193
+ def self.load_members
194
+ object_of :credit_card_id, String
195
+ object_of :payer_id, String
196
+ object_of :last4, String
197
+ object_of :type, String
198
+ object_of :expire_month, Integer
199
+ object_of :expire_year, Integer
200
+ end
201
+
202
+ end
203
+ class PaymentCard < Base
204
+
205
+ def self.load_members
206
+ object_of :id, String
207
+ object_of :number, String
208
+ object_of :type, String
209
+ object_of :expire_month, Integer
210
+ object_of :expire_year, Integer
211
+ object_of :start_month, String
212
+ object_of :start_year, String
213
+ object_of :cvv2, String
214
+ object_of :first_name, String
215
+ object_of :last_name, String
216
+ object_of :billing_country, String
217
+ object_of :billing_address, Address
218
+ object_of :external_customer_id, String
219
+ object_of :status, String
220
+ object_of :valid_until, String
221
+ end
222
+
223
+ end
224
+ class BankAccount < Base
225
+
226
+ def self.load_members
227
+ object_of :id, String
228
+ object_of :account_number, String
229
+ object_of :account_number_type, String
230
+ object_of :routing_number, String
231
+ object_of :account_type, String
232
+ object_of :account_name, String
233
+ object_of :check_type, String
234
+ object_of :auth_type, String
235
+ object_of :auth_capture_timestamp, String
236
+ object_of :bank_name, String
237
+ object_of :country_code, String
238
+ object_of :first_name, String
239
+ object_of :last_name, String
240
+ object_of :birth_date, String
241
+ object_of :billing_address, Address
242
+ object_of :state, String
243
+ object_of :confirmation_status, String
244
+ object_of :payer_id, String
245
+ object_of :external_customer_id, String
246
+ object_of :merchant_id, String
247
+ object_of :create_time, String
248
+ object_of :update_time, String
249
+ object_of :valid_until, String
250
+ end
251
+
252
+ include RequestDataType
253
+
254
+ def create()
255
+ path = "v1/vault/bank-accounts"
256
+ response = api.post(path, self.to_hash, http_header)
257
+ self.merge!(response)
258
+ success?
259
+ end
260
+
261
+ class << self
262
+ def find(resource_id)
263
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
264
+ path = "v1/vault/bank-accounts/#{resource_id}"
265
+ self.new(api.get(path))
266
+ end
267
+ end
268
+
269
+ def delete()
270
+ path = "v1/vault/bank-accounts/#{self.id}"
271
+ response = api.delete(path, {})
272
+ self.merge!(response)
273
+ success?
274
+ end
275
+
276
+ def update(patch_request)
277
+ patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
278
+ path = "v1/vault/bank-accounts/#{self.id}"
279
+ response = api.patch(path, patch_request.to_hash, http_header)
280
+ self.merge!(response)
281
+ success?
282
+ end
283
+
284
+ end
285
+ class ExtendedBankAccount < BankAccount
286
+
287
+ def self.load_members
288
+ object_of :mandate_reference_number, String
289
+ end
290
+
291
+ end
292
+ class BankToken < Base
293
+
294
+ def self.load_members
295
+ object_of :bank_id, String
296
+ object_of :external_customer_id, String
297
+ object_of :mandate_reference_number, String
298
+ end
299
+
300
+ end
301
+ class Credit < Base
302
+
303
+ def self.load_members
304
+ object_of :id, String
305
+ object_of :type, String
306
+ end
307
+
308
+ end
309
+ class Incentive < Base
310
+
311
+ def self.load_members
312
+ object_of :id, String
313
+ object_of :code, String
314
+ object_of :name, String
315
+ object_of :description, String
316
+ object_of :minimum_purchase_amount, Currency
317
+ object_of :logo_image_url, String
318
+ object_of :expiry_date, String
319
+ object_of :type, String
320
+ object_of :terms, String
321
+ end
322
+
323
+ end
324
+ class Currency < Base
325
+
326
+ def self.load_members
327
+ object_of :currency, String
328
+ object_of :value, String
329
+ end
330
+
331
+ end
332
+ class CarrierAccountToken < Base
333
+
334
+ def self.load_members
335
+ object_of :carrier_account_id, String
336
+ object_of :external_customer_id, String
337
+ end
338
+
339
+ end
340
+ class FundingOption < Base
341
+
342
+ def self.load_members
343
+ object_of :id, String
344
+ array_of :funding_sources, FundingSource
345
+ object_of :backup_funding_instrument, FundingInstrument
346
+ object_of :currency_conversion, CurrencyConversion
347
+ object_of :installment_info, InstallmentInfo
348
+ end
349
+
350
+ end
351
+ class FundingSource < Base
352
+
353
+ def self.load_members
354
+ object_of :funding_mode, String
355
+ object_of :funding_instrument_type, String
356
+ object_of :soft_descriptor, String
357
+ object_of :amount, Currency
358
+ object_of :legal_text, String
359
+ object_of :funding_detail, FundingDetail
360
+ object_of :additional_text, String
361
+ object_of :extends, FundingInstrument
362
+ end
363
+
364
+ end
365
+ class FundingDetail < Base
366
+
367
+ def self.load_members
368
+ object_of :clearing_time, String
369
+ object_of :payment_hold_date, String
370
+ end
371
+
372
+ end
373
+ class CurrencyConversion < Base
374
+
375
+ def self.load_members
376
+ object_of :conversion_date, String
377
+ object_of :from_currency, String
378
+ object_of :from_amount, Number
379
+ object_of :to_currency, String
380
+ object_of :to_amount, Number
381
+ object_of :conversion_type, String
382
+ object_of :conversion_type_changeable, Boolean
383
+ object_of :web_url, String
384
+ end
385
+
386
+ end
387
+ class InstallmentInfo < Base
388
+
389
+ def self.load_members
390
+ object_of :installment_id, String
391
+ object_of :network, String
392
+ object_of :issuer, String
393
+ array_of :installment_options, InstallmentOption
394
+ end
395
+
396
+ end
397
+ class InstallmentOption < Base
398
+
399
+ def self.load_members
400
+ object_of :term, Integer
401
+ object_of :monthly_payment, Currency
402
+ object_of :discount_amount, Currency
403
+ object_of :discount_percentage, Percentage
404
+ end
405
+
406
+ end
407
+ class Percentage < Base
408
+
409
+ def self.load_members
410
+ end
411
+
412
+ end
413
+ class PayerInfo < Base
414
+
415
+ def self.load_members
416
+ object_of :email, String
417
+ object_of :external_remember_me_id, String
418
+ object_of :buyer_account_number, String
419
+ object_of :first_name, String
420
+ object_of :last_name, String
421
+ object_of :payer_id, String
422
+ object_of :phone, String
423
+ object_of :phone_type, String
424
+ object_of :birth_date, String
425
+ object_of :tax_id, String
426
+ object_of :tax_id_type, String
427
+ object_of :billing_address, Address
428
+ object_of :shipping_address, ShippingAddress
429
+ end
430
+
431
+ end
432
+ class ShippingAddress < Base
433
+
434
+ def self.load_members
435
+ object_of :line1, String
436
+ object_of :city, String
437
+ object_of :state, String
438
+ object_of :postal_code, String
439
+ object_of :country_code, String
440
+ object_of :recipient_name, String
441
+ end
442
+
443
+ end
444
+ class AllOf < Base
445
+
446
+ def self.load_members
447
+ array_of :related_resources, RelatedResources
448
+ end
449
+
450
+ end
451
+ class Transaction < Base
452
+
453
+ def self.load_members
454
+ object_of :amount, Amount
455
+ object_of :payee, Payee
456
+ object_of :description, String
457
+ object_of :invoice_number, String
458
+ object_of :custom, String
459
+ object_of :soft_descriptor, String
460
+ object_of :item_list, ItemList
461
+ array_of :related_resources, RelatedResources
462
+ array_of :transactions, Transaction
463
+ end
464
+
465
+ end
466
+ class CartBase < Base
467
+
468
+ def self.load_members
469
+ object_of :amount, Amount
470
+ object_of :payee, Payee
471
+ object_of :description, String
472
+ object_of :note_to_payee, String
473
+ object_of :custom, String
474
+ object_of :invoice_number, String
475
+ object_of :soft_descriptor, String
476
+ object_of :payment_options, PaymentOptions
477
+ object_of :item_list, ItemList
478
+ end
479
+
480
+ end
481
+ class Amount < Base
482
+
483
+ def self.load_members
484
+ object_of :currency, String
485
+ object_of :total, String
486
+ object_of :details, Details
487
+ end
488
+
489
+ end
490
+ class Details < Base
491
+
492
+ def self.load_members
493
+ object_of :subtotal, String
494
+ object_of :shipping, String
495
+ object_of :tax, String
496
+ object_of :handling_fee, String
497
+ object_of :shipping_discount, String
498
+ object_of :insurance, String
499
+ object_of :gift_wrap, String
500
+ end
501
+
502
+ end
503
+ class Payee < Base
504
+
505
+ def self.load_members
506
+ end
507
+
508
+ end
509
+ class Phone < Base
510
+
511
+ def self.load_members
512
+ object_of :country_code, String
513
+ object_of :national_number, String
514
+ object_of :extension, String
515
+ end
516
+
517
+ end
518
+ class PaymentOptions < Base
519
+
520
+ def self.load_members
521
+ object_of :allowed_payment_method, String
522
+ end
523
+
524
+ end
525
+ class Item < Base
526
+
527
+ def self.load_members
528
+ object_of :quantity, String
529
+ object_of :name, String
530
+ object_of :description, String
531
+ object_of :price, String
532
+ object_of :tax, String
533
+ object_of :currency, String
534
+ object_of :sku, String
535
+ object_of :url, String
536
+ object_of :category, String
537
+ array_of :supplementary_data, NameValuePair
538
+ array_of :postback_data, NameValuePair
539
+ end
540
+
541
+ end
542
+ class NameValuePair < Base
543
+
544
+ def self.load_members
545
+ object_of :name, String
546
+ object_of :value, String
547
+ end
548
+
549
+ end
550
+ class ItemList < Base
551
+
552
+ def self.load_members
553
+ array_of :items, Item
554
+ object_of :shipping_address, ShippingAddress
555
+ end
556
+
557
+ end
558
+ class RelatedResources < Base
559
+
560
+ def self.load_members
561
+ object_of :order, Order
562
+ object_of :sale, Sale
563
+ object_of :authorization, Authorization
564
+ object_of :capture, Capture
565
+ object_of :refund, Refund
566
+ end
567
+
568
+ end
569
+ class Sale < Base
570
+
571
+ def self.load_members
572
+ object_of :id, String
573
+ object_of :purchase_unit_reference_id, String
574
+ object_of :amount, Amount
575
+ object_of :payment_mode, String
576
+ object_of :state, String
577
+ object_of :reason_code, String
578
+ object_of :protection_eligibility, String
579
+ object_of :protection_eligibility_type, String
580
+ object_of :clearing_time, String
581
+ object_of :parent_payment, String
582
+ object_of :create_time, String
583
+ object_of :update_time, String
584
+ array_of :links, Links
585
+ end
586
+
587
+ include RequestDataType
588
+
589
+ class << self
590
+ def find(resource_id)
591
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
592
+ path = "v1/payments/sale/#{resource_id}"
593
+ self.new(api.get(path))
594
+ end
595
+ end
596
+
597
+ def refund(refund)
598
+ refund = Refund.new(refund) unless refund.is_a? Refund
599
+ path = "v1/payments/sale/#{self.id}/refund"
600
+ response = api.post(path, refund.to_hash, http_header)
601
+ Refund.new(response)
602
+ end
603
+
604
+ end
605
+ class AnyOf < Base
606
+
607
+ def self.load_members
608
+ object_of :refund, Refund
609
+ end
610
+
611
+ end
612
+ class Authorization < Base
613
+
614
+ def self.load_members
615
+ object_of :id, String
616
+ object_of :amount, Amount
617
+ object_of :payment_mode, String
618
+ object_of :state, String
619
+ object_of :protection_eligibility, String
620
+ object_of :protection_eligibility_type, String
621
+ object_of :parent_payment, String
622
+ object_of :valid_until, String
623
+ object_of :create_time, String
624
+ object_of :update_time, String
625
+ array_of :links, Links
626
+ end
627
+
628
+ include RequestDataType
629
+
630
+ class << self
631
+ def find(resource_id)
632
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
633
+ path = "v1/payments/authorization/#{resource_id}"
634
+ self.new(api.get(path))
635
+ end
636
+ end
637
+
638
+ def capture(capture)
639
+ capture = Capture.new(capture) unless capture.is_a? Capture
640
+ path = "v1/payments/authorization/#{self.id}/capture"
641
+ response = api.post(path, capture.to_hash, http_header)
642
+ Capture.new(response)
643
+ end
644
+
645
+ def void()
646
+ path = "v1/payments/authorization/#{self.id}/void"
647
+ response = api.post(path, {}, http_header)
648
+ self.merge!(response)
649
+ success?
650
+ end
651
+
652
+ def reauthorize()
653
+ path = "v1/payments/authorization/#{self.id}/reauthorize"
654
+ response = api.post(path, self.to_hash, http_header)
655
+ self.merge!(response)
656
+ success?
657
+ end
658
+
659
+ end
660
+ class Order < Base
661
+
662
+ def self.load_members
663
+ object_of :id, String
664
+ object_of :purchase_unit_reference_id, String
665
+ object_of :amount, Amount
666
+ object_of :payment_mode, String
667
+ object_of :state, String
668
+ object_of :pending_reason, String
669
+ object_of :"protection-eligibility", String
670
+ object_of :"protection-eligibility_type", String
671
+ object_of :parent_payment, String
672
+ object_of :create_time, String
673
+ object_of :update_time, String
674
+ array_of :links, Links
675
+ end
676
+
677
+ include RequestDataType
678
+
679
+ class << self
680
+ def find(resource_id)
681
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
682
+ path = "v1/payments/orders/#{resource_id}"
683
+ self.new(api.get(path))
684
+ end
685
+ end
686
+
687
+ def capture(capture)
688
+ capture = Capture.new(capture) unless capture.is_a? Capture
689
+ path = "v1/payments/orders/#{self.id}/capture"
690
+ response = api.post(path, capture.to_hash, http_header)
691
+ Capture.new(response)
692
+ end
693
+
694
+ def void()
695
+ path = "v1/payments/orders/#{self.id}/do-void"
696
+ response = api.post(path, {}, http_header)
697
+ self.merge!(response)
698
+ success?
699
+ end
700
+
701
+ def authorize()
702
+ path = "v1/payments/orders/#{self.id}/authorize"
703
+ response = api.post(path, self.to_hash, http_header)
704
+ Authorization.new(response)
705
+ end
706
+
707
+ end
708
+ class Capture < Base
709
+
710
+ def self.load_members
711
+ object_of :id, String
712
+ object_of :amount, Amount
713
+ object_of :is_final_capture, Boolean
714
+ object_of :state, String
715
+ object_of :parent_payment, String
716
+ object_of :create_time, String
717
+ object_of :update_time, String
718
+ array_of :links, Links
719
+ end
720
+
721
+ include RequestDataType
722
+
723
+ class << self
724
+ def find(resource_id)
725
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
726
+ path = "v1/payments/capture/#{resource_id}"
727
+ self.new(api.get(path))
728
+ end
729
+ end
730
+
731
+ def refund(refund)
732
+ refund = Refund.new(refund) unless refund.is_a? Refund
733
+ path = "v1/payments/capture/#{self.id}/refund"
734
+ response = api.post(path, refund.to_hash, http_header)
735
+ Refund.new(response)
736
+ end
737
+
738
+ end
739
+ class Refund < Base
740
+
741
+ def self.load_members
742
+ object_of :id, String
743
+ object_of :amount, Amount
744
+ object_of :state, String
745
+ object_of :reason, String
746
+ object_of :sale_id, String
747
+ object_of :capture_id, String
748
+ object_of :parent_payment, String
749
+ object_of :description, String
750
+ object_of :create_time, String
751
+ object_of :update_time, String
752
+ array_of :links, Links
753
+ end
754
+
755
+ include RequestDataType
756
+
757
+ class << self
758
+ def find(resource_id)
759
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
760
+ path = "v1/payments/refund/#{resource_id}"
761
+ self.new(api.get(path))
762
+ end
763
+ end
764
+
765
+ end
766
+ class Error < Base
767
+
768
+ def self.load_members
769
+ object_of :name, String
770
+ object_of :debug_id, String
771
+ object_of :message, String
772
+ object_of :information_link, String
773
+ array_of :details, ErrorDetails
774
+ end
775
+
776
+ end
777
+ class ErrorDetails < Base
778
+
779
+ def self.load_members
780
+ object_of :field, String
781
+ object_of :issue, String
782
+ end
783
+
784
+ end
785
+ class PaymentInstruction < Base
786
+
787
+ def self.load_members
788
+ object_of :reference_number, String
789
+ object_of :instruction_type, String
790
+ object_of :recipient_banking_instruction, RecipientBankingInstruction
791
+ object_of :amount, Currency
792
+ object_of :payment_due_date, String
793
+ object_of :note, String
794
+ array_of :links, Links
795
+ end
796
+
797
+ include RequestDataType
798
+
799
+ class << self
800
+ def find(resource_id)
801
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
802
+ path = "v1/payments/payments/payment/#{resource_id}/payment-instruction"
803
+ self.new(api.get(path))
804
+ end
805
+ end
806
+
807
+ end
808
+ class RecipientBankingInstruction < Base
809
+
810
+ def self.load_members
811
+ object_of :bank_name, String
812
+ object_of :account_holder_name, String
813
+ object_of :account_number, String
814
+ object_of :routing_number, String
815
+ object_of :international_bank_account_number, String
816
+ object_of :bank_identifier_code, String
817
+ end
818
+
819
+ end
820
+ class RedirectUrls < Base
821
+
822
+ def self.load_members
823
+ object_of :return_url, String
824
+ object_of :cancel_url, String
825
+ end
826
+
827
+ end
828
+ class PatchRequest < Base
829
+
830
+ def self.load_members
831
+ object_of :op, String
832
+ object_of :path, String
833
+ end
834
+
835
+ end
836
+ class Patch < Base
837
+
838
+ def self.load_members
839
+ object_of :op, String
840
+ object_of :path, String
841
+ end
842
+
843
+ end
844
+ class PaymentExecution < Base
845
+
846
+ def self.load_members
847
+ object_of :payer_id, String
848
+ array_of :transactions, CartBase
849
+ end
850
+
851
+ end
852
+ class PaymentHistory < Base
853
+
854
+ def self.load_members
855
+ array_of :payments, Payment
856
+ object_of :count, Integer
857
+ object_of :next_id, String
858
+ end
859
+
860
+ end
861
+ class CreditCardList < Base
862
+
863
+ def self.load_members
864
+ array_of :"credit-cards", CreditCard
865
+ object_of :count, Integer
866
+ object_of :next_id, String
867
+ end
868
+
869
+ end
870
+ class BankAccountsList < Base
871
+
872
+ def self.load_members
873
+ array_of :"bank-accounts", BankAccount
874
+ object_of :count, Integer
875
+ object_of :next_id, String
876
+ end
877
+
878
+ end
879
+ class Invoice < Base
880
+
881
+ def self.load_members
882
+ object_of :id, String
883
+ object_of :number, String
884
+ object_of :uri, String
885
+ object_of :status, String
886
+ object_of :merchant_info, MerchantInfo
887
+ array_of :billing_info, BillingInfo
888
+ object_of :shipping_info, ShippingInfo
889
+ array_of :items, InvoiceItem
890
+ object_of :invoice_date, String
891
+ object_of :payment_term, PaymentTerm
892
+ object_of :discount, Cost
893
+ object_of :shipping_cost, ShippingCost
894
+ object_of :custom, CustomAmount
895
+ object_of :tax_calculated_after_discount, Boolean
896
+ object_of :tax_inclusive, Boolean
897
+ object_of :terms, String
898
+ object_of :note, String
899
+ object_of :merchant_memo, String
900
+ object_of :logo_url, String
901
+ object_of :total_amount, Currency
902
+ array_of :payment_details, PaymentDetail
903
+ array_of :refund_details, RefundDetail
904
+ object_of :metadata, Metadata
905
+ end
906
+
907
+ include RequestDataType
908
+
909
+ def create()
910
+ path = "v1/invoicing/invoices"
911
+ response = api.post(path, self.to_hash, http_header)
912
+ self.merge!(response)
913
+ success?
914
+ end
915
+
916
+ class << self
917
+ def self.search(options)
918
+ path = "v1/invoicing/search"
919
+ response = api.post(path, options)
920
+ Invoices.new(response)
921
+ end
922
+ end
923
+
924
+ def send_invoice()
925
+ path = "v1/invoicing/invoices/#{self.id}/send"
926
+ response = api.post(path, {}, http_header)
927
+ self.merge!(response)
928
+ success?
929
+ end
930
+
931
+ def remind(notification)
932
+ notification = Notification.new(notification) unless notification.is_a? Notification
933
+ path = "v1/invoicing/invoices/#{self.id}/remind"
934
+ response = api.post(path, notification.to_hash, http_header)
935
+ self.merge!(response)
936
+ success?
937
+ end
938
+
939
+ def cancel(cancel_notification)
940
+ cancel_notification = CancelNotification.new(cancel_notification) unless cancel_notification.is_a? CancelNotification
941
+ path = "v1/invoicing/invoices/#{self.id}/cancel"
942
+ response = api.post(path, cancel_notification.to_hash, http_header)
943
+ self.merge!(response)
944
+ success?
945
+ end
946
+
947
+ def record_payment(payment_detail)
948
+ payment_detail = PaymentDetail.new(payment_detail) unless payment_detail.is_a? PaymentDetail
949
+ path = "v1/invoicing/invoices/#{self.id}/record-payment"
950
+ response = api.post(path, payment_detail.to_hash, http_header)
951
+ self.merge!(response)
952
+ success?
953
+ end
954
+
955
+ def record_refund(refund_detail)
956
+ refund_detail = RefundDetail.new(refund_detail) unless refund_detail.is_a? RefundDetail
957
+ path = "v1/invoicing/invoices/#{self.id}/record-refund"
958
+ response = api.post(path, refund_detail.to_hash, http_header)
959
+ self.merge!(response)
960
+ success?
961
+ end
962
+
963
+ class << self
964
+ def find(resource_id)
965
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
966
+ path = "v1/invoicing/invoices/#{resource_id}"
967
+ self.new(api.get(path))
968
+ end
969
+ end
970
+
971
+ class << self
972
+ def get_all(options = {})
973
+ path = "v1/invoicing/invoices/"
974
+ Invoices.new(api.get(path, options))
975
+ end
976
+ end
977
+
978
+ def update()
979
+ path = "v1/invoicing/invoices/#{self.id}"
980
+ response = api.put(path, self.to_hash, http_header)
981
+ self.merge!(response)
982
+ success?
983
+ end
984
+
985
+ def delete()
986
+ path = "v1/invoicing/invoices/#{self.id}"
987
+ response = api.delete(path, {})
988
+ self.merge!(response)
989
+ success?
990
+ end
991
+
992
+ end
993
+ class Invoices < Base
994
+
995
+ def self.load_members
996
+ object_of :total_count, Integer
997
+ array_of :invoices, Invoice
998
+ end
999
+
1000
+ end
1001
+ class InvoiceItem < Base
1002
+
1003
+ def self.load_members
1004
+ object_of :name, String
1005
+ object_of :description, String
1006
+ object_of :quantity, Number
1007
+ object_of :unit_price, Currency
1008
+ object_of :tax, Tax
1009
+ object_of :date, String
1010
+ object_of :discount, Cost
1011
+ end
1012
+
1013
+ end
1014
+ class MerchantInfo < Base
1015
+
1016
+ def self.load_members
1017
+ object_of :email, String
1018
+ object_of :first_name, String
1019
+ object_of :last_name, String
1020
+ object_of :address, Address
1021
+ object_of :business_name, String
1022
+ object_of :phone, Phone
1023
+ object_of :fax, Phone
1024
+ object_of :website, String
1025
+ object_of :tax_id, String
1026
+ object_of :additional_info, String
1027
+ end
1028
+
1029
+ end
1030
+ class BillingInfo < Base
1031
+
1032
+ def self.load_members
1033
+ object_of :email, String
1034
+ object_of :first_name, String
1035
+ object_of :last_name, String
1036
+ object_of :business_name, String
1037
+ object_of :address, Address
1038
+ object_of :language, String
1039
+ object_of :additional_info, String
1040
+ end
1041
+
1042
+ end
1043
+ class ShippingInfo < Base
1044
+
1045
+ def self.load_members
1046
+ object_of :first_name, String
1047
+ object_of :last_name, String
1048
+ object_of :business_name, String
1049
+ object_of :address, Address
1050
+ object_of :email, String
1051
+ end
1052
+
1053
+ end
1054
+ class InvoicingNotification < Base
1055
+
1056
+ def self.load_members
1057
+ object_of :subject, String
1058
+ object_of :note, String
1059
+ object_of :send_to_merchant, Boolean
1060
+ end
1061
+
1062
+ end
1063
+ class InvoicingMetaData < Base
1064
+
1065
+ def self.load_members
1066
+ object_of :created_date, String
1067
+ object_of :created_by, String
1068
+ object_of :cancelled_date, String
1069
+ object_of :cancelled_by, String
1070
+ object_of :last_updated_date, String
1071
+ object_of :last_updated_by, String
1072
+ object_of :first_sent_date, String
1073
+ object_of :last_sent_date, String
1074
+ object_of :last_sent_by, String
1075
+ end
1076
+
1077
+ end
1078
+ class InvoicingPaymentDetail < Base
1079
+
1080
+ def self.load_members
1081
+ object_of :type, String
1082
+ object_of :transaction_id, String
1083
+ object_of :transaction_type, String
1084
+ object_of :date, String
1085
+ object_of :method, String
1086
+ object_of :note, String
1087
+ end
1088
+
1089
+ end
1090
+ class InvoicingRefundDetail < Base
1091
+
1092
+ def self.load_members
1093
+ object_of :type, String
1094
+ object_of :date, String
1095
+ object_of :note, String
1096
+ end
1097
+
1098
+ end
1099
+ class InvoicingSearch < Base
1100
+
1101
+ def self.load_members
1102
+ object_of :email, String
1103
+ object_of :recipient_first_name, String
1104
+ object_of :recipient_last_name, String
1105
+ object_of :recipient_business_name, String
1106
+ object_of :number, String
1107
+ object_of :status, String
1108
+ object_of :lower_total_amount, Currency
1109
+ object_of :upper_total_amount, Currency
1110
+ object_of :start_invoice_date, String
1111
+ object_of :end_invoice_date, String
1112
+ object_of :start_due_date, String
1113
+ object_of :end_due_date, String
1114
+ object_of :start_payment_date, String
1115
+ object_of :end_payment_date, String
1116
+ object_of :start_creation_date, String
1117
+ object_of :end_creation_date, String
1118
+ object_of :page, Number
1119
+ object_of :page_size, Number
1120
+ object_of :total_count_required, Boolean
1121
+ end
1122
+
1123
+ end
1124
+ class PaymentTerm < Base
1125
+
1126
+ def self.load_members
1127
+ object_of :term_type, String
1128
+ object_of :due_date, String
1129
+ end
1130
+
1131
+ end
1132
+ class Cost < Base
1133
+
1134
+ def self.load_members
1135
+ object_of :percent, Number
1136
+ object_of :amount, Currency
1137
+ end
1138
+
1139
+ end
1140
+ class ShippingCost < Base
1141
+
1142
+ def self.load_members
1143
+ object_of :amount, Currency
1144
+ object_of :tax, Tax
1145
+ end
1146
+
1147
+ end
1148
+ class Tax < Base
1149
+
1150
+ def self.load_members
1151
+ object_of :id, String
1152
+ object_of :name, String
1153
+ object_of :percent, Number
1154
+ object_of :amount, Currency
1155
+ end
1156
+
1157
+ end
1158
+ class CustomAmount < Base
1159
+
1160
+ def self.load_members
1161
+ object_of :label, String
1162
+ object_of :amount, Currency
1163
+ end
1164
+
1165
+ end
1166
+ class PaymentDetail < Base
1167
+
1168
+ def self.load_members
1169
+ object_of :type, String
1170
+ object_of :transaction_id, String
1171
+ object_of :transaction_type, String
1172
+ object_of :date, String
1173
+ object_of :method, String
1174
+ object_of :note, String
1175
+ end
1176
+
1177
+ end
1178
+ class RefundDetail < Base
1179
+
1180
+ def self.load_members
1181
+ object_of :type, String
1182
+ object_of :date, String
1183
+ object_of :note, String
1184
+ end
1185
+
1186
+ end
1187
+ class Metadata < Base
1188
+
1189
+ def self.load_members
1190
+ object_of :created_date, String
1191
+ object_of :created_by, String
1192
+ object_of :cancelled_date, String
1193
+ object_of :cancelled_by, String
1194
+ object_of :last_updated_date, String
1195
+ object_of :last_updated_by, String
1196
+ object_of :first_sent_date, String
1197
+ object_of :last_sent_date, String
1198
+ object_of :last_sent_by, String
1199
+ object_of :payer_view_url, String
1200
+ end
1201
+
1202
+ end
1203
+ class Notification < Base
1204
+
1205
+ def self.load_members
1206
+ object_of :subject, String
1207
+ object_of :note, String
1208
+ object_of :send_to_merchant, Boolean
1209
+ end
1210
+
1211
+ end
1212
+ class Search < Base
1213
+
1214
+ def self.load_members
1215
+ object_of :email, String
1216
+ object_of :recipient_first_name, String
1217
+ object_of :recipient_last_name, String
1218
+ object_of :recipient_business_name, String
1219
+ object_of :number, String
1220
+ object_of :status, String
1221
+ object_of :lower_total_amount, Currency
1222
+ object_of :upper_total_amount, Currency
1223
+ object_of :start_invoice_date, String
1224
+ object_of :end_invoice_date, String
1225
+ object_of :start_due_date, String
1226
+ object_of :end_due_date, String
1227
+ object_of :start_payment_date, String
1228
+ object_of :end_payment_date, String
1229
+ object_of :start_creation_date, String
1230
+ object_of :end_creation_date, String
1231
+ object_of :page, Number
1232
+ object_of :page_size, Number
1233
+ object_of :total_count_required, Boolean
1234
+ end
1235
+
1236
+ end
1237
+ class CancelNotification < Base
1238
+
1239
+ def self.load_members
1240
+ object_of :subject, String
1241
+ object_of :note, String
1242
+ object_of :send_to_merchant, Boolean
1243
+ object_of :send_to_payer, Boolean
1244
+ end
1245
+
1246
+ end
1247
+ class Plan < Base
1248
+
1249
+ def self.load_members
1250
+ object_of :id, String
1251
+ object_of :name, String
1252
+ object_of :description, String
1253
+ object_of :type, String
1254
+ object_of :state, String
1255
+ object_of :create_time, String
1256
+ object_of :update_time, String
1257
+ array_of :payment_definitions, PaymentDefinition
1258
+ array_of :terms, Terms
1259
+ object_of :merchant_preferences, MerchantPreferences
1260
+ array_of :links, Links
1261
+ end
1262
+
1263
+ include RequestDataType
1264
+
1265
+ class << self
1266
+ def find(resource_id)
1267
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
1268
+ path = "v1/payments/billing-plans/#{resource_id}"
1269
+ self.new(api.get(path))
1270
+ end
1271
+ end
1272
+
1273
+ def create()
1274
+ path = "v1/payments/billing-plans/"
1275
+ response = api.post(path, self.to_hash, http_header)
1276
+ self.merge!(response)
1277
+ success?
1278
+ end
1279
+
1280
+ def update(patch_request)
1281
+ patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
1282
+ path = "v1/payments/billing-plans/#{self.id}"
1283
+ response = api.patch(path, patch_request.to_hash, http_header)
1284
+ self.merge!(response)
1285
+ success?
1286
+ end
1287
+
1288
+ class << self
1289
+ def all(options = {})
1290
+ path = "v1/payments/billing-plans/"
1291
+ PlanList.new(api.get(path, options))
1292
+ end
1293
+ end
1294
+
1295
+ end
1296
+ class PaymentDefinition < Base
1297
+
1298
+ def self.load_members
1299
+ object_of :id, String
1300
+ object_of :name, String
1301
+ object_of :type, String
1302
+ object_of :frequency_interval, String
1303
+ object_of :frequency, String
1304
+ object_of :cycles, String
1305
+ object_of :amount, Currency
1306
+ array_of :charge_models, ChargeModels
1307
+ end
1308
+
1309
+ end
1310
+ class ChargeModels < Base
1311
+
1312
+ def self.load_members
1313
+ object_of :id, String
1314
+ object_of :type, String
1315
+ object_of :amount, Currency
1316
+ end
1317
+
1318
+ end
1319
+ class Terms < Base
1320
+
1321
+ def self.load_members
1322
+ object_of :id, String
1323
+ object_of :type, String
1324
+ object_of :max_billing_amount, Currency
1325
+ object_of :occurrences, String
1326
+ object_of :amount_range, Currency
1327
+ object_of :buyer_editable, String
1328
+ end
1329
+
1330
+ end
1331
+ class MerchantPreferences < Base
1332
+
1333
+ def self.load_members
1334
+ object_of :id, String
1335
+ object_of :setup_fee, Currency
1336
+ object_of :cancel_url, String
1337
+ object_of :return_url, String
1338
+ object_of :notify_url, String
1339
+ object_of :max_fail_attempts, String
1340
+ object_of :auto_bill_amount, String
1341
+ object_of :initial_fail_amount_action, String
1342
+ object_of :accepted_payment_type, String
1343
+ object_of :char_set, String
1344
+ end
1345
+
1346
+ end
1347
+ class Links < Base
1348
+
1349
+ def self.load_members
1350
+ object_of :href, String
1351
+ object_of :rel, String
1352
+ object_of :targetSchema, HyperSchema
1353
+ object_of :method, String
1354
+ object_of :enctype, String
1355
+ object_of :schema, HyperSchema
1356
+ end
1357
+
1358
+ end
1359
+ class Schema < Base
1360
+
1361
+ def self.load_members
1362
+ object_of :type, Object
1363
+ object_of :properties, Schema
1364
+ object_of :patternProperties, Schema
1365
+ object_of :additionalProperties, Object
1366
+ object_of :items, Object
1367
+ object_of :additionalItems, Object
1368
+ object_of :required, Boolean
1369
+ object_of :dependencies, Object
1370
+ object_of :minimum, Number
1371
+ object_of :maximum, Number
1372
+ object_of :exclusiveMinimum, Boolean
1373
+ object_of :exclusiveMaximum, Boolean
1374
+ object_of :minItems, Integer
1375
+ object_of :maxItems, Integer
1376
+ object_of :uniqueItems, Boolean
1377
+ object_of :pattern, String
1378
+ object_of :minLength, Integer
1379
+ object_of :maxLength, Integer
1380
+ array_of :enum, Array
1381
+ object_of :title, String
1382
+ object_of :description, String
1383
+ object_of :format, String
1384
+ object_of :divisibleBy, Number
1385
+ object_of :disallow, Object
1386
+ object_of :extends, Object
1387
+ object_of :id, String
1388
+ object_of :$ref, String
1389
+ object_of :$schema, String
1390
+ end
1391
+
1392
+ end
1393
+ class HyperSchema < Schema
1394
+
1395
+ def self.load_members
1396
+ array_of :links, Links
1397
+ object_of :fragmentResolution, String
1398
+ object_of :readonly, Boolean
1399
+ object_of :contentEncoding, String
1400
+ object_of :pathStart, String
1401
+ object_of :mediaType, String
1402
+ end
1403
+
1404
+ end
1405
+ class PlanList < Base
1406
+
1407
+ def self.load_members
1408
+ array_of :plans, Plan
1409
+ object_of :total_items, String
1410
+ object_of :total_pages, String
1411
+ array_of :links, Links
1412
+ end
1413
+
1414
+ end
1415
+ class Agreement < Base
1416
+
1417
+ def self.load_members
1418
+ object_of :id, String
1419
+ object_of :name, String
1420
+ object_of :description, String
1421
+ object_of :start_date, String
1422
+ object_of :payer, Payer
1423
+ object_of :shipping_address, Address
1424
+ object_of :override_merchant_preferences, MerchantPreferences
1425
+ array_of :override_charge_models, OverrideChargeModel
1426
+ object_of :plan, Plan
1427
+ object_of :create_time, String
1428
+ object_of :update_time, String
1429
+ array_of :links, Links
1430
+ end
1431
+
1432
+ include RequestDataType
1433
+
1434
+ def create()
1435
+ path = "v1/payments/billing-agreements/"
1436
+ response = api.post(path, self.to_hash, http_header)
1437
+ self.merge!(response)
1438
+ success?
1439
+ end
1440
+
1441
+ def execute()
1442
+ path = "v1/payments/billing-agreements/#{self.id}/agreement-execute"
1443
+ response = api.post(path, {}, http_header)
1444
+ self.merge!(response)
1445
+ success?
1446
+ end
1447
+
1448
+ class << self
1449
+ def find(resource_id)
1450
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
1451
+ path = "v1/payments/billing-agreements/#{resource_id}"
1452
+ self.new(api.get(path))
1453
+ end
1454
+ end
1455
+
1456
+ def update(patch_request)
1457
+ patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
1458
+ path = "v1/payments/billing-agreements/#{self.id}"
1459
+ response = api.patch(path, patch_request.to_hash, http_header)
1460
+ self.merge!(response)
1461
+ success?
1462
+ end
1463
+
1464
+ def suspend(agreement_state_descriptor)
1465
+ agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
1466
+ path = "v1/payments/billing-agreements/#{self.id}/suspend"
1467
+ response = api.post(path, agreement_state_descriptor.to_hash, http_header)
1468
+ self.merge!(response)
1469
+ success?
1470
+ end
1471
+
1472
+ def re_activate(agreement_state_descriptor)
1473
+ agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
1474
+ path = "v1/payments/billing-agreements/#{self.id}/re-activate"
1475
+ response = api.post(path, agreement_state_descriptor.to_hash, http_header)
1476
+ self.merge!(response)
1477
+ success?
1478
+ end
1479
+
1480
+ def cancel(agreement_state_descriptor)
1481
+ agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
1482
+ path = "v1/payments/billing-agreements/#{self.id}/cancel"
1483
+ response = api.post(path, agreement_state_descriptor.to_hash, http_header)
1484
+ self.merge!(response)
1485
+ success?
1486
+ end
1487
+
1488
+ def bill_balance(agreement_state_descriptor)
1489
+ agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
1490
+ path = "v1/payments/billing-agreements/#{self.id}/bill-balance"
1491
+ response = api.post(path, agreement_state_descriptor.to_hash, http_header)
1492
+ self.merge!(response)
1493
+ success?
1494
+ end
1495
+
1496
+ def set_balance(currency)
1497
+ currency = Currency.new(currency) unless currency.is_a? Currency
1498
+ path = "v1/payments/billing-agreements/#{self.id}/set-balance"
1499
+ response = api.post(path, currency.to_hash, http_header)
1500
+ self.merge!(response)
1501
+ success?
1502
+ end
1503
+
1504
+ class << self
1505
+ def transactions(options = {})
1506
+ path = "v1/payments/billing-agreements/{agreement-id}/transactions"
1507
+ AgreementTransactions.new(api.get(path, options))
1508
+ end
1509
+ end
1510
+
1511
+ end
1512
+ class OverrideChargeModel < Base
1513
+
1514
+ def self.load_members
1515
+ object_of :charge_id, String
1516
+ object_of :amount, Currency
1517
+ end
1518
+
1519
+ end
1520
+ class AgreementStateDescriptor < Base
1521
+
1522
+ def self.load_members
1523
+ object_of :note, String
1524
+ object_of :amount, Currency
1525
+ end
1526
+
1527
+ end
1528
+ class AgreementTransactions < Base
1529
+
1530
+ def self.load_members
1531
+ array_of :agreement_transaction_list, AgreementTransaction
1532
+ end
1533
+
1534
+ end
1535
+ class AgreementTransaction < Base
1536
+
1537
+ def self.load_members
1538
+ object_of :transaction_id, String
1539
+ object_of :status, String
1540
+ object_of :transaction_type, String
1541
+ object_of :amount, Currency
1542
+ object_of :fee_amount, Currency
1543
+ object_of :net_amount, Currency
1544
+ object_of :payer_email, String
1545
+ object_of :payer_name, String
1546
+ object_of :time_updated, String
1547
+ object_of :time_zone, String
1548
+ end
1549
+
1550
+ end
1551
+ class WebProfile < Base
1552
+
1553
+ def self.load_members
1554
+ object_of :id, String
1555
+ object_of :name, String
1556
+ object_of :flow_config, FlowConfig
1557
+ object_of :input_fields, InputFields
1558
+ object_of :presentation, Presentation
1559
+ end
1560
+
1561
+ include RequestDataType
1562
+
1563
+ def create()
1564
+ path = "v1/payment-experience/web-profiles/"
1565
+ response = api.post(path, self.to_hash, http_header)
1566
+ CreateProfileResponse.new(response)
1567
+ end
1568
+
1569
+ def update()
1570
+ path = "v1/payment-experience/web-profiles/#{self.id}"
1571
+ response = api.put(path, self.to_hash, http_header)
1572
+ self.merge!(response)
1573
+ success?
1574
+ end
1575
+
1576
+ def partial_update(patch_request)
1577
+ patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
1578
+ path = "v1/payment-experience/web-profiles/#{self.id}"
1579
+ response = api.patch(path, patch_request.to_hash, http_header)
1580
+ self.merge!(response)
1581
+ success?
1582
+ end
1583
+
1584
+ class << self
1585
+ def find(resource_id)
1586
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
1587
+ path = "v1/payment-experience/web-profiles/#{resource_id}"
1588
+ self.new(api.get(path))
1589
+ end
1590
+ end
1591
+
1592
+ class << self
1593
+ def get_list(options = {})
1594
+ path = "v1/payment-experience/web-profiles/"
1595
+ WebProfileList.new(api.get(path, options))
1596
+ end
1597
+ end
1598
+
1599
+ def delete()
1600
+ path = "v1/payment-experience/web-profiles/#{self.id}"
1601
+ response = api.delete(path, {})
1602
+ self.merge!(response)
1603
+ success?
1604
+ end
1605
+
1606
+ end
1607
+ class FlowConfig < Base
1608
+
1609
+ def self.load_members
1610
+ object_of :landing_page_type, String
1611
+ object_of :bank_txn_pending_url, String
1612
+ end
1613
+
1614
+ end
1615
+ class InputFields < Base
1616
+
1617
+ def self.load_members
1618
+ object_of :allow_note, Boolean
1619
+ object_of :no_shipping, Integer
1620
+ object_of :address_override, Integer
1621
+ end
1622
+
1623
+ end
1624
+ class Presentation < Base
1625
+
1626
+ def self.load_members
1627
+ object_of :brand_name, String
1628
+ object_of :logo_image, String
1629
+ object_of :locale_code, String
1630
+ end
1631
+
1632
+ end
1633
+ class CreateProfileResponse < Base
1634
+
1635
+ def self.load_members
1636
+ object_of :id, String
1637
+ end
1638
+
1639
+ end
1640
+ class WebProfileList < Base
1641
+
1642
+ def self.load_members
1643
+ object_of :id, String
1644
+ object_of :name, String
1645
+ object_of :flow_config, FlowConfig
1646
+ object_of :input_fields, InputFields
1647
+ object_of :presentation, Presentation
1648
+ end
1649
+
1650
+ end
1651
+
1652
+ constants.each do |data_type_klass|
1653
+ data_type_klass = const_get(data_type_klass)
1654
+ data_type_klass.load_members if defined? data_type_klass.load_members
1655
+ end
1656
+
1657
+ end
1658
+ end
1659
+ end