Class: Square::OrderCustomAttributesApi
- Defined in:
- lib/square/api/order_custom_attributes_api.rb
Overview
OrderCustomAttributesApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#bulk_delete_order_custom_attributes(body:) ⇒ BulkDeleteOrderCustomAttributesResponse Hash
Deletes order [custom attributes]($m/CustomAttribute) as a bulk operation.
-
#bulk_upsert_order_custom_attributes(body:) ⇒ BulkUpsertOrderCustomAttributesResponse Hash
Creates or updates order [custom attributes]($m/CustomAttribute) as a bulk operation.
-
#create_order_custom_attribute_definition(body:) ⇒ CreateOrderCustomAttributeDefinitionResponse Hash
Creates an order-related custom attribute definition.
-
#delete_order_custom_attribute(order_id:, custom_attribute_key:) ⇒ DeleteOrderCustomAttributeResponse Hash
Deletes a [custom attribute]($m/CustomAttribute) associated with a customer profile.
-
#delete_order_custom_attribute_definition(key:) ⇒ DeleteOrderCustomAttributeDefinitionResponse Hash
Deletes an order-related [custom attribute definition]($m/CustomAttributeDefinition) from a Square seller account.
-
#initialize(config, http_call_back: nil) ⇒ OrderCustomAttributesApi
constructor
A new instance of OrderCustomAttributesApi.
-
#list_order_custom_attribute_definitions(visibility_filter: nil, cursor: nil, limit: nil) ⇒ ListOrderCustomAttributeDefinitionsResponse Hash
Lists the order-related [custom attribute definitions]($m/CustomAttributeDefinition) that belong to a Square seller account.
-
#list_order_custom_attributes(order_id:, visibility_filter: nil, cursor: nil, limit: nil, with_definitions: false) ⇒ ListOrderCustomAttributesResponse Hash
Lists the [custom attributes]($m/CustomAttribute) associated with an order.
-
#retrieve_order_custom_attribute(order_id:, custom_attribute_key:, version: nil, with_definition: false) ⇒ RetrieveOrderCustomAttributeResponse Hash
Retrieves a [custom attribute]($m/CustomAttribute) associated with an order.
-
#retrieve_order_custom_attribute_definition(key:, version: nil) ⇒ RetrieveOrderCustomAttributeDefinitionResponse Hash
Retrieves an order-related [custom attribute definition]($m/CustomAttributeDefinition) from a Square seller account.
-
#update_order_custom_attribute_definition(key:, body:) ⇒ UpdateOrderCustomAttributeDefinitionResponse Hash
Updates an order-related custom attribute definition for a Square seller account.
-
#upsert_order_custom_attribute(order_id:, custom_attribute_key:, body:) ⇒ UpsertOrderCustomAttributeResponse Hash
Creates or updates a [custom attribute]($m/CustomAttribute) for an order.
Methods inherited from BaseApi
#execute_request, #get_user_agent, #validate_parameters, #validate_parameters_types
Constructor Details
#initialize(config, http_call_back: nil) ⇒ OrderCustomAttributesApi
Returns a new instance of OrderCustomAttributesApi.
4 5 6 |
# File 'lib/square/api/order_custom_attributes_api.rb', line 4 def initialize(config, http_call_back: nil) super(config, http_call_back: http_call_back) end |
Instance Method Details
#bulk_delete_order_custom_attributes(body:) ⇒ BulkDeleteOrderCustomAttributesResponse Hash
Deletes order [custom attributes]($m/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]($e/OrderCustomAttributes/CreateOrde rCustomAttributeDefinition) 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`. An object containing the fields to POST for the request. See the corresponding object definition for field details.
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/square/api/order_custom_attributes_api.rb', line 268 def bulk_delete_order_custom_attributes(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/orders/custom-attributes/bulk-delete' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#bulk_upsert_order_custom_attributes(body:) ⇒ BulkUpsertOrderCustomAttributesResponse Hash
Creates or updates order [custom attributes]($m/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]($e/OrderCustomAttributes/CreateOrde rCustomAttributeDefinition) 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`. An object containing the fields to POST for the request. See the corresponding object definition for field details.
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/square/api/order_custom_attributes_api.rb', line 323 def bulk_upsert_order_custom_attributes(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/orders/custom-attributes/bulk-upsert' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#create_order_custom_attribute_definition(body:) ⇒ CreateOrderCustomAttributeDefinitionResponse Hash
Creates an order-related custom attribute definition. Use this endpoint to define a custom attribute that can be associated with orders. After creating a custom attribute definition, you can set the custom attribute for orders in the Square seller account. parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/square/api/order_custom_attributes_api.rb', line 81 def create_order_custom_attribute_definition(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/orders/custom-attribute-definitions' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#delete_order_custom_attribute(order_id:, custom_attribute_key:) ⇒ DeleteOrderCustomAttributeResponse Hash
Deletes a [custom attribute]($m/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`. [order]($m/Order). custom attribute to delete. This key must match the key of an existing custom attribute definition.
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
# File 'lib/square/api/order_custom_attributes_api.rb', line 442 def delete_order_custom_attribute(order_id:, custom_attribute_key:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/orders/{order_id}/custom-attributes/{custom_attribute_key}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'order_id' => { 'value' => order_id, 'encode' => true }, 'custom_attribute_key' => { 'value' => custom_attribute_key, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.delete( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#delete_order_custom_attribute_definition(key:) ⇒ DeleteOrderCustomAttributeDefinitionResponse Hash
Deletes an order-related [custom attribute definition]($m/CustomAttributeDefinition) from a Square seller account. Only the definition owner can delete a custom attribute definition. definition to delete.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/square/api/order_custom_attributes_api.rb', line 116 def delete_order_custom_attribute_definition(key:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/orders/custom-attribute-definitions/{key}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'key' => { 'value' => key, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.delete( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#list_order_custom_attribute_definitions(visibility_filter: nil, cursor: nil, limit: nil) ⇒ ListOrderCustomAttributeDefinitionsResponse Hash
Lists the order-related [custom attribute definitions]($m/CustomAttributeDefinition) that belong to a Square seller account. When all response pages are retrieved, the results include all custom attribute definitions that are visible to the requesting application, including those that are created by other applications and set to `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`. that all of the custom attributes be returned, or only those that are read-only or read-write. paged response from the previous call to this endpoint. Provide this cursor to retrieve the next page of results for your original request. For more information, see [Pagination](developer.squareup.com/docs/working-with-apis/paginat ion). to return in a single paged response. This limit is advisory. The response might contain more or fewer results. The minimum value is 1 and the maximum value is 100. The default value is 20. For more information, see [Pagination](developer.squareup.com/docs/working-with-apis/paginat ion).
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/square/api/order_custom_attributes_api.rb', line 36 def list_order_custom_attribute_definitions(visibility_filter: nil, cursor: nil, limit: nil) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/orders/custom-attribute-definitions' _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'visibility_filter' => visibility_filter, 'cursor' => cursor, 'limit' => limit ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#list_order_custom_attributes(order_id:, visibility_filter: nil, cursor: nil, limit: nil, with_definitions: false) ⇒ ListOrderCustomAttributesResponse Hash
Lists the [custom attributes]($m/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`. [order]($m/Order). that all of the custom attributes be returned, or only those that are read-only or read-write. paged response from the previous call to this endpoint. Provide this cursor to retrieve the next page of results for your original request. For more information, see [Pagination](developer.squareup.com/docs/working-with-apis/paginat ion). to return in a single paged response. This limit is advisory. The response might contain more or fewer results. The minimum value is 1 and the maximum value is 100. The default value is 20. For more information, see [Pagination](developer.squareup.com/docs/working-with-apis/paginat ion). Indicates whether to return the [custom attribute definition]($m/CustomAttributeDefinition) in the `definition` field of each custom attribute. Set this parameter to `true` to get the name and description of each custom attribute, information about the data type, or other definition details. The default value is `false`.
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/square/api/order_custom_attributes_api.rb', line 387 def list_order_custom_attributes(order_id:, visibility_filter: nil, cursor: nil, limit: nil, with_definitions: false) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/orders/{order_id}/custom-attributes' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'order_id' => { 'value' => order_id, 'encode' => true } ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'visibility_filter' => visibility_filter, 'cursor' => cursor, 'limit' => limit, 'with_definitions' => with_definitions ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#retrieve_order_custom_attribute(order_id:, custom_attribute_key:, version: nil, with_definition: false) ⇒ RetrieveOrderCustomAttributeResponse Hash
Retrieves a [custom attribute]($m/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`. [order]($m/Order). custom attribute to retrieve. This key must match the key of an existing custom attribute definition. concurrency](developer.squareup.com/docs/build-basics/common-api-p atterns/optimistic-concurrency) control, include this optional field and specify the current version of the custom attribute. Indicates whether to return the [custom attribute definition]($m/CustomAttributeDefinition) in the `definition` field of each custom attribute. Set this parameter to `true` to get the name and description of each custom attribute, information about the data type, or other definition details. The default value is `false`.
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# File 'lib/square/api/order_custom_attributes_api.rb', line 502 def retrieve_order_custom_attribute(order_id:, custom_attribute_key:, version: nil, with_definition: false) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/orders/{order_id}/custom-attributes/{custom_attribute_key}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'order_id' => { 'value' => order_id, 'encode' => true }, 'custom_attribute_key' => { 'value' => custom_attribute_key, 'encode' => true } ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'version' => version, 'with_definition' => with_definition ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#retrieve_order_custom_attribute_definition(key:, version: nil) ⇒ RetrieveOrderCustomAttributeDefinitionResponse Hash
Retrieves an order-related [custom attribute definition]($m/CustomAttributeDefinition) from a Square seller account. To retrieve a custom attribute definition created 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`. definition to retrieve. concurrency](developer.squareup.com/docs/build-basics/common-api-p atterns/optimistic-concurrency) control, include this optional field and specify the current version of the custom attribute.
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/square/api/order_custom_attributes_api.rb', line 162 def retrieve_order_custom_attribute_definition(key:, version: nil) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/orders/custom-attribute-definitions/{key}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'key' => { 'value' => key, 'encode' => true } ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'version' => version ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#update_order_custom_attribute_definition(key:, body:) ⇒ UpdateOrderCustomAttributeDefinitionResponse Hash
Updates an order-related custom attribute definition for a Square seller account. Only the definition owner can update a custom attribute definition. Note that sellers can view all custom attributes in exported customer data, including those set to `VISIBILITY_HIDDEN`. definition to update. parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/square/api/order_custom_attributes_api.rb', line 209 def update_order_custom_attribute_definition(key:, body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/orders/custom-attribute-definitions/{key}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'key' => { 'value' => key, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.put( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#upsert_order_custom_attribute(order_id:, custom_attribute_key:, body:) ⇒ UpsertOrderCustomAttributeResponse Hash
Creates or updates a [custom attribute]($m/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]($e/OrderCustomAttributes/CreateOrde rCustomAttributeDefinition) 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`. [order]($m/Order). custom attribute to create or update. This key must match the key of an existing custom attribute definition. object containing the fields to POST for the request. See the corresponding object definition for field details.
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
# File 'lib/square/api/order_custom_attributes_api.rb', line 565 def upsert_order_custom_attribute(order_id:, custom_attribute_key:, body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/orders/{order_id}/custom-attributes/{custom_attribute_key}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'order_id' => { 'value' => order_id, 'encode' => true }, 'custom_attribute_key' => { 'value' => custom_attribute_key, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |