WLUserManager.h 10.5 KB
/*
 Copyright 2010-2016 Warply Inc. All rights reserved.
 
 Redistribution and use in source and binary forms, without modification,
 are permitted provided that the following conditions are met:
 
 1. Redistributions of source code must retain the above copyright notice, this
 list of conditions and the following disclaimer.
 
 2. Redistributions in binaryform must reproduce the above copyright notice,
 this list of conditions and the following disclaimer in the documentation
 and/or other materials provided with the distribution.
 
 THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
 EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*!
 @header WLUserManager.h
 The ConsumerData Manager provides a functional interface for user related data.
 Use the methods declared here to get and send user name,email and MSISDN, add tags and connect your CRM id to our data.
 @copyright Warply Inc.
 */

#import <UIKit/UIKit.h>
#import "Warply.h"

/*!
 @class WLUserManager
 @discussion This manager enables the device and Warply server to exchange info about the user.
 */
@interface WLUserManager : NSObject
/*!
 @methodgroup Sending User Data
 @discusion These methods send user related data to the warply server. The users can then be targeted based on the values of the corresponding user related keys. There are some common data fields supported (email, msisdn, name) but you can also send custom data if the abeforementioned fields do not fit your needs.
 */

/*!
 @abstract Send user name.
 @discussion This class method send user name to Warply service.
 @param userName A string object with user name.
 */
+ (void)sendName:(NSString *)userName;
/*!
 @abstract Send user e-mail.
 @discussion This class method send user e-mail to Warply service. Also, make sure
 that e-mail is correct format prior sending it.
 @param userEmail A string object with user e-mail.
 */
+ (void)sendEmail:(NSString *)userEmail;
/*!
 @abstract Send user MSISDN.
 @discussion This class method send user MSISDN to Warply service.
 @param userMsisdn A string object with user msisdn.
 */
+ (void)sendMsisdn:(NSString *)userMsisdn;
/*!
 @abstract Sends a dictionary to warply containing data related to the user.
 @discussion Use this method if you want to send info about the users (in order to target them by warply)that is not one of the predefined fields (email, name, msisdn).
 @param customData A dictionary containing custom user data.
 */
+ (void)sendCustomData:(NSDictionary *)customData;
/*!
 @methodgroup Getting User Data
 */
/*!
 @abstract Get user name.
 @discussion This class method gets user name from Warply service.
 @attributeblock sucessBlock This block is called when getUserName is sucessful and returns a NSString with the user name or null if user name doesn't exists.
 @attributeblock failureBlock This block is called when getUserName fails and returns a NSError object with failure code and description.
 */
+ (void)getNameWithSuccessBlock:(void (^)(NSString *userName))success failureBlock:(void (^)(NSError *error))failure;
/*!
 @abstract Get user e-mail.
 @discussion This class method gets user e-mail from Warply service.
 @attributeblock sucessBlock This block is called when getUserEmail is sucessful and returns a NSString with the user e-mail or null if user e-mail doesn't exists.
 @attributeblock failureBlock This block is called when getUserEmail fails and returns a NSError object with failure code and description.
 */
+ (void)getEmailWithSuccessBlock:(void (^)(NSString *userEmail))success failureBlock:(void (^)(NSError *error))failure;
/*!
 @abstract Get user MSISDN.
 @discussion This class method gets user MSISDN from Warply service.
 @attributeblock sucessBlock This block is called when getUserMsisdn is sucessful and returns a NSString with the user MSISDN or null if user e-mail doesn't exists.
 @attributeblock failureBlock This block is called when getUserMsisdn fails and returns a NSError object with failure code and description.
 */
+ (void)getMsisdnWithSuccessBlock:(void (^)(NSString *userMsisdn))success failureBlock:(void (^)(NSError *error))failure;
/*!
 @abstract Get user custom data.
 @discussion This class method gets user MSISDN from Warply service.
 @attributeblock sucessBlock This block is called when the call is sucessful and returns a NSDictionary with the custom user data or null if no custom data exist.
 @attributeblock failureBlock This block is called when the call fails and returns a NSError object with failure code and description.
 */
+ (void)getCustomDataWithSuccessBlock:(void (^)(NSDictionary *customData))success failureBlock:(void (^)(NSError *error))failure;
/*!
 @methodgroup Sending User Advertising IDs
 */
/*!
 @abstract Send user advertising ids.
 @discussion This class method sends both user and vendor adverting identifiers.
 These identifiers are available only when user allows ad tracking from the device
 settings.
 @dependency AdSupport framework (Available on iOS 6 only).
 */
+ (void)sendUUIDS;
/*!
 @methodgroup Tagging Users
 @discusion These methods send user related tags to the warply server. The users can then be targeted based on these tags.
 */
/*!
 @abstract Adds a single user tag.
 @discussion This class method sends a tag to be added in Warply service. This event
 is sent immediately.
 @param tag A string object with an arbitrary tag.
 */
+ (void)addTag:(NSString *)tag;
/*!
 @abstract Adds an array of user tags.
 @discussion This class method sends an array of tags to be added in Warply service.
 This event is sent immediately.
 @param tag An array of tags. Each tag must me be a string object.
 */
+ (void)addTags:(NSArray *)tags;

/*!
 @abstract Removes the existing tags and adds an array of user tags.
 @discussion This class method sends an array of tags to be added in Warply service and replace any existing ones.
 This event is sent immediately.
 @param tag An array of tags. Each tag must me be a string object.
 */
+ (void)rewriteTags:(NSArray *)tags;

/*!
 @methodgroup Removing User Tags
 */
/*!
 @abstract Remove a single user tag.
 @discussion This class method sends a tag to be removed in Warply service. This event
 is sent immediately.
 @param tag An string object with an arbitrary tag.
 */
+ (void)removeTag:(NSString *)tag;
/*!
 @abstract Removes an array of user tags.
 @discussion This class method sends an array of tags to be removed in Warply service.
 This event is sent immediately.
 @param tags An array of tags. Each tag must me be a string object.
 */
+ (void)removeTags:(NSArray *)tags;

/*!
 @abstract Removes all user tags.
 */
+ (void)removeAllTags;
/*!
 @methodgroup Getting User Tags
 */
/*!
 @abstract Get user tags.
 @discussion This class method gets all the user tags from the Warply service.
 @attributeblock successBlock This block is called when getTags is sucessful and returns a NSArray object with the user tags.
 @attributeblock failureBlock This block is called when getTags fails and returns a NSError object that encapsulates information why registration did not succeed.
 */
+ (void)getTagsWithSuccessBlock:(void (^)(NSArray *tags))success failureBlock:(void (^)(NSError *error))failure;

/*!
 @methodgroup Creating and Resuming a session
 @discusion Using these methods, it is possible to register a user with a time invariant token and restore all previous user sessions. Use the methods declared here to register, login and logout user. Logging in to a previously created user session means that users are unonymously recognized by warply across all his/her devices. That way they can see all their personalized offers across all the devices on which they login. 
 */
/*!
 @abstract Login a user. If no user has been registered with this auth token, the user is being registered.
 @discussion This class method logins a user to Warply service. The login is sucessful only if
 previously the user is sucesfully registered.
 @param authToken User arbitrary time invariant token. Must be the same token used
 for registering the user.
 @attributeblock success This block is called when sessionLogin is sucessful.
 @attributeblock failure This block is called when sessionLogin fails and returns a NSError object with failure code and description.
 */
+ (void)sessionLogin:(NSString *)authToken successBlock:(void (^)(void))success failureBlock:(void (^)(void))failure;
/*!
 @abstract Logout a user.
 @discussion This class method logouts a user to Warply service. The logout is sucessful only if
 previously the user is sucesfully registered.
 @param authToken User arbitrary time invariant token. Must be the same token used
 for registering the user.
 @attributeblock success This block is called when sessionLogout is sucessful.
 @attributeblock failure This block is called when sessionLogout fails.
 */
+ (void)sessionLogout:(NSString *)authToken successBlock:(void (^)(void))success failureBlock:(void (^)(void))failure;

/*!
 @abstract Determine if the user wants to receive or not push notifications from the Warply server.
 @param enable BOOL value that determines if the user wants to receive or not push notifications from the Warply server. If enable == NO the Warply server does not send any push notifications to the specific user. Default value is YES.
 @attributeblock success This block is called when the call is sucessful.
 @attributeblock failure This block is called when the call fails.
 */
+ (void)setWarplyNotificationsEnabled:(BOOL)enable successBlock:(void (^)(void))success failureBlock:(void (^)(NSError *error))failure;

/*!
 @abstract This method retreives from the server the information of whether the user wants to receive Warply notifications or not @see + warplyNotificationsEnabledWithsuccessBlock:failureBlock:
 @attributeblock success This block is called when the call is sucessful and has a BOOL parameter that carries the information of whether the user wants to receive Warply notifications or not.
 @attributeblock failure This block is called when the call fails.
 */
+ (void)warplyNotificationsEnabledWithsuccessBlock:(void (^)(BOOL isEnabled))success failureBlock:(void (^)(NSError *error))failure;

@end