square.rb 18.0.0.20220216 → 20.0.0.20220512

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
  SHA256:
3
- metadata.gz: d63ad56661f521ead949670191ddb004cf944daedf7836047c9281e8e6600ecf
4
- data.tar.gz: 548171c3a90103f2a2492166e6b69f9c0dd7855f1c20d656e4c7c1f922053e86
3
+ metadata.gz: 1907488e99eddc840ad5c67c38ac3feaacf9b6440359b6085add2d248388ab7a
4
+ data.tar.gz: e6647691aec85fd628b47ac329248f9171a33570bf0eb37871391f7e246a8014
5
5
  SHA512:
6
- metadata.gz: 4d5f5cdb0c4992a16eca7327a67642d9fcb807ae040b7c3426d5635ac3ef9f40ab9d144fe011b60c5ad996b81b098e49a3e4cf8a3e6aa3dd4742fab08fd6e1b3
7
- data.tar.gz: 56b7b2f269877ec3b2f867d608e0a803a066e74bc958d2e0f60e156a034360e872d0c7eccefa5d552a35b700f2c9cb83b364a942e96968a713ab33013069dea5
6
+ metadata.gz: 1b0d5825af20339f09f49466d34a46825bc25c995eba52108174d1e78ed58083cc1c5b280fecefe4f1edbf94a8ca45aba427c0c01feafac02b6e0b076224f749
7
+ data.tar.gz: 572efdbd9f3ebb6915ab82e2c2b554e5b2e53d764f6a64f05c4cfd5373118e73f97b9076ad0ce8d0dc70c3c5a540d29db5fb101ceb4bde7da8638e0edc4eb448
data/README.md CHANGED
@@ -6,30 +6,54 @@
6
6
  [![Gem version](https://badge.fury.io/rb/square.rb.svg?new)](https://badge.fury.io/rb/square.rb)
7
7
  [![Apache-2 license](https://img.shields.io/badge/license-Apache2-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0)
8
8
 
9
- Use this gem to integrate Square payments into your app and grow your business with Square APIs including Catalog, Customers, Employees, Inventory, Labor, Locations, and Orders.
9
+ Use this library to integrate Square payments into your app and grow your business with Square APIs including Catalog, Customers, Employees, Inventory, Labor, Locations, and Orders.
10
10
 
11
11
  ## Requirements
12
12
 
13
- We support Ruby 2.6 through 3.1.
13
+ Use of the Square Ruby SDK requires:
14
+
15
+ * Ruby 2.6 through 3.1
14
16
 
15
17
  ## Installation
16
18
 
17
- Install the gem from the command line:
19
+ For more information, see [Set Up Your Square SDK for a Ruby Project](https://developer.squareup.com/docs/sdks/ruby/setup-project).
20
+
21
+ ## Quickstart
22
+
23
+ For more information, see [Square Ruby SDK Quickstart](https://developer.squareup.com/docs/sdks/ruby/quick-start).
24
+
25
+ ## Usage
26
+ For more information, see [Using the Square Ruby SDK](https://developer.squareup.com/docs/sdks/ruby/using-ruby-sdk).
27
+
28
+ ## Tests
29
+
30
+ First, clone the repo locally and `cd` into the directory.
31
+
32
+ ```sh
33
+ git clone https://github.com/square/square-ruby-sdk.git
34
+ cd square-ruby-sdk
35
+ ```
36
+
37
+ Next, make sure Bundler is installed and install the development dependencies.
18
38
 
19
- ```ruby
20
- gem install square.rb
39
+ ```sh
40
+ gem install bundler
41
+ bundle
21
42
  ```
22
43
 
23
- Or add the gem to your Gemfile and `bundle`:
44
+ Before running the tests, find a sandbox token in your [Developer Dashboard] and set a `SQUARE_SANDBOX_TOKEN` environment variable.
24
45
 
25
- ```ruby
26
- gem 'square.rb'
46
+ ```sh
47
+ export SQUARE_SANDBOX_TOKEN="YOUR SANDBOX TOKEN HERE"
27
48
  ```
28
49
 
29
- ### API Client
30
- * [Client]
50
+ And run the tests.
31
51
 
32
- ## API documentation
52
+ ```sh
53
+ rake
54
+ ```
55
+
56
+ ## SDK Reference
33
57
 
34
58
  ### Payments
35
59
  * [Payments]
@@ -38,6 +62,7 @@ gem 'square.rb'
38
62
  * [Checkout]
39
63
  * [Apple Pay]
40
64
  * [Cards]
65
+ * [Payouts]
41
66
 
42
67
  ### Terminal
43
68
  * [Terminal]
@@ -57,6 +82,7 @@ gem 'square.rb'
57
82
 
58
83
  ### Customers
59
84
  * [Customers]
85
+ * [Customer Custom Attributes]
60
86
  * [Customer Groups]
61
87
  * [Customer Segments]
62
88
 
@@ -75,6 +101,7 @@ gem 'square.rb'
75
101
  * [Locations]
76
102
  * [Devices]
77
103
  * [Cash Drawers]
104
+ * [Vendors]
78
105
 
79
106
  ### Team
80
107
  * [Team]
@@ -98,216 +125,6 @@ gem 'square.rb'
98
125
  * [V1 Items]
99
126
  * [Transactions]
100
127
 
101
- ## Usage
102
-
103
- First time using Square? Here’s how to get started:
104
-
105
- 1. **Create a Square account.** If you don’t have one already, [sign up for a developer account].
106
- 1. **Create an application.** Go to your [Developer Dashboard] and create your first application. All you need to do is give it a name. When you’re doing this for your production application, enter the name as you would want a customer to see it.
107
- 1. **Make your first API call.** Almost all Square API calls require a location ID. You’ll make your first call to #list_locations, which happens to be one of the API calls that don’t require a location ID. For more information about locations, see the [Locations] API documentation.
108
-
109
- Now let’s call your first Square API. Open your favorite text editor, create a new file called `locations.rb`, and copy the following code into that file:
110
-
111
- ```ruby
112
- require 'square'
113
-
114
- # Create an instance of the API Client and initialize it with the credentials
115
- # for the Square account whose assets you want to manage.
116
-
117
- client = Square::Client.new(
118
- access_token: 'YOUR SANDBOX ACCESS TOKEN HERE',
119
- environment: 'sandbox'
120
- )
121
-
122
- # Call list_locations method to get all locations in this Square account
123
- result = client.locations.list_locations
124
-
125
- # Call the #success? method to see if the call succeeded
126
- if result.success?
127
- # The #data Struct contains a list of locations
128
- locations = result.data.locations
129
-
130
- # Iterate over the list
131
- locations.each do |location|
132
- # Each location is represented as a Hash
133
- location.each do |key, value|
134
- puts "#{key}: #{value}"
135
- end
136
- end
137
- else
138
- # Handle the case that the result is an error.
139
- warn 'Error calling LocationsApi.listlocations ...'
140
-
141
- # The #errors method returns an Array of error Hashes
142
- result.errors.each do |key, value|
143
- warn "#{key}: #{value}"
144
- end
145
- end
146
- ```
147
-
148
- Next, get an access token and reference it in your code. Go back to your application in the Developer Dashboard, in the Sandbox section click Show in the Sandbox Access Token box, copy that access token, and replace `'YOUR SANDBOX ACCESS TOKEN HERE'` with that token.
149
-
150
- **Important** When you eventually switch from trying things out on sandbox to actually working with your real production resources, you should not embed the access token in your code. Make sure you store and access your production access tokens securely.
151
-
152
- Now save `locations.rb` and run it:
153
-
154
- ```sh
155
- ruby locations.rb
156
- ```
157
-
158
- If your call is successful, you’ll get a response that looks like this:
159
-
160
- ```
161
- address : {'address_line_1': '1455 Market Street', 'administrative_district_level_1': 'CA', 'country': 'US', 'locality': 'San Francisco', 'postal_code': '94103'}
162
- # ...
163
- ```
164
-
165
- Yay! You successfully made your first call. If you didn’t, you would see an error message that looks something like this:
166
-
167
- ```
168
- Error calling LocationsApi.listlocations
169
- category : AUTHENTICATION_ERROR
170
- code : UNAUTHORIZED
171
- detail : This request could not be authorized.
172
- ```
173
-
174
- This error was returned when an invalid token was used to call the API.
175
-
176
- After you’ve tried out the Square APIs and tested your application using sandbox, you will want to switch to your production credentials so that you can manage real Square resources. Don't forget to switch your access token from sandbox to production for real data.
177
-
178
- ## SDK patterns
179
-
180
- If you know a few patterns, you’ll be able to call any API in the SDK. Here are some important ones:
181
-
182
- ### Get an access token
183
-
184
- To use the Square API to manage the resources (such as payments, orders, customers, etc.) of a Square account, you need to create an application (or use an existing one) in the Developer Dashboard and get an access token.
185
-
186
- When you call a Square API, you call it using an access key. An access key has specific permissions to resources in a specific Square account that can be accessed by a specific application in a specific developer account.
187
- Use an access token that is appropriate for your use case. There are two options:
188
-
189
- - To manage the resources for your own Square account, use the Personal Access Token for the application created in your Square account.
190
- - To manage resources for other Square accounts, use OAuth to ask owners of the accounts you want to manage so that you can work on their behalf. When you implement OAuth, you ask the Square account holder for permission to manage resources in their account (you can define the specific resources to access) and get an OAuth access token and refresh token for their account.
191
-
192
- **Important** For both use cases, make sure you store and access the tokens securely.
193
-
194
- ### Import and Instantiate the Client Class
195
-
196
- To use the Square API, you import the Client class, instantiate a Client object, and initialize it with the appropriate access token. Here’s how:
197
-
198
- - Instantiate a `Square::Client` object with the access token for the Square account whose resources you want to manage. To access sandbox resources, initialize the `Square::Client` with environment set to sandbox:
199
-
200
- ```ruby
201
- client = Square::Client.new(
202
- access_token: 'SANDBOX ACCESS TOKEN HERE',
203
- environment: 'sandbox'
204
- )
205
- ```
206
-
207
- - To access production resources, set environment to production:
208
-
209
- ```ruby
210
- client = Square::Client.new(
211
- access_token: 'ACCESS TOKEN HERE',
212
- environment: 'production'
213
- )
214
- ```
215
-
216
- - To set a custom environment provide a `custom_url`, and set environment to `custom`:
217
-
218
- ```ruby
219
- client = Square::Client.new(
220
- access_token:'ACCESS TOKEN HERE',
221
- environment: 'custom',
222
- custom_url: 'https://your.customdomain.com'
223
- )
224
- ```
225
-
226
- ### Get an Instance of an API object and call its methods
227
-
228
- Each API is implemented as a class. The Client object instantiates every API class and exposes them as properties so you can easily start using any Square API. You work with an API by calling methods on an instance of an API class. Here’s how:
229
-
230
- - Work with an API by calling the methods on the API object. For example, you would call list_customers to get a list of all customers in the Square account:
231
-
232
- ```ruby
233
- result = client.customers.list_customers
234
- ```
235
-
236
- See the SDK documentation for the list of methods for each API class.
237
-
238
- Pass complex parameters (such as create, update, search, etc.) as a Hash. For example, you would pass a Hash containing the values used to create a new customer using create_customer:
239
-
240
- ```ruby
241
- # Create a unique key for this creation operation so you don't accidentally
242
- # create the customer multiple times if you need to retry this operation.
243
- require 'securerandom'
244
-
245
- idempotency_key = SecureRandom.uuid
246
-
247
- # To create a customer, you'll need to specify at least a few required fields.
248
- request_body = {idempotency_key: idempotency_key, given_name: 'Amelia', family_name: 'Earhardt'}
249
-
250
- # Call create_customer method to create a new customer in this Square account
251
- result = client.customers.create_customer(request_body)
252
- ```
253
-
254
- If your call succeeds, you’ll see a response that looks like this:
255
-
256
- ```
257
- {'customer': {'created_at': '2019-06-28T21:23:05.126Z', 'creation_source': 'THIRD_PARTY', 'family_name': 'Earhardt', 'given_name': 'Amelia', 'id': 'CBASEDwl3El91nohQ2FLEk4aBfcgAQ', 'preferences': {'email_unsubscribed': False}, 'updated_at': '2019-06-28T21:23:05.126Z'}}
258
- ```
259
-
260
- - Use idempotency for create, update, or other calls that you want to avoid calling twice. To make an idempotent API call, you add the idempotency_key with a unique value in the Hash for the API call’s request.
261
- - Specify a location ID for APIs such as Transactions, Orders, and Checkout that deal with payments. When a payment or order is created in Square, it is always associated with a location.
262
-
263
- ### Handle the response
264
-
265
- API calls return a response object that contains properties that describe both the request (headers and request) and the response (status_code, reason_phrase, text, errors, body, and cursor). The response also has #success? and #error? helper methods so you can easily determine the success or failure of a call:
266
-
267
- ```ruby
268
- if result.success?
269
- p result.data
270
- elsif result.error?
271
- warn result.errors.inspect
272
- end
273
- ```
274
-
275
- - Read the response payload. The response payload is returned as a Struct from the #data method. For retrieve calls, a Struct containing a single item is returned with a key name that is the name of the object (for example, customer). For list calls, a Struct containing a Array of objects is returned with a key name that is the plural of the object name (for example, customers).
276
- - Make sure you get all items returned in a list call by checking the cursor value returned in the API response. When you call a list API the first time, set the cursor to an empty String or omit it from the API request. If the API response contains a cursor with a value, you call the API again to get the next page of items and continue to call that API again until the cursor is an empty String.
277
-
278
- ## Tests
279
-
280
- First, clone the repo locally and `cd` into the directory.
281
-
282
- ```sh
283
- git clone https://github.com/square/square-ruby-sdk.git
284
- cd square-ruby-sdk
285
- ```
286
-
287
- Next, make sure Bundler is installed and install the development dependencies.
288
-
289
- ```sh
290
- gem install bundler
291
- bundle
292
- ```
293
-
294
- Before running the tests, find a sandbox token in your [Developer Dashboard] and set a `SQUARE_SANDBOX_TOKEN` environment variable.
295
-
296
- ```sh
297
- export SQUARE_SANDBOX_TOKEN="YOUR SANDBOX TOKEN HERE"
298
- ```
299
-
300
- And run the tests.
301
-
302
- ```sh
303
- rake
304
- ```
305
-
306
- ## Learn more
307
-
308
- The Square Platform is built on the [Square API]. Square has a number of other SDKs that enable you to securely handle credit card information on both mobile and web so that you can process payments via the Square API.
309
-
310
- You can also use the Square API to create applications or services that work with payments, orders, inventory, etc. that have been created and managed in Square’s in-person hardware products (Square Point of Sale and Square Register).
311
128
 
312
129
  [//]: # "Link anchor definitions"
313
130
  [Square Logo]: https://docs.connect.squareup.com/images/github/github-square-logo.svg
@@ -320,6 +137,7 @@ You can also use the Square API to create applications or services that work wit
320
137
  [Terminal]: doc/api/terminal.md
321
138
  [Team]: doc/api/team.md
322
139
  [Cash Drawers]: doc/api/cash-drawers.md
140
+ [Vendors]: doc/api/vendors.md
323
141
  [Customer Groups]: doc/api/customer-groups.md
324
142
  [Customer Segments]: doc/api/customer-segments.md
325
143
  [Bank Accounts]: doc/api/bank-accounts.md
@@ -327,6 +145,7 @@ You can also use the Square API to create applications or services that work wit
327
145
  [Checkout]: doc/api/checkout.md
328
146
  [Catalog]: doc/api/catalog.md
329
147
  [Customers]: doc/api/customers.md
148
+ [Customer Custom Attributes]: doc/api/customer-custom-attributes.md
330
149
  [Employees]: doc/api/employees.md
331
150
  [Inventory]: doc/api/inventory.md
332
151
  [Labor]: doc/api/labor.md
@@ -348,5 +167,6 @@ You can also use the Square API to create applications or services that work wit
348
167
  [Sites]: doc/api/sites.md
349
168
  [Snippets]: doc/api/snippets.md
350
169
  [Cards]: doc/api/cards.md
170
+ [Payouts]: doc/api/payouts.md
351
171
  [Gift Cards]: doc/api/gift-cards.md
352
172
  [Gift Card Activities]: doc/api/gift-card-activities.md
@@ -38,7 +38,7 @@ module Square
38
38
  end
39
39
 
40
40
  def get_user_agent
41
- user_agent = 'Square-Ruby-SDK/18.0.0.20220216 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}'
41
+ user_agent = 'Square-Ruby-SDK/20.0.0.20220512 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}'
42
42
  user_agent['{engine}'] = RUBY_ENGINE
43
43
  user_agent['{engine-version}'] = RUBY_ENGINE_VERSION
44
44
  user_agent['{os-info}'] = RUBY_PLATFORM
@@ -74,6 +74,9 @@ module Square
74
74
  # `APPOINTMENTS_WRITE` for the OAuth scope.
75
75
  # To call this endpoint with seller-level permissions, set
76
76
  # `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
77
+ # For calls to this endpoint with seller-level permissions to succeed, the
78
+ # seller must have subscribed to *Appointments Plus*
79
+ # or *Appointments Premium*.
77
80
  # @param [CreateBookingRequest] body Required parameter: An object
78
81
  # containing the fields to POST for the request. See the corresponding
79
82
  # object definition for field details.
@@ -303,6 +306,9 @@ module Square
303
306
  # `APPOINTMENTS_WRITE` for the OAuth scope.
304
307
  # To call this endpoint with seller-level permissions, set
305
308
  # `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
309
+ # For calls to this endpoint with seller-level permissions to succeed, the
310
+ # seller must have subscribed to *Appointments Plus*
311
+ # or *Appointments Premium*.
306
312
  # @param [String] booking_id Required parameter: The ID of the
307
313
  # [Booking]($m/Booking) object representing the to-be-updated booking.
308
314
  # @param [UpdateBookingRequest] body Required parameter: An object
@@ -348,6 +354,9 @@ module Square
348
354
  # `APPOINTMENTS_WRITE` for the OAuth scope.
349
355
  # To call this endpoint with seller-level permissions, set
350
356
  # `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
357
+ # For calls to this endpoint with seller-level permissions to succeed, the
358
+ # seller must have subscribed to *Appointments Plus*
359
+ # or *Appointments Premium*.
351
360
  # @param [String] booking_id Required parameter: The ID of the
352
361
  # [Booking]($m/Booking) object representing the to-be-cancelled booking.
353
362
  # @param [CancelBookingRequest] body Required parameter: An object
@@ -8,6 +8,13 @@ module Square
8
8
  # Links a `checkoutId` to a `checkout_page_url` that customers are
9
9
  # directed to in order to provide their payment information using a
10
10
  # payment processing workflow hosted on connect.squareup.com.
11
+ # NOTE: The Checkout API has been updated with new features.
12
+ # For more information, see [Checkout API
13
+ # highlights](https://developer.squareup.com/docs/checkout-api#checkout-api-
14
+ # highlights).
15
+ # We recommend that you use the
16
+ # new [CreatePaymentLink]($e/Checkout/CreatePaymentLink)
17
+ # endpoint in place of this previously released endpoint.
11
18
  # @param [String] location_id Required parameter: The ID of the business
12
19
  # location to associate the checkout with.
13
20
  # @param [CreateCheckoutRequest] body Required parameter: An object
@@ -47,5 +54,200 @@ module Square
47
54
  _response, data: decoded, errors: _errors
48
55
  )
49
56
  end
57
+
58
+ # Lists all payment links.
59
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
60
+ # a previous call to this endpoint. Provide this cursor to retrieve the
61
+ # next set of results for the original query. If a cursor is not provided,
62
+ # the endpoint returns the first page of the results. For more
63
+ # information, see
64
+ # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
65
+ # .
66
+ # @param [Integer] limit Optional parameter: A limit on the number of
67
+ # results to return per page. The limit is advisory and the implementation
68
+ # might return more or less results. If the supplied limit is negative,
69
+ # zero, or greater than the maximum limit of 1000, it is ignored. Default
70
+ # value: `100`
71
+ # @return [ListPaymentLinksResponse Hash] response from the API call
72
+ def list_payment_links(cursor: nil,
73
+ limit: nil)
74
+ # Prepare query url.
75
+ _query_builder = config.get_base_uri
76
+ _query_builder << '/v2/online-checkout/payment-links'
77
+ _query_builder = APIHelper.append_url_with_query_parameters(
78
+ _query_builder,
79
+ 'cursor' => cursor,
80
+ 'limit' => limit
81
+ )
82
+ _query_url = APIHelper.clean_url _query_builder
83
+
84
+ # Prepare headers.
85
+ _headers = {
86
+ 'accept' => 'application/json'
87
+ }
88
+
89
+ # Prepare and execute HttpRequest.
90
+ _request = config.http_client.get(
91
+ _query_url,
92
+ headers: _headers
93
+ )
94
+ OAuth2.apply(config, _request)
95
+ _response = execute_request(_request)
96
+
97
+ # Return appropriate response type.
98
+ decoded = APIHelper.json_deserialize(_response.raw_body)
99
+ _errors = APIHelper.map_response(decoded, ['errors'])
100
+ ApiResponse.new(
101
+ _response, data: decoded, errors: _errors
102
+ )
103
+ end
104
+
105
+ # Creates a Square-hosted checkout page. Applications can share the
106
+ # resulting payment link with their buyer to pay for goods and services.
107
+ # @param [CreatePaymentLinkRequest] body Required parameter: An object
108
+ # containing the fields to POST for the request. See the corresponding
109
+ # object definition for field details.
110
+ # @return [CreatePaymentLinkResponse Hash] response from the API call
111
+ def create_payment_link(body:)
112
+ # Prepare query url.
113
+ _query_builder = config.get_base_uri
114
+ _query_builder << '/v2/online-checkout/payment-links'
115
+ _query_url = APIHelper.clean_url _query_builder
116
+
117
+ # Prepare headers.
118
+ _headers = {
119
+ 'accept' => 'application/json',
120
+ 'Content-Type' => 'application/json'
121
+ }
122
+
123
+ # Prepare and execute HttpRequest.
124
+ _request = config.http_client.post(
125
+ _query_url,
126
+ headers: _headers,
127
+ parameters: body.to_json
128
+ )
129
+ OAuth2.apply(config, _request)
130
+ _response = execute_request(_request)
131
+
132
+ # Return appropriate response type.
133
+ decoded = APIHelper.json_deserialize(_response.raw_body)
134
+ _errors = APIHelper.map_response(decoded, ['errors'])
135
+ ApiResponse.new(
136
+ _response, data: decoded, errors: _errors
137
+ )
138
+ end
139
+
140
+ # Deletes a payment link.
141
+ # @param [String] id Required parameter: The ID of the payment link to
142
+ # delete.
143
+ # @return [DeletePaymentLinkResponse Hash] response from the API call
144
+ def delete_payment_link(id:)
145
+ # Prepare query url.
146
+ _query_builder = config.get_base_uri
147
+ _query_builder << '/v2/online-checkout/payment-links/{id}'
148
+ _query_builder = APIHelper.append_url_with_template_parameters(
149
+ _query_builder,
150
+ 'id' => { 'value' => id, 'encode' => true }
151
+ )
152
+ _query_url = APIHelper.clean_url _query_builder
153
+
154
+ # Prepare headers.
155
+ _headers = {
156
+ 'accept' => 'application/json'
157
+ }
158
+
159
+ # Prepare and execute HttpRequest.
160
+ _request = config.http_client.delete(
161
+ _query_url,
162
+ headers: _headers
163
+ )
164
+ OAuth2.apply(config, _request)
165
+ _response = execute_request(_request)
166
+
167
+ # Return appropriate response type.
168
+ decoded = APIHelper.json_deserialize(_response.raw_body)
169
+ _errors = APIHelper.map_response(decoded, ['errors'])
170
+ ApiResponse.new(
171
+ _response, data: decoded, errors: _errors
172
+ )
173
+ end
174
+
175
+ # Retrieves a payment link.
176
+ # @param [String] id Required parameter: The ID of link to retrieve.
177
+ # @return [RetrievePaymentLinkResponse Hash] response from the API call
178
+ def retrieve_payment_link(id:)
179
+ # Prepare query url.
180
+ _query_builder = config.get_base_uri
181
+ _query_builder << '/v2/online-checkout/payment-links/{id}'
182
+ _query_builder = APIHelper.append_url_with_template_parameters(
183
+ _query_builder,
184
+ 'id' => { 'value' => id, 'encode' => true }
185
+ )
186
+ _query_url = APIHelper.clean_url _query_builder
187
+
188
+ # Prepare headers.
189
+ _headers = {
190
+ 'accept' => 'application/json'
191
+ }
192
+
193
+ # Prepare and execute HttpRequest.
194
+ _request = config.http_client.get(
195
+ _query_url,
196
+ headers: _headers
197
+ )
198
+ OAuth2.apply(config, _request)
199
+ _response = execute_request(_request)
200
+
201
+ # Return appropriate response type.
202
+ decoded = APIHelper.json_deserialize(_response.raw_body)
203
+ _errors = APIHelper.map_response(decoded, ['errors'])
204
+ ApiResponse.new(
205
+ _response, data: decoded, errors: _errors
206
+ )
207
+ end
208
+
209
+ # Updates a payment link. You can update the `payment_link` fields such as
210
+ # `description`, `checkout_options`, and `pre_populated_data`.
211
+ # You cannot update other fields such as the `order_id`, `version`, `URL`,
212
+ # or `timestamp` field.
213
+ # @param [String] id Required parameter: The ID of the payment link to
214
+ # update.
215
+ # @param [UpdatePaymentLinkRequest] body Required parameter: An object
216
+ # containing the fields to POST for the request. See the corresponding
217
+ # object definition for field details.
218
+ # @return [UpdatePaymentLinkResponse Hash] response from the API call
219
+ def update_payment_link(id:,
220
+ body:)
221
+ # Prepare query url.
222
+ _query_builder = config.get_base_uri
223
+ _query_builder << '/v2/online-checkout/payment-links/{id}'
224
+ _query_builder = APIHelper.append_url_with_template_parameters(
225
+ _query_builder,
226
+ 'id' => { 'value' => id, 'encode' => true }
227
+ )
228
+ _query_url = APIHelper.clean_url _query_builder
229
+
230
+ # Prepare headers.
231
+ _headers = {
232
+ 'accept' => 'application/json',
233
+ 'Content-Type' => 'application/json'
234
+ }
235
+
236
+ # Prepare and execute HttpRequest.
237
+ _request = config.http_client.put(
238
+ _query_url,
239
+ headers: _headers,
240
+ parameters: body.to_json
241
+ )
242
+ OAuth2.apply(config, _request)
243
+ _response = execute_request(_request)
244
+
245
+ # Return appropriate response type.
246
+ decoded = APIHelper.json_deserialize(_response.raw_body)
247
+ _errors = APIHelper.map_response(decoded, ['errors'])
248
+ ApiResponse.new(
249
+ _response, data: decoded, errors: _errors
250
+ )
251
+ end
50
252
  end
51
253
  end