Class: Square::Catalog::Object_::Client
- Inherits:
-
Object
- Object
- Square::Catalog::Object_::Client
- Defined in:
- lib/square/catalog/object/client.rb
Instance Method Summary collapse
-
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteCatalogObjectResponse
Deletes a single [CatalogObject](entity:CatalogObject) based on the provided ID and returns the set of successfully deleted IDs in the response.
-
#get(request_options: {}, **params) ⇒ Square::Types::GetCatalogObjectResponse
Returns a single [CatalogItem](entity:CatalogItem) as a [CatalogObject](entity:CatalogObject) based on the provided ID.
- #initialize(client:) ⇒ Square::Catalog::Object_::Client constructor
-
#upsert(request_options: {}, **params) ⇒ Square::Types::UpsertCatalogObjectResponse
Creates a new or updates the specified [CatalogObject](entity:CatalogObject).
Constructor Details
#initialize(client:) ⇒ Square::Catalog::Object_::Client
8 9 10 |
# File 'lib/square/catalog/object/client.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteCatalogObjectResponse
Deletes a single [CatalogObject](entity:CatalogObject) based on the provided ID and returns the set of successfully deleted IDs in the response. Deletion is a cascading event such that all children of the targeted object are also deleted. For example, deleting a [CatalogItem](entity:CatalogItem) will also delete all of its [CatalogItemVariation](entity:CatalogItemVariation) children.
To ensure consistency, only one delete request is processed at a time per seller account. While one (batch or non-batch) delete request is being processed, other (batched and non-batched) delete requests are rejected with the ‘429` error code.
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/square/catalog/object/client.rb', line 74 def delete(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "DELETE", path: "v2/catalog/object/#{params[:object_id]}" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::DeleteCatalogObjectResponse.load(_response.body) end raise _response.body end |
#get(request_options: {}, **params) ⇒ Square::Types::GetCatalogObjectResponse
Returns a single [CatalogItem](entity:CatalogItem) as a [CatalogObject](entity:CatalogObject) based on the provided ID. The returned object includes all of the relevant [CatalogItem](entity:CatalogItem) information including: [CatalogItemVariation](entity:CatalogItemVariation) children, references to its [CatalogModifierList](entity:CatalogModifierList) objects, and the ids of any [CatalogTax](entity:CatalogTax) objects that apply to it.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/square/catalog/object/client.rb', line 43 def get(request_options: {}, **params) _query_param_names = %w[include_related_objects catalog_version include_category_path_to_root] _query = params.slice(*_query_param_names) params = params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/catalog/object/#{params[:object_id]}", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::GetCatalogObjectResponse.load(_response.body) end raise _response.body end |
#upsert(request_options: {}, **params) ⇒ Square::Types::UpsertCatalogObjectResponse
Creates a new or updates the specified [CatalogObject](entity:CatalogObject).
To ensure consistency, only one update request is processed at a time per seller account. While one (batch or non-batch) update request is being processed, other (batched and non-batched) update requests are rejected with the ‘429` error code.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/square/catalog/object/client.rb', line 19 def upsert(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/catalog/object", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::UpsertCatalogObjectResponse.load(_response.body) end raise _response.body end |