paypal-rest-api 0.3.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +97 -16
  3. data/VERSION +1 -1
  4. data/lib/paypal-api/api_collections/authentication.rb +1 -1
  5. data/lib/paypal-api/api_collections/authorized_payments.rb +1 -1
  6. data/lib/paypal-api/api_collections/captured_payments.rb +1 -1
  7. data/lib/paypal-api/api_collections/catalog_products.rb +1 -1
  8. data/lib/paypal-api/api_collections/disputes.rb +1 -1
  9. data/lib/paypal-api/api_collections/invoice_templates.rb +1 -1
  10. data/lib/paypal-api/api_collections/invoices.rb +1 -1
  11. data/lib/paypal-api/api_collections/orders.rb +1 -1
  12. data/lib/paypal-api/api_collections/partner_referrals.rb +48 -0
  13. data/lib/paypal-api/api_collections/payment_experience_web_profiles.rb +94 -0
  14. data/lib/paypal-api/api_collections/payment_tokens.rb +70 -0
  15. data/lib/paypal-api/api_collections/payout_items.rb +1 -1
  16. data/lib/paypal-api/api_collections/payouts.rb +1 -1
  17. data/lib/paypal-api/api_collections/referenced_payout_items.rb +2 -2
  18. data/lib/paypal-api/api_collections/referenced_payouts.rb +1 -1
  19. data/lib/paypal-api/api_collections/refunds.rb +1 -1
  20. data/lib/paypal-api/api_collections/setup_tokens.rb +47 -0
  21. data/lib/paypal-api/api_collections/shipment_tracking.rb +1 -1
  22. data/lib/paypal-api/api_collections/subscription_plans.rb +1 -1
  23. data/lib/paypal-api/api_collections/subscriptions.rb +1 -1
  24. data/lib/paypal-api/api_collections/transaction_search.rb +46 -0
  25. data/lib/paypal-api/api_collections/user_info.rb +1 -1
  26. data/lib/paypal-api/api_collections/users.rb +2 -2
  27. data/lib/paypal-api/api_collections/webhook_events.rb +1 -1
  28. data/lib/paypal-api/api_collections/webhook_lookups.rb +1 -1
  29. data/lib/paypal-api/api_collections/webhooks.rb +1 -1
  30. data/lib/paypal-api/client/access_token_methods.rb +36 -0
  31. data/lib/paypal-api/client/api_methods.rb +140 -0
  32. data/lib/paypal-api/client/environment_methods.rb +34 -0
  33. data/lib/paypal-api/client/http_methods.rb +70 -0
  34. data/lib/paypal-api/client.rb +5 -215
  35. data/lib/paypal-api/error.rb +3 -1
  36. data/lib/paypal-api/request.rb +47 -22
  37. data/lib/paypal-api/request_executor.rb +32 -15
  38. data/lib/paypal-api/response.rb +68 -0
  39. data/lib/paypal-api.rb +27 -3
  40. metadata +12 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb41159069ce06e4af428ec51fd553c176383626ac51eae019484f7bf65d22c8
4
- data.tar.gz: 6c91629dd7dc266198642ae2ed4606c764cf8e376a39695fb7fbdf5ebfd22e28
3
+ metadata.gz: dbd16b786c08d41262b404eb893480c37dbd1b4084dcb4f26a5d7f849d187970
4
+ data.tar.gz: 720a713a163ca01db1e414149673f416e484616d2e86442eb75ac0d17a29620a
5
5
  SHA512:
