square.rb 13.0.0.20210721 → 16.0.0.20211117
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +38 -21
- data/lib/square/api/apple_pay_api.rb +1 -1
- data/lib/square/api/base_api.rb +5 -9
- data/lib/square/api/bookings_api.rb +64 -4
- data/lib/square/api/cards_api.rb +1 -1
- data/lib/square/api/catalog_api.rb +10 -10
- data/lib/square/api/checkout_api.rb +1 -1
- data/lib/square/api/customer_groups_api.rb +12 -4
- data/lib/square/api/customer_segments_api.rb +10 -2
- data/lib/square/api/customers_api.rb +15 -7
- data/lib/square/api/devices_api.rb +1 -1
- data/lib/square/api/disputes_api.rb +1 -1
- data/lib/square/api/gift_card_activities_api.rb +26 -20
- data/lib/square/api/gift_cards_api.rb +32 -26
- data/lib/square/api/inventory_api.rb +6 -6
- data/lib/square/api/invoices_api.rb +5 -5
- data/lib/square/api/labor_api.rb +70 -68
- data/lib/square/api/locations_api.rb +2 -2
- data/lib/square/api/loyalty_api.rb +9 -9
- data/lib/square/api/mobile_authorization_api.rb +1 -1
- data/lib/square/api/o_auth_api.rb +22 -15
- data/lib/square/api/orders_api.rb +43 -6
- data/lib/square/api/payments_api.rb +12 -6
- data/lib/square/api/refunds_api.rb +1 -1
- data/lib/square/api/sites_api.rb +2 -1
- data/lib/square/api/snippets_api.rb +1 -1
- data/lib/square/api/subscriptions_api.rb +159 -16
- data/lib/square/api/team_api.rb +6 -6
- data/lib/square/api/terminal_api.rb +4 -4
- data/lib/square/api/transactions_api.rb +0 -188
- data/lib/square/api/v1_transactions_api.rb +2 -2
- data/lib/square/api_helper.rb +19 -17
- data/lib/square/client.rb +6 -11
- data/lib/square/configuration.rb +19 -20
- data/lib/square/http/api_response.rb +1 -1
- data/lib/square/http/faraday_client.rb +21 -2
- data/lib/square/utilities/date_time_helper.rb +2 -2
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +48 -49
- metadata +11 -9
- data/lib/square/api/v1_employees_api.rb +0 -362
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25ab6d01177792b1eb326af1a782a12ab26eff2678b44666aac14954907740e2
|
4
|
+
data.tar.gz: 1ba81bfd71af7fd3124015de59166e33401f0e230301d4ea45e6c70438380741
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0fa97ef6d70db8247d6a14cb946a942f9327faa37e881ce8628cd8f68e38bb6c91238cf10419dc915597701b69c73ecb0f1813d45be4d6f37eaa837c1646364
|
7
|
+
data.tar.gz: a9337cd596b733099e84765048134f4edc183f548ac6638da50257bfb0d3b0529271d17c509a1f9b34342abe9e7184d56ec4fe1f292ea1fa2ad36036228384d1
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -8,6 +8,10 @@
|
|
8
8
|
|
9
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.
|
10
10
|
|
11
|
+
## Requirements
|
12
|
+
|
13
|
+
We support Ruby 2.5.x, 2.6.x, and 2.7.x.
|
14
|
+
|
11
15
|
## Installation
|
12
16
|
|
13
17
|
Install the gem from the command line:
|
@@ -33,6 +37,9 @@ gem 'square.rb'
|
|
33
37
|
* [Disputes]
|
34
38
|
* [Checkout]
|
35
39
|
* [Apple Pay]
|
40
|
+
* [Cards]
|
41
|
+
|
42
|
+
### Terminal
|
36
43
|
* [Terminal]
|
37
44
|
|
38
45
|
### Orders
|
@@ -56,6 +63,10 @@ gem 'square.rb'
|
|
56
63
|
### Loyalty
|
57
64
|
* [Loyalty]
|
58
65
|
|
66
|
+
### Gift Cards
|
67
|
+
* [Gift Cards]
|
68
|
+
* [Gift Card Activities]
|
69
|
+
|
59
70
|
### Bookings
|
60
71
|
* [Bookings]
|
61
72
|
|
@@ -63,12 +74,11 @@ gem 'square.rb'
|
|
63
74
|
* [Merchants]
|
64
75
|
* [Locations]
|
65
76
|
* [Devices]
|
77
|
+
* [Cash Drawers]
|
66
78
|
|
67
79
|
### Team
|
68
80
|
* [Team]
|
69
|
-
* [Employees]
|
70
81
|
* [Labor]
|
71
|
-
* [Cash Drawers]
|
72
82
|
|
73
83
|
### Financials
|
74
84
|
* [Bank Accounts]
|
@@ -82,6 +92,7 @@ gem 'square.rb'
|
|
82
92
|
* [OAuth]
|
83
93
|
|
84
94
|
### Deprecated APIs
|
95
|
+
* [Employees]
|
85
96
|
* [V1 Employees]
|
86
97
|
* [V1 Transactions]
|
87
98
|
* [V1 Items]
|
@@ -104,8 +115,8 @@ require 'square'
|
|
104
115
|
# for the Square account whose assets you want to manage.
|
105
116
|
|
106
117
|
client = Square::Client.new(
|
107
|
-
|
108
|
-
|
118
|
+
access_token: 'YOUR SANDBOX ACCESS TOKEN HERE',
|
119
|
+
environment: 'sandbox'
|
109
120
|
)
|
110
121
|
|
111
122
|
# Call list_locations method to get all locations in this Square account
|
@@ -113,10 +124,10 @@ result = client.locations.list_locations
|
|
113
124
|
|
114
125
|
# Call the #success? method to see if the call succeeded
|
115
126
|
if result.success?
|
116
|
-
|
127
|
+
# The #data Struct contains a list of locations
|
117
128
|
locations = result.data.locations
|
118
129
|
|
119
|
-
|
130
|
+
# Iterate over the list
|
120
131
|
locations.each do |location|
|
121
132
|
# Each location is represented as a Hash
|
122
133
|
location.each do |key, value|
|
@@ -165,6 +176,7 @@ This error was returned when an invalid token was used to call the API.
|
|
165
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.
|
166
177
|
|
167
178
|
## SDK patterns
|
179
|
+
|
168
180
|
If you know a few patterns, you’ll be able to call any API in the SDK. Here are some important ones:
|
169
181
|
|
170
182
|
### Get an access token
|
@@ -185,30 +197,31 @@ To use the Square API, you import the Client class, instantiate a Client object,
|
|
185
197
|
|
186
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:
|
187
199
|
|
188
|
-
```ruby
|
189
|
-
client = Square::Client.new(
|
200
|
+
```ruby
|
201
|
+
client = Square::Client.new(
|
190
202
|
access_token: 'SANDBOX ACCESS TOKEN HERE',
|
191
203
|
environment: 'sandbox'
|
192
|
-
)
|
193
|
-
```
|
204
|
+
)
|
205
|
+
```
|
194
206
|
|
195
207
|
- To access production resources, set environment to production:
|
196
208
|
|
197
|
-
```ruby
|
198
|
-
client = Square::Client.new(
|
209
|
+
```ruby
|
210
|
+
client = Square::Client.new(
|
199
211
|
access_token: 'ACCESS TOKEN HERE',
|
200
212
|
environment: 'production'
|
201
|
-
)
|
202
|
-
```
|
213
|
+
)
|
214
|
+
```
|
203
215
|
|
204
216
|
- To set a custom environment provide a `custom_url`, and set environment to `custom`:
|
205
217
|
|
206
|
-
```ruby
|
207
|
-
client = Square::Client.new(
|
218
|
+
```ruby
|
219
|
+
client = Square::Client.new(
|
208
220
|
access_token:'ACCESS TOKEN HERE',
|
209
221
|
environment: 'custom',
|
210
222
|
custom_url: 'https://your.customdomain.com'
|
211
|
-
)
|
223
|
+
)
|
224
|
+
```
|
212
225
|
|
213
226
|
### Get an Instance of an API object and call its methods
|
214
227
|
|
@@ -216,9 +229,9 @@ Each API is implemented as a class. The Client object instantiates every API cla
|
|
216
229
|
|
217
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:
|
218
231
|
|
219
|
-
```ruby
|
220
|
-
result = client.customers.list_customers
|
221
|
-
```
|
232
|
+
```ruby
|
233
|
+
result = client.customers.list_customers
|
234
|
+
```
|
222
235
|
|
223
236
|
See the SDK documentation for the list of methods for each API class.
|
224
237
|
|
@@ -239,6 +252,7 @@ result = client.customers.create_customer(request_body)
|
|
239
252
|
```
|
240
253
|
|
241
254
|
If your call succeeds, you’ll see a response that looks like this:
|
255
|
+
|
242
256
|
```
|
243
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'}}
|
244
258
|
```
|
@@ -263,7 +277,7 @@ end
|
|
263
277
|
|
264
278
|
## Tests
|
265
279
|
|
266
|
-
First, clone the
|
280
|
+
First, clone the repo locally and `cd` into the directory.
|
267
281
|
|
268
282
|
```sh
|
269
283
|
git clone https://github.com/square/square-ruby-sdk.git
|
@@ -333,3 +347,6 @@ You can also use the Square API to create applications or services that work wit
|
|
333
347
|
[Transactions]: doc/api/transactions.md
|
334
348
|
[Sites]: doc/api/sites.md
|
335
349
|
[Snippets]: doc/api/snippets.md
|
350
|
+
[Cards]: doc/api/cards.md
|
351
|
+
[Gift Cards]: doc/api/gift-cards.md
|
352
|
+
[Gift Card Activities]: doc/api/gift-card-activities.md
|
data/lib/square/api/base_api.rb
CHANGED
@@ -8,34 +8,30 @@ module Square
|
|
8
8
|
@http_call_back = http_call_back
|
9
9
|
|
10
10
|
@global_headers = {
|
11
|
-
'user-agent' => 'Square-Ruby-SDK/
|
11
|
+
'user-agent' => 'Square-Ruby-SDK/16.0.0.20211117',
|
12
12
|
'Square-Version' => config.square_version
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
16
|
def validate_parameters(args)
|
17
17
|
args.each do |_name, value|
|
18
|
-
if value.nil?
|
19
|
-
raise ArgumentError, "Required parameter #{_name} cannot be nil."
|
20
|
-
end
|
18
|
+
raise ArgumentError, "Required parameter #{_name} cannot be nil." if value.nil?
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
24
22
|
def execute_request(request, binary: false)
|
25
|
-
@http_call_back
|
23
|
+
@http_call_back&.on_before_request(request)
|
26
24
|
|
27
25
|
APIHelper.clean_hash(request.headers)
|
28
26
|
request.headers.merge!(@global_headers)
|
29
|
-
unless config.additional_headers.nil?
|
30
|
-
request.headers.merge!(config.additional_headers)
|
31
|
-
end
|
27
|
+
request.headers.merge!(config.additional_headers) unless config.additional_headers.nil?
|
32
28
|
|
33
29
|
response = if binary
|
34
30
|
config.http_client.execute_as_binary(request)
|
35
31
|
else
|
36
32
|
config.http_client.execute_as_string(request)
|
37
33
|
end
|
38
|
-
@http_call_back
|
34
|
+
@http_call_back&.on_after_response(response)
|
39
35
|
|
40
36
|
response
|
41
37
|
end
|
@@ -5,6 +5,66 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
+
# Retrieve a collection of bookings.
|
9
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
10
|
+
# per page to return in a paged response.
|
11
|
+
# @param [String] cursor Optional parameter: The pagination cursor from the
|
12
|
+
# preceding response to return the next page of the results. Do not set this
|
13
|
+
# when retrieving the first page of the results.
|
14
|
+
# @param [String] team_member_id Optional parameter: The team member for
|
15
|
+
# whom to retrieve bookings. If this is not set, bookings of all members are
|
16
|
+
# retrieved.
|
17
|
+
# @param [String] location_id Optional parameter: The location for which to
|
18
|
+
# retrieve bookings. If this is not set, all locations' bookings are
|
19
|
+
# retrieved.
|
20
|
+
# @param [String] start_at_min Optional parameter: The RFC 3339 timestamp
|
21
|
+
# specifying the earliest of the start time. If this is not set, the current
|
22
|
+
# time is used.
|
23
|
+
# @param [String] start_at_max Optional parameter: The RFC 3339 timestamp
|
24
|
+
# specifying the latest of the start time. If this is not set, the time of
|
25
|
+
# 31 days after `start_at_min` is used.
|
26
|
+
# @return [ListBookingsResponse Hash] response from the API call
|
27
|
+
def list_bookings(limit: nil,
|
28
|
+
cursor: nil,
|
29
|
+
team_member_id: nil,
|
30
|
+
location_id: nil,
|
31
|
+
start_at_min: nil,
|
32
|
+
start_at_max: nil)
|
33
|
+
# Prepare query url.
|
34
|
+
_query_builder = config.get_base_uri
|
35
|
+
_query_builder << '/v2/bookings'
|
36
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
37
|
+
_query_builder,
|
38
|
+
'limit' => limit,
|
39
|
+
'cursor' => cursor,
|
40
|
+
'team_member_id' => team_member_id,
|
41
|
+
'location_id' => location_id,
|
42
|
+
'start_at_min' => start_at_min,
|
43
|
+
'start_at_max' => start_at_max
|
44
|
+
)
|
45
|
+
_query_url = APIHelper.clean_url _query_builder
|
46
|
+
|
47
|
+
# Prepare headers.
|
48
|
+
_headers = {
|
49
|
+
'accept' => 'application/json'
|
50
|
+
}
|
51
|
+
|
52
|
+
# Prepare and execute HttpRequest.
|
53
|
+
_request = config.http_client.get(
|
54
|
+
_query_url,
|
55
|
+
headers: _headers
|
56
|
+
)
|
57
|
+
OAuth2.apply(config, _request)
|
58
|
+
_response = execute_request(_request)
|
59
|
+
|
60
|
+
# Return appropriate response type.
|
61
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
62
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
63
|
+
ApiResponse.new(
|
64
|
+
_response, data: decoded, errors: _errors
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
8
68
|
# Creates a booking.
|
9
69
|
# @param [CreateBookingRequest] body Required parameter: An object
|
10
70
|
# containing the fields to POST for the request. See the corresponding
|
@@ -19,7 +79,7 @@ module Square
|
|
19
79
|
# Prepare headers.
|
20
80
|
_headers = {
|
21
81
|
'accept' => 'application/json',
|
22
|
-
'
|
82
|
+
'Content-Type' => 'application/json'
|
23
83
|
}
|
24
84
|
|
25
85
|
# Prepare and execute HttpRequest.
|
@@ -53,7 +113,7 @@ module Square
|
|
53
113
|
# Prepare headers.
|
54
114
|
_headers = {
|
55
115
|
'accept' => 'application/json',
|
56
|
-
'
|
116
|
+
'Content-Type' => 'application/json'
|
57
117
|
}
|
58
118
|
|
59
119
|
# Prepare and execute HttpRequest.
|
@@ -242,7 +302,7 @@ module Square
|
|
242
302
|
# Prepare headers.
|
243
303
|
_headers = {
|
244
304
|
'accept' => 'application/json',
|
245
|
-
'
|
305
|
+
'Content-Type' => 'application/json'
|
246
306
|
}
|
247
307
|
|
248
308
|
# Prepare and execute HttpRequest.
|
@@ -283,7 +343,7 @@ module Square
|
|
283
343
|
# Prepare headers.
|
284
344
|
_headers = {
|
285
345
|
'accept' => 'application/json',
|
286
|
-
'
|
346
|
+
'Content-Type' => 'application/json'
|
287
347
|
}
|
288
348
|
|
289
349
|
# Prepare and execute HttpRequest.
|
data/lib/square/api/cards_api.rb
CHANGED
@@ -29,7 +29,7 @@ module Square
|
|
29
29
|
# Prepare headers.
|
30
30
|
_headers = {
|
31
31
|
'accept' => 'application/json',
|
32
|
-
'
|
32
|
+
'Content-Type' => 'application/json'
|
33
33
|
}
|
34
34
|
|
35
35
|
# Prepare and execute HttpRequest.
|
@@ -68,7 +68,7 @@ module Square
|
|
68
68
|
# Prepare headers.
|
69
69
|
_headers = {
|
70
70
|
'accept' => 'application/json',
|
71
|
-
'
|
71
|
+
'Content-Type' => 'application/json'
|
72
72
|
}
|
73
73
|
|
74
74
|
# Prepare and execute HttpRequest.
|
@@ -115,7 +115,7 @@ module Square
|
|
115
115
|
# Prepare headers.
|
116
116
|
_headers = {
|
117
117
|
'accept' => 'application/json',
|
118
|
-
'
|
118
|
+
'Content-Type' => 'application/json'
|
119
119
|
}
|
120
120
|
|
121
121
|
# Prepare and execute HttpRequest.
|
@@ -307,7 +307,7 @@ module Square
|
|
307
307
|
# Prepare headers.
|
308
308
|
_headers = {
|
309
309
|
'accept' => 'application/json',
|
310
|
-
'
|
310
|
+
'Content-Type' => 'application/json'
|
311
311
|
}
|
312
312
|
|
313
313
|
# Prepare and execute HttpRequest.
|
@@ -435,7 +435,7 @@ module Square
|
|
435
435
|
# Searches for [CatalogObject]($m/CatalogObject) of any type by matching
|
436
436
|
# supported search attribute values,
|
437
437
|
# excluding custom attribute values on items or item variations, against one
|
438
|
-
# or more of the specified query
|
438
|
+
# or more of the specified query filters.
|
439
439
|
# This (`SearchCatalogObjects`) endpoint differs from the
|
440
440
|
# [SearchCatalogItems]($e/Catalog/SearchCatalogItems)
|
441
441
|
# endpoint in the following aspects:
|
@@ -462,7 +462,7 @@ module Square
|
|
462
462
|
# Prepare headers.
|
463
463
|
_headers = {
|
464
464
|
'accept' => 'application/json',
|
465
|
-
'
|
465
|
+
'Content-Type' => 'application/json'
|
466
466
|
}
|
467
467
|
|
468
468
|
# Prepare and execute HttpRequest.
|
@@ -485,7 +485,7 @@ module Square
|
|
485
485
|
# Searches for catalog items or item variations by matching supported search
|
486
486
|
# attribute values, including
|
487
487
|
# custom attribute values, against one or more of the specified query
|
488
|
-
#
|
488
|
+
# filters.
|
489
489
|
# This (`SearchCatalogItems`) endpoint differs from the
|
490
490
|
# [SearchCatalogObjects]($e/Catalog/SearchCatalogObjects)
|
491
491
|
# endpoint in the following aspects:
|
@@ -512,7 +512,7 @@ module Square
|
|
512
512
|
# Prepare headers.
|
513
513
|
_headers = {
|
514
514
|
'accept' => 'application/json',
|
515
|
-
'
|
515
|
+
'Content-Type' => 'application/json'
|
516
516
|
}
|
517
517
|
|
518
518
|
# Prepare and execute HttpRequest.
|
@@ -548,7 +548,7 @@ module Square
|
|
548
548
|
# Prepare headers.
|
549
549
|
_headers = {
|
550
550
|
'accept' => 'application/json',
|
551
|
-
'
|
551
|
+
'Content-Type' => 'application/json'
|
552
552
|
}
|
553
553
|
|
554
554
|
# Prepare and execute HttpRequest.
|
@@ -584,7 +584,7 @@ module Square
|
|
584
584
|
# Prepare headers.
|
585
585
|
_headers = {
|
586
586
|
'accept' => 'application/json',
|
587
|
-
'
|
587
|
+
'Content-Type' => 'application/json'
|
588
588
|
}
|
589
589
|
|
590
590
|
# Prepare and execute HttpRequest.
|
@@ -11,14 +11,22 @@ module Square
|
|
11
11
|
# set of results for your original query. For more information, see
|
12
12
|
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
13
13
|
# ion).
|
14
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
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).
|
14
20
|
# @return [ListCustomerGroupsResponse Hash] response from the API call
|
15
|
-
def list_customer_groups(cursor: nil
|
21
|
+
def list_customer_groups(cursor: nil,
|
22
|
+
limit: nil)
|
16
23
|
# Prepare query url.
|
17
24
|
_query_builder = config.get_base_uri
|
18
25
|
_query_builder << '/v2/customers/groups'
|
19
26
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
20
27
|
_query_builder,
|
21
|
-
'cursor' => cursor
|
28
|
+
'cursor' => cursor,
|
29
|
+
'limit' => limit
|
22
30
|
)
|
23
31
|
_query_url = APIHelper.clean_url _query_builder
|
24
32
|
|
@@ -58,7 +66,7 @@ module Square
|
|
58
66
|
# Prepare headers.
|
59
67
|
_headers = {
|
60
68
|
'accept' => 'application/json',
|
61
|
-
'
|
69
|
+
'Content-Type' => 'application/json'
|
62
70
|
}
|
63
71
|
|
64
72
|
# Prepare and execute HttpRequest.
|
@@ -169,7 +177,7 @@ module Square
|
|
169
177
|
# Prepare headers.
|
170
178
|
_headers = {
|
171
179
|
'accept' => 'application/json',
|
172
|
-
'
|
180
|
+
'Content-Type' => 'application/json'
|
173
181
|
}
|
174
182
|
|
175
183
|
# Prepare and execute HttpRequest.
|
@@ -11,14 +11,22 @@ module Square
|
|
11
11
|
# the next set of query results. For more information, see
|
12
12
|
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
13
13
|
# ion).
|
14
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
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).
|
14
20
|
# @return [ListCustomerSegmentsResponse Hash] response from the API call
|
15
|
-
def list_customer_segments(cursor: nil
|
21
|
+
def list_customer_segments(cursor: nil,
|
22
|
+
limit: nil)
|
16
23
|
# Prepare query url.
|
17
24
|
_query_builder = config.get_base_uri
|
18
25
|
_query_builder << '/v2/customers/segments'
|
19
26
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
20
27
|
_query_builder,
|
21
|
-
'cursor' => cursor
|
28
|
+
'cursor' => cursor,
|
29
|
+
'limit' => limit
|
22
30
|
)
|
23
31
|
_query_url = APIHelper.clean_url _query_builder
|
24
32
|
|
@@ -17,13 +17,20 @@ module Square
|
|
17
17
|
# set of results for your original query. For more information, see
|
18
18
|
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
19
19
|
# ion).
|
20
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
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).
|
20
26
|
# @param [CustomerSortField] sort_field Optional parameter: Indicates how
|
21
|
-
# customers should be sorted.
|
27
|
+
# customers should be sorted. The default value is `DEFAULT`.
|
22
28
|
# @param [SortOrder] sort_order Optional parameter: Indicates whether
|
23
29
|
# customers should be sorted in ascending (`ASC`) or descending (`DESC`)
|
24
|
-
# order.
|
30
|
+
# order. The default value is `ASC`.
|
25
31
|
# @return [ListCustomersResponse Hash] response from the API call
|
26
32
|
def list_customers(cursor: nil,
|
33
|
+
limit: nil,
|
27
34
|
sort_field: nil,
|
28
35
|
sort_order: nil)
|
29
36
|
# Prepare query url.
|
@@ -32,6 +39,7 @@ module Square
|
|
32
39
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
33
40
|
_query_builder,
|
34
41
|
'cursor' => cursor,
|
42
|
+
'limit' => limit,
|
35
43
|
'sort_field' => sort_field,
|
36
44
|
'sort_order' => sort_order
|
37
45
|
)
|
@@ -80,7 +88,7 @@ module Square
|
|
80
88
|
# Prepare headers.
|
81
89
|
_headers = {
|
82
90
|
'accept' => 'application/json',
|
83
|
-
'
|
91
|
+
'Content-Type' => 'application/json'
|
84
92
|
}
|
85
93
|
|
86
94
|
# Prepare and execute HttpRequest.
|
@@ -124,7 +132,7 @@ module Square
|
|
124
132
|
# Prepare headers.
|
125
133
|
_headers = {
|
126
134
|
'accept' => 'application/json',
|
127
|
-
'
|
135
|
+
'Content-Type' => 'application/json'
|
128
136
|
}
|
129
137
|
|
130
138
|
# Prepare and execute HttpRequest.
|
@@ -156,7 +164,7 @@ module Square
|
|
156
164
|
# @param [String] customer_id Required parameter: The ID of the customer to
|
157
165
|
# delete.
|
158
166
|
# @param [Long] version Optional parameter: The current version of the
|
159
|
-
# customer profile.
|
167
|
+
# customer profile. As a best practice, you should include this parameter
|
160
168
|
# to enable [optimistic
|
161
169
|
# concurrency](https://developer.squareup.com/docs/working-with-apis/optimis
|
162
170
|
# tic-concurrency) control. For more information, see [Delete a customer
|
@@ -266,7 +274,7 @@ module Square
|
|
266
274
|
# Prepare headers.
|
267
275
|
_headers = {
|
268
276
|
'accept' => 'application/json',
|
269
|
-
'
|
277
|
+
'Content-Type' => 'application/json'
|
270
278
|
}
|
271
279
|
|
272
280
|
# Prepare and execute HttpRequest.
|
@@ -312,7 +320,7 @@ module Square
|
|
312
320
|
# Prepare headers.
|
313
321
|
_headers = {
|
314
322
|
'accept' => 'application/json',
|
315
|
-
'
|
323
|
+
'Content-Type' => 'application/json'
|
316
324
|
}
|
317
325
|
|
318
326
|
# Prepare and execute HttpRequest.
|