square.rb 18.0.0.20220216 → 18.1.0.20220316

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: bbb5aeea53c32ac7828ffb52501c522f8e4811bb81aa4f0deb453802dcc9147e
4
+ data.tar.gz: 2526651aefdbeb8e605d35ef011de1c21f241e860c9d3fde2853b3c9e8912932
5
5
  SHA512:
6
- metadata.gz: 4d5f5cdb0c4992a16eca7327a67642d9fcb807ae040b7c3426d5635ac3ef9f40ab9d144fe011b60c5ad996b81b098e49a3e4cf8a3e6aa3dd4742fab08fd6e1b3
7
- data.tar.gz: 56b7b2f269877ec3b2f867d608e0a803a066e74bc958d2e0f60e156a034360e872d0c7eccefa5d552a35b700f2c9cb83b364a942e96968a713ab33013069dea5
6
+ metadata.gz: 500aa37342e9b95690d2541bc0f55d4b2ba2797290439a9da44bb1056b3aaf20d741a30b853afdaf9a81be4720b1b2284062974ac5c31908b17e0bc858725fa8
7
+ data.tar.gz: 83e45f18a23572b205a30ac3aad83529a6f94e0ae2a340ce28d3a06b243ace51e315114ca5e24cfa8676420d705dd7d80aec69053306eb63f799578c9a499f97
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]
@@ -98,216 +122,6 @@ gem 'square.rb'
98
122
  * [V1 Items]
99
123
  * [Transactions]
100
124
 
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
125
 
312
126
  [//]: # "Link anchor definitions"
313
127
  [Square Logo]: https://docs.connect.squareup.com/images/github/github-square-logo.svg
@@ -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/18.1.0.20220316 ({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
@@ -9,14 +9,15 @@ module Square
9
9
  # @param [String] cursor Optional parameter: A pagination cursor returned by
10
10
  # a previous call to this endpoint. Provide this cursor to retrieve the next
11
11
  # set of results for your original query. For more information, see
12
- # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
13
- # ion).
12
+ # [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
13
+ # atterns/pagination).
14
14
  # @param [Integer] limit Optional parameter: The maximum number of results
15
15
  # to return in a single page. This limit is advisory. The response might
16
- # contain more or fewer results. The limit is ignored if it is less than 1
17
- # or greater than 50. The default value is 50. For more information, see
18
- # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
19
- # ion).
16
+ # contain more or fewer results. If the limit is less than 1 or greater than
17
+ # 50, Square returns a `400 VALUE_TOO_LOW` or `400 VALUE_TOO_HIGH` error.
18
+ # The default value is 50. For more information, see
19
+ # [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
20
+ # atterns/pagination).
20
21
  # @return [ListCustomerGroupsResponse Hash] response from the API call
21
22
  def list_customer_groups(cursor: nil,
22
23
  limit: nil)
@@ -9,14 +9,15 @@ module Square
9
9
  # @param [String] cursor Optional parameter: A pagination cursor returned by
10
10
  # previous calls to `ListCustomerSegments`. This cursor is used to retrieve
11
11
  # the next set of query results. For more information, see
12
- # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
13
- # ion).
12
+ # [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
13
+ # atterns/pagination).
14
14
  # @param [Integer] limit Optional parameter: The maximum number of results
15
15
  # to return in a single page. This limit is advisory. The response might
16
- # contain more or fewer results. The limit is ignored if it is less than 1
17
- # or greater than 50. The default value is 50. For more information, see
18
- # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
19
- # ion).
16
+ # contain more or fewer results. If the specified limit is less than 1 or
17
+ # greater than 50, Square returns a `400 VALUE_TOO_LOW` or `400
18
+ # VALUE_TOO_HIGH` error. The default value is 50. For more information, see
19
+ # [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
20
+ # atterns/pagination).
20
21
  # @return [ListCustomerSegmentsResponse Hash] response from the API call
21
22
  def list_customer_segments(cursor: nil,
22
23
  limit: nil)
@@ -15,14 +15,16 @@ module Square
15
15
  # @param [String] cursor Optional parameter: A pagination cursor returned by
16
16
  # a previous call to this endpoint. Provide this cursor to retrieve the next
17
17
  # set of results for your original query. For more information, see
18
- # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
19
- # ion).
18
+ # [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
19
+ # atterns/pagination).
20
20
  # @param [Integer] limit Optional parameter: The maximum number of results
21
21
  # to return in a single page. This limit is advisory. The response might
22
- # contain more or fewer results. The limit is ignored if it is less than 1
23
- # or greater than 100. The default value is 100. For more information, see
24
- # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
25
- # ion).
22
+ # contain more or fewer results. If the specified limit is less than 1 or
23
+ # greater than 100, Square returns a `400 VALUE_TOO_LOW` or `400
24
+ # VALUE_TOO_HIGH` error. The default value is 100. For more information,
25
+ # see
26
+ # [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
27
+ # atterns/pagination).
26
28
  # @param [CustomerSortField] sort_field Optional parameter: Indicates how
27
29
  # customers should be sorted. The default value is `DEFAULT`.
28
30
  # @param [SortOrder] sort_order Optional parameter: Indicates whether
@@ -166,8 +168,9 @@ module Square
166
168
  # @param [Long] version Optional parameter: The current version of the
167
169
  # customer profile. As a best practice, you should include this parameter
168
170
  # to enable [optimistic
169
- # concurrency](https://developer.squareup.com/docs/working-with-apis/optimis
170
- # tic-concurrency) control. For more information, see [Delete a customer
171
+ # concurrency](https://developer.squareup.com/docs/build-basics/common-api-p
172
+ # atterns/optimistic-concurrency) control. For more information, see
173
+ # [Delete a customer
171
174
  # profile](https://developer.squareup.com/docs/customers-api/use-the-api/kee
172
175
  # p-records#delete-customer-profile).
173
176
  # @return [DeleteCustomerResponse Hash] response from the API call
@@ -424,9 +424,10 @@ module Square
424
424
  )
425
425
  end
426
426
 
427
- # Searches for loyalty rewards in a loyalty account.
428
- # In the current implementation, the endpoint supports search by the reward
429
- # `status`.
427
+ # Searches for loyalty rewards. This endpoint accepts a request with no
428
+ # query filters and returns results for all loyalty accounts.
429
+ # If you include a `query` object, `loyalty_account_id` is required and
430
+ # `status` is optional.
430
431
  # If you know a reward ID, use the
431
432
  # [RetrieveLoyaltyReward]($e/Loyalty/RetrieveLoyaltyReward) endpoint.
432
433
  # Search results are sorted by `updated_at` in descending order.
@@ -0,0 +1,257 @@
1
+ module Square
2
+ # VendorsApi
3
+ class VendorsApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Creates one or more [Vendor]($m/Vendor) objects to represent suppliers to
9
+ # a seller.
10
+ # @param [BulkCreateVendorsRequest] body Required parameter: An object
11
+ # containing the fields to POST for the request. See the corresponding
12
+ # object definition for field details.
13
+ # @return [BulkCreateVendorsResponse Hash] response from the API call
14
+ def bulk_create_vendors(body:)
15
+ # Prepare query url.
16
+ _query_builder = config.get_base_uri
17
+ _query_builder << '/v2/vendors/bulk-create'
18
+ _query_url = APIHelper.clean_url _query_builder
19
+
20
+ # Prepare headers.
21
+ _headers = {
22
+ 'accept' => 'application/json',
23
+ 'Content-Type' => 'application/json'
24
+ }
25
+
26
+ # Prepare and execute HttpRequest.
27
+ _request = config.http_client.post(
28
+ _query_url,
29
+ headers: _headers,
30
+ parameters: body.to_json
31
+ )
32
+ OAuth2.apply(config, _request)
33
+ _response = execute_request(_request)
34
+
35
+ # Return appropriate response type.
36
+ decoded = APIHelper.json_deserialize(_response.raw_body)
37
+ _errors = APIHelper.map_response(decoded, ['errors'])
38
+ ApiResponse.new(
39
+ _response, data: decoded, errors: _errors
40
+ )
41
+ end
42
+
43
+ # Retrieves one or more vendors of specified [Vendor]($m/Vendor) IDs.
44
+ # @param [BulkRetrieveVendorsRequest] body Required parameter: An object
45
+ # containing the fields to POST for the request. See the corresponding
46
+ # object definition for field details.
47
+ # @return [BulkRetrieveVendorsResponse Hash] response from the API call
48
+ def bulk_retrieve_vendors(body:)
49
+ # Prepare query url.
50
+ _query_builder = config.get_base_uri
51
+ _query_builder << '/v2/vendors/bulk-retrieve'
52
+ _query_url = APIHelper.clean_url _query_builder
53
+
54
+ # Prepare headers.
55
+ _headers = {
56
+ 'accept' => 'application/json',
57
+ 'Content-Type' => 'application/json'
58
+ }
59
+
60
+ # Prepare and execute HttpRequest.
61
+ _request = config.http_client.post(
62
+ _query_url,
63
+ headers: _headers,
64
+ parameters: body.to_json
65
+ )
66
+ OAuth2.apply(config, _request)
67
+ _response = execute_request(_request)
68
+
69
+ # Return appropriate response type.
70
+ decoded = APIHelper.json_deserialize(_response.raw_body)
71
+ _errors = APIHelper.map_response(decoded, ['errors'])
72
+ ApiResponse.new(
73
+ _response, data: decoded, errors: _errors
74
+ )
75
+ end
76
+
77
+ # Updates one or more of existing [Vendor]($m/Vendor) objects as suppliers
78
+ # to a seller.
79
+ # @param [BulkUpdateVendorsRequest] body Required parameter: An object
80
+ # containing the fields to POST for the request. See the corresponding
81
+ # object definition for field details.
82
+ # @return [BulkUpdateVendorsResponse Hash] response from the API call
83
+ def bulk_update_vendors(body:)
84
+ # Prepare query url.
85
+ _query_builder = config.get_base_uri
86
+ _query_builder << '/v2/vendors/bulk-update'
87
+ _query_url = APIHelper.clean_url _query_builder
88
+
89
+ # Prepare headers.
90
+ _headers = {
91
+ 'accept' => 'application/json',
92
+ 'Content-Type' => 'application/json'
93
+ }
94
+
95
+ # Prepare and execute HttpRequest.
96
+ _request = config.http_client.put(
97
+ _query_url,
98
+ headers: _headers,
99
+ parameters: body.to_json
100
+ )
101
+ OAuth2.apply(config, _request)
102
+ _response = execute_request(_request)
103
+
104
+ # Return appropriate response type.
105
+ decoded = APIHelper.json_deserialize(_response.raw_body)
106
+ _errors = APIHelper.map_response(decoded, ['errors'])
107
+ ApiResponse.new(
108
+ _response, data: decoded, errors: _errors
109
+ )
110
+ end
111
+
112
+ # Creates a single [Vendor]($m/Vendor) object to represent a supplier to a
113
+ # seller.
114
+ # @param [CreateVendorRequest] body Required parameter: An object containing
115
+ # the fields to POST for the request. See the corresponding object
116
+ # definition for field details.
117
+ # @return [CreateVendorResponse Hash] response from the API call
118
+ def create_vendor(body:)
119
+ # Prepare query url.
120
+ _query_builder = config.get_base_uri
121
+ _query_builder << '/v2/vendors/create'
122
+ _query_url = APIHelper.clean_url _query_builder
123
+
124
+ # Prepare headers.
125
+ _headers = {
126
+ 'accept' => 'application/json',
127
+ 'Content-Type' => 'application/json'
128
+ }
129
+
130
+ # Prepare and execute HttpRequest.
131
+ _request = config.http_client.post(
132
+ _query_url,
133
+ headers: _headers,
134
+ parameters: body.to_json
135
+ )
136
+ OAuth2.apply(config, _request)
137
+ _response = execute_request(_request)
138
+
139
+ # Return appropriate response type.
140
+ decoded = APIHelper.json_deserialize(_response.raw_body)
141
+ _errors = APIHelper.map_response(decoded, ['errors'])
142
+ ApiResponse.new(
143
+ _response, data: decoded, errors: _errors
144
+ )
145
+ end
146
+
147
+ # Searches for vendors using a filter against supported [Vendor]($m/Vendor)
148
+ # properties and a supported sorter.
149
+ # @param [SearchVendorsRequest] body Required parameter: An object
150
+ # containing the fields to POST for the request. See the corresponding
151
+ # object definition for field details.
152
+ # @return [SearchVendorsResponse Hash] response from the API call
153
+ def search_vendors(body:)
154
+ # Prepare query url.
155
+ _query_builder = config.get_base_uri
156
+ _query_builder << '/v2/vendors/search'
157
+ _query_url = APIHelper.clean_url _query_builder
158
+
159
+ # Prepare headers.
160
+ _headers = {
161
+ 'accept' => 'application/json',
162
+ 'Content-Type' => 'application/json'
163
+ }
164
+
165
+ # Prepare and execute HttpRequest.
166
+ _request = config.http_client.post(
167
+ _query_url,
168
+ headers: _headers,
169
+ parameters: body.to_json
170
+ )
171
+ OAuth2.apply(config, _request)
172
+ _response = execute_request(_request)
173
+
174
+ # Return appropriate response type.
175
+ decoded = APIHelper.json_deserialize(_response.raw_body)
176
+ _errors = APIHelper.map_response(decoded, ['errors'])
177
+ ApiResponse.new(
178
+ _response, data: decoded, errors: _errors
179
+ )
180
+ end
181
+
182
+ # Retrieves the vendor of a specified [Vendor]($m/Vendor) ID.
183
+ # @param [String] vendor_id Required parameter: ID of the
184
+ # [Vendor]($m/Vendor) to retrieve.
185
+ # @return [RetrieveVendorResponse Hash] response from the API call
186
+ def retrieve_vendor(vendor_id:)
187
+ # Prepare query url.
188
+ _query_builder = config.get_base_uri
189
+ _query_builder << '/v2/vendors/{vendor_id}'
190
+ _query_builder = APIHelper.append_url_with_template_parameters(
191
+ _query_builder,
192
+ 'vendor_id' => { 'value' => vendor_id, 'encode' => true }
193
+ )
194
+ _query_url = APIHelper.clean_url _query_builder
195
+
196
+ # Prepare headers.
197
+ _headers = {
198
+ 'accept' => 'application/json'
199
+ }
200
+
201
+ # Prepare and execute HttpRequest.
202
+ _request = config.http_client.get(
203
+ _query_url,
204
+ headers: _headers
205
+ )
206
+ OAuth2.apply(config, _request)
207
+ _response = execute_request(_request)
208
+
209
+ # Return appropriate response type.
210
+ decoded = APIHelper.json_deserialize(_response.raw_body)
211
+ _errors = APIHelper.map_response(decoded, ['errors'])
212
+ ApiResponse.new(
213
+ _response, data: decoded, errors: _errors
214
+ )
215
+ end
216
+
217
+ # Updates an existing [Vendor]($m/Vendor) object as a supplier to a seller.
218
+ # @param [UpdateVendorRequest] body Required parameter: An object containing
219
+ # the fields to POST for the request. See the corresponding object
220
+ # definition for field details.
221
+ # @param [String] vendor_id Required parameter: Example:
222
+ # @return [UpdateVendorResponse Hash] response from the API call
223
+ def update_vendor(body:,
224
+ vendor_id:)
225
+ # Prepare query url.
226
+ _query_builder = config.get_base_uri
227
+ _query_builder << '/v2/vendors/{vendor_id}'
228
+ _query_builder = APIHelper.append_url_with_template_parameters(
229
+ _query_builder,
230
+ 'vendor_id' => { 'value' => vendor_id, 'encode' => true }
231
+ )
232
+ _query_url = APIHelper.clean_url _query_builder
233
+
234
+ # Prepare headers.
235
+ _headers = {
236
+ 'accept' => 'application/json',
237
+ 'Content-Type' => 'application/json'
238
+ }
239
+
240
+ # Prepare and execute HttpRequest.
241
+ _request = config.http_client.put(
242
+ _query_url,
243
+ headers: _headers,
244
+ parameters: body.to_json
245
+ )
246
+ OAuth2.apply(config, _request)
247
+ _response = execute_request(_request)
248
+
249
+ # Return appropriate response type.
250
+ decoded = APIHelper.json_deserialize(_response.raw_body)
251
+ _errors = APIHelper.map_response(decoded, ['errors'])
252
+ ApiResponse.new(
253
+ _response, data: decoded, errors: _errors
254
+ )
255
+ end
256
+ end
257
+ end
data/lib/square/client.rb CHANGED
@@ -4,7 +4,7 @@ module Square
4
4
  attr_reader :config
5
5
 
6
6
  def sdk_version
7
- '18.0.0.20220216'
7
+ '18.1.0.20220316'
8
8
  end
9
9
 
10
10
  def square_version
@@ -213,12 +213,18 @@ module Square
213
213
  @terminal ||= TerminalApi.new config
214
214
  end
215
215
 
216
+ # Access to vendors controller.
217
+ # @return [VendorsApi] Returns the controller instance.
218
+ def vendors
219
+ @vendors ||= VendorsApi.new config
220
+ end
221
+
216
222
  def initialize(connection: nil, timeout: 60, max_retries: 0,
217
223
  retry_interval: 1, backoff_factor: 2,
218
224
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
219
225
  retry_methods: %i[get put], environment: 'production',
220
226
  custom_url: 'https://connect.squareup.com',
221
- square_version: '2022-02-16', access_token: '',
227
+ square_version: '2022-03-16', access_token: '',
222
228
  user_agent_detail: '', additional_headers: {}, config: nil)
223
229
  @config = if config.nil?
224
230
  Configuration.new(connection: connection, timeout: timeout,
@@ -20,7 +20,7 @@ module Square
20
20
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
21
21
  retry_methods: %i[get put], environment: 'production',
22
22
  custom_url: 'https://connect.squareup.com',
23
- square_version: '2022-02-16', access_token: '',
23
+ square_version: '2022-03-16', access_token: '',
24
24
  user_agent_detail: '', additional_headers: {})
25
25
  # The Faraday connection object passed by the SDK user for making requests
26
26
  @connection = connection
data/lib/square.rb CHANGED
@@ -63,3 +63,4 @@ require_relative 'square/api/snippets_api'
63
63
  require_relative 'square/api/subscriptions_api'
64
64
  require_relative 'square/api/team_api'
65
65
  require_relative 'square/api/terminal_api'
66
+ require_relative 'square/api/vendors_api'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: square.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 18.0.0.20220216
4
+ version: 18.1.0.20220316
5
5
  platform: ruby
6
6
  authors:
7
7
  - Square Developer Platform
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-15 00:00:00.000000000 Z
11
+ date: 2022-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -170,6 +170,7 @@ files:
170
170
  - lib/square/api/terminal_api.rb
171
171
  - lib/square/api/transactions_api.rb
172
172
  - lib/square/api/v1_transactions_api.rb
173
+ - lib/square/api/vendors_api.rb
173
174
  - lib/square/api_helper.rb
174
175
  - lib/square/client.rb
175
176
  - lib/square/configuration.rb