Promotions and Vouchers

Promotions


Get all promotions of a customer


This method retrieves all available promotions that are defined for a customer.

Note: The API key must have the PROMOTIONS_DETAILS_FOR_CLIENT_READ permission from the Client group.

Method name:
Promotions.getPromotions(statuses, types, page)
Promotions.getPromotions(statuses, types, limit, page)
Promotions.getPromotions(statuses, types, page, includeMeta)
Promotions.getPromotions(promotionsApiQuery)

WARNING:

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 by UUID


This method retrieves the promotion with the specified UUID.

Note: The API key must have the PROMOTIONS_DETAILS_FOR_CLIENT_READ permission from the Client group.

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 by code


This method retrieves the promotion with the specified code.

Note: The API key must have the PROMOTIONS_DETAILS_FOR_CLIENT_READ permission from the Client group.

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 UUID


This method activates the promotion with the specified UUID.

Note: The API key must have the PROMOTIONS_ACTIVATE_PROMOTIONS_UPDATE permission from the Promotions group.

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 code


This method activates the promotion with the specified code.

Note: The API key must have the PROMOTIONS_ACTIVATE_PROMOTIONS_UPDATE permission from the Promotions group.

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);

Activate promotions in a batch


This method activates promotions with a code or with UUID in a batch.

Note: The API key must have the PROMOTIONS_ACTIVATE_PROMOTIONS_UPDATE permission from the Promotions group.

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 promotion by UUID


This method deactivates the promotion with the specified UUID.

Note: The API key must have the PROMOTIONS_DEACTIVATE_PROMOTIONS_UPDATE permission from the Promotions group.

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 code


This method deactivates the promotion with the specified code.

Note: The API key must have the PROMOTIONS_DEACTIVATE_PROMOTIONS_UPDATE permission from the Promotions group.

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);

Deactivate promotions in a batch


This method deactivates promotions with a code or with UUID in a batch.

Note: The API key must have the PROMOTIONS_DEACTIVATE_PROMOTIONS_UPDATE permission from the Promotions group.

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


Get or assign voucher from pool


This method retrieves an assigned voucher code or assigns a voucher from a pool identified by UUID to the customer.

Once a voucher is assigned using this method, the same voucher is returned for the profile every time the method is called.

When the voucher is assigned for the first time, a voucherCode.assigned event is produced.

Note: The API key must have the VOUCHERS_ITEM_ASSIGN_CREATE and VOUCHERS_ITEM_ASSIGN_READ permission from the Assign group.

Declared In:
Headers/SNRPromotions.h

Related To:
AssignVoucherResponse

Class:
Promotions

Declaration:

static func getOrAssignVoucher(poolUUID: String, success: ((AssignVoucherResponse) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
poolUUID String no - Unique identifier of a code pool
success ((AssignVoucherResponse) -> Void) yes - Closure/Block to be executed when the operation is completed successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation is completed with an error

Return Value:
No value is returned.

Example:

let poolUUID: String = "POOL_UUID"
Promotions.getOrAssignVoucher(poolUUID: poolUUID, success: { (assignVoucherResponse) in
  // success
failure: { (error) in
  // failure
})

Assign voucher code from pool


This method assigns a voucher from a pool identified by UUID to the profile.

Every request returns a different code until the pool is empty.

A voucherCode.assigned event is produced.

Note: Returns the HTTP 416 status code when the pool is empty.
Note: The API key must have the VOUCHERS_ITEM_ASSIGN_CREATE and VOUCHERS_ITEM_ASSIGN_READ permission from the Assign group.

Declared In:
Headers/SNRPromotions.h

Related To:
AssignVoucherResponse

Class:
Promotions

Declaration:

static func assignVoucherCode(poolUUID: String, success: ((AssignVoucherResponse) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
poolUUID String yes - Unique identifier of a code pool
success ((AssignVoucherResponse) -> Void) yes - Closure/Block to be executed when the operation is completed successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation is completed with an error

Return Value:
No value is returned.

Example:

let poolUUID: String = "POOL_UUID"
Promotions.assignVoucherCode(poolUUID: poolUUID, success: { (assignVoucherResponse) in
  // success
}, failure: { (error) in
  // failure
})

Get voucher codes assigned to customer


This method retrieves voucher codes for a customer.

Note: The API key must have the VOUCHERS_ITEM_ASSIGN_READ permission from the Assign group.

Declared In:
Headers/SNRPromotions.h

Related To:
VoucherCodesResponse

Class:
Promotions

Declaration:

static func getAssignedVoucherCodes(success: ((VoucherCodesResponse) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
success ((VoucherCodesResponse) -> Void) yes - Closure/Block to be executed when the operation is completed successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation is completed with an error

Return Value:
No value is returned.

Example:

Promotions.getAssignedVoucherCodes(success: { (voucherCodesResponse) in
  // success
}, failure: { (error) in
  // failure
})

😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker