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 31 32 33 34 35 36 |
# 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::PRODUCTION, method: "POST", path: "v2/locations/custom-attributes/bulk-delete", body: params ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::BulkDeleteLocationCustomAttributesResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end 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`.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/square/locations/custom_attributes/client.rb', line 50 def batch_upsert(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/locations/custom-attributes/bulk-upsert", body: params ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::BulkUpsertLocationCustomAttributesResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end 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`.
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/square/locations/custom_attributes/client.rb', line 178 def delete(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "DELETE", path: "v2/locations/#{params[:location_id]}/custom-attributes/#{params[:key]}" ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::DeleteLocationCustomAttributeResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end 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`.
114 115 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 |
# File 'lib/square/locations/custom_attributes/client.rb', line 114 def get(request_options: {}, **params) _query_param_names = [ %w[with_definition version], %i[with_definition version] ].flatten _query = params.slice(*_query_param_names) params = params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/locations/#{params[:location_id]}/custom-attributes/#{params[:key]}", query: _query ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::RetrieveLocationCustomAttributeResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end 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`.
79 80 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 |
# File 'lib/square/locations/custom_attributes/client.rb', line 79 def list(request_options: {}, **params) _query_param_names = [ %w[visibility_filter limit cursor with_definitions], %i[visibility_filter limit cursor with_definitions] ].flatten _query = params.slice(*_query_param_names) params = params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/locations/#{params[:location_id]}/custom-attributes", query: _query ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::ListLocationCustomAttributesResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end 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`.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/square/locations/custom_attributes/client.rb', line 150 def upsert(request_options: {}, **params) _path_param_names = %w[location_id key] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/locations/#{params[:location_id]}/custom-attributes/#{params[:key]}", body: params.except(*_path_param_names) ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::UpsertLocationCustomAttributeResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |