Class: Square::Locations::CustomAttributes::Client
- Inherits:
-
Object
- Object
- Square::Locations::CustomAttributes::Client
- Defined in:
- lib/square/locations/custom_attributes/client.rb
Instance Method Summary collapse
-
#batch_delete(request_options: {}, **params) ⇒ Square::Types::BulkDeleteLocationCustomAttributesResponse
Deletes [custom attributes](entity:CustomAttribute) for locations as a bulk operation.
-
#batch_upsert(request_options: {}, **params) ⇒ Square::Types::BulkUpsertLocationCustomAttributesResponse
Creates or updates [custom attributes](entity:CustomAttribute) for locations as a bulk operation.
-
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteLocationCustomAttributeResponse
Deletes a [custom attribute](entity:CustomAttribute) associated with a location.
-
#get(request_options: {}, **params) ⇒ Square::Types::RetrieveLocationCustomAttributeResponse
Retrieves a [custom attribute](entity:CustomAttribute) associated with a location.
- #initialize(client:) ⇒ Square::Locations::CustomAttributes::Client constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListLocationCustomAttributesResponse
Lists the [custom attributes](entity:CustomAttribute) associated with a location.
-
#upsert(request_options: {}, **params) ⇒ Square::Types::UpsertLocationCustomAttributeResponse
Creates or updates a [custom attribute](entity:CustomAttribute) for a location.
Constructor Details
#initialize(client:) ⇒ Square::Locations::CustomAttributes::Client
8 9 10 |
# File 'lib/square/locations/custom_attributes/client.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#batch_delete(request_options: {}, **params) ⇒ Square::Types::BulkDeleteLocationCustomAttributesResponse
Deletes [custom attributes](entity: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`.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/square/locations/custom_attributes/client.rb', line 17 def batch_delete(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/locations/custom-attributes/bulk-delete", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::BulkDeleteLocationCustomAttributesResponse.load(_response.body) end raise _response.body end |
#batch_upsert(request_options: {}, **params) ⇒ Square::Types::BulkUpsertLocationCustomAttributesResponse
Creates or updates [custom attributes](entity: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](api-endpoint:LocationCustomAttributes-CreateLocationCustomAttributeDefinition) 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`.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/square/locations/custom_attributes/client.rb', line 44 def batch_upsert(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/locations/custom-attributes/bulk-upsert", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::BulkUpsertLocationCustomAttributesResponse.load(_response.body) end raise _response.body end |
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteLocationCustomAttributeResponse
Deletes a [custom attribute](entity:CustomAttribute) associated with a location. To delete a custom attribute owned by another application, the ‘visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`.
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/square/locations/custom_attributes/client.rb', line 142 def delete(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "DELETE", path: "v2/locations/#{params[:location_id]}/custom-attributes/#{params[:key]}" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::DeleteLocationCustomAttributeResponse.load(_response.body) end raise _response.body end |
#get(request_options: {}, **params) ⇒ Square::Types::RetrieveLocationCustomAttributeResponse
Retrieves a [custom attribute](entity: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`.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/square/locations/custom_attributes/client.rb', line 93 def get(request_options: {}, **params) _query_param_names = %w[with_definition version] _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/locations/#{params[:location_id]}/custom-attributes/#{params[:key]}", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::RetrieveLocationCustomAttributeResponse.load(_response.body) end raise _response.body end |
#list(request_options: {}, **params) ⇒ Square::Types::ListLocationCustomAttributesResponse
Lists the [custom attributes](entity: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`.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/square/locations/custom_attributes/client.rb', line 67 def list(request_options: {}, **params) _query_param_names = %w[visibility_filter limit cursor 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/locations/#{params[:location_id]}/custom-attributes", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::ListLocationCustomAttributesResponse.load(_response.body) end raise _response.body end |
#upsert(request_options: {}, **params) ⇒ Square::Types::UpsertLocationCustomAttributeResponse
Creates or updates a [custom attribute](entity: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](api-endpoint:LocationCustomAttributes-CreateLocationCustomAttributeDefinition) endpoint. To create or update a custom attribute owned by another application, the ‘visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`.
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/square/locations/custom_attributes/client.rb', line 120 def upsert(request_options: {}, **params) _path_param_names = %w[location_id key] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/locations/#{params[:location_id]}/custom-attributes/#{params[:key]}", body: params.except(*_path_param_names) ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::UpsertLocationCustomAttributeResponse.load(_response.body) end raise _response.body end |