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.

Declared In:
Headers/SNRPromotions.h

Related To:
PromotionResponse

Class:
Promotions

Declaration:

static func getPromotions(success: ((PromotionResponse) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
success ((PromotionResponse) -> 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.getPromotions(success: { (promotionResponse) in
  // success
	print(promotionResponse.items)
}, failure: { (error) in
  // failure
})

Get promotions with query parameters


This method retrieves promotions that match the parameters defined in an API query.

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

Declared In:
Headers/SNRPromotions.h

Related To:
PromotionsApiQuery
PromotionResponse

Class:
Promotions

Declaration:

static func getPromotions(apiQuery: PromotionsApiQuery, success: ((PromotionResponse) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
apiQuery PromotionsApiQuery no - Object that stores all query parameters
success ((PromotionResponse) -> 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 apiQuery = PromotionsApiQuery()
apiQuery.types = [SNR_PROMOTION_TYPE_GENERAL]
apiQuery.statuses = [SNR_PROMOTION_STATUS_ACTIVE, SNR_PROMOTION_STATUS_ASSIGNED]
apiQuery.types = [SNR_PROMOTION_TYPE_GENERAL]
apiQuery.sorting = [
	[SNR_PROMOTION_SORTING_KEY_EXPIRE_AT: SNR_API_QUERY_SORTING_ASC],
	[SNR_PROMOTION_SORTING_KEY_TYPE: SNR_API_QUERY_SORTING_DESC]
]
apiQuery.limit = 50
apiQuery.page = 1
apiQuery.includeMeta = true
Promotions.getPromotions(apiQuery: apiQuery, success: { (promotionResponse) in
  // success
}, failure: { (error) in
  // failure
})

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.

Declared In:
Headers/SNRPromotions.h

Related To:
Promotion

Class:
Promotions

Declaration:

static func getPromotion(uuid: String, success: ((Promotion) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
uuid String yes - UUID of the promotion
success ((Promotion) -> 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 UUID: String = "UUID"
Promotions.getPromotion(uuid: UUID, success: { (promotion) in
  // success
	print(promotion.code)
	print(promotion.discountValue)
}, failure: { (error) in
  // failure
})

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.

Declared In:
Headers/SNRPromotions.h

Related To:
Promotion

Class:
Promotions

Declaration:

static func getPromotion(code: String, success: ((PromotionResponse) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
code String true - Code of the promotion
success ((Promotion) -> 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 code: String = "CODE"
Promotions.getPromotion(code: code, success: { (promotion) in
  // success
	print(promotion.code)
	print(promotion.discountValue)
}, failure: { (error) in
  // failure
})

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.

Declared In:
Headers/SNRPromotions.h

Class:
Promotions

Declaration:

static func activatePromotion(uuid: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
uuid String yes - UUID of the promotion
success ((Bool) -> 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 UUID: String = "UUID"
Promotions.activatePromotion(uuid: UUID, success: { (isSuccess) in
  // success
}, failure: { (error) in
  // failure
})

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.

Declared In:
Headers/SNRPromotions.h

Class:
Promotions

Declaration:

static func activatePromotion(code: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
code String yes - Code of the promotion
success ((Bool) -> 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 code: String = "CODE"
Promotions.activatePromotion(code: code, success: { (isSuccess) in
  // success
}, failure: { (error) in
  // failure
})

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.

Declared In:
Headers/SNRPromotions.h

Related To:
PromotionIdentifier

Class:
Promotions

Declaration:

static func activatePromotions(identifiers: [PromotionIdentifier], success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
identifiers [PromotionIdentifier] yes - List of identifiers of the promotions that you want to activate
success ((Bool) -> 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 UUIDs = "UUID_1, UUID2, UUID_3"
let UUIDsArray = UUIDs.components(separatedBy: ",").filter { !$0.isEmpty }

var promotionIdentifiers: [PromotionIdentifier] = [PromotionIdentifier]()

UUIDsArray.forEach { uuid in
	let promotionIdentifier = PromotionIdentifier(uuid: uuid)
	promotionIdentifiers.append(promotionIdentifier)
}

Promotions.activatePromotions(identifiers: promotionIdentifiers, success: { (success) in
  // success
}, failure: { (error) in
  // failure
})

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.

Declared In:
Headers/SNRPromotions.h

Class:
Promotions

Declaration:

static func deactivatePromotion(uuid: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
uuid String yes - UUID of the promotion
success ((Bool) -> 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 UUID: String = "UUID"
Promotions.deactivatePromotion(uuid: UUID, success: { (isSuccess) in
  // success
}, failure: { (error) in
  // failure
})

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.

Declared In:
Headers/SNRPromotions.h

Class:
Promotions

Declaration:

static func deactivatePromotion(code: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
code String yes - Code of the promotion
success ((Bool) -> 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 code: String = "CODE"
Promotions.deactivatePromotion(code: code, success: { (isSuccess) in
  // success
}, failure: { (error) in
  // failure
})

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.

Declared In:
Headers/SNRPromotions.h

Related To:
PromotionIdentifier

Class:
Promotions

Declaration:

static func deactivatePromotions(identifiers: [PromotionIdentifier], success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters:

Parameter Type Mandatory Default Description
identifiers [PromotionIdentifier] yes - List of identifiers of the promotions that you want to de-activate
success ((Bool) -> 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 UUIDs = "UUID_1, UUID2, UUID_3"
let UUIDsArray = UUIDs.components(separatedBy: ",").filter { !$0.isEmpty }

var promotionIdentifiers: [PromotionIdentifier] = [PromotionIdentifier]()

UUIDsArray.forEach { uuid in
	let promotionIdentifier = PromotionIdentifier(uuid: uuid)
	promotionIdentifiers.append(promotionIdentifier)
}

Promotions.deactivatePromotions(identifiers: promotionIdentifiers, success: { (success) in
  // success
}, failure: { (error) in
  // failure
})

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 - Pool’s universally unique identifier
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 - Pool’s universally unique identifier
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