MerchantCustomAttributesApi merchantCustomAttributesApi = client.getMerchantCustomAttributesApi();
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
.
CompletableFuture<ListMerchantCustomAttributeDefinitionsResponse> listMerchantCustomAttributeDefinitionsAsync(
final String visibilityFilter,
final Integer limit,
final String cursor)
Parameter | Type | Tags | Description |
---|---|---|---|
visibilityFilter |
String |
Query, Optional | Filters the CustomAttributeDefinition results by their visibility values. |
limit |
Integer |
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 |
String |
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. |
ListMerchantCustomAttributeDefinitionsResponse
merchantCustomAttributesApi.listMerchantCustomAttributeDefinitionsAsync(null, null, null).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
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.
CompletableFuture<CreateMerchantCustomAttributeDefinitionResponse> createMerchantCustomAttributeDefinitionAsync(
final CreateMerchantCustomAttributeDefinitionRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
CreateMerchantCustomAttributeDefinitionRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
CreateMerchantCustomAttributeDefinitionResponse
CreateMerchantCustomAttributeDefinitionRequest body = new CreateMerchantCustomAttributeDefinitionRequest.Builder(
new CustomAttributeDefinition.Builder()
.key("alternative_seller_name")
.name("Alternative Merchant Name")
.description("This is the other name this merchant goes by.")
.visibility("VISIBILITY_READ_ONLY")
.build()
)
.build();
merchantCustomAttributesApi.createMerchantCustomAttributeDefinitionAsync(body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
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.
CompletableFuture<DeleteMerchantCustomAttributeDefinitionResponse> deleteMerchantCustomAttributeDefinitionAsync(
final String key)
Parameter | Type | Tags | Description |
---|---|---|---|
key |
String |
Template, Required | The key of the custom attribute definition to delete. |
DeleteMerchantCustomAttributeDefinitionResponse
String key = "key0";
merchantCustomAttributesApi.deleteMerchantCustomAttributeDefinitionAsync(key).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
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
.
CompletableFuture<RetrieveMerchantCustomAttributeDefinitionResponse> retrieveMerchantCustomAttributeDefinitionAsync(
final String key,
final Integer version)
Parameter | Type | Tags | Description |
---|---|---|---|
key |
String |
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 |
Integer |
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. |
RetrieveMerchantCustomAttributeDefinitionResponse
String key = "key0";
merchantCustomAttributesApi.retrieveMerchantCustomAttributeDefinitionAsync(key, null).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
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.
CompletableFuture<UpdateMerchantCustomAttributeDefinitionResponse> updateMerchantCustomAttributeDefinitionAsync(
final String key,
final UpdateMerchantCustomAttributeDefinitionRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
key |
String |
Template, Required | The key of the custom attribute definition to update. |
body |
UpdateMerchantCustomAttributeDefinitionRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
UpdateMerchantCustomAttributeDefinitionResponse
String key = "key0";
UpdateMerchantCustomAttributeDefinitionRequest body = new UpdateMerchantCustomAttributeDefinitionRequest.Builder(
new CustomAttributeDefinition.Builder()
.description("Update the description as desired.")
.visibility("VISIBILITY_READ_ONLY")
.build()
)
.build();
merchantCustomAttributesApi.updateMerchantCustomAttributeDefinitionAsync(key, body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
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
.
CompletableFuture<BulkDeleteMerchantCustomAttributesResponse> bulkDeleteMerchantCustomAttributesAsync(
final BulkDeleteMerchantCustomAttributesRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
BulkDeleteMerchantCustomAttributesRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
BulkDeleteMerchantCustomAttributesResponse
BulkDeleteMerchantCustomAttributesRequest body = new BulkDeleteMerchantCustomAttributesRequest.Builder(
new LinkedHashMap<String, BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest>() {{
put("id1", new BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest.Builder()
.build());
put("id2", new BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest.Builder()
.build());
}}
)
.build();
merchantCustomAttributesApi.bulkDeleteMerchantCustomAttributesAsync(body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
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
.
CompletableFuture<BulkUpsertMerchantCustomAttributesResponse> bulkUpsertMerchantCustomAttributesAsync(
final BulkUpsertMerchantCustomAttributesRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
BulkUpsertMerchantCustomAttributesRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
BulkUpsertMerchantCustomAttributesResponse
BulkUpsertMerchantCustomAttributesRequest body = new BulkUpsertMerchantCustomAttributesRequest.Builder(
new LinkedHashMap<String, BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest>() {{
put("key0", new BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest.Builder(
"merchant_id0",
new CustomAttribute.Builder()
.build()
)
.build());
put("key1", new BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest.Builder(
"merchant_id0",
new CustomAttribute.Builder()
.build()
)
.build());
}}
)
.build();
merchantCustomAttributesApi.bulkUpsertMerchantCustomAttributesAsync(body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
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
.
CompletableFuture<ListMerchantCustomAttributesResponse> listMerchantCustomAttributesAsync(
final String merchantId,
final String visibilityFilter,
final Integer limit,
final String cursor,
final Boolean withDefinitions)
Parameter | Type | Tags | Description |
---|---|---|---|
merchantId |
String |
Template, Required | The ID of the target merchant. |
visibilityFilter |
String |
Query, Optional | Filters the CustomAttributeDefinition results by their visibility values. |
limit |
Integer |
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 |
String |
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. |
withDefinitions |
Boolean |
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 |
ListMerchantCustomAttributesResponse
String merchantId = "merchant_id0";
Boolean withDefinitions = false;
merchantCustomAttributesApi.listMerchantCustomAttributesAsync(merchantId, null, null, null, withDefinitions).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
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
.
CompletableFuture<DeleteMerchantCustomAttributeResponse> deleteMerchantCustomAttributeAsync(
final String merchantId,
final String key)
Parameter | Type | Tags | Description |
---|---|---|---|
merchantId |
String |
Template, Required | The ID of the target merchant. |
key |
String |
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. |
DeleteMerchantCustomAttributeResponse
String merchantId = "merchant_id0";
String key = "key0";
merchantCustomAttributesApi.deleteMerchantCustomAttributeAsync(merchantId, key).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
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
.
CompletableFuture<RetrieveMerchantCustomAttributeResponse> retrieveMerchantCustomAttributeAsync(
final String merchantId,
final String key,
final Boolean withDefinition,
final Integer version)
Parameter | Type | Tags | Description |
---|---|---|---|
merchantId |
String |
Template, Required | The ID of the target merchant. |
key |
String |
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. |
withDefinition |
Boolean |
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 |
Integer |
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. |
RetrieveMerchantCustomAttributeResponse
String merchantId = "merchant_id0";
String key = "key0";
Boolean withDefinition = false;
merchantCustomAttributesApi.retrieveMerchantCustomAttributeAsync(merchantId, key, withDefinition, null).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
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
.
CompletableFuture<UpsertMerchantCustomAttributeResponse> upsertMerchantCustomAttributeAsync(
final String merchantId,
final String key,
final UpsertMerchantCustomAttributeRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
merchantId |
String |
Template, Required | The ID of the target merchant. |
key |
String |
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 |
UpsertMerchantCustomAttributeRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
UpsertMerchantCustomAttributeResponse
String merchantId = "merchant_id0";
String key = "key0";
UpsertMerchantCustomAttributeRequest body = new UpsertMerchantCustomAttributeRequest.Builder(
new CustomAttribute.Builder()
.build()
)
.build();
merchantCustomAttributesApi.upsertMerchantCustomAttributeAsync(merchantId, key, body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});