Promotions and vouchers
Promotions
Get promotions for a customer
Use this method to get all possible combinations of promotions defined for this customer.
The method returns promotions with statuses, types, and optional metadata provided in the list. A special query is built upon your params.
This method returns IDataApiCall with a parameterized List<PromotionResponse>
object to execute the request.
Method name: Promotions.getPromotions(statuses, types, page) Method name: Promotions.getPromotions(statuses, types, limit, page) Method name: Promotions.getPromotions(statuses, types, page, includeMeta) Method name: Promotions.getPromotions(promotionsApiQuery)
Methods using arguments are now deprecated.
Only Promotions.getPromotions(promotionsApiQuery) is valid.
Declaration
public static IDataApiCall<PromotionResponse> getPromotions(@Nullable List<PromotionStatus> statuses,
@Nullable List<PromotionType> types, int page)
public static IDataApiCall<PromotionResponse> getPromotions(@Nullable List<PromotionStatus> statuses,
@Nullable List<PromotionType> types, int limit, int page)
public static IDataApiCall<PromotionResponse> getPromotions(@Nullable List<PromotionStatus> statuses,
@Nullable List<PromotionType> types, int page, boolean includeMeta)
public static IDataApiCall<PromotionResponse> getPromotions(PromotionsApiQuery promotionsApiQuery)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
statuses | List |
yes | - | Specify a status filter, can be any combination or an empty list. |
types | List |
yes | - | Specify type filter, can be any combination or an empty list. |
page | int | yes | - | Query for a specific page, minimum 1. |
limit | int | yes | 100 | Query for promotions limit. |
includeMeta | boolean | yes | false | Decide whether to include metadata in the final response. |
promotionsApiQuery | PromotionsApiQuery | yes | — | Class responsible for storing all queryParameters. |
Return Value
IDataApiCall<PromotionResponse> object to execute the request.
Example
if (apiCall != null)
apiCall.cancel();
PromotionsApiQuery query = new PromotionsApiQuery();
query.limit = limit;
query.statuses = statuses;
query.page = 5;
query.includeMeta = true;
LinkedHashMap<PromotionSortingKey, ApiQuerySortingOrder> sortParams = new LinkedHashMap<>();
sortParams.put(PromotionSortingKey.TYPE, ApiQuerySortingOrder.ASCENDING);
sortParams.put(PromotionSortingKey.CREATED_AT, ApiQuerySortingOrder.ASCENDING);
sortParams.put(PromotionSortingKey.EXPIRE_AT, ApiQuerySortingOrder.DESCENDING);
query.setSortParameters(sortParams);
apiCall = Promotions.getPromotions(query);
apiCall.execute(this::onSuccess, this::onFailure);
Get promotion information by its UUID
Use this method to get promotion by UUID. This method returns an IDataApiCall with a parameterized SinglePromotionResponse
object to execute the request.
Method name: Promotions.getPromotionByUuid(uuid)
Declaration
public static IDataApiCall<SinglePromotionResponse> getPromotionByUuid(@NonNull String uuid)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
uuid | String | yes | - | UUID of the promotion that you want to get. |
Return Value
IDataApiCall<SinglePromotionResponse> object to execute the request.
Example
IDataApiCall<SinglePromotionResponse> apiCall = Promotions.getPromotionByUuid(uuid);
apiCall.execute(response -> {
if (response != null) {
Promotion promotion = response.getPromotion();
}
}, this::showAlertError);
Get promotion information by its code
Use this method to get a promotion by code. This method returns an IDataApiCall with a parameterized SinglePromotionResponse
object to execute the request.
Method name: Promotions.getPromotionByCode(code)
Declaration
public static IDataApiCall<SinglePromotionResponse> getPromotionByCode(@NonNull String code)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
code | String | yes | - | Code of the promotion that you want to get. |
Return Value
IDataApiCall<SinglePromotionResponse> object to execute the request.
Example
IDataApiCall<SinglePromotionResponse> apiCall = Promotions.getPromotionByCode(code);
apiCall.execute(response -> {
if (response != null) {
Promotion promotion = response.getPromotion();
}
}, this::showAlertError);
Activate promotion by its UUID
Use this method to activate a promotion by UUID. The method returns an IApiCall needed to execute the request.
Method name: Promotions.activatePromotionByUuid(uuid)
Declaration
public static IApiCall activatePromotionByUuid(@NonNull String uuid)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
uuid | String | yes | - | UUID of the promotion that will be activated. |
Return Value
IApiCall object to execute the request.
Example
IApiCall apiCall = Promotions.activatePromotionByUuid(uuid);
apiCall.execute(this::onSuccess, this::onFailure);
Activate promotion by its code
Use this method to activate a promotion by code. The method returns an IApiCall needed to execute the request.
Method name: Promotions.activatePromotionByCode(code)
Declaration
public static IApiCall activatePromotionByCode(@NonNull String code)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
code | String | yes | - | Code of the promotion that will be activated. |
Return Value
IApiCall object to execute the request.
Example
IApiCall apiCall = Promotions.activatePromotionByCode(code);
Deactivate promotion by its UUID
Use this method to deactivate a promotion by UUID. The method returns an IApiCall needed to execute the request.
Method name: Promotions.deactivatePromotionByUuid(uuid)
Declaration
public static IApiCall deactivatePromotionByUuid(@NonNull String uuid)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
uuid | String | yes | - | UUID of the promotion that will be deactivated. |
Return Value
IApiCall object to execute the request.
Example
IApiCall apiCall = Promotions.deactivatePromotionByUuid(uuid);
apiCall.execute(this::onSuccess, this::onFailure);
Deactivate promotion by its code
Use this method to deactivate a promotion by code. The method returns an IApiCall needed to execute the request.
Method name: Promotions.deactivatePromotionByCode(code)
Declaration
public static IApiCall deactivatePromotionByCode(@NonNull String code)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
code | String | yes | - | Code of the promotion that will be deactivated. |
Return Value
IApiCall object to execute the request.
Example
IApiCall apiCall = Promotions.deactivatePromotionByCode(code);
apiCall.execute(this::onSuccess, this::onFailure);
Activate promotions in a batch
Use this method to activate promotions with code or with UUID in a batch.
Method name: Promotions.activatePromotionsBatch(promotionsToActivate)
Declaration
public static IApiCall activatePromotionsBatch(List<PromotionIdentifier> promotionsToActivate)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
promotionsToActivate | List<PromotionIdentifier> | yes | - | List of promotions to be activated |
Return Value
IApiCall object to execute the request.
Example
IApiCall call = Promotions.activatePromotionsBatch(promotionsToActivate);
call.execute(this::onSuccess, this::onFailure);
Deactivate promotions in a batch
Use this method to deactivate promotions with code or with UUID in a batch.
Method name: Promotions.deactivatePromotionsBatch(promotionsToDeactivate)
Declaration
public static IApiCall deactivatePromotionsBatch(List<PromotionIdentifier> promotionsToDeactivate)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
promotionsToDeactivate | List<PromotionIdentifier> | yes | - | List of promotions to be activated |
Return Value
IApiCall object to execute the request.
Example
IApiCall call = Promotions.deactivatePromotionsBatch(promotionsToDeactivate);
call.execute(this::onSuccess, this::onFailure);
Vouchers
Assign voucher code from a pool
Use this method to assign a voucher to a customer. The pool is identified by UUID.
Every request returns different code until the pool is empty. When the pool is empty, the method returns the HTTP 416 status code. Methods returns IDataApiCall with parameterized AssignVoucherResponse object to execute the request.
Method name: Promotions.assignVoucherCode(poolUuid)
Declaration
public static IDataApiCall<AssignVoucherResponse> assignVoucherCode(@NonNull String poolUuid)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
poolUuid | String | yes | - | Pool’s universally unique identifier. |
Return Value
IDataApiCall<AssignVoucherResponse> object to execute the request.
Example
IDataApiCall<AssignVoucherResponse> call = Promotions.assignVoucherCode(poolUuid);
call.execute(this::onSuccess, this::onFailure);
Get voucher codes assigned to a customer
Use this method to get a customer’s voucher codes. The methods returns an IDataApiCall with a parameterized VoucherCodesResponse
object to execute the request.
Method name: Promotions.getAssignedVoucherCodes()
Declaration
public static IDataApiCall<VoucherCodesResponse> getAssignedVoucherCodes()
Parameters
No parameters required.
Return Value
IDataApiCall<VoucherCodesResponse> object to execute the request.
Example
IDataApiCall<VoucherCodesResponse> call = Promotions.getAssignedVoucherCodes();
call.execute(this::onSuccess, this::onFailure);
Get or assign voucher from a pool
Retrieve the code assigned to a customer. If no code was assigned earlier, the method assigns one from a pool identified by UUID. For each customer, the same code is retrieved every time. This can be used, for example, to retrieve unique codes used to identify a customer.
The methods returns an IDataApiCall with a parameterized AssignVoucherResponse
object to execute the request.
Method name: Promotions.getOrAssignVoucher(poolUuid)
Declaration
public static IDataApiCall<AssignVoucherResponse> getOrAssignVoucher(@NonNull String poolUuid)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
poolUuid | String | yes | - | Pool’s universally unique identifier. |
Return Value
IDataApiCall<AssignVoucherResponse> object to execute the request.
Example
IDataApiCall<AssignVoucherResponse> call = Promotions.getOrAssignVoucher(poolUuid);
call.execute(this::onSuccess, this::onFailure);