Promotions and Vouchers

Promotions


Get all promotions of a Customer


Gets all available promotions that are defined for this customer.

Declared In

SNRPromotions.h

PromotionResponse

Class Name

Promotions

Method Name

getPromotions(success:failure:)

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 finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Promotions.getPromotions(success: { (promotionResponse) in
	// success
	print(promotionResponse.items)
}, failure: { (error) in
	// failure
})

Get promotions with query parameters


Gets promotions that are defined for parameters provided in the query object.

Declared In

SNRPromotions.h

PromotionsApiQuery PromotionResponse

Class Name

Promotions

Method Name

getPromotions(apiQuery:success:failure:)

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 finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

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


Gets a promotion identified by UUID.

Declared In

SNRPromotions.h

Promotion

Class Name

Promotions

Method Name

getPromotion(uuid:success:failure:)

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 finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

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


Gets a promotion identified by code.

Declared In

SNRPromotions.h

PromotionResponse

Class Name

Promotions

Method Name

getPromotion(code:success:failure:)

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 ((PromotionResponse) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

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


Activates a promotion identified by UUID.

Declared In

SNRPromotions.h

Class Name

Promotions

Method Name

activatePromotion(uuid:success:failure:)

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 finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let UUID: String = "UUID"
Promotions.activatePromotion(uuid: UUID, success: { (isSuccess) in
	// success
}, failure: { (error) in
	// failure
})

Activate promotion by code


Activates a promotion identified by code.

Declared In

SNRPromotions.h

Class Name

Promotions

Method Name

activatePromotion(code:success:failure:)

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 finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let code: String = "CODE"
Promotions.activatePromotion(code: code, success: { (isSuccess) in
	// success
}, failure: { (error) in
	// failure
})

Activate promotions with identifiers


Activates promotions with code or with UUID in a batch.

Declared In

SNRPromotions.h

PromotionIdentifier

Class Name

Promotions

Method Name

activatePromotions(identifiers:success:failure:)

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 finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

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


De-activates a promotion identified by UUID.

Declared In

SNRPromotions.h

Class Name

Promotions

Method Name

deactivatePromotion(uuid:success:failure:)

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 finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let UUID: String = "UUID"
Promotions.deactivatePromotion(uuid: UUID, success: { (isSuccess) in
	// success
}, failure: { (error) in
	// failure
})

Deactivate promotion by code


De-activates promotion identified by code.

Declared In

SNRPromotions.h

Class Name

Promotions

Method Name

deactivatePromotion(code:success:failure:)

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 finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let code: String = "CODE"
Promotions.deactivatePromotion(code: code, success: { (isSuccess) in
	// success
}, failure: { (error) in
	// failure
})

Deactivate promotions with identifiers


De-activates promotions with code or with UUID in a batch.

Declared In

SNRPromotions.h

PromotionIdentifier

Class Name

Promotions

Method Name

deactivatePromotions(identifiers:success:failure:)

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 finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

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


Gets a voucher code permanently assigned to a customer (the same code every time).

If no code is permanently assigned, the method assigns a voucher from the provided pool so that the same code is returned in all future calls.

Declared In

SNRPromotions.h

AssignVoucherResponse

Class Name

Promotions

Method Name

getOrAssignVoucher(poolUUID:success:failure:)

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 finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

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

Assign voucher code from pool


Assigns a voucher from a pool to a customer.

Every request returns different code until the pool is empty.

Note: 416 HTTP status code is returned when pool is empty.

Declared In

SNRPromotions.h

AssignVoucherResponse

Class Name

Promotions

Method Name

assignVoucherCode(poolUUID:success:failure:)

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 finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

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

Get Customer-assigned voucher codes


Gets a customer’s voucher codes.

Declared In

SNRPromotions.h

VoucherCodesResponse

Class Name

Promotions

Method Name

getAssignedVoucherCodes(success:failure:)

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 finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

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