VOVoucherManagerProtocol

@protocol VOVoucherManagerProtocol

VOVoucherManagerProtocol is the protocol for the VOVoucherManager. This protocol is responsible for all network and caching methods for a VOVoucher (Gift).

  • Creates a pending VOVoucher. This will save & validate the VOVoucher created in the create process This VOVoucher will not be sent to users until the activate call is made.

    Declaration

    Objective-C

    - (void)createPendingVoucher:(nonnull VOVoucher *)voucher
                       onSuccess:(nonnull void (^)(VOVoucher *_Nonnull))onSucceed
                         onError:(nonnull void (^)(NSError *_Nonnull))onError;

    Swift

    func createPendingVoucher(_ voucher: Any!, onSuccess onSucceed: ((UnsafeMutablePointer<Int32>?) -> Void)!, onError: ((UnsafeMutablePointer<Int32>?) -> Void)!)

    Parameters

    voucher

    - the VOVoucher that is being created

    onSucceed

    - success callblock when the request completes

    onError

    - block to be executed upon failure of the request.

  • Validates payment and sends the VOVoucher to users

    Declaration

    Objective-C

    - (void)activateVoucherWithId:(long long)voucherId
          paymentSourceDictionary:(nullable NSDictionary *)paymentSourceDictionary
                        onSuccess:(nonnull void (^)(VOVoucher *_Nonnull))onSuccess
                          onError:(nonnull void (^)(NSError *_Nonnull))onError;

    Swift

    func activateVoucher(withId voucherId: Int64, paymentSourceDictionary: Any!, onSuccess: ((UnsafeMutablePointer<Int32>?) -> Void)!, onError: ((UnsafeMutablePointer<Int32>?) -> Void)!)

    Parameters

    voucherId

    - the id of the VOVoucher sent to the server

    paymentSourceDictionary

    - payment information if necessary, if nil it is assumed this is a FREE VOVoucher

    onSuccess

    - block to be executed upon successful completion of the request.

    onError

    - block to be executed upon failure of the request.

  • Unwraps a VOVoucher. @discussion - Multiple people can unwrap a VOVoucher but only one person can claim a VOVoucher. Usually the unwrap & claim call occur one right after the other. ## Note - Unwrap must be called before claim for the user.

    Declaration

    Objective-C

    - (void)unwrapVoucherWithId:(long long)voucherId
                          score:(NSInteger)score
                      onSuccess:(nonnull void (^)(VOVoucher *_Nonnull))onSuccess
                        onError:(nonnull void (^)(NSError *_Nonnull))onError;

    Swift

    func unwrapVoucher(withId voucherId: Int64, score: Any!, onSuccess: ((UnsafeMutablePointer<Int32>?) -> Void)!, onError: ((UnsafeMutablePointer<Int32>?) -> Void)!)

    Parameters

    voucherId

    - the id of the VOVoucher sent to the server

    score

    - the score achieved in the game, if a game was played

    onSuccess

    - block to be executed upon successful completion of the request.

    onError

    - block to be executed upon failure of the request.

  • Claims a VOVoucher. After a VOVoucher is claimed no other users will be able to claim.

    Declaration

    Objective-C

    - (void)claimVoucherWithId:(long long)voucherId
                     onSuccess:(nonnull void (^)(VOVoucher *_Nonnull))onSuccess
                       onError:(nonnull void (^)(NSError *_Nonnull))onError;

    Swift

    func claimVoucher(withId voucherId: Int64, onSuccess: ((UnsafeMutablePointer<Int32>?) -> Void)!, onError: ((UnsafeMutablePointer<Int32>?) -> Void)!)

    Parameters

    voucherId

    - the id of the VOVoucher sent to the server

    onSuccess

    - block to be executed upon successful completion of the request.

    onError

    - block to be executed upon failure of the request.

  • Claims a VOVoucher. After a VOVoucher is claimed no other users will be able to claim.

    Declaration

    Objective-C

    - (void)claimVoucherWithId:(long long)voucherId
                 claimDestInfo:(nullable NSDictionary *)claimDestInfo
                     onSuccess:(nonnull void (^)(VOVoucher *_Nonnull))onSuccess
                       onError:(nonnull void (^)(NSError *_Nonnull))onError;

    Swift

    func claimVoucher(withId voucherId: Int64, claimDestInfo: Any!, onSuccess: ((UnsafeMutablePointer<Int32>?) -> Void)!, onError: ((UnsafeMutablePointer<Int32>?) -> Void)!)

    Parameters

    voucherId

    - the id of the VOVoucher sent to the server

    claimDestInfo

    - the claim parameters to be sent back with the request

    onSuccess

    - block to be executed upon successful completion of the request.

    onError

    - block to be executed upon failure of the request.

  • Retrieves a VOVoucher from server or cache.

    Declaration

    Objective-C

    - (void)requestVoucher:(long long)voucherId
                forceFetch:(BOOL)forceFetch
                 onSuccess:(nonnull void (^)(VOVoucher *_Nonnull))onSuccess
                   onError:(nonnull void (^)(NSError *_Nonnull))onError;

    Swift

    func requestVoucher(_ voucherId: Int64, forceFetch: Any!, onSuccess: ((UnsafeMutablePointer<Int32>?) -> Void)!, onError: ((UnsafeMutablePointer<Int32>?) -> Void)!)

    Parameters

    voucherId

    - the id of the VOVoucher sent to the server

    forceFetch

    - If enabled, a network request will be made regardless of how up-to-date the cache value is.

    onSuccess

    - block to be executed upon successful completion of the request.

    onError

    - block to be executed upon failure of the request.

  • Retrieves sent feed vouchers of the logged in user. The vouchers are ordered from newest to oldest.

    Note

    A VOUser needs to be logged in with VOUserManager or the request will 403.

    Declaration

    Objective-C

    - (void)requestSentFeedVouchersWithLimit:(int)limit
                                onCompletion:
                                    (nonnull void (^)(
                                        NSArray<VOFeedVoucher *> *_Nullable,
                                        NSURL *_Nullable,
                                        NSError *_Nullable))onCompletion;

    Swift

    func requestSentFeedVouchers(withLimit limit: Int32, onCompletion: ((Int32) -> Void)!)

    Parameters

    limit

    - the number of results on each page.

    onCompletion

    - block to be executed upon completion of the request. Has the list of feed vouchers and the url to the next page.

  • Retrieves received feed vouchers of the logged in user. The vouchers are ordered from newest to oldest.

    Note

    A VOUser needs to be logged in with VOUserManager or the request will 403.

    Declaration

    Objective-C

    - (void)requestReceivedFeedVouchersWithLimit:(int)limit
                                    onCompletion:
                                        (nonnull void (^)(
                                            NSArray<VOFeedVoucher *> *_Nullable,
                                            NSURL *_Nullable,
                                            NSError *_Nullable))onCompletion;

    Swift

    func requestReceivedFeedVouchers(withLimit limit: Int32, onCompletion: ((Int32) -> Void)!)

    Parameters

    limit

    - the number of results on each page.

    onCompletion

    - block to be executed upon completion of the request. Has the list of feed vouchers and the url to the next page.

  • Retrieves feed vouchers with an amount for the logged in user. The vouchers are ordered from newest to oldest.

    Note

    A VOUser needs to be logged in with VOUserManager or the request will 403.

    Declaration

    Objective-C

    - (void)requestWalletFeedVouchersWithLimit:(int)limit
                                  onCompletion:
                                      (nonnull void (^)(
                                          NSArray<VOFeedVoucher *> *_Nullable,
                                          NSURL *_Nullable,
                                          NSError *_Nullable))onCompletion;

    Swift

    func requestWalletFeedVouchers(withLimit limit: Int32, onCompletion: ((Int32) -> Void)!)

    Parameters

    limit

    - the number of results on each page.

    onCompletion

    - block to be executed upon completion of the request. Has the list of feed vouchers and the url to the next page.

  • Retrieves feed vouchers using a page URL from one of the calls that returns a nextPageUrl. The vouchers are ordered from newest to oldest.

    Note

    A VOUser needs to be logged in with VOUserManager or the request will 403.

    Declaration

    Objective-C

    - (void)requestFeedVouchersWithPageUrl:(nonnull NSURL *)pageUrl
                              onCompletion:(nonnull void (^)(
                                               NSArray<VOFeedVoucher *> *_Nullable,
                                               NSURL *_Nullable,
                                               NSError *_Nullable))onCompletion;

    Swift

    func requestFeedVouchers(withPageUrl pageUrl: Any!, onCompletion: ((Int32) -> Void)!)

    Parameters

    pageUrl

    - the page URL from one of the calls that returns a nextPageUrl

    onCompletion

    - block to be executed upon completion of the request. Has the list of feed vouchers and the url to the next page.

  • Retrieves the voucher associated with an invite code if one exists.

    Declaration

    Objective-C

    - (void)requestVoucherWithInviteCode:(nonnull NSString *)inviteCode
                               onSuccess:
                                   (nonnull void (^)(VOVoucher *_Nonnull))onSuccess
                                 onError:
                                     (nonnull void (^)(NSError *_Nonnull))onError;

    Swift

    func requestVoucher(withInviteCode inviteCode: Any!, onSuccess: ((UnsafeMutablePointer<Int32>?) -> Void)!, onError: ((UnsafeMutablePointer<Int32>?) -> Void)!)

    Parameters

    onSuccess

    - block to be executed upon successful completion of the request. Passes the voucher as a parameter.

    onError

    - block to be executed upon failure of the request.

  • Retrieves the promo associated with the promo code

    Declaration

    Objective-C

    - (void)requestPromo:(nonnull NSString *)promoCode
            onCompletion:(nonnull void (^)(VOPromo *_Nullable,
                                           NSError *_Nullable))onCompletion;

    Swift

    func requestPromo(_ promoCode: Any!, onCompletion: ((UnsafeMutablePointer<Int32>?, UnsafeMutablePointer<Int32>?) -> Void)!)

    Parameters

    promoCode

    the promo code for the promotion.

    onCompletion

    block to be executed upon completion of the request.

  • Retrieves a voucher based on the promoCode

    Declaration

    Objective-C

    - (void)requestVoucherWithPromoCode:(nonnull NSString *)promoCode
                           onCompletion:
                               (nonnull void (^)(VOVoucher *_Nullable,
                                                 NSError *_Nullable))onCompletion;

    Swift

    func requestVoucher(withPromoCode promoCode: Any!, onCompletion: ((UnsafeMutablePointer<Int32>?, UnsafeMutablePointer<Int32>?) -> Void)!)

    Parameters

    promoCode

    the promo code for the promotion

    onCompletion

    block to be executed upon completion of the request

  • Retrieves the share URL for a Voucher

    Declaration

    Objective-C

    - (void)requestShareUrlForVoucherId:(long long)voucherID
                           onCompletion:
                               (nonnull void (^)(NSURL *_Nullable,
                                                 NSError *_Nullable))onCompletion;

    Swift

    func requestShareUrl(forVoucherId voucherID: Int64, onCompletion: ((UnsafeMutablePointer<Int32>?, UnsafeMutablePointer<Int32>?) -> Void)!)

    Parameters

    voucherID

    - the id for the desired Voucher

    onCompletion

    - code block to be completed when the request is finished

  • Returns an in-progress VOVoucher that has been previously saved via the saveVoucherDraft: method.

    Note

    This method returns nil if one does not exist.

    Declaration

    Objective-C

    - (nullable VOMutableVoucher *)voucherDraft;

    Swift

    func voucherDraft() -> Any!

    Return Value

    An instance of VOMutableVoucher

  • Persists an in-progress VOVoucher.

    Declaration

    Objective-C

    - (void)saveVoucherDraft:(nonnull VOMutableVoucher *)voucher;

    Swift

    func saveVoucherDraft(_ voucher: Any!)

    Parameters

    voucher

    - the in-progress VOVoucher that needs to be cached.

  • Clears the in-progress VOVoucher in cache that has been previously saved via the saveVoucherDraft: method.

    Declaration

    Objective-C

    - (void)deleteVoucherDraft;

    Swift

    func deleteVoucherDraft()
  • Deletes the voucher identified by voucherId.

    Declaration

    Objective-C

    - (void)deleteVoucherWithId:(long long)voucherId
                   onCompletion:(nonnull void (^)(NSError *_Nullable))onCompletion;

    Swift

    func deleteVoucher(withId voucherId: Int64, onCompletion: ((UnsafeMutablePointer<Int32>?) -> Void)!)

    Parameters

    voucherId

    - the id of the VOVoucher to delete

    onCompletion

    - block to be executed upon completion of the request. Returns nil on success, otherwise returns an error.