merchant_custom_attributes_api = client.merchant_custom_attributes
MerchantCustomAttributesApi
- List Merchant Custom Attribute Definitions
- Create Merchant Custom Attribute Definition
- Delete Merchant Custom Attribute Definition
- Retrieve Merchant Custom Attribute Definition
- Update Merchant Custom Attribute Definition
- Bulk Delete Merchant Custom Attributes
- Bulk Upsert Merchant Custom Attributes
- List Merchant Custom Attributes
- Delete Merchant Custom Attribute
- Retrieve Merchant Custom Attribute
- Upsert Merchant Custom Attribute
Lists the merchant-related custom attribute definitions 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
.
def list_merchant_custom_attribute_definitions(self,
visibility_filter=None,
limit=None,
cursor=None)
Parameter | Type | Tags | Description |
---|---|---|---|
visibility_filter |
str (Visibility Filter) |
Query, Optional | Filters the CustomAttributeDefinition results by their visibility values. |
limit |
int |
Query, Optional | The maximum number of results 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. |
cursor |
str |
Query, Optional | The cursor returned in the 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. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type List Merchant Custom Attribute Definitions Response
.
result = merchant_custom_attributes_api.list_merchant_custom_attribute_definitions()
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Creates a merchant-related custom attribute definition 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 or
BulkUpsertMerchantCustomAttributes
to set the custom attribute for a merchant.
def create_merchant_custom_attribute_definition(self,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Create Merchant Custom Attribute Definition Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Create Merchant Custom Attribute Definition Response
.
body = {
'custom_attribute_definition': {
'key': 'alternative_seller_name',
'name': 'Alternative Merchant Name',
'description': 'This is the other name this merchant goes by.',
'visibility': 'VISIBILITY_READ_ONLY'
}
}
result = merchant_custom_attributes_api.create_merchant_custom_attribute_definition(body)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Deletes a merchant-related custom attribute definition 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.
def delete_merchant_custom_attribute_definition(self,
key)
Parameter | Type | Tags | Description |
---|---|---|---|
key |
str |
Template, Required | The key of the custom attribute definition to delete. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Delete Merchant Custom Attribute Definition Response
.
key = 'key0'
result = merchant_custom_attributes_api.delete_merchant_custom_attribute_definition(key)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Retrieves a merchant-related custom attribute definition 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
.
def retrieve_merchant_custom_attribute_definition(self,
key,
version=None)
Parameter | Type | Tags | Description |
---|---|---|---|
key |
str |
Template, Required | The key of the custom attribute definition to retrieve. If the requesting application is not the definition owner, you must use the qualified key. |
version |
int |
Query, Optional | The current version of the 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. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Retrieve Merchant Custom Attribute Definition Response
.
key = 'key0'
result = merchant_custom_attributes_api.retrieve_merchant_custom_attribute_definition(key)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Updates a merchant-related custom attribute definition 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.
def update_merchant_custom_attribute_definition(self,
key,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
key |
str |
Template, Required | The key of the custom attribute definition to update. |
body |
Update Merchant Custom Attribute Definition Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Update Merchant Custom Attribute Definition Response
.
key = 'key0'
body = {
'custom_attribute_definition': {
'description': 'Update the description as desired.',
'visibility': 'VISIBILITY_READ_ONLY'
}
}
result = merchant_custom_attributes_api.update_merchant_custom_attribute_definition(
key,
body
)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Deletes custom attributes 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
.
def bulk_delete_merchant_custom_attributes(self,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Bulk Delete Merchant Custom Attributes Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Bulk Delete Merchant Custom Attributes Response
.
body = {
'values': {
'id1': {},
'id2': {}
}
}
result = merchant_custom_attributes_api.bulk_delete_merchant_custom_attributes(body)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Creates or updates custom attributes 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 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
.
def bulk_upsert_merchant_custom_attributes(self,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Bulk Upsert Merchant Custom Attributes Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Bulk Upsert Merchant Custom Attributes Response
.
body = {
'values': {
'key0': {
'merchant_id': 'merchant_id0',
'custom_attribute': {}
},
'key1': {
'merchant_id': 'merchant_id0',
'custom_attribute': {}
}
}
}
result = merchant_custom_attributes_api.bulk_upsert_merchant_custom_attributes(body)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Lists the custom attributes 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
.
def list_merchant_custom_attributes(self,
merchant_id,
visibility_filter=None,
limit=None,
cursor=None,
with_definitions=False)
Parameter | Type | Tags | Description |
---|---|---|---|
merchant_id |
str |
Template, Required | The ID of the target merchant. |
visibility_filter |
str (Visibility Filter) |
Query, Optional | Filters the CustomAttributeDefinition results by their visibility values. |
limit |
int |
Query, Optional | The maximum number of results 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. |
cursor |
str |
Query, Optional | The cursor returned in the 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. |
with_definitions |
bool |
Query, Optional | Indicates whether to return the custom attribute definition in the definition field of eachcustom attribute. Set this parameter to true to get the name and description of each customattribute, information about the data type, or other definition details. The default value is false .Default: False |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type List Merchant Custom Attributes Response
.
merchant_id = 'merchant_id0'
with_definitions = False
result = merchant_custom_attributes_api.list_merchant_custom_attributes(
merchant_id,
with_definitions=with_definitions
)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Deletes a custom attribute associated with a merchant.
To delete a custom attribute owned by another application, the visibility
setting must be
VISIBILITY_READ_WRITE_VALUES
.
def delete_merchant_custom_attribute(self,
merchant_id,
key)
Parameter | Type | Tags | Description |
---|---|---|---|
merchant_id |
str |
Template, Required | The ID of the target merchant. |
key |
str |
Template, Required | The key of the custom attribute to delete. This key must match the key of a customattribute definition in the Square seller account. If the requesting application is not the definition owner, you must use the qualified key. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Delete Merchant Custom Attribute Response
.
merchant_id = 'merchant_id0'
key = 'key0'
result = merchant_custom_attributes_api.delete_merchant_custom_attribute(
merchant_id,
key
)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Retrieves a custom attribute 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
.
def retrieve_merchant_custom_attribute(self,
merchant_id,
key,
with_definition=False,
version=None)
Parameter | Type | Tags | Description |
---|---|---|---|
merchant_id |
str |
Template, Required | The ID of the target merchant. |
key |
str |
Template, Required | The key of the custom attribute to retrieve. This key must match the key of a customattribute definition in the Square seller account. If the requesting application is not the definition owner, you must use the qualified key. |
with_definition |
bool |
Query, Optional | Indicates whether to return the custom attribute definition in the definition field ofthe custom attribute. Set this parameter to true to get the name and description of the customattribute, information about the data type, or other definition details. The default value is false .Default: False |
version |
int |
Query, Optional | The current version of the 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. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Retrieve Merchant Custom Attribute Response
.
merchant_id = 'merchant_id0'
key = 'key0'
with_definition = False
result = merchant_custom_attributes_api.retrieve_merchant_custom_attribute(
merchant_id,
key,
with_definition=with_definition
)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Creates or updates a custom attribute 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 endpoint.
To create or update a custom attribute owned by another application, the visibility
setting
must be VISIBILITY_READ_WRITE_VALUES
.
def upsert_merchant_custom_attribute(self,
merchant_id,
key,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
merchant_id |
str |
Template, Required | The ID of the target merchant. |
key |
str |
Template, Required | The key of the custom attribute to create or update. This key must match the key of acustom attribute definition in the Square seller account. If the requesting application is not the definition owner, you must use the qualified key. |
body |
Upsert Merchant Custom Attribute Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Upsert Merchant Custom Attribute Response
.
merchant_id = 'merchant_id0'
key = 'key0'
body = {
'custom_attribute': {}
}
result = merchant_custom_attributes_api.upsert_merchant_custom_attribute(
merchant_id,
key,
body
)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)