Class: Square::LocationCustomAttributesApi
- Defined in:
- lib/square/api/location_custom_attributes_api.rb
Overview
LocationCustomAttributesApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#bulk_delete_location_custom_attributes(body:) ⇒ BulkDeleteLocationCustomAttributesResponse Hash
Deletes [custom attributes]($m/CustomAttribute) for locations as a bulk operation.
-
#bulk_upsert_location_custom_attributes(body:) ⇒ BulkUpsertLocationCustomAttributesResponse Hash
Creates or updates [custom attributes]($m/CustomAttribute) for locations as a bulk operation.
-
#create_location_custom_attribute_definition(body:) ⇒ CreateLocationCustomAttributeDefinitionResponse Hash
Creates a location-related [custom attribute definition]($m/CustomAttributeDefinition) for a Square seller account.
-
#delete_location_custom_attribute(location_id:, key:) ⇒ DeleteLocationCustomAttributeResponse Hash
Deletes a [custom attribute]($m/CustomAttribute) associated with a location.
-
#delete_location_custom_attribute_definition(key:) ⇒ DeleteLocationCustomAttributeDefinitionResponse Hash
Deletes a location-related [custom attribute definition]($m/CustomAttributeDefinition) from a Square seller account.
-
#initialize(config, http_call_back: nil) ⇒ LocationCustomAttributesApi
constructor
A new instance of LocationCustomAttributesApi.
-
#list_location_custom_attribute_definitions(visibility_filter: nil, limit: nil, cursor: nil) ⇒ ListLocationCustomAttributeDefinitionsResponse Hash
Lists the location-related [custom attribute definitions]($m/CustomAttributeDefinition) that belong to a Square seller account.
-
#list_location_custom_attributes(location_id:, visibility_filter: nil, limit: nil, cursor: nil, with_definitions: false) ⇒ ListLocationCustomAttributesResponse Hash
Lists the [custom attributes]($m/CustomAttribute) associated with a location.
-
#retrieve_location_custom_attribute(location_id:, key:, with_definition: false, version: nil) ⇒ RetrieveLocationCustomAttributeResponse Hash
Retrieves a [custom attribute]($m/CustomAttribute) associated with a location.
-
#retrieve_location_custom_attribute_definition(key:, version: nil) ⇒ RetrieveLocationCustomAttributeDefinitionResponse Hash
Retrieves a location-related [custom attribute definition]($m/CustomAttributeDefinition) from a Square seller account.
-
#update_location_custom_attribute_definition(key:, body:) ⇒ UpdateLocationCustomAttributeDefinitionResponse Hash
Updates a location-related [custom attribute definition]($m/CustomAttributeDefinition) for a Square seller account.
-
#upsert_location_custom_attribute(location_id:, key:, body:) ⇒ UpsertLocationCustomAttributeResponse Hash
Creates or updates a [custom attribute]($m/CustomAttribute) for a location.
Methods inherited from BaseApi
#execute_request, #get_user_agent, #validate_parameters, #validate_parameters_types
Constructor Details
#initialize(config, http_call_back: nil) ⇒ LocationCustomAttributesApi
Returns a new instance of LocationCustomAttributesApi.
4 5 6 |
# File 'lib/square/api/location_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_location_custom_attributes(body:) ⇒ BulkDeleteLocationCustomAttributesResponse Hash
Deletes [custom attributes]($m/CustomAttribute) for locations as a bulk operation. To delete a custom attribute owned by another application, the `visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`. parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/square/api/location_custom_attributes_api.rb', line 258 def bulk_delete_location_custom_attributes(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/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_location_custom_attributes(body:) ⇒ BulkUpsertLocationCustomAttributesResponse Hash
Creates or updates [custom attributes]($m/CustomAttribute) for locations as a bulk operation. Use this endpoint to set the value of one or more custom attributes for one or more locations. A custom attribute is based on a custom attribute definition in a Square seller account, which is created using the [CreateLocationCustomAttributeDefinition]($e/LocationCustomAttributes/Crea teLocationCustomAttributeDefinition) endpoint. This `BulkUpsertLocationCustomAttributes` 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 a location 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`. parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/square/api/location_custom_attributes_api.rb', line 310 def bulk_upsert_location_custom_attributes(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/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_location_custom_attribute_definition(body:) ⇒ CreateLocationCustomAttributeDefinitionResponse Hash
Creates a location-related [custom attribute definition]($m/CustomAttributeDefinition) for a Square seller account. Use this endpoint to define a custom attribute that can be associated with locations. A custom attribute definition specifies the `key`, `visibility`, `schema`, and other properties for a custom attribute. After the definition is created, you can call [UpsertLocationCustomAttribute]($e/LocationCustomAttributes/UpsertLocation CustomAttribute) or [BulkUpsertLocationCustomAttributes]($e/LocationCustomAttributes/BulkUpser tLocationCustomAttributes) to set the custom attribute for locations. parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.
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 109 110 |
# File 'lib/square/api/location_custom_attributes_api.rb', line 83 def create_location_custom_attribute_definition(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/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_location_custom_attribute(location_id:, key:) ⇒ DeleteLocationCustomAttributeResponse Hash
Deletes a [custom attribute]($m/CustomAttribute) associated with a location. To delete a custom attribute owned by another application, the `visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`. [location]($m/Location). delete. This key must match the `key` of a custom attribute definition in the Square seller account. If the requesting application is not the definition owner, you must use the qualified key.
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
# File 'lib/square/api/location_custom_attributes_api.rb', line 426 def delete_location_custom_attribute(location_id:, key:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/{location_id}/custom-attributes/{key}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'location_id' => { 'value' => location_id, 'encode' => true }, '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 |
#delete_location_custom_attribute_definition(key:) ⇒ DeleteLocationCustomAttributeDefinitionResponse Hash
Deletes a location-related [custom attribute definition]($m/CustomAttributeDefinition) from a Square seller account. Deleting a custom attribute definition also deletes the corresponding custom attribute from all locations. Only the definition owner can delete a custom attribute definition. definition to delete.
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 146 147 148 149 150 |
# File 'lib/square/api/location_custom_attributes_api.rb', line 121 def delete_location_custom_attribute_definition(key:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/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_location_custom_attribute_definitions(visibility_filter: nil, limit: nil, cursor: nil) ⇒ ListLocationCustomAttributeDefinitionsResponse Hash
Lists the location-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`. the `CustomAttributeDefinition` results by their `visibility` values. 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/build-basics/common-api-p atterns/pagination). 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/build-basics/common-api-p atterns/pagination).
32 33 34 35 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 |
# File 'lib/square/api/location_custom_attributes_api.rb', line 32 def list_location_custom_attribute_definitions(visibility_filter: nil, limit: nil, cursor: nil) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/custom-attribute-definitions' _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'visibility_filter' => visibility_filter, 'limit' => limit, 'cursor' => cursor ) _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_location_custom_attributes(location_id:, visibility_filter: nil, limit: nil, cursor: nil, with_definitions: false) ⇒ ListLocationCustomAttributesResponse Hash
Lists the [custom attributes]($m/CustomAttribute) associated with a location. 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`. [location]($m/Location). the `CustomAttributeDefinition` results by their `visibility` values. 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/build-basics/common-api-p atterns/pagination). 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/build-basics/common-api-p atterns/pagination). 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`.
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 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 |
# File 'lib/square/api/location_custom_attributes_api.rb', line 372 def list_location_custom_attributes(location_id:, visibility_filter: nil, limit: nil, cursor: nil, with_definitions: false) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/{location_id}/custom-attributes' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'location_id' => { 'value' => location_id, 'encode' => true } ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'visibility_filter' => visibility_filter, 'limit' => limit, 'cursor' => cursor, '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_location_custom_attribute(location_id:, key:, with_definition: false, version: nil) ⇒ RetrieveLocationCustomAttributeResponse Hash
Retrieves a [custom attribute]($m/CustomAttribute) associated with a location. 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`. [location]($m/Location). retrieve. This key must match the `key` of a custom attribute definition in the Square seller account. If the requesting application is not the definition owner, you must use the qualified key. Indicates whether to return the [custom attribute definition]($m/CustomAttributeDefinition) in the `definition` field of the custom attribute. Set this parameter to `true` to get the name and description of the custom attribute, information about the data type, or other definition details. The default value is `false`. custom attribute, which is used for strongly consistent reads to guarantee that you receive the most up-to-date data. When included in the request, Square returns the specified version or a higher version if one exists. If the specified version is higher than the current version, Square returns a `BAD_REQUEST` error.
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
# File 'lib/square/api/location_custom_attributes_api.rb', line 486 def retrieve_location_custom_attribute(location_id:, key:, with_definition: false, version: nil) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/{location_id}/custom-attributes/{key}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'location_id' => { 'value' => location_id, 'encode' => true }, 'key' => { 'value' => key, 'encode' => true } ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'with_definition' => with_definition, '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 |
#retrieve_location_custom_attribute_definition(key:, version: nil) ⇒ RetrieveLocationCustomAttributeDefinitionResponse Hash
Retrieves a location-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`. definition to retrieve. If the requesting application is not the definition owner, you must use the qualified key. custom attribute definition, which is used for strongly consistent reads to guarantee that you receive the most up-to-date data. When included in the request, Square returns the specified version or a higher version if one exists. If the specified version is higher than the current version, Square returns a `BAD_REQUEST` error.
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 197 198 199 200 201 |
# File 'lib/square/api/location_custom_attributes_api.rb', line 167 def retrieve_location_custom_attribute_definition(key:, version: nil) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/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_location_custom_attribute_definition(key:, body:) ⇒ UpdateLocationCustomAttributeDefinitionResponse Hash
Updates a location-related [custom attribute definition]($m/CustomAttributeDefinition) for a Square seller account. Use this endpoint to update the following fields: `name`, `description`, `visibility`, or the `schema` for a `Selection` data type. Only the definition owner can update a custom attribute definition. definition to update. parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.
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 242 243 244 245 246 247 |
# File 'lib/square/api/location_custom_attributes_api.rb', line 215 def update_location_custom_attribute_definition(key:, body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/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_location_custom_attribute(location_id:, key:, body:) ⇒ UpsertLocationCustomAttributeResponse Hash
Creates or updates a [custom attribute]($m/CustomAttribute) for a location. Use this endpoint to set the value of a custom attribute for a specified location. A custom attribute is based on a custom attribute definition in a Square seller account, which is created using the [CreateLocationCustomAttributeDefinition]($e/LocationCustomAttributes/Crea teLocationCustomAttributeDefinition) endpoint. To create or update a custom attribute owned by another application, the `visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`. [location]($m/Location). create or update. This key must match the `key` of a custom attribute definition in the Square seller account. If the requesting application is not the definition owner, you must use the qualified key. object containing the fields to POST for the request. See the corresponding object definition for field details.
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
# File 'lib/square/api/location_custom_attributes_api.rb', line 548 def upsert_location_custom_attribute(location_id:, key:, body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/{location_id}/custom-attributes/{key}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'location_id' => { 'value' => location_id, 'encode' => true }, '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.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 |