paypal-sdk-rest 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,420 +1,459 @@
1
- # Stub objects for REST
2
- # Auto generated code
3
-
4
- require 'uuidtools'
5
-
6
- require 'paypal-sdk-core'
7
-
8
- module PayPal::SDK
9
- module REST
10
- module DataTypes
11
-
12
- class DataType < Core::API::DataTypes::Base
13
- attr_accessor :error
14
- attr_writer :header, :request_id
15
-
16
- def header
17
- @header ||= {}
18
- end
19
-
20
- def request_id
21
- @request_id ||= UUIDTools::UUID.random_create.to_s
22
- end
23
-
24
- def http_header
25
- { "PayPal-Request-Id" => request_id.to_s }.merge(header)
26
- end
27
-
28
- def success?
29
- @error.nil?
30
- end
31
-
32
- def merge!(values)
33
- @error = nil
34
- super
35
- end
36
-
37
- def self.load_members
38
- end
39
- end
40
-
41
- class Resource < DataType
42
- end
43
-
44
- class EnumType < Core::API::DataTypes::Enum
45
- end
46
-
47
- class Refund < Resource
48
- def self.load_members
49
- object_of :id, String
50
- object_of :create_time, String
51
- object_of :update_time, String
52
- object_of :state, String
53
- object_of :amount, Amount
54
- object_of :sale_id, String
55
- object_of :capture_id, String
56
- object_of :parent_payment, String
57
- object_of :description, String
58
- array_of :links, Link
59
- end
60
-
61
- include RequestDataType
62
-
63
- class << self
64
- def find(refundid)
65
- raise ArgumentError.new("refundid required") if refundid.to_s.strip.empty?
66
- url = sprintf("v1/payments/refund/%s", refundid.to_s.strip)
67
- response = api.get(url)
68
- new(response)
69
- end
70
- end
71
- end
72
-
73
-
74
-
75
- class Resource < DataType
76
- def self.load_members
77
- end
78
- end
79
-
80
-
81
-
82
- class Amount < Resource
83
- def self.load_members
84
- object_of :total, String
85
- object_of :currency, String
86
- object_of :details, AmountDetails
87
- end
88
- end
89
-
90
-
91
-
92
- class AmountDetails < Resource
93
- def self.load_members
94
- object_of :subtotal, String
95
- object_of :tax, String
96
- object_of :shipping, String
97
- object_of :fee, String
98
- end
99
- end
100
-
101
-
102
-
103
- class Link < Resource
104
- def self.load_members
105
- object_of :href, String
106
- object_of :rel, String
107
- object_of :method, String
108
- end
109
- end
110
-
111
-
112
-
113
- class Payment < Resource
114
- def self.load_members
115
- object_of :id, String
116
- object_of :create_time, String
117
- object_of :update_time, String
118
- object_of :state, String
119
- object_of :intent, String
120
- object_of :payer, Payer
121
- array_of :transactions, Transaction
122
- object_of :redirect_urls, RedirectUrls
123
- array_of :links, Link
124
- end
125
-
126
- include RequestDataType
127
-
128
- class << self
129
- def all(options = {})
130
- url = "v1/payments/payment"
131
- response = api.get(url, options)
132
- PaymentHistory.new(response)
133
- end
134
- end
135
-
136
- def create()
137
- url = "v1/payments/payment"
138
- response = api.post(url, self.to_hash, self.http_header)
139
- self.merge!(response)
140
- success?
141
- end
142
-
143
- class << self
144
- def find(paymentid)
145
- raise ArgumentError.new("paymentid required") if paymentid.to_s.strip.empty?
146
- url = sprintf("v1/payments/payment/%s", paymentid.to_s.strip)
147
- response = api.get(url)
148
- new(response)
149
- end
150
- end
151
-
152
- def execute(payment_execution)
153
- raise ArgumentError.new("id required") if self.id.to_s.strip.empty?
154
- url = sprintf("v1/payments/payment/%s/execute", self.id.to_s.strip)
155
- payment_execution = PaymentExecution.new(payment_execution) unless payment_execution.is_a? PaymentExecution
156
- response = api.post(url, payment_execution.to_hash, payment_execution.http_header)
157
- self.merge!(response)
158
- success?
159
- end
160
- end
161
-
162
-
163
-
164
- class Payer < Resource
165
- def self.load_members
166
- object_of :payment_method, String
167
- object_of :payer_info, PayerInfo
168
- array_of :funding_instruments, FundingInstrument
169
- end
170
- end
171
-
172
-
173
-
174
- class PayerInfo < Resource
175
- def self.load_members
176
- object_of :email, String
177
- object_of :first_name, String
178
- object_of :last_name, String
179
- object_of :payer_id, String
180
- object_of :shipping_address, Address
181
- object_of :phone, String
182
- end
183
- end
184
-
185
-
186
-
187
- class Address < Resource
188
- def self.load_members
189
- object_of :line1, String
190
- object_of :line2, String
191
- object_of :city, String
192
- object_of :state, String
193
- object_of :postal_code, String
194
- object_of :country_code, String
195
- object_of :type, String
196
- object_of :phone, String
197
- end
198
- end
199
-
200
-
201
-
202
- class FundingInstrument < Resource
203
- def self.load_members
204
- object_of :credit_card, CreditCard
205
- object_of :credit_card_token, CreditCardToken
206
- end
207
- end
208
-
209
-
210
-
211
- class CreditCard < Resource
212
- def self.load_members
213
- object_of :id, String
214
- object_of :valid_until, String
215
- object_of :state, String
216
- object_of :payer_id, String
217
- object_of :type, String
218
- object_of :number, String
219
- object_of :expire_month, String
220
- object_of :expire_year, String
221
- object_of :cvv2, String
222
- object_of :first_name, String
223
- object_of :last_name, String
224
- object_of :billing_address, Address
225
- array_of :links, Link
226
- end
227
-
228
- include RequestDataType
229
-
230
- def create()
231
- url = "v1/vault/credit-card"
232
- response = api.post(url, self.to_hash, self.http_header)
233
- self.merge!(response)
234
- success?
235
- end
236
-
237
- class << self
238
- def find(creditcardid)
239
- raise ArgumentError.new("creditcardid required") if creditcardid.to_s.strip.empty?
240
- url = sprintf("v1/vault/credit-card/%s", creditcardid.to_s.strip)
241
- response = api.get(url)
242
- new(response)
243
- end
244
- end
245
- end
246
-
247
-
248
-
249
- class CreditCardToken < Resource
250
- def self.load_members
251
- object_of :credit_card_id, String
252
- object_of :payer_id, String
253
- end
254
- end
255
-
256
-
257
-
258
- class Transaction < Resource
259
- def self.load_members
260
- object_of :amount, Amount
261
- object_of :payee, Payee
262
- object_of :description, String
263
- object_of :item_list, ItemList
264
- array_of :related_resources, SubTransaction
265
- end
266
- end
267
-
268
-
269
-
270
- class Payee < Resource
271
- def self.load_members
272
- object_of :merchant_id, String
273
- object_of :email, String
274
- object_of :phone, String
275
- end
276
- end
277
-
278
-
279
-
280
- class ItemList < Resource
281
- def self.load_members
282
- array_of :items, Item
283
- object_of :shipping_address, ShippingAddress
284
- end
285
- end
286
-
287
-
288
-
289
- class Item < Resource
290
- def self.load_members
291
- object_of :name, String
292
- object_of :sku, String
293
- object_of :price, String
294
- object_of :currency, String
295
- object_of :quantity, String
296
- end
297
- end
298
-
299
-
300
-
301
- class ShippingAddress < Address
302
- def self.load_members
303
- object_of :recipient_name, String
304
- end
305
- end
306
-
307
-
308
-
309
- class SubTransaction < Resource
310
- def self.load_members
311
- object_of :sale, Sale
312
- object_of :authorization, Authorization
313
- object_of :refund, Refund
314
- object_of :capture, Capture
315
- end
316
- end
317
-
318
-
319
-
320
- class Sale < Resource
321
- def self.load_members
322
- object_of :id, String
323
- object_of :create_time, String
324
- object_of :update_time, String
325
- object_of :state, String
326
- object_of :amount, Amount
327
- object_of :parent_payment, String
328
- array_of :links, Link
329
- end
330
-
331
- include RequestDataType
332
-
333
- class << self
334
- def find(saleid)
335
- raise ArgumentError.new("saleid required") if saleid.to_s.strip.empty?
336
- url = sprintf("v1/payments/sale/%s", saleid.to_s.strip)
337
- response = api.get(url)
338
- new(response)
339
- end
340
- end
341
-
342
- def refund(refund)
343
- raise ArgumentError.new("id required") if self.id.to_s.strip.empty?
344
- url = sprintf("v1/payments/sale/%s/refund", self.id.to_s.strip)
345
- refund = Refund.new(refund) unless refund.is_a? Refund
346
- response = api.post(url, refund.to_hash, refund.http_header)
347
- Refund.new(response)
348
- end
349
- end
350
-
351
-
352
-
353
- class Authorization < Resource
354
- def self.load_members
355
- object_of :id, String
356
- object_of :create_time, String
357
- object_of :update_time, String
358
- object_of :state, String
359
- object_of :amount, Amount
360
- object_of :parent_payment, String
361
- array_of :links, Link
362
- end
363
- end
364
-
365
-
366
-
367
- class Capture < Resource
368
- def self.load_members
369
- object_of :id, String
370
- object_of :create_time, String
371
- object_of :update_time, String
372
- object_of :state, String
373
- object_of :amount, Amount
374
- object_of :parent_payment, String
375
- object_of :authorization_id, String
376
- object_of :description, String
377
- array_of :links, Link
378
- end
379
- end
380
-
381
-
382
-
383
- class RedirectUrls < Resource
384
- def self.load_members
385
- object_of :return_url, String
386
- object_of :cancel_url, String
387
- end
388
- end
389
-
390
-
391
-
392
- class PaymentExecution < Resource
393
- def self.load_members
394
- object_of :payer_id, String
395
- array_of :transactions, Amount
396
- end
397
- end
398
-
399
-
400
-
401
- class PaymentHistory < Resource
402
- def self.load_members
403
- array_of :payments, Payment
404
- object_of :count, Integer
405
- object_of :next_id, String
406
- end
407
- end
408
-
409
-
410
-
411
-
412
-
413
- constants.each do |data_type_klass|
414
- data_type_klass = const_get(data_type_klass)
415
- data_type_klass.load_members if defined? data_type_klass.load_members
416
- end
417
-
418
- end
419
- end
420
- 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
+ end
35
+
36
+ class Payment < Base
37
+
38
+ def self.load_members
39
+ object_of :id, String
40
+ object_of :create_time, DateTime
41
+ object_of :update_time, DateTime
42
+ object_of :intent, String
43
+ object_of :payer, Payer
44
+ array_of :transactions, Transaction
45
+ object_of :state, String
46
+ object_of :redirect_urls, RedirectUrls
47
+ array_of :links, Links
48
+ end
49
+
50
+ include RequestDataType
51
+
52
+ def create()
53
+ path = "v1/payments/payment"
54
+ response = api.post(path, self.to_hash, http_header)
55
+ self.merge!(response)
56
+ success?
57
+ end
58
+
59
+ class << self
60
+ def find(resource_id)
61
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
62
+ path = "v1/payments/payment/#{resource_id}"
63
+ self.new(api.get(path))
64
+ end
65
+ end
66
+
67
+ def execute(payment_execution)
68
+ payment_execution = PaymentExecution.new(payment_execution) unless payment_execution.is_a? PaymentExecution
69
+ path = "v1/payments/payment/#{self.id}/execute"
70
+ response = api.post(path, payment_execution.to_hash, http_header)
71
+ self.merge!(response)
72
+ success?
73
+ end
74
+
75
+ class << self
76
+ def all(options = {})
77
+ path = "v1/payments/payment"
78
+ PaymentHistory.new(api.get(path, options))
79
+ end
80
+ end
81
+
82
+ end
83
+ class Payer < Base
84
+
85
+ def self.load_members
86
+ object_of :payment_method, String
87
+ array_of :funding_instruments, FundingInstrument
88
+ object_of :payer_info, PayerInfo
89
+ end
90
+
91
+ end
92
+ class FundingInstrument < Base
93
+
94
+ def self.load_members
95
+ object_of :credit_card, CreditCard
96
+ object_of :credit_card_token, CreditCardToken
97
+ end
98
+
99
+ end
100
+ class CreditCard < Base
101
+
102
+ def self.load_members
103
+ object_of :id, String
104
+ object_of :number, String
105
+ object_of :type, String
106
+ object_of :expire_month, Integer
107
+ object_of :expire_year, Integer
108
+ object_of :cvv2, String
109
+ object_of :first_name, String
110
+ object_of :last_name, String
111
+ object_of :billing_address, Address
112
+ object_of :payer_id, String
113
+ object_of :state, String
114
+ object_of :valid_until, String
115
+ array_of :links, Links
116
+ end
117
+
118
+ include RequestDataType
119
+
120
+ def create()
121
+ path = "v1/vault/credit-card"
122
+ response = api.post(path, self.to_hash, http_header)
123
+ self.merge!(response)
124
+ success?
125
+ end
126
+
127
+ class << self
128
+ def find(resource_id)
129
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
130
+ path = "v1/vault/credit-card/#{resource_id}"
131
+ self.new(api.get(path))
132
+ end
133
+ end
134
+
135
+ def delete()
136
+ path = "v1/vault/credit-card/#{self.id}"
137
+ response = api.delete(path, {})
138
+ self.merge!(response)
139
+ success?
140
+ end
141
+
142
+ end
143
+ class Address < Base
144
+
145
+ def self.load_members
146
+ object_of :line1, String
147
+ object_of :line2, String
148
+ object_of :city, String
149
+ object_of :country_code, String
150
+ object_of :postal_code, String
151
+ object_of :state, String
152
+ object_of :phone, String
153
+ end
154
+
155
+ end
156
+ class Links < Base
157
+
158
+ def self.load_members
159
+ object_of :href, String
160
+ object_of :rel, String
161
+ object_of :targetSchema, HyperSchema
162
+ object_of :method, String
163
+ object_of :enctype, String
164
+ object_of :schema, HyperSchema
165
+ end
166
+
167
+ end
168
+ class HyperSchema < Base
169
+
170
+ def self.load_members
171
+ array_of :links, Links
172
+ object_of :fragmentResolution, String
173
+ object_of :readonly, Boolean
174
+ object_of :contentEncoding, String
175
+ object_of :pathStart, String
176
+ object_of :mediaType, String
177
+ end
178
+
179
+ end
180
+ class CreditCardToken < Base
181
+
182
+ def self.load_members
183
+ object_of :credit_card_id, String
184
+ object_of :payer_id, String
185
+ object_of :last4, String
186
+ object_of :type, String
187
+ object_of :expire_month, Integer
188
+ object_of :expire_year, Integer
189
+ end
190
+
191
+ end
192
+ class PayerInfo < Base
193
+
194
+ def self.load_members
195
+ object_of :email, String
196
+ object_of :first_name, String
197
+ object_of :last_name, String
198
+ object_of :payer_id, String
199
+ object_of :phone, String
200
+ object_of :shipping_address, Address
201
+ end
202
+
203
+ end
204
+ class Transaction < Base
205
+
206
+ def self.load_members
207
+ object_of :amount, Amount
208
+ object_of :payee, Payee
209
+ object_of :description, String
210
+ object_of :item_list, ItemList
211
+ array_of :related_resources, RelatedResources
212
+ array_of :transactions, Transaction
213
+ end
214
+
215
+ end
216
+ class Amount < Base
217
+
218
+ def self.load_members
219
+ object_of :currency, String
220
+ object_of :total, String
221
+ object_of :details, Details
222
+ end
223
+
224
+ end
225
+ class Details < Base
226
+
227
+ def self.load_members
228
+ object_of :shipping, String
229
+ object_of :subtotal, String
230
+ object_of :tax, String
231
+ object_of :fee, String
232
+ end
233
+
234
+ end
235
+ class Payee < Base
236
+
237
+ def self.load_members
238
+ object_of :email, String
239
+ object_of :merchant_id, String
240
+ object_of :phone, String
241
+ end
242
+
243
+ end
244
+ class Item < Base
245
+
246
+ def self.load_members
247
+ object_of :quantity, String
248
+ object_of :name, String
249
+ object_of :price, String
250
+ object_of :currency, String
251
+ object_of :sku, String
252
+ end
253
+
254
+ end
255
+ class ShippingAddress < Address
256
+
257
+ def self.load_members
258
+ object_of :recipient_name, String
259
+ end
260
+
261
+ end
262
+ class ItemList < Base
263
+
264
+ def self.load_members
265
+ array_of :items, Item
266
+ object_of :shipping_address, ShippingAddress
267
+ end
268
+
269
+ end
270
+ class RelatedResources < Base
271
+
272
+ def self.load_members
273
+ object_of :sale, Sale
274
+ object_of :authorization, Authorization
275
+ object_of :capture, Capture
276
+ object_of :refund, Refund
277
+ end
278
+
279
+ end
280
+ class Sale < Base
281
+
282
+ def self.load_members
283
+ object_of :id, String
284
+ object_of :create_time, DateTime
285
+ object_of :update_time, DateTime
286
+ object_of :amount, Amount
287
+ object_of :state, String
288
+ object_of :parent_payment, String
289
+ array_of :links, Links
290
+ end
291
+
292
+ include RequestDataType
293
+
294
+ class << self
295
+ def find(resource_id)
296
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
297
+ path = "v1/payments/sale/#{resource_id}"
298
+ self.new(api.get(path))
299
+ end
300
+ end
301
+
302
+ def refund(refund)
303
+ refund = Refund.new(refund) unless refund.is_a? Refund
304
+ path = "v1/payments/sale/#{self.id}/refund"
305
+ response = api.post(path, refund.to_hash, http_header)
306
+ Refund.new(response)
307
+ end
308
+
309
+ end
310
+ class Authorization < Base
311
+
312
+ def self.load_members
313
+ object_of :id, String
314
+ object_of :create_time, DateTime
315
+ object_of :update_time, DateTime
316
+ object_of :amount, Amount
317
+ object_of :state, String
318
+ object_of :parent_payment, String
319
+ object_of :valid_until, String
320
+ array_of :links, Links
321
+ end
322
+
323
+ include RequestDataType
324
+
325
+ class << self
326
+ def find(resource_id)
327
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
328
+ path = "v1/payments/authorization/#{resource_id}"
329
+ self.new(api.get(path))
330
+ end
331
+ end
332
+
333
+ def capture(capture)
334
+ capture = Capture.new(capture) unless capture.is_a? Capture
335
+ path = "v1/payments/authorization/#{self.id}/capture"
336
+ response = api.post(path, capture.to_hash, http_header)
337
+ Capture.new(response)
338
+ end
339
+
340
+ def void()
341
+ path = "v1/payments/authorization/#{self.id}/void"
342
+ response = api.post(path, {}, http_header)
343
+ self.merge!(response)
344
+ success?
345
+ end
346
+
347
+ def reauthorize()
348
+ path = "v1/payments/authorization/#{self.id}/reauthorize"
349
+ response = api.post(path, self.to_hash, http_header)
350
+ self.merge!(response)
351
+ success?
352
+ end
353
+
354
+ end
355
+ class Capture < Base
356
+
357
+ def self.load_members
358
+ object_of :id, String
359
+ object_of :create_time, DateTime
360
+ object_of :update_time, DateTime
361
+ object_of :amount, Amount
362
+ object_of :is_final_capture, Boolean
363
+ object_of :state, String
364
+ object_of :parent_payment, String
365
+ array_of :links, Links
366
+ end
367
+
368
+ include RequestDataType
369
+
370
+ class << self
371
+ def find(resource_id)
372
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
373
+ path = "v1/payments/capture/#{resource_id}"
374
+ self.new(api.get(path))
375
+ end
376
+ end
377
+
378
+ def refund(refund)
379
+ refund = Refund.new(refund) unless refund.is_a? Refund
380
+ path = "v1/payments/capture/#{self.id}/refund"
381
+ response = api.post(path, refund.to_hash, http_header)
382
+ Refund.new(response)
383
+ end
384
+
385
+ end
386
+ class Refund < Base
387
+
388
+ def self.load_members
389
+ object_of :id, String
390
+ object_of :create_time, DateTime
391
+ object_of :amount, Amount
392
+ object_of :state, String
393
+ object_of :sale_id, String
394
+ object_of :capture_id, String
395
+ object_of :parent_payment, String
396
+ array_of :links, Links
397
+ end
398
+
399
+ include RequestDataType
400
+
401
+ class << self
402
+ def find(resource_id)
403
+ raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
404
+ path = "v1/payments/refund/#{resource_id}"
405
+ self.new(api.get(path))
406
+ end
407
+ end
408
+
409
+ end
410
+ class RedirectUrls < Base
411
+
412
+ def self.load_members
413
+ object_of :return_url, String
414
+ object_of :cancel_url, String
415
+ end
416
+
417
+ end
418
+ class PaymentHistory < Base
419
+
420
+ def self.load_members
421
+ array_of :payments, Payment
422
+ object_of :count, Integer
423
+ object_of :next_id, String
424
+ end
425
+
426
+ end
427
+ class PaymentExecution < Base
428
+
429
+ def self.load_members
430
+ object_of :payer_id, String
431
+ array_of :transactions, Transactions
432
+ end
433
+
434
+ end
435
+ class Transactions < Base
436
+
437
+ def self.load_members
438
+ object_of :amount, Amount
439
+ end
440
+
441
+ end
442
+ class CreditCardHistory < Base
443
+
444
+ def self.load_members
445
+ array_of :"credit-cards", CreditCard
446
+ object_of :count, Integer
447
+ object_of :next_id, String
448
+ end
449
+
450
+ end
451
+
452
+ constants.each do |data_type_klass|
453
+ data_type_klass = const_get(data_type_klass)
454
+ data_type_klass.load_members if defined? data_type_klass.load_members
455
+ end
456
+
457
+ end
458
+ end
459
+ end