square.rb 6.0.0.20200625 → 6.5.0.20201028
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +37 -30
- data/lib/square.rb +61 -60
- data/lib/square/api/apple_pay_api.rb +3 -1
- data/lib/square/api/bank_accounts_api.rb +12 -15
- data/lib/square/api/base_api.rb +2 -2
- data/lib/square/api/cash_drawers_api.rb +11 -5
- data/lib/square/api/catalog_api.rb +119 -49
- data/lib/square/api/checkout_api.rb +4 -2
- data/lib/square/api/customer_groups_api.rb +18 -8
- data/lib/square/api/customer_segments_api.rb +7 -3
- data/lib/square/api/customers_api.rb +47 -27
- data/lib/square/api/devices_api.rb +17 -6
- data/lib/square/api/disputes_api.rb +39 -34
- data/lib/square/api/employees_api.rb +10 -5
- data/lib/square/api/inventory_api.rb +30 -15
- data/lib/square/api/invoices_api.rb +359 -0
- data/lib/square/api/labor_api.rb +131 -22
- data/lib/square/api/locations_api.rb +20 -12
- data/lib/square/api/loyalty_api.rb +59 -65
- data/lib/square/api/merchants_api.rb +9 -4
- data/lib/square/api/mobile_authorization_api.rb +3 -1
- data/lib/square/api/o_auth_api.rb +10 -4
- data/lib/square/api/orders_api.rb +111 -90
- data/lib/square/api/payments_api.rb +75 -65
- data/lib/square/api/refunds_api.rb +21 -11
- data/lib/square/api/subscriptions_api.rb +263 -0
- data/lib/square/api/team_api.rb +32 -16
- data/lib/square/api/terminal_api.rb +156 -7
- data/lib/square/api/transactions_api.rb +32 -18
- data/lib/square/api/v1_employees_api.rb +59 -27
- data/lib/square/api/v1_items_api.rb +195 -115
- data/lib/square/api/v1_locations_api.rb +6 -2
- data/lib/square/api/v1_transactions_api.rb +49 -27
- data/lib/square/api_helper.rb +14 -9
- data/lib/square/client.rb +23 -16
- data/lib/square/configuration.rb +12 -4
- data/lib/square/http/api_response.rb +2 -0
- data/lib/square/http/faraday_client.rb +1 -0
- data/spec/user_journey_spec.rb +2 -5
- data/test/api/api_test_base.rb +1 -6
- data/test/api/test_catalog_api.rb +1 -4
- data/test/api/test_customers_api.rb +1 -4
- data/test/api/test_employees_api.rb +1 -4
- data/test/api/test_labor_api.rb +2 -6
- data/test/api/test_locations_api.rb +22 -33
- data/test/api/test_merchants_api.rb +1 -4
- data/test/api/test_payments_api.rb +3 -6
- data/test/api/test_refunds_api.rb +3 -6
- data/test/http_response_catcher.rb +0 -5
- data/test/test_helper.rb +0 -5
- metadata +33 -14
- data/lib/square/api/reporting_api.rb +0 -138
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e89b291628ca9e34dd317c1cabd319b96d3e7861de70eb8e9b1e006f521bd9e7
|
4
|
+
data.tar.gz: 316cd50188c224693b87df34043991a7cea712cfdc22814d08b90268924bd85b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d3b58b7592ba99f662b7e6601f9eee48535fa61a5009c159d05a21080e75b5af4f182ba7907e6350830400790fcd802531a62b5130da19392e95e6c8af9322f
|
7
|
+
data.tar.gz: abf4ab1de91013ea370e77fa7186a2f9436831b2611d6bc574d1c1401c6f2d99676c5984c37a5024f5bbd231799b4d4a599bdc43b00557a213f8191a7039cc65
|
data/README.md
CHANGED
@@ -38,6 +38,12 @@ gem 'square.rb'
|
|
38
38
|
### Orders
|
39
39
|
* [Orders]
|
40
40
|
|
41
|
+
### Subscriptions
|
42
|
+
* [Subscriptions]
|
43
|
+
|
44
|
+
### Invoices
|
45
|
+
* [Invoices]
|
46
|
+
|
41
47
|
### Items
|
42
48
|
* [Catalog]
|
43
49
|
* [Inventory]
|
@@ -74,7 +80,6 @@ gem 'square.rb'
|
|
74
80
|
* [V1 Transactions]
|
75
81
|
* [V1 Items]
|
76
82
|
* [Transactions]
|
77
|
-
* [Reporting]
|
78
83
|
|
79
84
|
## Usage
|
80
85
|
|
@@ -275,37 +280,39 @@ The Square Platform is built on the [Square API]. Square has a number of other S
|
|
275
280
|
|
276
281
|
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).
|
277
282
|
|
283
|
+
[//]: # "Link anchor definitions"
|
278
284
|
[Square Logo]: https://docs.connect.squareup.com/images/github/github-square-logo.svg
|
279
285
|
[Developer Dashboard]: https://developer.squareup.com/apps
|
280
286
|
[Square API]: https://squareup.com/developers
|
281
287
|
[sign up for a developer account]: https://squareup.com/signup?v=developers
|
282
288
|
[Client]: doc/client.md
|
283
|
-
[Devices]: doc/devices.md
|
284
|
-
[Disputes]: doc/disputes.md
|
285
|
-
[Terminal]: doc/terminal.md
|
286
|
-
[Team]: doc/team.md
|
287
|
-
[Cash Drawers]: doc/cash-drawers.md
|
288
|
-
[Customer Groups]: doc/customer-groups.md
|
289
|
-
[Customer Segments]: doc/customer-segments.md
|
290
|
-
[Bank Accounts]: doc/bank-accounts
|
291
|
-
[Payments]: doc/payments.md
|
292
|
-
[Checkout]: doc/checkout.md
|
293
|
-
[Catalog]: doc/catalog.md
|
294
|
-
[Customers]: doc/customers.md
|
295
|
-
[Employees]: doc/employees.md
|
296
|
-
[Inventory]: doc/inventory.md
|
297
|
-
[Labor]: doc/labor.md
|
298
|
-
[Loyalty]: doc/loyalty.md
|
299
|
-
[Locations]: doc/locations.md
|
300
|
-
[Merchants]: doc/merchants.md
|
301
|
-
[Orders]: doc/orders.md
|
302
|
-
[
|
303
|
-
[
|
304
|
-
[
|
305
|
-
[
|
306
|
-
[
|
307
|
-
[
|
308
|
-
[V1
|
309
|
-
[V1
|
310
|
-
[V1
|
311
|
-
[
|
289
|
+
[Devices]: doc/apis/devices.md
|
290
|
+
[Disputes]: doc/apis/disputes.md
|
291
|
+
[Terminal]: doc/apis/terminal.md
|
292
|
+
[Team]: doc/apis/team.md
|
293
|
+
[Cash Drawers]: doc/apis/cash-drawers.md
|
294
|
+
[Customer Groups]: doc/apis/customer-groups.md
|
295
|
+
[Customer Segments]: doc/apis/customer-segments.md
|
296
|
+
[Bank Accounts]: doc/apis/bank-accounts
|
297
|
+
[Payments]: doc/apis/payments.md
|
298
|
+
[Checkout]: doc/apis/checkout.md
|
299
|
+
[Catalog]: doc/apis/catalog.md
|
300
|
+
[Customers]: doc/apis/customers.md
|
301
|
+
[Employees]: doc/apis/employees.md
|
302
|
+
[Inventory]: doc/apis/inventory.md
|
303
|
+
[Labor]: doc/apis/labor.md
|
304
|
+
[Loyalty]: doc/apis/loyalty.md
|
305
|
+
[Locations]: doc/apis/locations.md
|
306
|
+
[Merchants]: doc/apis/merchants.md
|
307
|
+
[Orders]: doc/apis/orders.md
|
308
|
+
[Invoices]: doc/apis/invoices.md
|
309
|
+
[Apple Pay]: doc/apis/apple-pay.md
|
310
|
+
[Refunds]: doc/apis/refunds.md
|
311
|
+
[Subscriptions]: doc/apis/subscriptions.md
|
312
|
+
[Mobile Authorization]: doc/apis/mobile-authorization.md
|
313
|
+
[O Auth]: doc/apis/o-auth.md
|
314
|
+
[V1 Locations]: doc/apis/v1-locations.md
|
315
|
+
[V1 Employees]: doc/apis/v1-employees.md
|
316
|
+
[V1 Transactions]: doc/apis/v1-transactions.md
|
317
|
+
[V1 Items]: doc/apis/v1-items.md
|
318
|
+
[Transactions]: doc/apis/transactions.md
|
data/lib/square.rb
CHANGED
@@ -1,60 +1,61 @@
|
|
1
|
-
require 'date'
|
2
|
-
require 'json'
|
3
|
-
require 'faraday'
|
4
|
-
require 'certifi'
|
5
|
-
require 'logging'
|
6
|
-
|
7
|
-
require_relative 'square/api_helper.rb'
|
8
|
-
require_relative 'square/client.rb'
|
9
|
-
|
10
|
-
# Utilities
|
11
|
-
require_relative 'square/utilities/file_wrapper.rb'
|
12
|
-
|
13
|
-
# Http
|
14
|
-
require_relative 'square/http/api_response.rb'
|
15
|
-
require_relative 'square/http/http_call_back.rb'
|
16
|
-
require_relative 'square/http/http_client.rb'
|
17
|
-
require_relative 'square/http/faraday_client.rb'
|
18
|
-
require_relative 'square/http/http_method_enum.rb'
|
19
|
-
require_relative 'square/http/http_request.rb'
|
20
|
-
require_relative 'square/http/http_response.rb'
|
21
|
-
require_relative 'square/http/auth/o_auth2.rb'
|
22
|
-
|
23
|
-
# Models
|
24
|
-
|
25
|
-
# Exceptions
|
26
|
-
require_relative 'square/exceptions/api_exception.rb'
|
27
|
-
|
28
|
-
require_relative 'square/configuration.rb'
|
29
|
-
|
30
|
-
# Controllers
|
31
|
-
require_relative 'square/api/base_api.rb'
|
32
|
-
require_relative 'square/api/mobile_authorization_api.rb'
|
33
|
-
require_relative 'square/api/o_auth_api.rb'
|
34
|
-
require_relative 'square/api/v1_locations_api.rb'
|
35
|
-
require_relative 'square/api/v1_employees_api.rb'
|
36
|
-
require_relative 'square/api/v1_transactions_api.rb'
|
37
|
-
require_relative 'square/api/v1_items_api.rb'
|
38
|
-
require_relative 'square/api/apple_pay_api.rb'
|
39
|
-
require_relative 'square/api/bank_accounts_api.rb'
|
40
|
-
require_relative 'square/api/cash_drawers_api.rb'
|
41
|
-
require_relative 'square/api/catalog_api.rb'
|
42
|
-
require_relative 'square/api/customers_api.rb'
|
43
|
-
require_relative 'square/api/customer_groups_api.rb'
|
44
|
-
require_relative 'square/api/customer_segments_api.rb'
|
45
|
-
require_relative 'square/api/devices_api.rb'
|
46
|
-
require_relative 'square/api/disputes_api.rb'
|
47
|
-
require_relative 'square/api/employees_api.rb'
|
48
|
-
require_relative 'square/api/inventory_api.rb'
|
49
|
-
require_relative 'square/api/
|
50
|
-
require_relative 'square/api/
|
51
|
-
require_relative 'square/api/
|
52
|
-
require_relative 'square/api/checkout_api.rb'
|
53
|
-
require_relative 'square/api/
|
54
|
-
require_relative 'square/api/
|
55
|
-
require_relative 'square/api/
|
56
|
-
require_relative 'square/api/
|
57
|
-
require_relative 'square/api/payments_api.rb'
|
58
|
-
require_relative 'square/api/refunds_api.rb'
|
59
|
-
require_relative 'square/api/
|
60
|
-
require_relative 'square/api/
|
1
|
+
require 'date'
|
2
|
+
require 'json'
|
3
|
+
require 'faraday'
|
4
|
+
require 'certifi'
|
5
|
+
require 'logging'
|
6
|
+
|
7
|
+
require_relative 'square/api_helper.rb'
|
8
|
+
require_relative 'square/client.rb'
|
9
|
+
|
10
|
+
# Utilities
|
11
|
+
require_relative 'square/utilities/file_wrapper.rb'
|
12
|
+
|
13
|
+
# Http
|
14
|
+
require_relative 'square/http/api_response.rb'
|
15
|
+
require_relative 'square/http/http_call_back.rb'
|
16
|
+
require_relative 'square/http/http_client.rb'
|
17
|
+
require_relative 'square/http/faraday_client.rb'
|
18
|
+
require_relative 'square/http/http_method_enum.rb'
|
19
|
+
require_relative 'square/http/http_request.rb'
|
20
|
+
require_relative 'square/http/http_response.rb'
|
21
|
+
require_relative 'square/http/auth/o_auth2.rb'
|
22
|
+
|
23
|
+
# Models
|
24
|
+
|
25
|
+
# Exceptions
|
26
|
+
require_relative 'square/exceptions/api_exception.rb'
|
27
|
+
|
28
|
+
require_relative 'square/configuration.rb'
|
29
|
+
|
30
|
+
# Controllers
|
31
|
+
require_relative 'square/api/base_api.rb'
|
32
|
+
require_relative 'square/api/mobile_authorization_api.rb'
|
33
|
+
require_relative 'square/api/o_auth_api.rb'
|
34
|
+
require_relative 'square/api/v1_locations_api.rb'
|
35
|
+
require_relative 'square/api/v1_employees_api.rb'
|
36
|
+
require_relative 'square/api/v1_transactions_api.rb'
|
37
|
+
require_relative 'square/api/v1_items_api.rb'
|
38
|
+
require_relative 'square/api/apple_pay_api.rb'
|
39
|
+
require_relative 'square/api/bank_accounts_api.rb'
|
40
|
+
require_relative 'square/api/cash_drawers_api.rb'
|
41
|
+
require_relative 'square/api/catalog_api.rb'
|
42
|
+
require_relative 'square/api/customers_api.rb'
|
43
|
+
require_relative 'square/api/customer_groups_api.rb'
|
44
|
+
require_relative 'square/api/customer_segments_api.rb'
|
45
|
+
require_relative 'square/api/devices_api.rb'
|
46
|
+
require_relative 'square/api/disputes_api.rb'
|
47
|
+
require_relative 'square/api/employees_api.rb'
|
48
|
+
require_relative 'square/api/inventory_api.rb'
|
49
|
+
require_relative 'square/api/invoices_api.rb'
|
50
|
+
require_relative 'square/api/labor_api.rb'
|
51
|
+
require_relative 'square/api/locations_api.rb'
|
52
|
+
require_relative 'square/api/checkout_api.rb'
|
53
|
+
require_relative 'square/api/transactions_api.rb'
|
54
|
+
require_relative 'square/api/loyalty_api.rb'
|
55
|
+
require_relative 'square/api/merchants_api.rb'
|
56
|
+
require_relative 'square/api/orders_api.rb'
|
57
|
+
require_relative 'square/api/payments_api.rb'
|
58
|
+
require_relative 'square/api/refunds_api.rb'
|
59
|
+
require_relative 'square/api/subscriptions_api.rb'
|
60
|
+
require_relative 'square/api/team_api.rb'
|
61
|
+
require_relative 'square/api/terminal_api.rb'
|
@@ -44,7 +44,9 @@ module Square
|
|
44
44
|
# Return appropriate response type.
|
45
45
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
46
46
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
47
|
-
ApiResponse.new(
|
47
|
+
ApiResponse.new(
|
48
|
+
_response, data: decoded, errors: _errors
|
49
|
+
)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
@@ -7,9 +7,6 @@ module Square
|
|
7
7
|
|
8
8
|
# Returns a list of [BankAccount](#type-bankaccount) objects linked to a
|
9
9
|
# Square account.
|
10
|
-
# For more information, see
|
11
|
-
# [Bank Accounts
|
12
|
-
# API](https://developer.squareup.com/docs/docs/bank-accounts-api).
|
13
10
|
# @param [String] cursor Optional parameter: The pagination cursor returned
|
14
11
|
# by a previous call to this endpoint. Use it in the next `ListBankAccounts`
|
15
12
|
# request to retrieve the next set of results. See the
|
@@ -53,15 +50,13 @@ module Square
|
|
53
50
|
# Return appropriate response type.
|
54
51
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
55
52
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
56
|
-
ApiResponse.new(
|
53
|
+
ApiResponse.new(
|
54
|
+
_response, data: decoded, errors: _errors
|
55
|
+
)
|
57
56
|
end
|
58
57
|
|
59
58
|
# Returns details of a [BankAccount](#type-bankaccount) identified by V1
|
60
59
|
# bank account ID.
|
61
|
-
# For more information, see
|
62
|
-
# [Retrieve a bank account by using an ID issued by V1 Bank Accounts
|
63
|
-
# API](https://developer.squareup.com/docs/docs/bank-accounts-api#retrieve-a
|
64
|
-
# -bank-account-by-using-an-id-issued-by-the-v1-bank-accounts-api).
|
65
60
|
# @param [String] v1_bank_account_id Required parameter: Connect V1 ID of
|
66
61
|
# the desired `BankAccount`. For more information, see [Retrieve a bank
|
67
62
|
# account by using an ID issued by V1 Bank Accounts
|
@@ -74,7 +69,7 @@ module Square
|
|
74
69
|
_query_builder << '/v2/bank-accounts/by-v1-id/{v1_bank_account_id}'
|
75
70
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
76
71
|
_query_builder,
|
77
|
-
'v1_bank_account_id' => v1_bank_account_id
|
72
|
+
'v1_bank_account_id' => { 'value' => v1_bank_account_id, 'encode' => true }
|
78
73
|
)
|
79
74
|
_query_url = APIHelper.clean_url _query_builder
|
80
75
|
|
@@ -94,13 +89,13 @@ module Square
|
|
94
89
|
# Return appropriate response type.
|
95
90
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
96
91
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
97
|
-
ApiResponse.new(
|
92
|
+
ApiResponse.new(
|
93
|
+
_response, data: decoded, errors: _errors
|
94
|
+
)
|
98
95
|
end
|
99
96
|
|
100
97
|
# Returns details of a [BankAccount](#type-bankaccount)
|
101
|
-
# linked to a Square account.
|
102
|
-
# [Bank Accounts
|
103
|
-
# API](https://developer.squareup.com/docs/docs/bank-accounts-api).
|
98
|
+
# linked to a Square account.
|
104
99
|
# @param [String] bank_account_id Required parameter: Square-issued ID of
|
105
100
|
# the desired `BankAccount`.
|
106
101
|
# @return [GetBankAccountResponse Hash] response from the API call
|
@@ -110,7 +105,7 @@ module Square
|
|
110
105
|
_query_builder << '/v2/bank-accounts/{bank_account_id}'
|
111
106
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
112
107
|
_query_builder,
|
113
|
-
'bank_account_id' => bank_account_id
|
108
|
+
'bank_account_id' => { 'value' => bank_account_id, 'encode' => true }
|
114
109
|
)
|
115
110
|
_query_url = APIHelper.clean_url _query_builder
|
116
111
|
|
@@ -130,7 +125,9 @@ module Square
|
|
130
125
|
# Return appropriate response type.
|
131
126
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
132
127
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
133
|
-
ApiResponse.new(
|
128
|
+
ApiResponse.new(
|
129
|
+
_response, data: decoded, errors: _errors
|
130
|
+
)
|
134
131
|
end
|
135
132
|
end
|
136
133
|
end
|
data/lib/square/api/base_api.rb
CHANGED
@@ -8,8 +8,8 @@ module Square
|
|
8
8
|
@http_call_back = http_call_back
|
9
9
|
|
10
10
|
@global_headers = {
|
11
|
-
'user-agent' => 'Square-Ruby-SDK/6.
|
12
|
-
'Square-Version' =>
|
11
|
+
'user-agent' => 'Square-Ruby-SDK/6.5.0.20201028',
|
12
|
+
'Square-Version' => config.square_version
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
@@ -57,7 +57,9 @@ module Square
|
|
57
57
|
# Return appropriate response type.
|
58
58
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
59
59
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
60
|
-
ApiResponse.new(
|
60
|
+
ApiResponse.new(
|
61
|
+
_response, data: decoded, errors: _errors
|
62
|
+
)
|
61
63
|
end
|
62
64
|
|
63
65
|
# Provides the summary details for a single cash drawer shift. See
|
@@ -73,7 +75,7 @@ module Square
|
|
73
75
|
_query_builder << '/v2/cash-drawers/shifts/{shift_id}'
|
74
76
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
75
77
|
_query_builder,
|
76
|
-
'shift_id' => shift_id
|
78
|
+
'shift_id' => { 'value' => shift_id, 'encode' => true }
|
77
79
|
)
|
78
80
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
79
81
|
_query_builder,
|
@@ -97,7 +99,9 @@ module Square
|
|
97
99
|
# Return appropriate response type.
|
98
100
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
99
101
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
100
|
-
ApiResponse.new(
|
102
|
+
ApiResponse.new(
|
103
|
+
_response, data: decoded, errors: _errors
|
104
|
+
)
|
101
105
|
end
|
102
106
|
|
103
107
|
# Provides a paginated list of events for a single cash drawer shift.
|
@@ -118,7 +122,7 @@ module Square
|
|
118
122
|
_query_builder << '/v2/cash-drawers/shifts/{shift_id}/events'
|
119
123
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
120
124
|
_query_builder,
|
121
|
-
'shift_id' => shift_id
|
125
|
+
'shift_id' => { 'value' => shift_id, 'encode' => true }
|
122
126
|
)
|
123
127
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
124
128
|
_query_builder,
|
@@ -144,7 +148,9 @@ module Square
|
|
144
148
|
# Return appropriate response type.
|
145
149
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
146
150
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
147
|
-
ApiResponse.new(
|
151
|
+
ApiResponse.new(
|
152
|
+
_response, data: decoded, errors: _errors
|
153
|
+
)
|
148
154
|
end
|
149
155
|
end
|
150
156
|
end
|
@@ -44,7 +44,9 @@ module Square
|
|
44
44
|
# Return appropriate response type.
|
45
45
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
46
46
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
47
|
-
ApiResponse.new(
|
47
|
+
ApiResponse.new(
|
48
|
+
_response, data: decoded, errors: _errors
|
49
|
+
)
|
48
50
|
end
|
49
51
|
|
50
52
|
# Returns a set of objects based on the provided ID.
|
@@ -83,7 +85,9 @@ module Square
|
|
83
85
|
# Return appropriate response type.
|
84
86
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
85
87
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
86
|
-
ApiResponse.new(
|
88
|
+
ApiResponse.new(
|
89
|
+
_response, data: decoded, errors: _errors
|
90
|
+
)
|
87
91
|
end
|
88
92
|
|
89
93
|
# Creates or updates up to 10,000 target objects based on the provided
|
@@ -128,22 +132,19 @@ module Square
|
|
128
132
|
# Return appropriate response type.
|
129
133
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
130
134
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
131
|
-
ApiResponse.new(
|
135
|
+
ApiResponse.new(
|
136
|
+
_response, data: decoded, errors: _errors
|
137
|
+
)
|
132
138
|
end
|
133
139
|
|
134
|
-
#
|
135
|
-
#
|
136
|
-
# [CatalogObject](#type-catalogobject).
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
# part and an image file part in
|
140
|
+
# Uploads an image file to be represented by a
|
141
|
+
# [CatalogImage](#type-catalogimage) object linked to an existing
|
142
|
+
# [CatalogObject](#type-catalogobject) instance. A call to this endpoint can
|
143
|
+
# upload an image, link an image to
|
144
|
+
# a catalog object, or do both.
|
145
|
+
# This `CreateCatalogImage` endpoint accepts HTTP multipart/form-data
|
146
|
+
# requests with a JSON part and an image file part in
|
142
147
|
# JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.
|
143
|
-
# Additional information and an example cURL request can be found in the
|
144
|
-
# [Create a Catalog Image
|
145
|
-
# recipe](https://developer.squareup.com/docs/more-apis/catalog/cookbook/cre
|
146
|
-
# ate-catalog-images).
|
147
148
|
# @param [CreateCatalogImageRequest] request Optional parameter: Example:
|
148
149
|
# @param [File | UploadIO] image_file Optional parameter: Example:
|
149
150
|
# @return [CreateCatalogImageResponse Hash] response from the API call
|
@@ -192,11 +193,13 @@ module Square
|
|
192
193
|
# Return appropriate response type.
|
193
194
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
194
195
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
195
|
-
ApiResponse.new(
|
196
|
+
ApiResponse.new(
|
197
|
+
_response, data: decoded, errors: _errors
|
198
|
+
)
|
196
199
|
end
|
197
200
|
|
198
|
-
#
|
199
|
-
# limits
|
201
|
+
# Retrieves information about the Square Catalog API, such as batch size
|
202
|
+
# limits that can be used by the `BatchUpsertCatalogObjects` endpoint.
|
200
203
|
# @return [CatalogInfoResponse Hash] response from the API call
|
201
204
|
def catalog_info
|
202
205
|
# Prepare query url.
|
@@ -220,7 +223,9 @@ module Square
|
|
220
223
|
# Return appropriate response type.
|
221
224
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
222
225
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
223
|
-
ApiResponse.new(
|
226
|
+
ApiResponse.new(
|
227
|
+
_response, data: decoded, errors: _errors
|
228
|
+
)
|
224
229
|
end
|
225
230
|
|
226
231
|
# Returns a list of [CatalogObject](#type-catalogobject)s that includes
|
@@ -275,7 +280,9 @@ module Square
|
|
275
280
|
# Return appropriate response type.
|
276
281
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
277
282
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
278
|
-
ApiResponse.new(
|
283
|
+
ApiResponse.new(
|
284
|
+
_response, data: decoded, errors: _errors
|
285
|
+
)
|
279
286
|
end
|
280
287
|
|
281
288
|
# Creates or updates the target [CatalogObject](#type-catalogobject).
|
@@ -307,7 +314,9 @@ module Square
|
|
307
314
|
# Return appropriate response type.
|
308
315
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
309
316
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
310
|
-
ApiResponse.new(
|
317
|
+
ApiResponse.new(
|
318
|
+
_response, data: decoded, errors: _errors
|
319
|
+
)
|
311
320
|
end
|
312
321
|
|
313
322
|
# Deletes a single [CatalogObject](#type-catalogobject) based on the
|
@@ -329,7 +338,7 @@ module Square
|
|
329
338
|
_query_builder << '/v2/catalog/object/{object_id}'
|
330
339
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
331
340
|
_query_builder,
|
332
|
-
'object_id' => object_id
|
341
|
+
'object_id' => { 'value' => object_id, 'encode' => true }
|
333
342
|
)
|
334
343
|
_query_url = APIHelper.clean_url _query_builder
|
335
344
|
|
@@ -349,7 +358,9 @@ module Square
|
|
349
358
|
# Return appropriate response type.
|
350
359
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
351
360
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
352
|
-
ApiResponse.new(
|
361
|
+
ApiResponse.new(
|
362
|
+
_response, data: decoded, errors: _errors
|
363
|
+
)
|
353
364
|
end
|
354
365
|
|
355
366
|
# Returns a single [CatalogItem](#type-catalogitem) as a
|
@@ -365,12 +376,12 @@ module Square
|
|
365
376
|
# @param [Boolean] include_related_objects Optional parameter: If `true`,
|
366
377
|
# the response will include additional objects that are related to the
|
367
378
|
# requested object, as follows: If the `object` field of the response
|
368
|
-
# contains a CatalogItem
|
369
|
-
#
|
379
|
+
# contains a `CatalogItem`, its associated `CatalogCategory`, `CatalogTax`,
|
380
|
+
# `CatalogImage` and `CatalogModifierList` objects will be returned in the
|
370
381
|
# `related_objects` field of the response. If the `object` field of the
|
371
|
-
# response contains a CatalogItemVariation
|
372
|
-
# returned in the `related_objects` field of the response. Default
|
373
|
-
# `false`
|
382
|
+
# response contains a `CatalogItemVariation`, its parent `CatalogItem` will
|
383
|
+
# be returned in the `related_objects` field of the response. Default
|
384
|
+
# value: `false`
|
374
385
|
# @return [RetrieveCatalogObjectResponse Hash] response from the API call
|
375
386
|
def retrieve_catalog_object(object_id:,
|
376
387
|
include_related_objects: false)
|
@@ -379,7 +390,7 @@ module Square
|
|
379
390
|
_query_builder << '/v2/catalog/object/{object_id}'
|
380
391
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
381
392
|
_query_builder,
|
382
|
-
'object_id' => object_id
|
393
|
+
'object_id' => { 'value' => object_id, 'encode' => true }
|
383
394
|
)
|
384
395
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
385
396
|
_query_builder,
|
@@ -403,25 +414,28 @@ module Square
|
|
403
414
|
# Return appropriate response type.
|
404
415
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
405
416
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
406
|
-
ApiResponse.new(
|
417
|
+
ApiResponse.new(
|
418
|
+
_response, data: decoded, errors: _errors
|
419
|
+
)
|
407
420
|
end
|
408
421
|
|
409
|
-
#
|
410
|
-
#
|
411
|
-
#
|
412
|
-
#
|
413
|
-
#
|
414
|
-
#
|
415
|
-
#
|
416
|
-
# -
|
417
|
-
#
|
418
|
-
#
|
419
|
-
#
|
420
|
-
#
|
421
|
-
#
|
422
|
-
#
|
423
|
-
#
|
424
|
-
#
|
422
|
+
# Searches for [CatalogObject](#type-CatalogObject) of any types against
|
423
|
+
# supported search attribute values,
|
424
|
+
# excluding custom attribute values on items or item variations, against one
|
425
|
+
# or more of the specified query expressions,
|
426
|
+
# This (`SearchCatalogObjects`) endpoint differs from the
|
427
|
+
# [SearchCatalogItems](#endpoint-Catalog-SearchCatalogItems)
|
428
|
+
# endpoint in the following aspects:
|
429
|
+
# - `SearchCatalogItems` can only search for items or item variations,
|
430
|
+
# whereas `SearchCatalogObjects` can search for any type of catalog objects.
|
431
|
+
# - `SearchCatalogItems` supports the custom attribute query filters to
|
432
|
+
# return items or item variations that contain custom attribute values,
|
433
|
+
# where `SearchCatalogObjects` does not.
|
434
|
+
# - `SearchCatalogItems` does not support the `include_deleted_objects`
|
435
|
+
# filter to search for deleted items or item variations, whereas
|
436
|
+
# `SearchCatalogObjects` does.
|
437
|
+
# - The both endpoints have different call conventions, including the query
|
438
|
+
# filter formats.
|
425
439
|
# @param [SearchCatalogObjectsRequest] body Required parameter: An object
|
426
440
|
# containing the fields to POST for the request. See the corresponding
|
427
441
|
# object definition for field details.
|
@@ -450,7 +464,59 @@ module Square
|
|
450
464
|
# Return appropriate response type.
|
451
465
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
452
466
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
453
|
-
ApiResponse.new(
|
467
|
+
ApiResponse.new(
|
468
|
+
_response, data: decoded, errors: _errors
|
469
|
+
)
|
470
|
+
end
|
471
|
+
|
472
|
+
# Searches for catalog items or item variations by matching supported search
|
473
|
+
# attribute values, including
|
474
|
+
# custom attribute values, against one or more of the specified query
|
475
|
+
# expressions,
|
476
|
+
# This (`SearchCatalogItems`) endpoint differs from the
|
477
|
+
# [SearchCatalogObjects](#endpoint-Catalog-SearchCatalogObjects)
|
478
|
+
# endpoint in the following aspects:
|
479
|
+
# - `SearchCatalogItems` can only search for items or item variations,
|
480
|
+
# whereas `SearchCatalogObjects` can search for any type of catalog objects.
|
481
|
+
# - `SearchCatalogItems` supports the custom attribute query filters to
|
482
|
+
# return items or item variations that contain custom attribute values,
|
483
|
+
# where `SearchCatalogObjects` does not.
|
484
|
+
# - `SearchCatalogItems` does not support the `include_deleted_objects`
|
485
|
+
# filter to search for deleted items or item variations, whereas
|
486
|
+
# `SearchCatalogObjects` does.
|
487
|
+
# - The both endpoints use different call conventions, including the query
|
488
|
+
# filter formats.
|
489
|
+
# @param [SearchCatalogItemsRequest] body Required parameter: An object
|
490
|
+
# containing the fields to POST for the request. See the corresponding
|
491
|
+
# object definition for field details.
|
492
|
+
# @return [SearchCatalogItemsResponse Hash] response from the API call
|
493
|
+
def search_catalog_items(body:)
|
494
|
+
# Prepare query url.
|
495
|
+
_query_builder = config.get_base_uri
|
496
|
+
_query_builder << '/v2/catalog/search-catalog-items'
|
497
|
+
_query_url = APIHelper.clean_url _query_builder
|
498
|
+
|
499
|
+
# Prepare headers.
|
500
|
+
_headers = {
|
501
|
+
'accept' => 'application/json',
|
502
|
+
'content-type' => 'application/json; charset=utf-8'
|
503
|
+
}
|
504
|
+
|
505
|
+
# Prepare and execute HttpRequest.
|
506
|
+
_request = config.http_client.post(
|
507
|
+
_query_url,
|
508
|
+
headers: _headers,
|
509
|
+
parameters: body.to_json
|
510
|
+
)
|
511
|
+
OAuth2.apply(config, _request)
|
512
|
+
_response = execute_request(_request)
|
513
|
+
|
514
|
+
# Return appropriate response type.
|
515
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
516
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
517
|
+
ApiResponse.new(
|
518
|
+
_response, data: decoded, errors: _errors
|
519
|
+
)
|
454
520
|
end
|
455
521
|
|
456
522
|
# Updates the [CatalogModifierList](#type-catalogmodifierlist) objects
|
@@ -484,7 +550,9 @@ module Square
|
|
484
550
|
# Return appropriate response type.
|
485
551
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
486
552
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
487
|
-
ApiResponse.new(
|
553
|
+
ApiResponse.new(
|
554
|
+
_response, data: decoded, errors: _errors
|
555
|
+
)
|
488
556
|
end
|
489
557
|
|
490
558
|
# Updates the [CatalogTax](#type-catalogtax) objects that apply to the
|
@@ -518,7 +586,9 @@ module Square
|
|
518
586
|
# Return appropriate response type.
|
519
587
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
520
588
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
521
|
-
ApiResponse.new(
|
589
|
+
ApiResponse.new(
|
590
|
+
_response, data: decoded, errors: _errors
|
591
|
+
)
|
522
592
|
end
|
523
593
|
end
|
524
594
|
end
|