Class: Square::Orders::CustomAttributes::Client
- Inherits:
-
Object
- Object
- Square::Orders::CustomAttributes::Client
- Defined in:
- lib/square/orders/custom_attributes/client.rb
Instance Method Summary collapse
-
#batch_delete(request_options: {}, **params) ⇒ Square::Types::BulkDeleteOrderCustomAttributesResponse
Deletes order [custom attributes](entity:CustomAttribute) as a bulk operation.
-
#batch_upsert(request_options: {}, **params) ⇒ Square::Types::BulkUpsertOrderCustomAttributesResponse
Creates or updates order [custom attributes](entity:CustomAttribute) as a bulk operation.
-
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteOrderCustomAttributeResponse
Deletes a [custom attribute](entity:CustomAttribute) associated with a customer profile.
-
#get(request_options: {}, **params) ⇒ Square::Types::RetrieveOrderCustomAttributeResponse
Retrieves a [custom attribute](entity:CustomAttribute) associated with an order.
- #initialize(client:) ⇒ Square::Orders::CustomAttributes::Client constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListOrderCustomAttributesResponse
Lists the [custom attributes](entity:CustomAttribute) associated with an order.
-
#upsert(request_options: {}, **params) ⇒ Square::Types::UpsertOrderCustomAttributeResponse
Creates or updates a [custom attribute](entity:CustomAttribute) for an order.
Constructor Details
#initialize(client:) ⇒ Square::Orders::CustomAttributes::Client
8 9 10 |
# File 'lib/square/orders/custom_attributes/client.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#batch_delete(request_options: {}, **params) ⇒ Square::Types::BulkDeleteOrderCustomAttributesResponse
Deletes order [custom attributes](entity:CustomAttribute) as a bulk operation.
Use this endpoint to delete one or more custom attributes from one or more orders. A custom attribute is based on a custom attribute definition in a Square seller account. (To create a custom attribute definition, use the [CreateOrderCustomAttributeDefinition](api-endpoint:OrderCustomAttributes-CreateOrderCustomAttributeDefinition) endpoint.)
This ‘BulkDeleteOrderCustomAttributes` endpoint accepts a map of 1 to 25 individual delete requests and returns a map of individual delete responses. Each delete request has a unique ID and provides an order ID and custom attribute. Each delete response is returned with the ID of the corresponding request.
To delete a custom attribute owned by another application, the ‘visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom attributes (also known as custom fields) are always set to `VISIBILITY_READ_WRITE_VALUES`.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/square/orders/custom_attributes/client.rb', line 28 def batch_delete(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/orders/custom-attributes/bulk-delete", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::BulkDeleteOrderCustomAttributesResponse.load(_response.body) end raise _response.body end |
#batch_upsert(request_options: {}, **params) ⇒ Square::Types::BulkUpsertOrderCustomAttributesResponse
Creates or updates order [custom attributes](entity:CustomAttribute) as a bulk operation.
Use this endpoint to delete one or more custom attributes from one or more orders. A custom attribute is based on a custom attribute definition in a Square seller account. (To create a custom attribute definition, use the [CreateOrderCustomAttributeDefinition](api-endpoint:OrderCustomAttributes-CreateOrderCustomAttributeDefinition) endpoint.)
This ‘BulkUpsertOrderCustomAttributes` endpoint accepts a map of 1 to 25 individual upsert requests and returns a map of individual upsert responses. Each upsert request has a unique ID and provides an order ID and custom attribute. Each upsert response is returned with the ID of the corresponding request.
To create or update a custom attribute owned by another application, the ‘visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom attributes (also known as custom fields) are always set to `VISIBILITY_READ_WRITE_VALUES`.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/square/orders/custom_attributes/client.rb', line 59 def batch_upsert(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/orders/custom-attributes/bulk-upsert", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::BulkUpsertOrderCustomAttributesResponse.load(_response.body) end raise _response.body end |
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteOrderCustomAttributeResponse
Deletes a [custom attribute](entity:CustomAttribute) associated with a customer profile.
To delete a custom attribute owned by another application, the ‘visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom attributes (also known as custom fields) are always set to `VISIBILITY_READ_WRITE_VALUES`.
167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/square/orders/custom_attributes/client.rb', line 167 def delete(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "DELETE", path: "v2/orders/#{params[:order_id]}/custom-attributes/#{params[:custom_attribute_key]}" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::DeleteOrderCustomAttributeResponse.load(_response.body) end raise _response.body end |
#get(request_options: {}, **params) ⇒ Square::Types::RetrieveOrderCustomAttributeResponse
Retrieves a [custom attribute](entity:CustomAttribute) associated with an order.
You can use the ‘with_definition` query parameter to also retrieve the custom attribute definition in the same call.
To retrieve a custom attribute owned by another application, the ‘visibility` setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom attributes also known as custom fields) are always set to `VISIBILITY_READ_WRITE_VALUES`.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/square/orders/custom_attributes/client.rb', line 113 def get(request_options: {}, **params) _query_param_names = %w[version with_definition] _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/orders/#{params[:order_id]}/custom-attributes/#{params[:custom_attribute_key]}", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::RetrieveOrderCustomAttributeResponse.load(_response.body) end raise _response.body end |
#list(request_options: {}, **params) ⇒ Square::Types::ListOrderCustomAttributesResponse
Lists the [custom attributes](entity:CustomAttribute) associated with an order.
You can use the ‘with_definitions` query parameter to also retrieve custom attribute definitions in the same call.
When all response pages are retrieved, the results include all custom attributes that are visible to the requesting application, including those that are owned by other applications and set to ‘VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/square/orders/custom_attributes/client.rb', line 84 def list(request_options: {}, **params) _query_param_names = %w[visibility_filter cursor limit with_definitions] _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/orders/#{params[:order_id]}/custom-attributes", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::ListOrderCustomAttributesResponse.load(_response.body) end raise _response.body end |
#upsert(request_options: {}, **params) ⇒ Square::Types::UpsertOrderCustomAttributeResponse
Creates or updates a [custom attribute](entity:CustomAttribute) for an order.
Use this endpoint to set the value of a custom attribute for a specific order. A custom attribute is based on a custom attribute definition in a Square seller account. (To create a custom attribute definition, use the [CreateOrderCustomAttributeDefinition](api-endpoint:OrderCustomAttributes-CreateOrderCustomAttributeDefinition) endpoint.)
To create or update a custom attribute owned by another application, the ‘visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom attributes (also known as custom fields) are always set to `VISIBILITY_READ_WRITE_VALUES`.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/square/orders/custom_attributes/client.rb', line 143 def upsert(request_options: {}, **params) _path_param_names = %w[order_id custom_attribute_key] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/orders/#{params[:order_id]}/custom-attributes/#{params[:custom_attribute_key]}", body: params.except(*_path_param_names) ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::UpsertOrderCustomAttributeResponse.load(_response.body) end raise _response.body end |