Class: Square::OrderCustomAttributesApi

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

Overview

OrderCustomAttributesApi

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_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.

Parameters:

  • body (BulkDeleteOrderCustomAttributesRequest)

    Required parameter:

Returns:

  • (BulkDeleteOrderCustomAttributesResponse Hash)

    response from the API call



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/square/api/order_custom_attributes_api.rb', line 189

def bulk_delete_order_custom_attributes(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/orders/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_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.

Parameters:

  • body (BulkUpsertOrderCustomAttributesRequest)

    Required parameter:

Returns:

  • (BulkUpsertOrderCustomAttributesResponse Hash)

    response from the API call



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/square/api/order_custom_attributes_api.rb', line 232

def bulk_upsert_order_custom_attributes(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/orders/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_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.

Parameters:

  • body (CreateOrderCustomAttributeDefinitionRequest)

    Required

Returns:

  • (CreateOrderCustomAttributeDefinitionResponse Hash)

    response from the API call



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

def create_order_custom_attribute_definition(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/orders/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_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](entity:Order). custom attribute to delete. This key must match the key of an existing custom attribute definition.

Parameters:

  • order_id (String)

    Required parameter: The ID of the target

  • custom_attribute_key (String)

    Required parameter: The key of the

Returns:

  • (DeleteOrderCustomAttributeResponse Hash)

    response from the API call



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/square/api/order_custom_attributes_api.rb', line 321

def delete_order_custom_attribute(order_id:,
                                  custom_attribute_key:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/v2/orders/{order_id}/custom-attributes/{custom_attribute_key}',
                                 'default')
               .template_param(new_parameter(order_id, key: 'order_id')
                                .should_encode(true))
               .template_param(new_parameter(custom_attribute_key, key: 'custom_attribute_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_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.

Parameters:

  • key (String)

    Required parameter: The key of the custom attribute

Returns:

  • (DeleteOrderCustomAttributeDefinitionResponse Hash)

    response from the API call



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/square/api/order_custom_attributes_api.rb', line 84

def delete_order_custom_attribute_definition(key:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/v2/orders/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_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).

Parameters:

  • visibility_filter (VisibilityFilter) (defaults to: nil)

    Optional parameter: Requests

  • cursor (String) (defaults to: nil)

    Optional parameter: The cursor returned in the

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of results

Returns:

  • (ListOrderCustomAttributeDefinitionsResponse Hash)

    response from the API call



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/square/api/order_custom_attributes_api.rb', line 32

def list_order_custom_attribute_definitions(visibility_filter: nil,
                                            cursor: nil,
                                            limit: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/orders/custom-attribute-definitions',
                                 'default')
               .query_param(new_parameter(visibility_filter, key: 'visibility_filter'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(limit, key: 'limit'))
               .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_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](entity: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](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:

  • order_id (String)

    Required parameter: The ID of the target

  • visibility_filter (VisibilityFilter) (defaults to: nil)

    Optional parameter: Requests

  • cursor (String) (defaults to: nil)

    Optional parameter: The cursor returned in the

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of results

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

    Optional parameter:

Returns:

  • (ListOrderCustomAttributesResponse Hash)

    response from the API call



284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/square/api/order_custom_attributes_api.rb', line 284

def list_order_custom_attributes(order_id:,
                                 visibility_filter: nil,
                                 cursor: nil,
                                 limit: nil,
                                 with_definitions: false)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/orders/{order_id}/custom-attributes',
                                 'default')
               .template_param(new_parameter(order_id, key: 'order_id')
                                .should_encode(true))
               .query_param(new_parameter(visibility_filter, key: 'visibility_filter'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(limit, key: 'limit'))
               .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_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](entity: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](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:

  • order_id (String)

    Required parameter: The ID of the target

  • custom_attribute_key (String)

    Required parameter: The key of the

  • version (Integer) (defaults to: nil)

    Optional parameter: To enable [optimistic

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

    Optional parameter:

Returns:

  • (RetrieveOrderCustomAttributeResponse Hash)

    response from the API call



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/square/api/order_custom_attributes_api.rb', line 367

def retrieve_order_custom_attribute(order_id:,
                                    custom_attribute_key:,
                                    version: nil,
                                    with_definition: false)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/orders/{order_id}/custom-attributes/{custom_attribute_key}',
                                 'default')
               .template_param(new_parameter(order_id, key: 'order_id')
                                .should_encode(true))
               .template_param(new_parameter(custom_attribute_key, key: 'custom_attribute_key')
                                .should_encode(true))
               .query_param(new_parameter(version, key: 'version'))
               .query_param(new_parameter(with_definition, key: 'with_definition'))
               .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_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.

Parameters:

  • key (String)

    Required parameter: The key of the custom attribute

  • version (Integer) (defaults to: nil)

    Optional parameter: To enable [optimistic

Returns:

  • (RetrieveOrderCustomAttributeDefinitionResponse Hash)

    response from the API call



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/square/api/order_custom_attributes_api.rb', line 115

def retrieve_order_custom_attribute_definition(key:,
                                               version: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/orders/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_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.

Parameters:

  • key (String)

    Required parameter: The key of the custom attribute

  • body (UpdateOrderCustomAttributeDefinitionRequest)

    Required

Returns:

  • (UpdateOrderCustomAttributeDefinitionResponse Hash)

    response from the API call



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/square/api/order_custom_attributes_api.rb', line 144

def update_order_custom_attribute_definition(key:,
                                             body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/v2/orders/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_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](entity: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.

Parameters:

  • order_id (String)

    Required parameter: The ID of the target

  • custom_attribute_key (String)

    Required parameter: The key of the

  • body (UpsertOrderCustomAttributeRequest)

    Required parameter: An

Returns:

  • (UpsertOrderCustomAttributeResponse Hash)

    response from the API call



413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/square/api/order_custom_attributes_api.rb', line 413

def upsert_order_custom_attribute(order_id:,
                                  custom_attribute_key:,
                                  body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/orders/{order_id}/custom-attributes/{custom_attribute_key}',
                                 'default')
               .template_param(new_parameter(order_id, key: 'order_id')
                                .should_encode(true))
               .template_param(new_parameter(custom_attribute_key, key: 'custom_attribute_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