Promotions
Get all promotions of a customer
This method retrieves all available promotions that are defined for a customer.
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
+ (void)getPromotionsWithSuccess:(nonnull void (^)(SNRPromotionResponse *promotionResponse))success failure:(nonnull void (^)(NSError *error))failure
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
})
[SNRPromotions getPromotionsWithSuccess:^(SNRPromotionResponse *promotionResponse) {
/ success
} failure:^(SNRApiError *error) {
// failure
}];
Get promotions with query parameters
This method retrieves promotions that match the parameters defined in an API query.
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
+ (void)getPromotionsWithApiQuery:(nonnull SNRPromotionsApiQuery *)apiQuery success:(nonnull void (^)(SNRPromotionResponse *promotionResponse))success failure:(nonnull void (^)(NSError *error))failure
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
})
SNRPromotionsApiQuery *apiQuery = [SNRPromotionsApiQuery new];
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 = YES;
[SNRPromotions getPromotionsWithApiQuery:apiQuery success:^(SNRPromotionResponse *promotionResponse) {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Get promotion by UUID
This method retrieves the promotion with the specified UUID.
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
+ (void)getPromotionByUuid:(nonnull NSString *)uuid success:(nonnull void (^)(SNRPromotion *promotion))success failure:(nonnull void (^)(NSError *error))failure
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
})
NSString *UUID = @"UUID";
[SNRPromotions getPromotionByUuid:UUID success:^(SNRPromotion *promotion) {
// success
} failure:^(SNRApiError *error) {
// failure
}]
Get promotion by code
This method retrieves the promotion with the specified code.
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
+ (void)getPromotionByCode:(nonnull NSString *)code success:(nonnull void (^)(SNRPromotion *promotion))success failure:(nonnull void (^)(NSError *error))failure
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
})
NSString *code = @"CODE";
[SNRPromotions getPromotionByCode:code success:^(SNRPromotion *promotion) {
// success
} failure:^(SNRApiError *error) {
// failure
}]
Activate promotion by UUID
This method activates the promotion with the specified UUID.
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
+ (void)activatePromotionByUuid:(NSString *)uuid success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
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
})
NSString *UUID = @"UUID";
[SNRPromotions activatePromotionByUuid:UUID success:^(BOOL isSuccess) {
// success
} failure:^(SNRApiError *error) {
// failure
}]
Activate promotion by code
This method activates the promotion with the specified code.
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
+ (void)activatePromotionByCode:(NSString *)code success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
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
})
NSString *code = @"CODE";
[SNRPromotions activatePromotionByCode:code success:^(BOOL isSuccess) {
// success
} failure:^(SNRApiError *error) {
// failure
}]
Activate promotions in a batch
This method activates promotions with a code or with UUID in a batch.
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
+ (void)activatePromotionsWithIdentifiers:(nonnull NSArray<SNRPromotionIdentifier *> *)identifiers success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(SNRApiError *error))failure
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.
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
+ (void)deactivatePromotionByUuid:(nonnull NSString *)uuid success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
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
})
NSString *UUID = @"UUID";
[SNRPromotions deactivatePromotionByUuid:UUID success:^(BOOL isSuccess) {
// success
} failure:^(SNRApiError *error) {
// failure
}]
Deactivate promotion by code
This method deactivates the promotion with the specified code.
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
+ (void)deactivatePromotionByCode:(nonnull NSString *)code success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
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
})
NSString *code = @"CODE";
[SNRPromotions deactivatePromotionByCode:code success:^(BOOL isSuccess) {
// success
} failure:^(SNRApiError *error) {
// failure
}]
Deactivate promotions in a batch
This method deactivates promotions with a code or with UUID in a batch.
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
+ (void)deactivatePromotionsWithIdentifiers:(nonnull NSArray<SNRPromotionIdentifier *> *)identifiers success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(SNRApiError *error))failure
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.
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
+ (void)getOrAssignVoucherWithPoolUUID:(nonnull NSString *)poolUUID success:(nonnull void (^)(SNRAssignVoucherResponse *assignVoucherResponse))success failure:(nonnull void (^)(NSError *error))failure
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
})
NSString *poolUUID = @"POOL_UUID";
[SNRPromotions getOrAssignVoucherWithPoolUUID:poolUUID success:^(SNRAssignVoucherResponse *assignVoucherResponse) {
// success
} failure:^(NSError * _Nonnull error) {
// 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.
Returns the HTTP 416 status code when the pool is empty.
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
+ (void)assignVoucherCodeWithPoolUUID:(nonnull NSString *)poolUUID success:(nonnull void (^)(SNRAssignVoucherResponse *assignVoucherResponse))success failure:(nonnull void (^)(NSError *error))failure
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
})
NSString *poolUUID = @"POOL_UUID";
[SNRPromotions assignVoucherCodeWithPoolUUID:poolUUID success:^(SNRAssignVoucherResponse *assignVoucherResponse) {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Get voucher codes assigned to customer
This method retrieves voucher codes for a customer.
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
+ (void)getAssignedVoucherCodesWithSuccess:(nonnull void (^)(SNRVoucherCodesResponse *voucherCodesResponse))success failure:(nonnull void (^)(NSError *error))failure
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
})
[SNRPromotions getAssignedVoucherCodesWithSuccess:^(SNRVoucherCodesResponse *voucherCodesResponse) {
// success
} failure:^(NSError * _Nonnull error) {
// failure
}];