Sent and Received Vouchers
You can request sent or received VOFeedVoucher
s of the logged in user. To request sent vouchers, you send the requestSentFeedVouchersWithLimit:onCompletion
message to your VOVoucherManager
object. Set a limit to fix the number of sent vouchers returned. On success you receive an array of VOFeedVoucher
objects, which are light versions of VOVoucher
. You also receive an NSURL
to the next page of sent vouchers if they exist. To request received vouchers you send a similar requestReceivedFeedVouchersWithLimit:onCompletion
message to your VOVoucherManager
object.
Sent Feed Vouchers
[self.voucherManager requestSentFeedVouchersWithLimit:10 onCompletion:^(NSMutableArray<VOFeedVoucher *> * _Nullable feedVouchers, NSURL * _Nullable nextPageUrl, NSError * _Nullable error) {
self.sentVouchers = feedVouchers;
self.nextPageUrl = nextPageUrl;
[self.collectionView reloadData];
}];
voucherManager.requestSentFeedVouchers(withLimit: 10, onCompletion: { feedVouchers, nextPageUrl, error in
self.sentVouchers = feedVouchers
self.nextPageUrl = nextPageUrl
self.collectionView.reloadData()
})
A logged in user can also delete a sent voucher. Note that deletion succeeds only when the voucher is unclaimed. See Deleting a Voucher for sample code.
Received Feed Vouchers
[self.voucherManager requestReceivedFeedVouchersWithLimit:10 onCompletion:^(NSMutableArray<VOFeedVoucher *> * _Nullable feedVouchers, NSURL * _Nullable nextPageUrl, NSError * _Nullable error) {
self.receivedVouchers = feedVouchers;
self.nextPageUrl = nextPageUrl;
[self.collectionView reloadData];
}];
voucherManager.requestReceivedFeedVouchers(withLimit: 10, onCompletion: { feedVouchers, nextPageUrl, error in
self.receivedVouchers = feedVouchers
self.nextPageUrl = nextPageUrl
self.collectionView.reloadData()
})
Transform a Feed Voucher to a Voucher
Once you have an array of sent or received feed vouchers, you can transform a VOFeedVoucher
into a VOVoucher
by sending the requestVoucher:forceFetch:onSuccess:onError
message to your VOVoucherManager
object. Pass the voucherId of the VOFeedVoucher
you want to transform.
[self.voucherManager requestVoucher:voucherId forceFetch:YES onSuccess:^(VOVoucher *voucher) {
self.voucher = voucher;
} onError:^(NSError * _Nonnull error) {
//handle error;
}];
voucherManager.requestVoucher(voucherId, forceFetch: true, onSuccess: { voucher in
self.voucher = voucher
}, onError: { error in
//handle error
})