6
- metadata.gz: 4dfa83c73dbf06ac3badf8151241baa837a075f17bbe40927b8b1280bbff3867bdf8da3b4ed2e4b4126530767019aabf82899941edc0efeccdca42eba7d597e5
7
- data.tar.gz: '08df1fc1d94b9c395e684a366aed64c50f94a2e357ee1d0ddb0894ba2bd5db7a2a8513799caa6138c87784fe1932f7bbcd8028f0c679e843fa9f0cfbe9b97f69'
6
+ metadata.gz: d7d63364e602fe0ae3840fefcf68efbd4432243fb337ef8c4a42ec45d8e3744565456696b8f06d04c426520d25c27dd21a0447df9e6ff7017d4c6556453ca568
7
+ data.tar.gz: 02ebf31571711bb7a0a347b38d8c0c6c116d6ec2bb135912a6ed1da7cc499a469f2cabb3ccd0c9317dbad520e101eabdc3006422fa3498e9df7bb518cc537e8b
data/README.md CHANGED
@@ -1,3 +1,8 @@
1
+ [![Gem Version](https://badge.fury.io/rb/paypal-rest-api.svg)](https://badge.fury.io/rb/paypal-rest-api)
2
+ [![GitHub Actions](https://github.com/aglushkov/paypal-rest-api/actions/workflows/main.yml/badge.svg?event=push)](https://github.com/aglushkov/paypal-rest-api/actions/workflows/main.yml)
3
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/11efd530f1df171dac2b/test_coverage)](https://codeclimate.com/github/aglushkov/paypal-rest-api/test_coverage)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/11efd530f1df171dac2b/maintainability)](https://codeclimate.com/github/aglushkov/paypal-rest-api/maintainability)
5
+
1
6
  # PaypalAPI
2
7
 
3
8
  ## Installation
@@ -10,12 +15,13 @@ bundle add paypal-rest-api
10
15
 
11
16
  - Supported Ruby Versions - *(2.6 .. 3.3), head, jruby-9.4, truffleruby-24*
12
17
  - No dependencies;
13
- - Automatic authorization & reauthorization;
18
+ - Automatic authorization & re-authorization;
14
19
  - Auto-retries (configured);
15
20
  - Automatically added Paypal-Request-Id header for idempotent requests if not
16
21
  provided;
17
22
  - Webhooks Offline verification (needs to download certificate once)
18
23
  - Custom callbacks before/after request
24
+ - Automatic pagination methods
19
25
 
20
26
  ## Usage
21
27
 
@@ -39,7 +45,7 @@ PaypalAPI.live? # => false
39
45
  PaypalAPI.api_url # => "https://api-m.sandbox.paypal.com"
40
46
  PaypalAPI.web_url # => "https://sandbox.paypal.com"
41
47
 
42
- response = between redeploys::Orders.show(order_id)
48
+ response = PaypalAPI::Orders.show(order_id)
43
49
  response = PaypalAPI::Orders.create(body: body)
44
50
  ```
45
51
 
@@ -80,22 +86,42 @@ response = PaypalAPI.put(path, query: query, body: body, headers: headers)
80
86
  response = PaypalAPI.delete(path, query: query, body: body, headers: headers)
81
87
  ```
82
88
 
83
- ### Parsing response
89
+ ### Response
84
90
 
85
- `response.body` is a main method that returns parsed JSON respoonse as a Hash.
91
+ `Response` object is returned after each `API` request.
86
92
 
87
- There are also many others helpful methods:
93
+ #### Original HTTP response data
88
94
 
89
- ```ruby
90
- response.body # Parsed JSON. JSON is parsed lazyly, keys are symbolized.
91
- response[:foo] # Gets :foo attribute from parsed body
92
- response.fetch(:foo) # Fetches :foo attribute from parsed body
93
- response.http_response # original Net::HTTP::Response
94
- response.http_body # original response string
95
- response.http_status # Integer http status
96
- response.http_headers # Hash with response headers (keys are strings)
97
- response.request # Request that generates this response
98
- ```
95
+ - `response.http_status` - response HTTP status as Integer
96
+ - `response.http_body` - response body as String
97
+ - `response.http_headers` - response headers as Hash with String keys
98
+ - `response.http_response` - original Net::HTTP::Response object
99
+ - `response.request` - Request object that was used to get this response
100
+
101
+ #### Parsed JSON body methods
102
+
103
+ - `response.body` - parsed JSON body, keys are Symbols
104
+ - `response[:field]` - gets `:field` attribute from parsed body,
105
+ returns nil if response have no such key
106
+ - `response.fetch(:field)` - gets `:field` attribute from parsed body,
107
+ raises KeyError if response has no such key
108
+
109
+ #### Error check methods
110
+
111
+ - `response.success?` - checks HTTP status code is 2xx
112
+ - `response.failed?` - checks HTTP status code is not 2xx
113
+
114
+ #### Using HATEOAS links
115
+
116
+ - `response.follow_up_link('approve', query: nil, body: nil, headers: nil)` -
117
+ Finds HATEOAS link is response with `rel=approve` and requests it. Returns
118
+ `nil` if no such link were found.
119
+
120
+ #### Pagination (see [Automatic Pagination][automatic_pagination] for examples)
121
+
122
+ - `response.each_page { |response| ... }` - iterates over each page in response
123
+ - `response.each_page_item(items_field) { |item| ... }` - iterates over each
124
+ page item
99
125
 
100
126
  ## Configuration options
101
127
 
@@ -130,7 +156,7 @@ Retries happen on any network error, on 409, 429, 5xx response status code.
130
156
 
131
157
  ```ruby
132
158
  client = PaypalAPI::Client.new(
133
- retries: {count: 2, sleep: [0, 0]}
159
+ retries: {enabled: !Rails.env.test?, count: 5, sleep: [0, 0.25, 0.75, 1.5, 2]}
134
160
  # ...
135
161
  )
136
162
  ```
@@ -168,6 +194,28 @@ client = PaypalAPI::Client.new(
168
194
  )
169
195
  ```
170
196
 
197
+ ## Automatic pagination
198
+
199
+ PayPal provides HATEOAS links in responses. This links can contain items with
200
+ `rel=next` attribute. We request next pages using this links.
201
+
202
+ We have two specific methods:
203
+
204
+ - `Response#each_page` - iterates over each page `Response` object
205
+ - `Response#each_page_item(items_field_name)` - iterates over items on each page
206
+
207
+ Example:
208
+
209
+ ```ruby
210
+ PaypalAPI::WebhookEvents.list(page_size: 25).each_page do |response|
211
+ # ...
212
+ end
213
+
214
+ PaypalAPI::WebhookEvents.list(page_size: 25).each_page_item(:events) do |hash|
215
+ # ...
216
+ end
217
+ ```
218
+
171
219
  ## Webhoooks verification
172
220
 
173
221
  Webhooks can be verified [offline](https://developer.paypal.com/api/rest/webhooks/rest/#link-selfverificationmethod)
@@ -351,6 +399,18 @@ All API endpoints accept this parameters:
351
399
  - `PaypalAPI::Orders.track`
352
400
  - `PaypalAPI::Orders.update_tracker`
353
401
 
402
+ ### Payment Tokens
403
+
404
+ - `PaypalAPI::PaymentTokens.create`
405
+ - `PaypalAPI::PaymentTokens.list`
406
+ - `PaypalAPI::PaymentTokens.show`
407
+ - `PaypalAPI::PaymentTokens.delete`
408
+
409
+ <!-- -->
410
+
411
+ - `PaypalAPI::SetupTokens.create`
412
+ - `PaypalAPI::SetupTokens.show`
413
+
354
414
  ### Payments
355
415
 
356
416
  - `PaypalAPI::AuthorizedPayments.show`
@@ -497,6 +557,25 @@ All API endpoints accept this parameters:
497
557
  - `PaypalAPI::ReferencedPayoutItems.create`
498
558
  - `PaypalAPI::ReferencedPayoutItems.show`
499
559
 
560
+ ### PartnerReferrals
561
+
562
+ - `PaypalAPI::PartnerReferrals.create`
563
+ - `PaypalAPI::PartnerReferrals.show`
564
+
565
+ ### PaymentExperienceWebProfiles
566
+
567
+ - `PaypalAPI::PaymentExperienceWebProfiles.create`
568
+ - `PaypalAPI::PaymentExperienceWebProfiles.list`
569
+ - `PaypalAPI::PaymentExperienceWebProfiles.show`
570
+ - `PaypalAPI::PaymentExperienceWebProfiles.replace`
571
+ - `PaypalAPI::PaymentExperienceWebProfiles.update`
572
+ - `PaypalAPI::PaymentExperienceWebProfiles.delete`
573
+
574
+ ### TransactionSearch
575
+
576
+ - `PaypalAPI::TransactionSearch.list_transactions`
577
+ - `PaypalAPI::TransactionSearch.list_all_balances`
578
+
500
579
  ## Development
501
580
 
502
581
  ```bash
@@ -512,3 +591,5 @@ Bug reports and pull requests are welcome on GitHub at <https://github.com/aglus
512
591
  ## License
513
592
 
514
593
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
594
+
595
+ [automatic_pagination]: #automatic-pagination
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.5.0
@@ -13,7 +13,7 @@ module PaypalAPI
13
13
  PATH = "/v1/oauth2/token"
14
14
 
15
15
  #
16
- # Common class and instance methods
16
+ # Common methods for PayplaAPI::Authentication class and client.authentication instance
17
17
  #
18
18
  module APIs
19
19
  #
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class AuthorizedPayments < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PayplaAPI::AuthorizedPayments class and client.authorized_payments instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class CapturedPayments < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::CapturedPayments class and client.captured_payments instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class CatalogProducts < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::CatalogProducts class and client.catalog_products instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class Disputes < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::Disputes class and client.disputes instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class InvoiceTemplates < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::InvoiceTemplates class and client.invoice_templates instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class Invoices < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::Invoices class and client.invoices instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class Orders < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::Orders class and client.orders instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaypalAPI
4
+ #
5
+ # Use the Partner Referrals API to add PayPal seller accounts to PayPal
6
+ # Complete Payments Platform for Marketplaces and Platforms.
7
+ #
8
+ # @see https://developer.paypal.com/docs/api/partner-referrals/v2/
9
+ #
10
+ class PartnerReferrals < APICollection
11
+ #
12
+ # Common methods for PaypalAPI::PartnerReferrals class and client.partner_referrals instance
13
+ #
14
+ module APIs
15
+ # @!macro [new] request
16
+ # @param query [Hash, nil] Request query parameters
17
+ # @param body [Hash, nil] Request body parameters
18
+ # @param headers [Hash, nil] Request headers
19
+ # @return [Response] Response object
20
+
21
+ #
22
+ # Create partner referral
23
+ #
24
+ # @see https://developer.paypal.com/docs/api/partner-referrals/v2/#partner-referrals_create
25
+ #
26
+ # @macro request
27
+ #
28
+ def create(query: nil, body: nil, headers: nil)
29
+ client.post("/v2/customer/partner-referrals", query: query, body: body, headers: headers)
30
+ end
31
+
32
+ #
33
+ # Show referral data
34
+ #
35
+ # @see https://developer.paypal.com/docs/api/partner-referrals/v2/#partner-referrals_read
36
+ #
37
+ # @param id [String] The ID of the partner-referrals data for which to show details
38
+ # @macro request
39
+ #
40
+ def show(partner_referral_id, query: nil, body: nil, headers: nil)
41
+ client.get("/v2/customer/partner-referrals/#{encode(partner_referral_id)}", query: query, body: body, headers: headers)
42
+ end
43
+ end
44
+
45
+ include APIs
46
+ extend APIs
47
+ end
48
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaypalAPI
4
+ #
5
+ # Use the Payment Experience API to create seamless payment experience profiles.
6
+ #
7
+ # @see https://developer.paypal.com/docs/api/orders/v2/
8
+ #
9
+ class PaymentExperienceWebProfiles < APICollection
10
+ #
11
+ # Common methods for PaypalAPI::PaymentExperienceWebProfiles class and client.orders instance
12
+ #
13
+ module APIs
14
+ # @!macro [new] request
15
+ # @param query [Hash, nil] Request query parameters
16
+ # @param body [Hash, nil] Request body parameters
17
+ # @param headers [Hash, nil] Request headers
18
+ # @return [Response] Response object
19
+
20
+ #
21
+ # Create web experience profile
22
+ #
23
+ # @see https://developer.paypal.com/docs/api/payment-experience/v1/#web-profile_create
24
+ #
25
+ # @macro request
26
+ #
27
+ def create(query: nil, body: nil, headers: nil)
28
+ client.post("/v1/payment-experience/web-profiles", query: query, body: body, headers: headers)
29
+ end
30
+
31
+ #
32
+ # List web experience profiles
33
+ #
34
+ # @see https://developer.paypal.com/docs/api/payment-experience/v1/#web-profile_get-list
35
+ #
36
+ # @macro request
37
+ #
38
+ def list(query: nil, body: nil, headers: nil)
39
+ client.get("/v1/payment-experience/web-profiles", query: query, body: body, headers: headers)
40
+ end
41
+
42
+ #
43
+ # Show web experience profile details by ID
44
+ #
45
+ # @see https://developer.paypal.com/docs/api/payment-experience/v1/#web-profile_get
46
+ #
47
+ # @param id [String] The ID of the profile for which to show details.
48
+ # @macro request
49
+ #
50
+ def show(id, query: nil, body: nil, headers: nil)
51
+ client.get("/v1/payment-experience/web-profiles/#{encode(id)}", query: query, body: body, headers: headers)
52
+ end
53
+
54
+ #
55
+ # Replace web experience profile
56
+ #
57
+ # @see https://developer.paypal.com/docs/api/payment-experience/v1/#web-profile_update
58
+ #
59
+ # @param id [String] The ID of the profile to replace.
60
+ # @macro request
61
+ #
62
+ def replace(id, query: nil, body: nil, headers: nil)
63
+ client.put("/v1/payment-experience/web-profiles/#{encode(id)}", query: query, body: body, headers: headers)
64
+ end
65
+
66
+ #
67
+ # Partially update web experience profile
68
+ #
69
+ # @see https://developer.paypal.com/docs/api/payment-experience/v1/#web-profile_partial-update
70
+ #
71
+ # @param id [String] The ID of the profile to update.
72
+ # @macro request
73
+ #
74
+ def update(id, query: nil, body: nil, headers: nil)
75
+ client.patch("/v1/payment-experience/web-profiles/#{encode(id)}", query: query, body: body, headers: headers)
76
+ end
77
+
78
+ #
79
+ # Delete web experience profile
80
+ #
81
+ # @see https://developer.paypal.com/docs/api/payment-experience/v1/#web-profile_delete
82
+ #
83
+ # @param id [String] The ID of the profile to delete.
84
+ # @macro request
85
+ #
86
+ def delete(id, query: nil, body: nil, headers: nil)
87
+ client.delete("/v1/payment-experience/web-profiles/#{encode(id)}", query: query, body: body, headers: headers)
88
+ end
89
+ end
90
+
91
+ include APIs
92
+ extend APIs
93
+ end
94
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaypalAPI
4
+ #
5
+ # Payment Method Tokens
6
+ #
7
+ # @see https://developer.paypal.com/docs/api/payment-tokens/v3/
8
+ #
9
+ class PaymentTokens < APICollection
10
+ #
11
+ # Common methods for PaypalAPI::PaymentTokens class and client.payment_tokens instance
12
+ #
13
+ module APIs
14
+ # @!macro [new] request
15
+ # @param query [Hash, nil] Request query parameters
16
+ # @param body [Hash, nil] Request body parameters
17
+ # @param headers [Hash, nil] Request headers
18
+ # @return [Response] Response object
19
+
20
+ #
21
+ # Create payment token for a given payment source
22
+ #
23
+ # @see https://developer.paypal.com/docs/api/payment-tokens/v3/#payment-tokens_create
24
+ #
25
+ # @macro request
26
+ #
27
+ def create(query: nil, body: nil, headers: nil)
28
+ client.post("/v3/vault/payment-tokens", query: query, body: body, headers: headers)
29
+ end
30
+
31
+ #
32
+ # List all payment tokens
33
+ #
34
+ # @see https://developer.paypal.com/docs/api/payment-tokens/v3/#customer_payment-tokens_get
35
+ #
36
+ # @macro request
37
+ #
38
+ def list(query: nil, body: nil, headers: nil)
39
+ client.get("/v3/vault/payment-tokens", query: query, body: body, headers: headers)
40
+ end
41
+
42
+ #
43
+ # Retrieve a payment token
44
+ #
45
+ # @see https://developer.paypal.com/docs/api/payment-tokens/v3/#payment-tokens_get
46
+ #
47
+ # @param id [String] ID of the payment token.
48
+ # @macro request
49
+ #
50
+ def show(id, query: nil, body: nil, headers: nil)
51
+ client.get("/v3/vault/payment-tokens/#{encode(id)}", query: query, body: body, headers: headers)
52
+ end
53
+
54
+ #
55
+ # Delete payment token
56
+ #
57
+ # @see https://developer.paypal.com/docs/api/payment-tokens/v3/#payment-tokens_delete
58
+ #
59
+ # @param id [String] ID of the payment token
60
+ # @macro request
61
+ #
62
+ def delete(id, query: nil, body: nil, headers: nil)
63
+ client.delete("/v3/vault/payment-tokens/#{encode(id)}", query: query, body: body, headers: headers)
64
+ end
65
+ end
66
+
67
+ include APIs
68
+ extend APIs
69
+ end
70
+ end
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class PayoutItems < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::PayoutItems class and client.payout_items instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class Payouts < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::Payouts class and client.payouts instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -4,11 +4,11 @@ module PaypalAPI
4
4
  #
5
5
  # Enables partner merchants and developers to process individual referenced payouts to recipients.
6
6
  #
7
- # @seehttps://developer.paypal.com/docs/api/referenced-payouts/v1/
7
+ # @see https://developer.paypal.com/docs/api/referenced-payouts/v1/
8
8
  #
9
9
  class ReferencedPayoutItems < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::ReferencedPayoutItems class and client.referenced_payout_items instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class ReferencedPayouts < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::ReferencedPayouts class and client.referenced_payouts instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class Refunds < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::Refunds class and client.refunds instance
12
12
  #
13
13
  module APIs
14
14
  #
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaypalAPI
4
+ #
5
+ # Payment Setup Tokens
6
+ #
7
+ # @see https://developer.paypal.com/docs/api/payment-tokens/v3/
8
+ #
9
+ class SetupTokens < APICollection
10
+ #
11
+ # Common methods for PaypalAPI::SetupTokens class and client.setup_tokens instance
12
+ #
13
+ module APIs
14
+ # @!macro [new] request
15
+ # @param query [Hash, nil] Request query parameters
16
+ # @param body [Hash, nil] Request body parameters
17
+ # @param headers [Hash, nil] Request headers
18
+ # @return [Response] Response object
19
+
20
+ #
21
+ # Create a setup token
22
+ #
23
+ # @see https://developer.paypal.com/docs/api/payment-tokens/v3/#setup-tokens_create
24
+ #
25
+ # @macro request
26
+ #
27
+ def create(query: nil, body: nil, headers: nil)
28
+ client.post("/v3/vault/setup-tokens", query: query, body: body, headers: headers)
29
+ end
30
+
31
+ #
32
+ # Retrieve a setup token
33
+ #
34
+ # @see https://developer.paypal.com/docs/api/payment-tokens/v3/#setup-tokens_get
35
+ #
36
+ # @param id [String] ID of the setup token.
37
+ # @macro request
38
+ #
39
+ def show(id, query: nil, body: nil, headers: nil)
40
+ client.get("/v3/vault/setup-tokens/#{encode(id)}", query: query, body: body, headers: headers)
41
+ end
42
+ end
43
+
44
+ include APIs
45
+ extend APIs
46
+ end
47
+ end
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class ShipmentTracking < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::ShipmentTracking class and client.shipment_tracking instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class SubscriptionPlans < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::SubscriptionPlans class and client.subscription_plans instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -8,7 +8,7 @@ module PaypalAPI
8
8
  #
9
9
  class Subscriptions < APICollection
10
10
  #
11
- # Common class and instance methods
11
+ # Common methods for PaypalAPI::Subscriptions class and client.subscriptions instance
12
12
  #
13
13
  module APIs
14
14
  # @!macro [new] request
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaypalAPI
4
+ #
5
+ # Use the Transaction Search API to get the history of transactions for a PayPal account.
6
+ #
7
+ # @see https://developer.paypal.com/docs/api/transaction-search/v1/
8
+ #
9
+ class TransactionSearch < APICollection
10
+ #
11
+ # Common methods for PaypalAPI::TransactionSearch class and client.transaction_search instance
12
+ #
13
+ module APIs
14
+ # @!macro [new] request
15
+ # @param query [Hash, nil] Request query parameters
16
+ # @param body [Hash, nil] Request body parameters
17
+ # @param headers [Hash, nil] Request headers
18
+ # @return [Response] Response object
19
+
20
+ #
21
+ # List transactions
22
+ #
23
+ # @see https://developer.paypal.com/docs/api/transaction-search/v1/#search_get
24
+ #
25
+ # @macro request
26
+ #
27
+ def list_transactions(query: nil, body: nil, headers: nil)
28
+ client.get("/v1/reporting/transactions", query: query, body: body, headers: headers)
29
+ end
30
+
31
+ #
32
+ # List all balances
33
+ #
34
+ # @see https://developer.paypal.com/docs/api/transaction-search/v1/#balances_get
35
+ #
36
+ # @macro request
37
+ #
38
+ def list_all_balances(query: nil, body: nil, headers: nil)
39
+ client.get("/v1/reporting/balances", query: query, body: body, headers: headers)
40
+ end
41
+ end
42
+
43
+ include APIs
44
+ extend APIs
45
+ end
46
+ end