Class: Square::MerchantCustomAttributesApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/square/api/merchant_custom_attributes_api.rb

Overview

MerchantCustomAttributesApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Square::BaseApi

Instance Method Details

#bulk_delete_merchant_custom_attributes(body:) ⇒ BulkDeleteMerchantCustomAttributesResponse Hash

Deletes [custom attributes]($m/CustomAttribute) for a merchant 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.

Parameters:

  • body (BulkDeleteMerchantCustomAttributesRequest)

    Required

Returns:

  • (BulkDeleteMerchantCustomAttributesResponse Hash)

    response from the API call



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/square/api/merchant_custom_attributes_api.rb', line 179

def bulk_delete_merchant_custom_attributes(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/merchants/custom-attributes/bulk-delete',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#bulk_upsert_merchant_custom_attributes(body:) ⇒ BulkUpsertMerchantCustomAttributesResponse Hash

Creates or updates [custom attributes]($m/CustomAttribute) for a merchant as a bulk operation. Use this endpoint to set the value of one or more custom attributes for a merchant. A custom attribute is based on a custom attribute definition in a Square seller account, which is created using the [CreateMerchantCustomAttributeDefinition]($e/MerchantCustomAttributes/Crea teMerchantCustomAttributeDefinition) endpoint. This ‘BulkUpsertMerchantCustomAttributes` 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 merchant 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.

Parameters:

  • body (BulkUpsertMerchantCustomAttributesRequest)

    Required

Returns:

  • (BulkUpsertMerchantCustomAttributesResponse Hash)

    response from the API call



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/square/api/merchant_custom_attributes_api.rb', line 219

def bulk_upsert_merchant_custom_attributes(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/merchants/custom-attributes/bulk-upsert',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#create_merchant_custom_attribute_definition(body:) ⇒ CreateMerchantCustomAttributeDefinitionResponse Hash

Creates a merchant-related [custom attribute definition]($m/CustomAttributeDefinition) for a Square seller account. Use this endpoint to define a custom attribute that can be associated with a merchant connecting to your application. A custom attribute definition specifies the ‘key`, `visibility`, `schema`, and other properties for a custom attribute. After the definition is created, you can call [UpsertMerchantCustomAttribute]($e/MerchantCustomAttributes/UpsertMerchant CustomAttribute) or [BulkUpsertMerchantCustomAttributes]($e/MerchantCustomAttributes/BulkUpser tMerchantCustomAttributes) to set the custom attribute for a merchant. parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (CreateMerchantCustomAttributeDefinitionRequest)

    Required

Returns:

  • (CreateMerchantCustomAttributeDefinitionResponse Hash)

    response from the API call



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/square/api/merchant_custom_attributes_api.rb', line 63

def create_merchant_custom_attribute_definition(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/merchants/custom-attribute-definitions',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#delete_merchant_custom_attribute(merchant_id:, key:) ⇒ DeleteMerchantCustomAttributeResponse Hash

Deletes a [custom attribute]($m/CustomAttribute) associated with a merchant. To delete a custom attribute owned by another application, the ‘visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`. [merchant](entity:Merchant). 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.

Parameters:

  • merchant_id (String)

    Required parameter: The ID of the target

  • key (String)

    Required parameter: The key of the custom attribute to

Returns:

  • (DeleteMerchantCustomAttributeResponse Hash)

    response from the API call



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/square/api/merchant_custom_attributes_api.rb', line 305

def delete_merchant_custom_attribute(merchant_id:,
                                     key:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/v2/merchants/{merchant_id}/custom-attributes/{key}',
                                 'default')
               .template_param(new_parameter(merchant_id, key: 'merchant_id')
                                .should_encode(true))
               .template_param(new_parameter(key, key: 'key')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#delete_merchant_custom_attribute_definition(key:) ⇒ DeleteMerchantCustomAttributeDefinitionResponse Hash

Deletes a merchant-related [custom attribute definition]($m/CustomAttributeDefinition) from a Square seller account. Deleting a custom attribute definition also deletes the corresponding custom attribute from the merchant. Only the definition owner can delete a custom attribute definition. definition to delete.

Parameters:

  • key (String)

    Required parameter: The key of the custom attribute

Returns:

  • (DeleteMerchantCustomAttributeDefinitionResponse Hash)

    response from the API call



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/square/api/merchant_custom_attributes_api.rb', line 89

def delete_merchant_custom_attribute_definition(key:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/v2/merchants/custom-attribute-definitions/{key}',
                                 'default')
               .template_param(new_parameter(key, key: 'key')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#list_merchant_custom_attribute_definitions(visibility_filter: nil, limit: nil, cursor: nil) ⇒ ListMerchantCustomAttributeDefinitionsResponse Hash

Lists the merchant-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).

Parameters:

  • visibility_filter (VisibilityFilter) (defaults to: nil)

    Optional parameter: Filters

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of results

  • cursor (String) (defaults to: nil)

    Optional parameter: The cursor returned in the

Returns:

  • (ListMerchantCustomAttributeDefinitionsResponse Hash)

    response from the API call



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/square/api/merchant_custom_attributes_api.rb', line 28

def list_merchant_custom_attribute_definitions(visibility_filter: nil,
                                               limit: nil,
                                               cursor: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/merchants/custom-attribute-definitions',
                                 'default')
               .query_param(new_parameter(visibility_filter, key: 'visibility_filter'))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#list_merchant_custom_attributes(merchant_id:, visibility_filter: nil, limit: nil, cursor: nil, with_definitions: false) ⇒ ListMerchantCustomAttributesResponse Hash

Lists the [custom attributes]($m/CustomAttribute) associated with a merchant. 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`. [merchant](entity:Merchant). 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](entity: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`.

Parameters:

  • merchant_id (String)

    Required parameter: The ID of the target

  • visibility_filter (VisibilityFilter) (defaults to: nil)

    Optional parameter: Filters

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of results

  • cursor (String) (defaults to: nil)

    Optional parameter: The cursor returned in the

  • with_definitions (TrueClass | FalseClass) (defaults to: false)

    Optional parameter:

Returns:

  • (ListMerchantCustomAttributesResponse Hash)

    response from the API call



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/square/api/merchant_custom_attributes_api.rb', line 269

def list_merchant_custom_attributes(merchant_id:,
                                    visibility_filter: nil,
                                    limit: nil,
                                    cursor: nil,
                                    with_definitions: false)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/merchants/{merchant_id}/custom-attributes',
                                 'default')
               .template_param(new_parameter(merchant_id, key: 'merchant_id')
                                .should_encode(true))
               .query_param(new_parameter(visibility_filter, key: 'visibility_filter'))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(with_definitions, key: 'with_definitions'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_merchant_custom_attribute(merchant_id:, key:, with_definition: false, version: nil) ⇒ RetrieveMerchantCustomAttributeResponse Hash

Retrieves a [custom attribute]($m/CustomAttribute) associated with a merchant. 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`. [merchant](entity:Merchant). 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](entity: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.

Parameters:

  • merchant_id (String)

    Required parameter: The ID of the target

  • key (String)

    Required parameter: The key of the custom attribute to

  • with_definition (TrueClass | FalseClass) (defaults to: false)

    Optional parameter:

  • version (Integer) (defaults to: nil)

    Optional parameter: The current version of the

Returns:

  • (RetrieveMerchantCustomAttributeResponse Hash)

    response from the API call



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/square/api/merchant_custom_attributes_api.rb', line 351

def retrieve_merchant_custom_attribute(merchant_id:,
                                       key:,
                                       with_definition: false,
                                       version: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/merchants/{merchant_id}/custom-attributes/{key}',
                                 'default')
               .template_param(new_parameter(merchant_id, key: 'merchant_id')
                                .should_encode(true))
               .template_param(new_parameter(key, key: 'key')
                                .should_encode(true))
               .query_param(new_parameter(with_definition, key: 'with_definition'))
               .query_param(new_parameter(version, key: 'version'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_merchant_custom_attribute_definition(key:, version: nil) ⇒ RetrieveMerchantCustomAttributeDefinitionResponse Hash

Retrieves a merchant-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.

Parameters:

  • key (String)

    Required parameter: The key of the custom attribute

  • version (Integer) (defaults to: nil)

    Optional parameter: The current version of the

Returns:

  • (RetrieveMerchantCustomAttributeDefinitionResponse Hash)

    response from the API call



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/square/api/merchant_custom_attributes_api.rb', line 120

def retrieve_merchant_custom_attribute_definition(key:,
                                                  version: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/merchants/custom-attribute-definitions/{key}',
                                 'default')
               .template_param(new_parameter(key, key: 'key')
                                .should_encode(true))
               .query_param(new_parameter(version, key: 'version'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#update_merchant_custom_attribute_definition(key:, body:) ⇒ UpdateMerchantCustomAttributeDefinitionResponse Hash

Updates a merchant-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.

Parameters:

  • key (String)

    Required parameter: The key of the custom attribute

  • body (UpdateMerchantCustomAttributeDefinitionRequest)

    Required

Returns:

  • (UpdateMerchantCustomAttributeDefinitionResponse Hash)

    response from the API call



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/square/api/merchant_custom_attributes_api.rb', line 150

def update_merchant_custom_attribute_definition(key:,
                                                body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/v2/merchants/custom-attribute-definitions/{key}',
                                 'default')
               .template_param(new_parameter(key, key: 'key')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#upsert_merchant_custom_attribute(merchant_id:, key:, body:) ⇒ UpsertMerchantCustomAttributeResponse Hash

Creates or updates a [custom attribute]($m/CustomAttribute) for a merchant. Use this endpoint to set the value of a custom attribute for a specified merchant. A custom attribute is based on a custom attribute definition in a Square seller account, which is created using the [CreateMerchantCustomAttributeDefinition]($e/MerchantCustomAttributes/Crea teMerchantCustomAttributeDefinition) endpoint. To create or update a custom attribute owned by another application, the ‘visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`. [merchant](entity:Merchant). 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.

Parameters:

  • merchant_id (String)

    Required parameter: The ID of the target

  • key (String)

    Required parameter: The key of the custom attribute to

  • body (UpsertMerchantCustomAttributeRequest)

    Required parameter: An

Returns:

  • (UpsertMerchantCustomAttributeResponse Hash)

    response from the API call



396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/square/api/merchant_custom_attributes_api.rb', line 396

def upsert_merchant_custom_attribute(merchant_id:,
                                     key:,
                                     body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/merchants/{merchant_id}/custom-attributes/{key}',
                                 'default')
               .template_param(new_parameter(merchant_id, key: 'merchant_id')
                                .should_encode(true))
               .template_param(new_parameter(key, key: 'key')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end