square.rb 17.1.0.20220120 → 19.0.0.20220420
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -221
- data/lib/square/api/base_api.rb +1 -1
- data/lib/square/api/customer_groups_api.rb +7 -6
- data/lib/square/api/customer_segments_api.rb +7 -6
- data/lib/square/api/customers_api.rb +11 -8
- data/lib/square/api/locations_api.rb +3 -4
- data/lib/square/api/loyalty_api.rb +4 -3
- data/lib/square/api/merchants_api.rb +10 -8
- data/lib/square/api/orders_api.rb +2 -2
- data/lib/square/api/payouts_api.rb +173 -0
- data/lib/square/api/subscriptions_api.rb +0 -3
- data/lib/square/api/terminal_api.rb +14 -6
- data/lib/square/api/vendors_api.rb +257 -0
- data/lib/square/api_helper.rb +29 -31
- data/lib/square/client.rb +17 -5
- data/lib/square/configuration.rb +12 -13
- data/lib/square/http/faraday_client.rb +28 -20
- data/lib/square/http/http_client.rb +31 -12
- data/lib/square/http/http_request.rb +6 -2
- data/lib/square.rb +2 -0
- metadata +47 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 431d8365d32b12be40203cfb143d88518f74cee228a0b36755cdc5fc8b782200
|
4
|
+
data.tar.gz: 5349f02eb93bf190d16d17ea0f13d3c434fdcb75a37825e1cdcb6406744c7385
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65afbe4492802c447ee9aa509cc282720a88e7e34f398609818e4cc60b2262d05584bdb736793d44f4a2d49299f350a4c8241666ebe452634e2ac73097424633
|
7
|
+
data.tar.gz: a0a524485adeb61c20502b6956df68fc908c0e9e52459421be2382ad962ccd17a0e4f128d1bf7ed341a2f9bed95c31da735512ddd73327d7ba739c52ae38d1f9
|
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
|
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
|
-
|
13
|
+
Use of the Square Ruby SDK requires:
|
14
|
+
|
15
|
+
* Ruby 2.6 through 3.1
|
14
16
|
|
15
17
|
## Installation
|
16
18
|
|
17
|
-
|
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
|
-
```
|
20
|
-
gem install
|
39
|
+
```sh
|
40
|
+
gem install bundler
|
41
|
+
bundle
|
21
42
|
```
|
22
43
|
|
23
|
-
|
44
|
+
Before running the tests, find a sandbox token in your [Developer Dashboard] and set a `SQUARE_SANDBOX_TOKEN` environment variable.
|
24
45
|
|
25
|
-
```
|
26
|
-
|
46
|
+
```sh
|
47
|
+
export SQUARE_SANDBOX_TOKEN="YOUR SANDBOX TOKEN HERE"
|
27
48
|
```
|
28
49
|
|
29
|
-
|
30
|
-
* [Client]
|
50
|
+
And run the tests.
|
31
51
|
|
32
|
-
|
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
|
data/lib/square/api/base_api.rb
CHANGED
@@ -38,7 +38,7 @@ module Square
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def get_user_agent
|
41
|
-
user_agent = 'Square-Ruby-SDK/
|
41
|
+
user_agent = 'Square-Ruby-SDK/19.0.0.20220420 ({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/
|
13
|
-
#
|
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.
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
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/
|
13
|
-
#
|
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.
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
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/
|
19
|
-
#
|
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.
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
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/
|
170
|
-
#
|
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
|
@@ -40,12 +40,11 @@ module Square
|
|
40
40
|
# Creating new locations allows for separate configuration of receipt
|
41
41
|
# layouts, item prices,
|
42
42
|
# and sales reports. Developers can use locations to separate sales activity
|
43
|
-
#
|
43
|
+
# through applications
|
44
44
|
# that integrate with Square from sales activity elsewhere in a seller's
|
45
45
|
# account.
|
46
|
-
# Locations created programmatically with the Locations API
|
47
|
-
#
|
48
|
-
# are visible to the seller for their own management, so ensure that
|
46
|
+
# Locations created programmatically with the Locations API last forever and
|
47
|
+
# are visible to the seller for their own management. Therefore, ensure that
|
49
48
|
# each location has a sensible and unique name.
|
50
49
|
# @param [CreateLocationRequest] body Required parameter: An object
|
51
50
|
# containing the fields to POST for the request. See the corresponding
|
@@ -424,9 +424,10 @@ module Square
|
|
424
424
|
)
|
425
425
|
end
|
426
426
|
|
427
|
-
# Searches for loyalty rewards
|
428
|
-
#
|
429
|
-
# `
|
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.
|
@@ -5,15 +5,17 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
8
|
+
# Provides details about the merchant associated with a given access token.
|
9
|
+
# The access token used to connect your application to a Square seller is
|
10
|
+
# associated
|
11
|
+
# with a single merchant. That means that `ListMerchants` returns a list
|
12
|
+
# with a single `Merchant` object. You can specify your personal access
|
13
|
+
# token
|
14
|
+
# to get your own merchant information or specify an OAuth token to get the
|
15
|
+
# information for the merchant that granted your application access.
|
14
16
|
# If you know the merchant ID, you can also use the
|
15
17
|
# [RetrieveMerchant]($e/Merchants/RetrieveMerchant)
|
16
|
-
# endpoint to
|
18
|
+
# endpoint to retrieve the merchant information.
|
17
19
|
# @param [Integer] cursor Optional parameter: The cursor generated by the
|
18
20
|
# previous response.
|
19
21
|
# @return [ListMerchantsResponse Hash] response from the API call
|
@@ -48,7 +50,7 @@ module Square
|
|
48
50
|
)
|
49
51
|
end
|
50
52
|
|
51
|
-
#
|
53
|
+
# Retrieves the `Merchant` object for the given `merchant_id`.
|
52
54
|
# @param [String] merchant_id Required parameter: The ID of the merchant to
|
53
55
|
# retrieve. If the string "me" is supplied as the ID, then retrieve the
|
54
56
|
# merchant that is currently accessible to this call.
|
@@ -311,8 +311,8 @@ module Square
|
|
311
311
|
# the
|
312
312
|
# `payment_ids` is canceled.
|
313
313
|
# - Be approved with [delayed
|
314
|
-
# capture](https://developer.squareup.com/docs/payments-api/take-payments
|
315
|
-
#
|
314
|
+
# capture](https://developer.squareup.com/docs/payments-api/take-payments/ca
|
315
|
+
# rd-payments/delayed-capture).
|
316
316
|
# Using a delayed capture payment with `PayOrder` completes the approved
|
317
317
|
# payment.
|
318
318
|
# @param [String] order_id Required parameter: The ID of the order being
|
@@ -0,0 +1,173 @@
|
|
1
|
+
module Square
|
2
|
+
# PayoutsApi
|
3
|
+
class PayoutsApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Retrieves a list of all payouts for the default location.
|
9
|
+
# You can filter payouts by location ID, status, time range, and order them
|
10
|
+
# in ascending or descending order.
|
11
|
+
# To call this endpoint, set `PAYOUTS_READ` for the OAuth scope.
|
12
|
+
# @param [String] location_id Optional parameter: The ID of the location for
|
13
|
+
# which to list the payouts. By default, payouts are returned for the
|
14
|
+
# default (main) location associated with the seller.
|
15
|
+
# @param [PayoutStatus] status Optional parameter: If provided, only payouts
|
16
|
+
# with the given status are returned.
|
17
|
+
# @param [String] begin_time Optional parameter: The timestamp for the
|
18
|
+
# beginning of the payout creation time, in RFC 3339 format. Inclusive.
|
19
|
+
# Default: The current time minus one year.
|
20
|
+
# @param [String] end_time Optional parameter: The timestamp for the end of
|
21
|
+
# the payout creation time, in RFC 3339 format. Default: The current time.
|
22
|
+
# @param [SortOrder] sort_order Optional parameter: The order in which
|
23
|
+
# payouts are listed.
|
24
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
25
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
26
|
+
# set of results for the original query. For more information, see
|
27
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
28
|
+
# . If request parameters change between requests, subsequent results may
|
29
|
+
# contain duplicates or missing records.
|
30
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
31
|
+
# to be returned in a single page. It is possible to receive fewer results
|
32
|
+
# than the specified limit on a given page. The default value of 100 is also
|
33
|
+
# the maximum allowed value. If the provided value is greater than 100, it
|
34
|
+
# is ignored and the default value is used instead. Default: `100`
|
35
|
+
# @return [ListPayoutsResponse Hash] response from the API call
|
36
|
+
def list_payouts(location_id: nil,
|
37
|
+
status: nil,
|
38
|
+
begin_time: nil,
|
39
|
+
end_time: nil,
|
40
|
+
sort_order: nil,
|
41
|
+
cursor: nil,
|
42
|
+
limit: nil)
|
43
|
+
# Prepare query url.
|
44
|
+
_query_builder = config.get_base_uri
|
45
|
+
_query_builder << '/v2/payouts'
|
46
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
47
|
+
_query_builder,
|
48
|
+
'location_id' => location_id,
|
49
|
+
'status' => status,
|
50
|
+
'begin_time' => begin_time,
|
51
|
+
'end_time' => end_time,
|
52
|
+
'sort_order' => sort_order,
|
53
|
+
'cursor' => cursor,
|
54
|
+
'limit' => limit
|
55
|
+
)
|
56
|
+
_query_url = APIHelper.clean_url _query_builder
|
57
|
+
|
58
|
+
# Prepare headers.
|
59
|
+
_headers = {
|
60
|
+
'accept' => 'application/json'
|
61
|
+
}
|
62
|
+
|
63
|
+
# Prepare and execute HttpRequest.
|
64
|
+
_request = config.http_client.get(
|
65
|
+
_query_url,
|
66
|
+
headers: _headers
|
67
|
+
)
|
68
|
+
OAuth2.apply(config, _request)
|
69
|
+
_response = execute_request(_request)
|
70
|
+
|
71
|
+
# Return appropriate response type.
|
72
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
73
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
74
|
+
ApiResponse.new(
|
75
|
+
_response, data: decoded, errors: _errors
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Retrieves details of a specific payout identified by a payout ID.
|
80
|
+
# To call this endpoint, set `PAYOUTS_READ` for the OAuth scope.
|
81
|
+
# @param [String] payout_id Required parameter: The ID of the payout to
|
82
|
+
# retrieve the information for.
|
83
|
+
# @return [GetPayoutResponse Hash] response from the API call
|
84
|
+
def get_payout(payout_id:)
|
85
|
+
# Prepare query url.
|
86
|
+
_query_builder = config.get_base_uri
|
87
|
+
_query_builder << '/v2/payouts/{payout_id}'
|
88
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
89
|
+
_query_builder,
|
90
|
+
'payout_id' => { 'value' => payout_id, 'encode' => true }
|
91
|
+
)
|
92
|
+
_query_url = APIHelper.clean_url _query_builder
|
93
|
+
|
94
|
+
# Prepare headers.
|
95
|
+
_headers = {
|
96
|
+
'accept' => 'application/json'
|
97
|
+
}
|
98
|
+
|
99
|
+
# Prepare and execute HttpRequest.
|
100
|
+
_request = config.http_client.get(
|
101
|
+
_query_url,
|
102
|
+
headers: _headers
|
103
|
+
)
|
104
|
+
OAuth2.apply(config, _request)
|
105
|
+
_response = execute_request(_request)
|
106
|
+
|
107
|
+
# Return appropriate response type.
|
108
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
109
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
110
|
+
ApiResponse.new(
|
111
|
+
_response, data: decoded, errors: _errors
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Retrieves a list of all payout entries for a specific payout.
|
116
|
+
# To call this endpoint, set `PAYOUTS_READ` for the OAuth scope.
|
117
|
+
# @param [String] payout_id Required parameter: The ID of the payout to
|
118
|
+
# retrieve the information for.
|
119
|
+
# @param [SortOrder] sort_order Optional parameter: The order in which
|
120
|
+
# payout entries are listed.
|
121
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
122
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
123
|
+
# set of results for the original query. For more information, see
|
124
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
125
|
+
# . If request parameters change between requests, subsequent results may
|
126
|
+
# contain duplicates or missing records.
|
127
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
128
|
+
# to be returned in a single page. It is possible to receive fewer results
|
129
|
+
# than the specified limit on a given page. The default value of 100 is also
|
130
|
+
# the maximum allowed value. If the provided value is greater than 100, it
|
131
|
+
# is ignored and the default value is used instead. Default: `100`
|
132
|
+
# @return [ListPayoutEntriesResponse Hash] response from the API call
|
133
|
+
def list_payout_entries(payout_id:,
|
134
|
+
sort_order: nil,
|
135
|
+
cursor: nil,
|
136
|
+
limit: nil)
|
137
|
+
# Prepare query url.
|
138
|
+
_query_builder = config.get_base_uri
|
139
|
+
_query_builder << '/v2/payouts/{payout_id}/payout-entries'
|
140
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
141
|
+
_query_builder,
|
142
|
+
'payout_id' => { 'value' => payout_id, 'encode' => true }
|
143
|
+
)
|
144
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
145
|
+
_query_builder,
|
146
|
+
'sort_order' => sort_order,
|
147
|
+
'cursor' => cursor,
|
148
|
+
'limit' => limit
|
149
|
+
)
|
150
|
+
_query_url = APIHelper.clean_url _query_builder
|
151
|
+
|
152
|
+
# Prepare headers.
|
153
|
+
_headers = {
|
154
|
+
'accept' => 'application/json'
|
155
|
+
}
|
156
|
+
|
157
|
+
# Prepare and execute HttpRequest.
|
158
|
+
_request = config.http_client.get(
|
159
|
+
_query_url,
|
160
|
+
headers: _headers
|
161
|
+
)
|
162
|
+
OAuth2.apply(config, _request)
|
163
|
+
_response = execute_request(_request)
|
164
|
+
|
165
|
+
# Return appropriate response type.
|
166
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
167
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
168
|
+
ApiResponse.new(
|
169
|
+
_response, data: decoded, errors: _errors
|
170
|
+
)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -260,9 +260,6 @@ module Square
|
|
260
260
|
end
|
261
261
|
|
262
262
|
# Lists all events for a specific subscription.
|
263
|
-
# In the current implementation, only `START_SUBSCRIPTION` and
|
264
|
-
# `STOP_SUBSCRIPTION` (when the subscription was canceled) events are
|
265
|
-
# returned.
|
266
263
|
# @param [String] subscription_id Required parameter: The ID of the
|
267
264
|
# subscription to retrieve the events for.
|
268
265
|
# @param [String] cursor Optional parameter: When the total number of
|