square.rb 3.20190814.0 → 3.20190925.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/square.rb +53 -52
- data/lib/square/api/apple_pay_api.rb +55 -55
- data/lib/square/api/base_api.rb +48 -45
- data/lib/square/api/catalog_api.rb +461 -461
- data/lib/square/api/checkout_api.rb +54 -54
- data/lib/square/api/customers_api.rb +335 -335
- data/lib/square/api/employees_api.rb +91 -91
- data/lib/square/api/inventory_api.rb +300 -300
- data/lib/square/api/labor_api.rb +558 -558
- data/lib/square/api/locations_api.rb +117 -45
- data/lib/square/api/merchants_api.rb +46 -0
- data/lib/square/api/mobile_authorization_api.rb +56 -56
- data/lib/square/api/o_auth_api.rb +168 -168
- data/lib/square/api/orders_api.rb +271 -269
- data/lib/square/api/payments_api.rb +282 -282
- data/lib/square/api/refunds_api.rb +149 -149
- data/lib/square/api/reporting_api.rb +145 -143
- data/lib/square/api/transactions_api.rb +379 -379
- data/lib/square/api/v1_employees_api.rb +720 -720
- data/lib/square/api/v1_items_api.rb +1651 -1651
- data/lib/square/api/v1_locations_api.rb +67 -67
- data/lib/square/api/v1_transactions_api.rb +574 -574
- data/lib/square/api_helper.rb +281 -281
- data/lib/square/client.rb +155 -139
- data/lib/square/configuration.rb +98 -88
- data/lib/square/exceptions/api_exception.rb +20 -20
- data/lib/square/http/api_response.rb +50 -50
- data/lib/square/http/auth/o_auth2.rb +17 -17
- data/lib/square/http/faraday_client.rb +64 -64
- data/lib/square/http/http_call_back.rb +24 -24
- data/lib/square/http/http_client.rb +104 -104
- data/lib/square/http/http_method_enum.rb +13 -13
- data/lib/square/http/http_request.rb +50 -50
- data/lib/square/http/http_response.rb +29 -29
- data/test/api/test_labor_api.rb +74 -0
- metadata +4 -3
- data/lib/square/api/v1_locations_api.rbe +0 -67
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beb32cc7558c26d539366f22c17808aa9a146aef2cc4096fb4ad30580eb95a60
|
4
|
+
data.tar.gz: 527c69329e6126ca6c8cd96a874b3ebd024be76b97f0f75435dca9649d692c9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4f5f6f3b975c1a2d12ee13681454f15ecfcc14846322b865b0604ef737a8574eb125decc816de80c6a51d9d44ea473fcddfaaed0cc4e77a1f7bac0462400cbd
|
7
|
+
data.tar.gz: 6e1140b5ba8204d3acda52e06762916bd4a490e66498972bc1cd7c1886055697f1a4ee798b341422143203fa6e47ae4ea457d818024431ee61b8d439b1093885
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Square Ruby SDK
|
4
4
|
|
5
5
|
[![Travis status](https://travis-ci.org/square/square-ruby-sdk.svg?branch=master)](https://travis-ci.org/square/square-ruby-sdk)
|
6
|
-
[![Gem version](https://badge.fury.io/rb/square.rb.svg)](https://badge.fury.io/rb/square.rb)
|
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
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.
|
@@ -40,8 +40,10 @@ gem 'square.rb'
|
|
40
40
|
* [Inventory]
|
41
41
|
* [Labor]
|
42
42
|
* [Locations]
|
43
|
+
* [Merchants]
|
43
44
|
* [Orders]
|
44
45
|
* [Apple Pay]
|
46
|
+
* [Refunds]
|
45
47
|
* [Reporting]
|
46
48
|
|
47
49
|
### Authorization APIs
|
@@ -212,7 +214,7 @@ If your call succeeds, you’ll see a response that looks like this:
|
|
212
214
|
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:
|
213
215
|
|
214
216
|
```ruby
|
215
|
-
if result.
|
217
|
+
if result.success?
|
216
218
|
p result.data
|
217
219
|
elsif result.error?
|
218
220
|
warn result.errors.inspect
|
@@ -269,8 +271,10 @@ You can also use the Square API to create applications or services that work wit
|
|
269
271
|
[Inventory]: doc/inventory.md
|
270
272
|
[Labor]: doc/labor.md
|
271
273
|
[Locations]: doc/locations.md
|
274
|
+
[Merchants]: doc/merchants.md
|
272
275
|
[Orders]: doc/orders.md
|
273
276
|
[Apple Pay]: doc/apple-pay.md
|
277
|
+
[Refunds]: doc/refunds.md
|
274
278
|
[Reporting]: doc/reporting.md
|
275
279
|
[Mobile Authorization]: doc/mobile-authorization.md
|
276
280
|
[O Auth]: doc/o-auth.md
|
data/lib/square.rb
CHANGED
@@ -1,52 +1,53 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
require 'date'
|
7
|
-
require 'json'
|
8
|
-
require 'faraday'
|
9
|
-
require 'certifi'
|
10
|
-
require 'logging'
|
11
|
-
|
12
|
-
require_relative 'square/api_helper.rb'
|
13
|
-
require_relative 'square/client.rb'
|
14
|
-
|
15
|
-
# Http
|
16
|
-
require_relative 'square/http/api_response.rb'
|
17
|
-
require_relative 'square/http/http_call_back.rb'
|
18
|
-
require_relative 'square/http/http_client.rb'
|
19
|
-
require_relative 'square/http/faraday_client.rb'
|
20
|
-
require_relative 'square/http/http_method_enum.rb'
|
21
|
-
require_relative 'square/http/http_request.rb'
|
22
|
-
require_relative 'square/http/http_response.rb'
|
23
|
-
require_relative 'square/http/auth/o_auth2.rb'
|
24
|
-
|
25
|
-
# Models
|
26
|
-
|
27
|
-
# Exceptions
|
28
|
-
require_relative 'square/exceptions/api_exception.rb'
|
29
|
-
|
30
|
-
require_relative 'square/configuration.rb'
|
31
|
-
|
32
|
-
# Controllers
|
33
|
-
require_relative 'square/api/base_api.rb'
|
34
|
-
require_relative 'square/api/mobile_authorization_api.rb'
|
35
|
-
require_relative 'square/api/o_auth_api.rb'
|
36
|
-
require_relative 'square/api/v1_locations_api.rb'
|
37
|
-
require_relative 'square/api/v1_employees_api.rb'
|
38
|
-
require_relative 'square/api/v1_transactions_api.rb'
|
39
|
-
require_relative 'square/api/v1_items_api.rb'
|
40
|
-
require_relative 'square/api/apple_pay_api.rb'
|
41
|
-
require_relative 'square/api/catalog_api.rb'
|
42
|
-
require_relative 'square/api/customers_api.rb'
|
43
|
-
require_relative 'square/api/employees_api.rb'
|
44
|
-
require_relative 'square/api/inventory_api.rb'
|
45
|
-
require_relative 'square/api/labor_api.rb'
|
46
|
-
require_relative 'square/api/locations_api.rb'
|
47
|
-
require_relative 'square/api/reporting_api.rb'
|
48
|
-
require_relative 'square/api/checkout_api.rb'
|
49
|
-
require_relative 'square/api/orders_api.rb'
|
50
|
-
require_relative 'square/api/transactions_api.rb'
|
51
|
-
require_relative 'square/api/
|
52
|
-
require_relative 'square/api/
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
require 'json'
|
8
|
+
require 'faraday'
|
9
|
+
require 'certifi'
|
10
|
+
require 'logging'
|
11
|
+
|
12
|
+
require_relative 'square/api_helper.rb'
|
13
|
+
require_relative 'square/client.rb'
|
14
|
+
|
15
|
+
# Http
|
16
|
+
require_relative 'square/http/api_response.rb'
|
17
|
+
require_relative 'square/http/http_call_back.rb'
|
18
|
+
require_relative 'square/http/http_client.rb'
|
19
|
+
require_relative 'square/http/faraday_client.rb'
|
20
|
+
require_relative 'square/http/http_method_enum.rb'
|
21
|
+
require_relative 'square/http/http_request.rb'
|
22
|
+
require_relative 'square/http/http_response.rb'
|
23
|
+
require_relative 'square/http/auth/o_auth2.rb'
|
24
|
+
|
25
|
+
# Models
|
26
|
+
|
27
|
+
# Exceptions
|
28
|
+
require_relative 'square/exceptions/api_exception.rb'
|
29
|
+
|
30
|
+
require_relative 'square/configuration.rb'
|
31
|
+
|
32
|
+
# Controllers
|
33
|
+
require_relative 'square/api/base_api.rb'
|
34
|
+
require_relative 'square/api/mobile_authorization_api.rb'
|
35
|
+
require_relative 'square/api/o_auth_api.rb'
|
36
|
+
require_relative 'square/api/v1_locations_api.rb'
|
37
|
+
require_relative 'square/api/v1_employees_api.rb'
|
38
|
+
require_relative 'square/api/v1_transactions_api.rb'
|
39
|
+
require_relative 'square/api/v1_items_api.rb'
|
40
|
+
require_relative 'square/api/apple_pay_api.rb'
|
41
|
+
require_relative 'square/api/catalog_api.rb'
|
42
|
+
require_relative 'square/api/customers_api.rb'
|
43
|
+
require_relative 'square/api/employees_api.rb'
|
44
|
+
require_relative 'square/api/inventory_api.rb'
|
45
|
+
require_relative 'square/api/labor_api.rb'
|
46
|
+
require_relative 'square/api/locations_api.rb'
|
47
|
+
require_relative 'square/api/reporting_api.rb'
|
48
|
+
require_relative 'square/api/checkout_api.rb'
|
49
|
+
require_relative 'square/api/orders_api.rb'
|
50
|
+
require_relative 'square/api/transactions_api.rb'
|
51
|
+
require_relative 'square/api/merchants_api.rb'
|
52
|
+
require_relative 'square/api/payments_api.rb'
|
53
|
+
require_relative 'square/api/refunds_api.rb'
|
@@ -1,55 +1,55 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# ApplePayApi
|
8
|
-
class ApplePayApi < BaseApi
|
9
|
-
def initialize(config, http_call_back: nil)
|
10
|
-
super(config, http_call_back: http_call_back)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Activates a domain for use with Web Apple Pay and Square. A validation
|
14
|
-
# will be performed on this domain by Apple to ensure is it properly set up
|
15
|
-
# as
|
16
|
-
# an Apple Pay enabled domain.
|
17
|
-
# This endpoint provides an easy way for platform developers to bulk
|
18
|
-
# activate
|
19
|
-
# Web Apple Pay with Square for merchants using their platform.
|
20
|
-
# To learn more about Apple Pay on Web see the Apple Pay section in the
|
21
|
-
# [Embedding the Square Payment
|
22
|
-
# Form](https://developer.squareup.com/docs/payment-form/add-digital-wallets
|
23
|
-
# /apple-pay) guide.
|
24
|
-
# @param [RegisterDomainRequest] body Required parameter: An object
|
25
|
-
# containing the fields to POST for the request. See the corresponding
|
26
|
-
# object definition for field details.
|
27
|
-
# @return [RegisterDomainResponse Hash] response from the API call
|
28
|
-
def register_domain(body:)
|
29
|
-
# Prepare query url.
|
30
|
-
_query_builder = config.get_base_uri
|
31
|
-
_query_builder << '/v2/apple-pay/domains'
|
32
|
-
_query_url = APIHelper.clean_url _query_builder
|
33
|
-
|
34
|
-
# Prepare headers.
|
35
|
-
_headers = {
|
36
|
-
'accept' => 'application/json',
|
37
|
-
'content-type' => 'application/json; charset=utf-8'
|
38
|
-
}
|
39
|
-
|
40
|
-
# Prepare and execute HttpRequest.
|
41
|
-
_request = config.http_client.post(
|
42
|
-
_query_url,
|
43
|
-
headers: _headers,
|
44
|
-
parameters: body.to_json
|
45
|
-
)
|
46
|
-
OAuth2.apply(config, _request)
|
47
|
-
_response = execute_request(_request)
|
48
|
-
|
49
|
-
# Return appropriate response type.
|
50
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
51
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
52
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# ApplePayApi
|
8
|
+
class ApplePayApi < BaseApi
|
9
|
+
def initialize(config, http_call_back: nil)
|
10
|
+
super(config, http_call_back: http_call_back)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Activates a domain for use with Web Apple Pay and Square. A validation
|
14
|
+
# will be performed on this domain by Apple to ensure is it properly set up
|
15
|
+
# as
|
16
|
+
# an Apple Pay enabled domain.
|
17
|
+
# This endpoint provides an easy way for platform developers to bulk
|
18
|
+
# activate
|
19
|
+
# Web Apple Pay with Square for merchants using their platform.
|
20
|
+
# To learn more about Apple Pay on Web see the Apple Pay section in the
|
21
|
+
# [Embedding the Square Payment
|
22
|
+
# Form](https://developer.squareup.com/docs/payment-form/add-digital-wallets
|
23
|
+
# /apple-pay) guide.
|
24
|
+
# @param [RegisterDomainRequest] body Required parameter: An object
|
25
|
+
# containing the fields to POST for the request. See the corresponding
|
26
|
+
# object definition for field details.
|
27
|
+
# @return [RegisterDomainResponse Hash] response from the API call
|
28
|
+
def register_domain(body:)
|
29
|
+
# Prepare query url.
|
30
|
+
_query_builder = config.get_base_uri
|
31
|
+
_query_builder << '/v2/apple-pay/domains'
|
32
|
+
_query_url = APIHelper.clean_url _query_builder
|
33
|
+
|
34
|
+
# Prepare headers.
|
35
|
+
_headers = {
|
36
|
+
'accept' => 'application/json',
|
37
|
+
'content-type' => 'application/json; charset=utf-8'
|
38
|
+
}
|
39
|
+
|
40
|
+
# Prepare and execute HttpRequest.
|
41
|
+
_request = config.http_client.post(
|
42
|
+
_query_url,
|
43
|
+
headers: _headers,
|
44
|
+
parameters: body.to_json
|
45
|
+
)
|
46
|
+
OAuth2.apply(config, _request)
|
47
|
+
_response = execute_request(_request)
|
48
|
+
|
49
|
+
# Return appropriate response type.
|
50
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
51
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
52
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/square/api/base_api.rb
CHANGED
@@ -1,45 +1,48 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# BaseApi.
|
8
|
-
class BaseApi
|
9
|
-
attr_accessor :config, :http_call_back
|
10
|
-
|
11
|
-
def initialize(config, http_call_back: nil)
|
12
|
-
@config = config
|
13
|
-
@http_call_back = http_call_back
|
14
|
-
|
15
|
-
@global_headers = {
|
16
|
-
'user-agent' => 'Square-
|
17
|
-
'Square-Version' => '2019-
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
def validate_parameters(args)
|
22
|
-
args.each do |_name, value|
|
23
|
-
if value.nil?
|
24
|
-
raise ArgumentError, "Required parameter #{_name} cannot be nil."
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def execute_request(request, binary: false)
|
30
|
-
@http_call_back.on_before_request(request) if @http_call_back
|
31
|
-
|
32
|
-
APIHelper.clean_hash(request.headers)
|
33
|
-
request.headers
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# BaseApi.
|
8
|
+
class BaseApi
|
9
|
+
attr_accessor :config, :http_call_back
|
10
|
+
|
11
|
+
def initialize(config, http_call_back: nil)
|
12
|
+
@config = config
|
13
|
+
@http_call_back = http_call_back
|
14
|
+
|
15
|
+
@global_headers = {
|
16
|
+
'user-agent' => 'Square-Ruby-SDK/3.20190925.0',
|
17
|
+
'Square-Version' => '2019-09-25'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def validate_parameters(args)
|
22
|
+
args.each do |_name, value|
|
23
|
+
if value.nil?
|
24
|
+
raise ArgumentError, "Required parameter #{_name} cannot be nil."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def execute_request(request, binary: false)
|
30
|
+
@http_call_back.on_before_request(request) if @http_call_back
|
31
|
+
|
32
|
+
APIHelper.clean_hash(request.headers)
|
33
|
+
request.headers.merge!(@global_headers)
|
34
|
+
unless config.additional_headers.nil?
|
35
|
+
request.headers.merge!(config.additional_headers)
|
36
|
+
end
|
37
|
+
|
38
|
+
response = if binary
|
39
|
+
config.http_client.execute_as_binary(request)
|
40
|
+
else
|
41
|
+
config.http_client.execute_as_string(request)
|
42
|
+
end
|
43
|
+
@http_call_back.on_after_response(response) if @http_call_back
|
44
|
+
|
45
|
+
response
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,461 +1,461 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# CatalogApi
|
8
|
-
class CatalogApi < BaseApi
|
9
|
-
def initialize(config, http_call_back: nil)
|
10
|
-
super(config, http_call_back: http_call_back)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Deletes a set of [CatalogItem](#type-catalogitem)s based on the
|
14
|
-
# provided list of target IDs and returns a set of successfully deleted IDs
|
15
|
-
# in
|
16
|
-
# the response. Deletion is a cascading event such that all children of the
|
17
|
-
# targeted object are also deleted. For example, deleting a CatalogItem will
|
18
|
-
# also delete all of its [CatalogItemVariation](#type-catalogitemvariation)
|
19
|
-
# children.
|
20
|
-
# `BatchDeleteCatalogObjects` succeeds even if only a portion of the
|
21
|
-
# targeted
|
22
|
-
# IDs can be deleted. The response will only include IDs that were
|
23
|
-
# actually deleted.
|
24
|
-
# @param [BatchDeleteCatalogObjectsRequest] body Required parameter: An
|
25
|
-
# object containing the fields to POST for the request. See the
|
26
|
-
# corresponding object definition for field details.
|
27
|
-
# @return [BatchDeleteCatalogObjectsResponse Hash] response from the API call
|
28
|
-
def batch_delete_catalog_objects(body:)
|
29
|
-
# Prepare query url.
|
30
|
-
_query_builder = config.get_base_uri
|
31
|
-
_query_builder << '/v2/catalog/batch-delete'
|
32
|
-
_query_url = APIHelper.clean_url _query_builder
|
33
|
-
|
34
|
-
# Prepare headers.
|
35
|
-
_headers = {
|
36
|
-
'accept' => 'application/json',
|
37
|
-
'content-type' => 'application/json; charset=utf-8'
|
38
|
-
}
|
39
|
-
|
40
|
-
# Prepare and execute HttpRequest.
|
41
|
-
_request = config.http_client.post(
|
42
|
-
_query_url,
|
43
|
-
headers: _headers,
|
44
|
-
parameters: body.to_json
|
45
|
-
)
|
46
|
-
OAuth2.apply(config, _request)
|
47
|
-
_response = execute_request(_request)
|
48
|
-
|
49
|
-
# Return appropriate response type.
|
50
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
51
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
52
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
53
|
-
end
|
54
|
-
|
55
|
-
# Returns a set of objects based on the provided ID.
|
56
|
-
# Each [CatalogItem](#type-catalogitem) returned in the set includes all of
|
57
|
-
# its
|
58
|
-
# child information including: all of its
|
59
|
-
# [CatalogItemVariation](#type-catalogitemvariation) objects, references to
|
60
|
-
# its [CatalogModifierList](#type-catalogmodifierlist) objects, and the ids
|
61
|
-
# of
|
62
|
-
# any [CatalogTax](#type-catalogtax) objects that apply to it.
|
63
|
-
# @param [BatchRetrieveCatalogObjectsRequest] body Required parameter: An
|
64
|
-
# object containing the fields to POST for the request. See the
|
65
|
-
# corresponding object definition for field details.
|
66
|
-
# @return [BatchRetrieveCatalogObjectsResponse Hash] response from the API call
|
67
|
-
def batch_retrieve_catalog_objects(body:)
|
68
|
-
# Prepare query url.
|
69
|
-
_query_builder = config.get_base_uri
|
70
|
-
_query_builder << '/v2/catalog/batch-retrieve'
|
71
|
-
_query_url = APIHelper.clean_url _query_builder
|
72
|
-
|
73
|
-
# Prepare headers.
|
74
|
-
_headers = {
|
75
|
-
'accept' => 'application/json',
|
76
|
-
'content-type' => 'application/json; charset=utf-8'
|
77
|
-
}
|
78
|
-
|
79
|
-
# Prepare and execute HttpRequest.
|
80
|
-
_request = config.http_client.post(
|
81
|
-
_query_url,
|
82
|
-
headers: _headers,
|
83
|
-
parameters: body.to_json
|
84
|
-
)
|
85
|
-
OAuth2.apply(config, _request)
|
86
|
-
_response = execute_request(_request)
|
87
|
-
|
88
|
-
# Return appropriate response type.
|
89
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
90
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
91
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
92
|
-
end
|
93
|
-
|
94
|
-
# Creates or updates up to 10,000 target objects based on the provided
|
95
|
-
# list of objects. The target objects are grouped into batches and each
|
96
|
-
# batch is
|
97
|
-
# inserted/updated in an all-or-nothing manner. If an object within a batch
|
98
|
-
# is
|
99
|
-
# malformed in some way, or violates a database constraint, the entire batch
|
100
|
-
# containing that item will be disregarded. However, other batches in the
|
101
|
-
# same
|
102
|
-
# request may still succeed. Each batch may contain up to 1,000 objects, and
|
103
|
-
# batches will be processed in order as long as the total object count for
|
104
|
-
# the
|
105
|
-
# request (items, variations, modifier lists, discounts, and taxes) is no
|
106
|
-
# more
|
107
|
-
# than 10,000.
|
108
|
-
# @param [BatchUpsertCatalogObjectsRequest] body Required parameter: An
|
109
|
-
# object containing the fields to POST for the request. See the
|
110
|
-
# corresponding object definition for field details.
|
111
|
-
# @return [BatchUpsertCatalogObjectsResponse Hash] response from the API call
|
112
|
-
def batch_upsert_catalog_objects(body:)
|
113
|
-
# Prepare query url.
|
114
|
-
_query_builder = config.get_base_uri
|
115
|
-
_query_builder << '/v2/catalog/batch-upsert'
|
116
|
-
_query_url = APIHelper.clean_url _query_builder
|
117
|
-
|
118
|
-
# Prepare headers.
|
119
|
-
_headers = {
|
120
|
-
'accept' => 'application/json',
|
121
|
-
'content-type' => 'application/json; charset=utf-8'
|
122
|
-
}
|
123
|
-
|
124
|
-
# Prepare and execute HttpRequest.
|
125
|
-
_request = config.http_client.post(
|
126
|
-
_query_url,
|
127
|
-
headers: _headers,
|
128
|
-
parameters: body.to_json
|
129
|
-
)
|
130
|
-
OAuth2.apply(config, _request)
|
131
|
-
_response = execute_request(_request)
|
132
|
-
|
133
|
-
# Return appropriate response type.
|
134
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
135
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
136
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
137
|
-
end
|
138
|
-
|
139
|
-
# Returns information about the Square Catalog API, such as batch size
|
140
|
-
# limits for `BatchUpsertCatalogObjects`.
|
141
|
-
# @return [CatalogInfoResponse Hash] response from the API call
|
142
|
-
def catalog_info
|
143
|
-
# Prepare query url.
|
144
|
-
_query_builder = config.get_base_uri
|
145
|
-
_query_builder << '/v2/catalog/info'
|
146
|
-
_query_url = APIHelper.clean_url _query_builder
|
147
|
-
|
148
|
-
# Prepare headers.
|
149
|
-
_headers = {
|
150
|
-
'accept' => 'application/json'
|
151
|
-
}
|
152
|
-
|
153
|
-
# Prepare and execute HttpRequest.
|
154
|
-
_request = config.http_client.get(
|
155
|
-
_query_url,
|
156
|
-
headers: _headers
|
157
|
-
)
|
158
|
-
OAuth2.apply(config, _request)
|
159
|
-
_response = execute_request(_request)
|
160
|
-
|
161
|
-
# Return appropriate response type.
|
162
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
163
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
164
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
165
|
-
end
|
166
|
-
|
167
|
-
# Returns a list of [CatalogObject](#type-catalogobject)s that includes
|
168
|
-
# all objects of a set of desired types (for example, all
|
169
|
-
# [CatalogItem](#type-catalogitem)
|
170
|
-
# and [CatalogTax](#type-catalogtax) objects) in the catalog. The `types`
|
171
|
-
# parameter
|
172
|
-
# is specified as a comma-separated list of valid
|
173
|
-
# [CatalogObject](#type-catalogobject) types:
|
174
|
-
# `ITEM`, `ITEM_VARIATION`, `MODIFIER`, `MODIFIER_LIST`, `CATEGORY`,
|
175
|
-
# `DISCOUNT`, `TAX`.
|
176
|
-
# __Important:__ ListCatalog does not return deleted catalog items. To
|
177
|
-
# retrieve
|
178
|
-
# deleted catalog items, use SearchCatalogObjects and set
|
179
|
-
# `include_deleted_objects`
|
180
|
-
# to `true`.
|
181
|
-
# @param [String] cursor Optional parameter: The pagination cursor returned
|
182
|
-
# in the previous response. Leave unset for an initial request. See
|
183
|
-
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
184
|
-
# for more information.
|
185
|
-
# @param [String] types Optional parameter: An optional case-insensitive,
|
186
|
-
# comma-separated list of object types to retrieve, for example
|
187
|
-
# `ITEM,ITEM_VARIATION,CATEGORY,IMAGE`. The legal values are taken from the
|
188
|
-
# [CatalogObjectType](#type-catalogobjecttype) enumeration, namely `ITEM`,
|
189
|
-
# `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`, `TAX`, `MODIFIER`,
|
190
|
-
# `MODIFIER_LIST`, or `IMAGE`.
|
191
|
-
# @return [ListCatalogResponse Hash] response from the API call
|
192
|
-
def list_catalog(cursor: nil,
|
193
|
-
types: nil)
|
194
|
-
# Prepare query url.
|
195
|
-
_query_builder = config.get_base_uri
|
196
|
-
_query_builder << '/v2/catalog/list'
|
197
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
198
|
-
_query_builder,
|
199
|
-
'cursor' => cursor,
|
200
|
-
'types' => types
|
201
|
-
)
|
202
|
-
_query_url = APIHelper.clean_url _query_builder
|
203
|
-
|
204
|
-
# Prepare headers.
|
205
|
-
_headers = {
|
206
|
-
'accept' => 'application/json'
|
207
|
-
}
|
208
|
-
|
209
|
-
# Prepare and execute HttpRequest.
|
210
|
-
_request = config.http_client.get(
|
211
|
-
_query_url,
|
212
|
-
headers: _headers
|
213
|
-
)
|
214
|
-
OAuth2.apply(config, _request)
|
215
|
-
_response = execute_request(_request)
|
216
|
-
|
217
|
-
# Return appropriate response type.
|
218
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
219
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
220
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
221
|
-
end
|
222
|
-
|
223
|
-
# Creates or updates the target [CatalogObject](#type-catalogobject).
|
224
|
-
# @param [UpsertCatalogObjectRequest] body Required parameter: An object
|
225
|
-
# containing the fields to POST for the request. See the corresponding
|
226
|
-
# object definition for field details.
|
227
|
-
# @return [UpsertCatalogObjectResponse Hash] response from the API call
|
228
|
-
def upsert_catalog_object(body:)
|
229
|
-
# Prepare query url.
|
230
|
-
_query_builder = config.get_base_uri
|
231
|
-
_query_builder << '/v2/catalog/object'
|
232
|
-
_query_url = APIHelper.clean_url _query_builder
|
233
|
-
|
234
|
-
# Prepare headers.
|
235
|
-
_headers = {
|
236
|
-
'accept' => 'application/json',
|
237
|
-
'content-type' => 'application/json; charset=utf-8'
|
238
|
-
}
|
239
|
-
|
240
|
-
# Prepare and execute HttpRequest.
|
241
|
-
_request = config.http_client.post(
|
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(_response, data: decoded, errors: _errors)
|
253
|
-
end
|
254
|
-
|
255
|
-
# Deletes a single [CatalogObject](#type-catalogobject) based on the
|
256
|
-
# provided ID and returns the set of successfully deleted IDs in the
|
257
|
-
# response.
|
258
|
-
# Deletion is a cascading event such that all children of the targeted
|
259
|
-
# object
|
260
|
-
# are also deleted. For example, deleting a [CatalogItem](#type-catalogitem)
|
261
|
-
# will also delete all of its
|
262
|
-
# [CatalogItemVariation](#type-catalogitemvariation) children.
|
263
|
-
# @param [String] object_id Required parameter: The ID of the
|
264
|
-
# [CatalogObject](#type-catalogobject) to be deleted. When an object is
|
265
|
-
# deleted, other objects in the graph that depend on that object will be
|
266
|
-
# deleted as well (for example, deleting a [CatalogItem](#type-catalogitem)
|
267
|
-
# will delete its [CatalogItemVariation](#type-catalogitemvariation)s).
|
268
|
-
# @return [DeleteCatalogObjectResponse Hash] response from the API call
|
269
|
-
def delete_catalog_object(object_id:)
|
270
|
-
# Prepare query url.
|
271
|
-
_query_builder = config.get_base_uri
|
272
|
-
_query_builder << '/v2/catalog/object/{object_id}'
|
273
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
274
|
-
_query_builder,
|
275
|
-
'object_id' => object_id
|
276
|
-
)
|
277
|
-
_query_url = APIHelper.clean_url _query_builder
|
278
|
-
|
279
|
-
# Prepare headers.
|
280
|
-
_headers = {
|
281
|
-
'accept' => 'application/json'
|
282
|
-
}
|
283
|
-
|
284
|
-
# Prepare and execute HttpRequest.
|
285
|
-
_request = config.http_client.delete(
|
286
|
-
_query_url,
|
287
|
-
headers: _headers
|
288
|
-
)
|
289
|
-
OAuth2.apply(config, _request)
|
290
|
-
_response = execute_request(_request)
|
291
|
-
|
292
|
-
# Return appropriate response type.
|
293
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
294
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
295
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
296
|
-
end
|
297
|
-
|
298
|
-
# Returns a single [CatalogItem](#type-catalogitem) as a
|
299
|
-
# [CatalogObject](#type-catalogobject) based on the provided ID. The
|
300
|
-
# returned
|
301
|
-
# object includes all of the relevant [CatalogItem](#type-catalogitem)
|
302
|
-
# information including: [CatalogItemVariation](#type-catalogitemvariation)
|
303
|
-
# children, references to its
|
304
|
-
# [CatalogModifierList](#type-catalogmodifierlist) objects, and the ids of
|
305
|
-
# any [CatalogTax](#type-catalogtax) objects that apply to it.
|
306
|
-
# @param [String] object_id Required parameter: The object ID of any type of
|
307
|
-
# [CatalogObject](#type-catalogobject)s to be retrieved.
|
308
|
-
# @param [Boolean] include_related_objects Optional parameter: If `true`,
|
309
|
-
# the response will include additional objects that are related to the
|
310
|
-
# requested object, as follows: If the `object` field of the response
|
311
|
-
# contains a [CatalogItem](#type-catalogitem), its associated
|
312
|
-
# [CatalogCategory](#type-catalogcategory),
|
313
|
-
# [CatalogTax](#type-catalogtax)es, [CatalogImage](#type-catalogimage)s and
|
314
|
-
# [CatalogModifierList](#type-catalogmodifierlist)s will be returned in the
|
315
|
-
# `related_objects` field of the response. If the `object` field of the
|
316
|
-
# response contains a [CatalogItemVariation](#type-catalogitemvariation),
|
317
|
-
# its parent [CatalogItem](#type-catalogitem) will be returned in the
|
318
|
-
# `related_objects` field of the response. Default value: `false`
|
319
|
-
# @return [RetrieveCatalogObjectResponse Hash] response from the API call
|
320
|
-
def retrieve_catalog_object(object_id:,
|
321
|
-
include_related_objects: nil)
|
322
|
-
# Prepare query url.
|
323
|
-
_query_builder = config.get_base_uri
|
324
|
-
_query_builder << '/v2/catalog/object/{object_id}'
|
325
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
326
|
-
_query_builder,
|
327
|
-
'object_id' => object_id
|
328
|
-
)
|
329
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
330
|
-
_query_builder,
|
331
|
-
'include_related_objects' => include_related_objects
|
332
|
-
)
|
333
|
-
_query_url = APIHelper.clean_url _query_builder
|
334
|
-
|
335
|
-
# Prepare headers.
|
336
|
-
_headers = {
|
337
|
-
'accept' => 'application/json'
|
338
|
-
}
|
339
|
-
|
340
|
-
# Prepare and execute HttpRequest.
|
341
|
-
_request = config.http_client.get(
|
342
|
-
_query_url,
|
343
|
-
headers: _headers
|
344
|
-
)
|
345
|
-
OAuth2.apply(config, _request)
|
346
|
-
_response = execute_request(_request)
|
347
|
-
|
348
|
-
# Return appropriate response type.
|
349
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
350
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
351
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
352
|
-
end
|
353
|
-
|
354
|
-
# Queries the targeted catalog using a variety of query types:
|
355
|
-
# [CatalogQuerySortedAttribute](#type-catalogquerysortedattribute),
|
356
|
-
# [CatalogQueryExact](#type-catalogqueryexact),
|
357
|
-
# [CatalogQueryRange](#type-catalogqueryrange),
|
358
|
-
# [CatalogQueryText](#type-catalogquerytext),
|
359
|
-
# [CatalogQueryItemsForTax](#type-catalogqueryitemsfortax), and
|
360
|
-
# [CatalogQueryItemsForModifierList](#type-catalogqueryitemsformodifierlist)
|
361
|
-
# .
|
362
|
-
# @param [SearchCatalogObjectsRequest] body Required parameter: An object
|
363
|
-
# containing the fields to POST for the request. See the corresponding
|
364
|
-
# object definition for field details.
|
365
|
-
# @return [SearchCatalogObjectsResponse Hash] response from the API call
|
366
|
-
def search_catalog_objects(body:)
|
367
|
-
# Prepare query url.
|
368
|
-
_query_builder = config.get_base_uri
|
369
|
-
_query_builder << '/v2/catalog/search'
|
370
|
-
_query_url = APIHelper.clean_url _query_builder
|
371
|
-
|
372
|
-
# Prepare headers.
|
373
|
-
_headers = {
|
374
|
-
'accept' => 'application/json',
|
375
|
-
'content-type' => 'application/json; charset=utf-8'
|
376
|
-
}
|
377
|
-
|
378
|
-
# Prepare and execute HttpRequest.
|
379
|
-
_request = config.http_client.post(
|
380
|
-
_query_url,
|
381
|
-
headers: _headers,
|
382
|
-
parameters: body.to_json
|
383
|
-
)
|
384
|
-
OAuth2.apply(config, _request)
|
385
|
-
_response = execute_request(_request)
|
386
|
-
|
387
|
-
# Return appropriate response type.
|
388
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
389
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
390
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
391
|
-
end
|
392
|
-
|
393
|
-
# Updates the [CatalogModifierList](#type-catalogmodifierlist) objects
|
394
|
-
# that apply to the targeted [CatalogItem](#type-catalogitem) without having
|
395
|
-
# to perform an upsert on the entire item.
|
396
|
-
# @param [UpdateItemModifierListsRequest] body Required parameter: An object
|
397
|
-
# containing the fields to POST for the request. See the corresponding
|
398
|
-
# object definition for field details.
|
399
|
-
# @return [UpdateItemModifierListsResponse Hash] response from the API call
|
400
|
-
def update_item_modifier_lists(body:)
|
401
|
-
# Prepare query url.
|
402
|
-
_query_builder = config.get_base_uri
|
403
|
-
_query_builder << '/v2/catalog/update-item-modifier-lists'
|
404
|
-
_query_url = APIHelper.clean_url _query_builder
|
405
|
-
|
406
|
-
# Prepare headers.
|
407
|
-
_headers = {
|
408
|
-
'accept' => 'application/json',
|
409
|
-
'content-type' => 'application/json; charset=utf-8'
|
410
|
-
}
|
411
|
-
|
412
|
-
# Prepare and execute HttpRequest.
|
413
|
-
_request = config.http_client.post(
|
414
|
-
_query_url,
|
415
|
-
headers: _headers,
|
416
|
-
parameters: body.to_json
|
417
|
-
)
|
418
|
-
OAuth2.apply(config, _request)
|
419
|
-
_response = execute_request(_request)
|
420
|
-
|
421
|
-
# Return appropriate response type.
|
422
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
423
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
424
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
425
|
-
end
|
426
|
-
|
427
|
-
# Updates the [CatalogTax](#type-catalogtax) objects that apply to the
|
428
|
-
# targeted [CatalogItem](#type-catalogitem) without having to perform an
|
429
|
-
# upsert on the entire item.
|
430
|
-
# @param [UpdateItemTaxesRequest] body Required parameter: An object
|
431
|
-
# containing the fields to POST for the request. See the corresponding
|
432
|
-
# object definition for field details.
|
433
|
-
# @return [UpdateItemTaxesResponse Hash] response from the API call
|
434
|
-
def update_item_taxes(body:)
|
435
|
-
# Prepare query url.
|
436
|
-
_query_builder = config.get_base_uri
|
437
|
-
_query_builder << '/v2/catalog/update-item-taxes'
|
438
|
-
_query_url = APIHelper.clean_url _query_builder
|
439
|
-
|
440
|
-
# Prepare headers.
|
441
|
-
_headers = {
|
442
|
-
'accept' => 'application/json',
|
443
|
-
'content-type' => 'application/json; charset=utf-8'
|
444
|
-
}
|
445
|
-
|
446
|
-
# Prepare and execute HttpRequest.
|
447
|
-
_request = config.http_client.post(
|
448
|
-
_query_url,
|
449
|
-
headers: _headers,
|
450
|
-
parameters: body.to_json
|
451
|
-
)
|
452
|
-
OAuth2.apply(config, _request)
|
453
|
-
_response = execute_request(_request)
|
454
|
-
|
455
|
-
# Return appropriate response type.
|
456
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
457
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
458
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
459
|
-
end
|
460
|
-
end
|
461
|
-
end
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# CatalogApi
|
8
|
+
class CatalogApi < BaseApi
|
9
|
+
def initialize(config, http_call_back: nil)
|
10
|
+
super(config, http_call_back: http_call_back)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Deletes a set of [CatalogItem](#type-catalogitem)s based on the
|
14
|
+
# provided list of target IDs and returns a set of successfully deleted IDs
|
15
|
+
# in
|
16
|
+
# the response. Deletion is a cascading event such that all children of the
|
17
|
+
# targeted object are also deleted. For example, deleting a CatalogItem will
|
18
|
+
# also delete all of its [CatalogItemVariation](#type-catalogitemvariation)
|
19
|
+
# children.
|
20
|
+
# `BatchDeleteCatalogObjects` succeeds even if only a portion of the
|
21
|
+
# targeted
|
22
|
+
# IDs can be deleted. The response will only include IDs that were
|
23
|
+
# actually deleted.
|
24
|
+
# @param [BatchDeleteCatalogObjectsRequest] body Required parameter: An
|
25
|
+
# object containing the fields to POST for the request. See the
|
26
|
+
# corresponding object definition for field details.
|
27
|
+
# @return [BatchDeleteCatalogObjectsResponse Hash] response from the API call
|
28
|
+
def batch_delete_catalog_objects(body:)
|
29
|
+
# Prepare query url.
|
30
|
+
_query_builder = config.get_base_uri
|
31
|
+
_query_builder << '/v2/catalog/batch-delete'
|
32
|
+
_query_url = APIHelper.clean_url _query_builder
|
33
|
+
|
34
|
+
# Prepare headers.
|
35
|
+
_headers = {
|
36
|
+
'accept' => 'application/json',
|
37
|
+
'content-type' => 'application/json; charset=utf-8'
|
38
|
+
}
|
39
|
+
|
40
|
+
# Prepare and execute HttpRequest.
|
41
|
+
_request = config.http_client.post(
|
42
|
+
_query_url,
|
43
|
+
headers: _headers,
|
44
|
+
parameters: body.to_json
|
45
|
+
)
|
46
|
+
OAuth2.apply(config, _request)
|
47
|
+
_response = execute_request(_request)
|
48
|
+
|
49
|
+
# Return appropriate response type.
|
50
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
51
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
52
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns a set of objects based on the provided ID.
|
56
|
+
# Each [CatalogItem](#type-catalogitem) returned in the set includes all of
|
57
|
+
# its
|
58
|
+
# child information including: all of its
|
59
|
+
# [CatalogItemVariation](#type-catalogitemvariation) objects, references to
|
60
|
+
# its [CatalogModifierList](#type-catalogmodifierlist) objects, and the ids
|
61
|
+
# of
|
62
|
+
# any [CatalogTax](#type-catalogtax) objects that apply to it.
|
63
|
+
# @param [BatchRetrieveCatalogObjectsRequest] body Required parameter: An
|
64
|
+
# object containing the fields to POST for the request. See the
|
65
|
+
# corresponding object definition for field details.
|
66
|
+
# @return [BatchRetrieveCatalogObjectsResponse Hash] response from the API call
|
67
|
+
def batch_retrieve_catalog_objects(body:)
|
68
|
+
# Prepare query url.
|
69
|
+
_query_builder = config.get_base_uri
|
70
|
+
_query_builder << '/v2/catalog/batch-retrieve'
|
71
|
+
_query_url = APIHelper.clean_url _query_builder
|
72
|
+
|
73
|
+
# Prepare headers.
|
74
|
+
_headers = {
|
75
|
+
'accept' => 'application/json',
|
76
|
+
'content-type' => 'application/json; charset=utf-8'
|
77
|
+
}
|
78
|
+
|
79
|
+
# Prepare and execute HttpRequest.
|
80
|
+
_request = config.http_client.post(
|
81
|
+
_query_url,
|
82
|
+
headers: _headers,
|
83
|
+
parameters: body.to_json
|
84
|
+
)
|
85
|
+
OAuth2.apply(config, _request)
|
86
|
+
_response = execute_request(_request)
|
87
|
+
|
88
|
+
# Return appropriate response type.
|
89
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
90
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
91
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Creates or updates up to 10,000 target objects based on the provided
|
95
|
+
# list of objects. The target objects are grouped into batches and each
|
96
|
+
# batch is
|
97
|
+
# inserted/updated in an all-or-nothing manner. If an object within a batch
|
98
|
+
# is
|
99
|
+
# malformed in some way, or violates a database constraint, the entire batch
|
100
|
+
# containing that item will be disregarded. However, other batches in the
|
101
|
+
# same
|
102
|
+
# request may still succeed. Each batch may contain up to 1,000 objects, and
|
103
|
+
# batches will be processed in order as long as the total object count for
|
104
|
+
# the
|
105
|
+
# request (items, variations, modifier lists, discounts, and taxes) is no
|
106
|
+
# more
|
107
|
+
# than 10,000.
|
108
|
+
# @param [BatchUpsertCatalogObjectsRequest] body Required parameter: An
|
109
|
+
# object containing the fields to POST for the request. See the
|
110
|
+
# corresponding object definition for field details.
|
111
|
+
# @return [BatchUpsertCatalogObjectsResponse Hash] response from the API call
|
112
|
+
def batch_upsert_catalog_objects(body:)
|
113
|
+
# Prepare query url.
|
114
|
+
_query_builder = config.get_base_uri
|
115
|
+
_query_builder << '/v2/catalog/batch-upsert'
|
116
|
+
_query_url = APIHelper.clean_url _query_builder
|
117
|
+
|
118
|
+
# Prepare headers.
|
119
|
+
_headers = {
|
120
|
+
'accept' => 'application/json',
|
121
|
+
'content-type' => 'application/json; charset=utf-8'
|
122
|
+
}
|
123
|
+
|
124
|
+
# Prepare and execute HttpRequest.
|
125
|
+
_request = config.http_client.post(
|
126
|
+
_query_url,
|
127
|
+
headers: _headers,
|
128
|
+
parameters: body.to_json
|
129
|
+
)
|
130
|
+
OAuth2.apply(config, _request)
|
131
|
+
_response = execute_request(_request)
|
132
|
+
|
133
|
+
# Return appropriate response type.
|
134
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
135
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
136
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
137
|
+
end
|
138
|
+
|
139
|
+
# Returns information about the Square Catalog API, such as batch size
|
140
|
+
# limits for `BatchUpsertCatalogObjects`.
|
141
|
+
# @return [CatalogInfoResponse Hash] response from the API call
|
142
|
+
def catalog_info
|
143
|
+
# Prepare query url.
|
144
|
+
_query_builder = config.get_base_uri
|
145
|
+
_query_builder << '/v2/catalog/info'
|
146
|
+
_query_url = APIHelper.clean_url _query_builder
|
147
|
+
|
148
|
+
# Prepare headers.
|
149
|
+
_headers = {
|
150
|
+
'accept' => 'application/json'
|
151
|
+
}
|
152
|
+
|
153
|
+
# Prepare and execute HttpRequest.
|
154
|
+
_request = config.http_client.get(
|
155
|
+
_query_url,
|
156
|
+
headers: _headers
|
157
|
+
)
|
158
|
+
OAuth2.apply(config, _request)
|
159
|
+
_response = execute_request(_request)
|
160
|
+
|
161
|
+
# Return appropriate response type.
|
162
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
163
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
164
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Returns a list of [CatalogObject](#type-catalogobject)s that includes
|
168
|
+
# all objects of a set of desired types (for example, all
|
169
|
+
# [CatalogItem](#type-catalogitem)
|
170
|
+
# and [CatalogTax](#type-catalogtax) objects) in the catalog. The `types`
|
171
|
+
# parameter
|
172
|
+
# is specified as a comma-separated list of valid
|
173
|
+
# [CatalogObject](#type-catalogobject) types:
|
174
|
+
# `ITEM`, `ITEM_VARIATION`, `MODIFIER`, `MODIFIER_LIST`, `CATEGORY`,
|
175
|
+
# `DISCOUNT`, `TAX`.
|
176
|
+
# __Important:__ ListCatalog does not return deleted catalog items. To
|
177
|
+
# retrieve
|
178
|
+
# deleted catalog items, use SearchCatalogObjects and set
|
179
|
+
# `include_deleted_objects`
|
180
|
+
# to `true`.
|
181
|
+
# @param [String] cursor Optional parameter: The pagination cursor returned
|
182
|
+
# in the previous response. Leave unset for an initial request. See
|
183
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
184
|
+
# for more information.
|
185
|
+
# @param [String] types Optional parameter: An optional case-insensitive,
|
186
|
+
# comma-separated list of object types to retrieve, for example
|
187
|
+
# `ITEM,ITEM_VARIATION,CATEGORY,IMAGE`. The legal values are taken from the
|
188
|
+
# [CatalogObjectType](#type-catalogobjecttype) enumeration, namely `ITEM`,
|
189
|
+
# `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`, `TAX`, `MODIFIER`,
|
190
|
+
# `MODIFIER_LIST`, or `IMAGE`.
|
191
|
+
# @return [ListCatalogResponse Hash] response from the API call
|
192
|
+
def list_catalog(cursor: nil,
|
193
|
+
types: nil)
|
194
|
+
# Prepare query url.
|
195
|
+
_query_builder = config.get_base_uri
|
196
|
+
_query_builder << '/v2/catalog/list'
|
197
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
198
|
+
_query_builder,
|
199
|
+
'cursor' => cursor,
|
200
|
+
'types' => types
|
201
|
+
)
|
202
|
+
_query_url = APIHelper.clean_url _query_builder
|
203
|
+
|
204
|
+
# Prepare headers.
|
205
|
+
_headers = {
|
206
|
+
'accept' => 'application/json'
|
207
|
+
}
|
208
|
+
|
209
|
+
# Prepare and execute HttpRequest.
|
210
|
+
_request = config.http_client.get(
|
211
|
+
_query_url,
|
212
|
+
headers: _headers
|
213
|
+
)
|
214
|
+
OAuth2.apply(config, _request)
|
215
|
+
_response = execute_request(_request)
|
216
|
+
|
217
|
+
# Return appropriate response type.
|
218
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
219
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
220
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
221
|
+
end
|
222
|
+
|
223
|
+
# Creates or updates the target [CatalogObject](#type-catalogobject).
|
224
|
+
# @param [UpsertCatalogObjectRequest] body Required parameter: An object
|
225
|
+
# containing the fields to POST for the request. See the corresponding
|
226
|
+
# object definition for field details.
|
227
|
+
# @return [UpsertCatalogObjectResponse Hash] response from the API call
|
228
|
+
def upsert_catalog_object(body:)
|
229
|
+
# Prepare query url.
|
230
|
+
_query_builder = config.get_base_uri
|
231
|
+
_query_builder << '/v2/catalog/object'
|
232
|
+
_query_url = APIHelper.clean_url _query_builder
|
233
|
+
|
234
|
+
# Prepare headers.
|
235
|
+
_headers = {
|
236
|
+
'accept' => 'application/json',
|
237
|
+
'content-type' => 'application/json; charset=utf-8'
|
238
|
+
}
|
239
|
+
|
240
|
+
# Prepare and execute HttpRequest.
|
241
|
+
_request = config.http_client.post(
|
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(_response, data: decoded, errors: _errors)
|
253
|
+
end
|
254
|
+
|
255
|
+
# Deletes a single [CatalogObject](#type-catalogobject) based on the
|
256
|
+
# provided ID and returns the set of successfully deleted IDs in the
|
257
|
+
# response.
|
258
|
+
# Deletion is a cascading event such that all children of the targeted
|
259
|
+
# object
|
260
|
+
# are also deleted. For example, deleting a [CatalogItem](#type-catalogitem)
|
261
|
+
# will also delete all of its
|
262
|
+
# [CatalogItemVariation](#type-catalogitemvariation) children.
|
263
|
+
# @param [String] object_id Required parameter: The ID of the
|
264
|
+
# [CatalogObject](#type-catalogobject) to be deleted. When an object is
|
265
|
+
# deleted, other objects in the graph that depend on that object will be
|
266
|
+
# deleted as well (for example, deleting a [CatalogItem](#type-catalogitem)
|
267
|
+
# will delete its [CatalogItemVariation](#type-catalogitemvariation)s).
|
268
|
+
# @return [DeleteCatalogObjectResponse Hash] response from the API call
|
269
|
+
def delete_catalog_object(object_id:)
|
270
|
+
# Prepare query url.
|
271
|
+
_query_builder = config.get_base_uri
|
272
|
+
_query_builder << '/v2/catalog/object/{object_id}'
|
273
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
274
|
+
_query_builder,
|
275
|
+
'object_id' => object_id
|
276
|
+
)
|
277
|
+
_query_url = APIHelper.clean_url _query_builder
|
278
|
+
|
279
|
+
# Prepare headers.
|
280
|
+
_headers = {
|
281
|
+
'accept' => 'application/json'
|
282
|
+
}
|
283
|
+
|
284
|
+
# Prepare and execute HttpRequest.
|
285
|
+
_request = config.http_client.delete(
|
286
|
+
_query_url,
|
287
|
+
headers: _headers
|
288
|
+
)
|
289
|
+
OAuth2.apply(config, _request)
|
290
|
+
_response = execute_request(_request)
|
291
|
+
|
292
|
+
# Return appropriate response type.
|
293
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
294
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
295
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
296
|
+
end
|
297
|
+
|
298
|
+
# Returns a single [CatalogItem](#type-catalogitem) as a
|
299
|
+
# [CatalogObject](#type-catalogobject) based on the provided ID. The
|
300
|
+
# returned
|
301
|
+
# object includes all of the relevant [CatalogItem](#type-catalogitem)
|
302
|
+
# information including: [CatalogItemVariation](#type-catalogitemvariation)
|
303
|
+
# children, references to its
|
304
|
+
# [CatalogModifierList](#type-catalogmodifierlist) objects, and the ids of
|
305
|
+
# any [CatalogTax](#type-catalogtax) objects that apply to it.
|
306
|
+
# @param [String] object_id Required parameter: The object ID of any type of
|
307
|
+
# [CatalogObject](#type-catalogobject)s to be retrieved.
|
308
|
+
# @param [Boolean] include_related_objects Optional parameter: If `true`,
|
309
|
+
# the response will include additional objects that are related to the
|
310
|
+
# requested object, as follows: If the `object` field of the response
|
311
|
+
# contains a [CatalogItem](#type-catalogitem), its associated
|
312
|
+
# [CatalogCategory](#type-catalogcategory),
|
313
|
+
# [CatalogTax](#type-catalogtax)es, [CatalogImage](#type-catalogimage)s and
|
314
|
+
# [CatalogModifierList](#type-catalogmodifierlist)s will be returned in the
|
315
|
+
# `related_objects` field of the response. If the `object` field of the
|
316
|
+
# response contains a [CatalogItemVariation](#type-catalogitemvariation),
|
317
|
+
# its parent [CatalogItem](#type-catalogitem) will be returned in the
|
318
|
+
# `related_objects` field of the response. Default value: `false`
|
319
|
+
# @return [RetrieveCatalogObjectResponse Hash] response from the API call
|
320
|
+
def retrieve_catalog_object(object_id:,
|
321
|
+
include_related_objects: nil)
|
322
|
+
# Prepare query url.
|
323
|
+
_query_builder = config.get_base_uri
|
324
|
+
_query_builder << '/v2/catalog/object/{object_id}'
|
325
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
326
|
+
_query_builder,
|
327
|
+
'object_id' => object_id
|
328
|
+
)
|
329
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
330
|
+
_query_builder,
|
331
|
+
'include_related_objects' => include_related_objects
|
332
|
+
)
|
333
|
+
_query_url = APIHelper.clean_url _query_builder
|
334
|
+
|
335
|
+
# Prepare headers.
|
336
|
+
_headers = {
|
337
|
+
'accept' => 'application/json'
|
338
|
+
}
|
339
|
+
|
340
|
+
# Prepare and execute HttpRequest.
|
341
|
+
_request = config.http_client.get(
|
342
|
+
_query_url,
|
343
|
+
headers: _headers
|
344
|
+
)
|
345
|
+
OAuth2.apply(config, _request)
|
346
|
+
_response = execute_request(_request)
|
347
|
+
|
348
|
+
# Return appropriate response type.
|
349
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
350
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
351
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
352
|
+
end
|
353
|
+
|
354
|
+
# Queries the targeted catalog using a variety of query types:
|
355
|
+
# [CatalogQuerySortedAttribute](#type-catalogquerysortedattribute),
|
356
|
+
# [CatalogQueryExact](#type-catalogqueryexact),
|
357
|
+
# [CatalogQueryRange](#type-catalogqueryrange),
|
358
|
+
# [CatalogQueryText](#type-catalogquerytext),
|
359
|
+
# [CatalogQueryItemsForTax](#type-catalogqueryitemsfortax), and
|
360
|
+
# [CatalogQueryItemsForModifierList](#type-catalogqueryitemsformodifierlist)
|
361
|
+
# .
|
362
|
+
# @param [SearchCatalogObjectsRequest] body Required parameter: An object
|
363
|
+
# containing the fields to POST for the request. See the corresponding
|
364
|
+
# object definition for field details.
|
365
|
+
# @return [SearchCatalogObjectsResponse Hash] response from the API call
|
366
|
+
def search_catalog_objects(body:)
|
367
|
+
# Prepare query url.
|
368
|
+
_query_builder = config.get_base_uri
|
369
|
+
_query_builder << '/v2/catalog/search'
|
370
|
+
_query_url = APIHelper.clean_url _query_builder
|
371
|
+
|
372
|
+
# Prepare headers.
|
373
|
+
_headers = {
|
374
|
+
'accept' => 'application/json',
|
375
|
+
'content-type' => 'application/json; charset=utf-8'
|
376
|
+
}
|
377
|
+
|
378
|
+
# Prepare and execute HttpRequest.
|
379
|
+
_request = config.http_client.post(
|
380
|
+
_query_url,
|
381
|
+
headers: _headers,
|
382
|
+
parameters: body.to_json
|
383
|
+
)
|
384
|
+
OAuth2.apply(config, _request)
|
385
|
+
_response = execute_request(_request)
|
386
|
+
|
387
|
+
# Return appropriate response type.
|
388
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
389
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
390
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
391
|
+
end
|
392
|
+
|
393
|
+
# Updates the [CatalogModifierList](#type-catalogmodifierlist) objects
|
394
|
+
# that apply to the targeted [CatalogItem](#type-catalogitem) without having
|
395
|
+
# to perform an upsert on the entire item.
|
396
|
+
# @param [UpdateItemModifierListsRequest] body Required parameter: An object
|
397
|
+
# containing the fields to POST for the request. See the corresponding
|
398
|
+
# object definition for field details.
|
399
|
+
# @return [UpdateItemModifierListsResponse Hash] response from the API call
|
400
|
+
def update_item_modifier_lists(body:)
|
401
|
+
# Prepare query url.
|
402
|
+
_query_builder = config.get_base_uri
|
403
|
+
_query_builder << '/v2/catalog/update-item-modifier-lists'
|
404
|
+
_query_url = APIHelper.clean_url _query_builder
|
405
|
+
|
406
|
+
# Prepare headers.
|
407
|
+
_headers = {
|
408
|
+
'accept' => 'application/json',
|
409
|
+
'content-type' => 'application/json; charset=utf-8'
|
410
|
+
}
|
411
|
+
|
412
|
+
# Prepare and execute HttpRequest.
|
413
|
+
_request = config.http_client.post(
|
414
|
+
_query_url,
|
415
|
+
headers: _headers,
|
416
|
+
parameters: body.to_json
|
417
|
+
)
|
418
|
+
OAuth2.apply(config, _request)
|
419
|
+
_response = execute_request(_request)
|
420
|
+
|
421
|
+
# Return appropriate response type.
|
422
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
423
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
424
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
425
|
+
end
|
426
|
+
|
427
|
+
# Updates the [CatalogTax](#type-catalogtax) objects that apply to the
|
428
|
+
# targeted [CatalogItem](#type-catalogitem) without having to perform an
|
429
|
+
# upsert on the entire item.
|
430
|
+
# @param [UpdateItemTaxesRequest] body Required parameter: An object
|
431
|
+
# containing the fields to POST for the request. See the corresponding
|
432
|
+
# object definition for field details.
|
433
|
+
# @return [UpdateItemTaxesResponse Hash] response from the API call
|
434
|
+
def update_item_taxes(body:)
|
435
|
+
# Prepare query url.
|
436
|
+
_query_builder = config.get_base_uri
|
437
|
+
_query_builder << '/v2/catalog/update-item-taxes'
|
438
|
+
_query_url = APIHelper.clean_url _query_builder
|
439
|
+
|
440
|
+
# Prepare headers.
|
441
|
+
_headers = {
|
442
|
+
'accept' => 'application/json',
|
443
|
+
'content-type' => 'application/json; charset=utf-8'
|
444
|
+
}
|
445
|
+
|
446
|
+
# Prepare and execute HttpRequest.
|
447
|
+
_request = config.http_client.post(
|
448
|
+
_query_url,
|
449
|
+
headers: _headers,
|
450
|
+
parameters: body.to_json
|
451
|
+
)
|
452
|
+
OAuth2.apply(config, _request)
|
453
|
+
_response = execute_request(_request)
|
454
|
+
|
455
|
+
# Return appropriate response type.
|
456
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
457
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
458
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
459
|
+
end
|
460
|
+
end
|
461
|
+
end
|