Skip to content

Commit

Permalink
Merge pull request #85 from petrucci34/master
Browse files Browse the repository at this point in the history
Suggestions to improve LDUserBuilder API
  • Loading branch information
danialzahid94 authored Apr 13, 2017
2 parents 7dea04b + 6324dc7 commit 84a36c1
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 237 deletions.
2 changes: 1 addition & 1 deletion Darkly/LDClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ - (BOOL)updateUser:(LDUserBuilder *)builder {
- (LDUserBuilder *)currentUserBuilder {
DEBUG_LOGX(@"LDClient currentUserBuilder method called");
if (clientStarted) {
return [LDUserBuilder retrieveCurrentBuilder:ldUser];
return [LDUserBuilder currentBuilder:ldUser];
} else {
DEBUG_LOGX(@"LDClient not started yet!");
return nil;
Expand Down
117 changes: 48 additions & 69 deletions Darkly/LDUserBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,118 +5,97 @@

#import "LDUserModel.h"

@interface LDUserBuilder : NSObject {

}

+ (LDUserModel *)compareNewBuilder:(LDUserBuilder *)iBuilder withUser:(LDUserModel *)iUser;
+ (LDUserBuilder *)retrieveCurrentBuilder:(LDUserModel *)iUser;
@interface LDUserBuilder : NSObject

/**
* Provide a key to the user builder to identify the user. If this key
* A key to the user builder to identify the user. If this key
* is not provided, one will be auto-generated. (Optional)
*
* @param key the key for the user
* @return the user builder
*/
- (LDUserBuilder *)withKey:(NSString *)key;
@property (nonatomic, copy, nullable) NSString *key;

/**
* Provide the ip address of the user. (Optional)
*
* @param ip the ip of the user
* @return the user builder
* The IP address of the user. (Optional)
*/
- (LDUserBuilder *)withIp:(NSString *)ip;
@property (nonatomic, copy, nullable) NSString *ip;

/**
* Provide the country of the user. (Optional)
*
* @param country the country of the user
* @return the user builder
* The country of the user. (Optional)
*/
- (LDUserBuilder *)withCountry:(NSString *)country;
@property (nonatomic, copy, nullable) NSString *country;

/**
* Provide the first name of the user. (Optional)
*
* @param firstName the firstName of the user
* @return the user builder
* The first name of the user. (Optional)
*/
- (LDUserBuilder *)withFirstName:(NSString *)firstName;
@property (nonatomic, copy, nullable) NSString *firstName;

/**
* Provide the last name of the user. (Optional)
*
* @param lastName the lastName of the user
* @return the user builder
* The last name of the user. (Optional)
*/
- (LDUserBuilder *)withLastName:(NSString *)lastName;
@property (nonatomic, copy, nullable) NSString *lastName;

/**
* Provide the email address of the user. (Optional)
*
* @param email the email of the user
* @return the user builder
* The email address of the user. (Optional)
*/
- (LDUserBuilder *)withEmail:(NSString *)email;
@property (nonatomic, copy, nullable) NSString *email;

/**
* Provide the avatar of the user. (Optional)
*
* @param avatar the avatar of the user
* @return the user builder
* The avatar of the user. (Optional)
*/
@property (nonatomic, copy, nullable) NSString *avatar;

/**
* The custom NSMutableDictionary data for the dictionary associated with
* the user. (Optional)
*/
@property (nonatomic, strong, nullable) NSMutableDictionary *customDictionary;

/**
* Provide whether the user is anonymous. Note, if a key is
* auto-generated for the user, then anonymous is set to YES. Default
* is NO. (Optional)
*/
- (LDUserBuilder *)withAvatar:(NSString *)avatar;
@property (nonatomic) BOOL isAnonymous;

/**
* Provide custom String data for the dictionary associated with
* the user. (Optional)
*
* @param inputKey key for the data
* @param value value for the data
* @return the user builder
*/
- (LDUserBuilder *)withCustomString:(NSString *)inputKey value:(NSString *)value;
- (void)customString:(nonnull NSString *)inputKey value:(nonnull NSString *)value;

/**
* Provide custom BOOL data for the dictionary associated with
* the user. (Optional)
*
* @param inputKey key for the data
* @param value value for the data
* @return the user builder
*/
- (LDUserBuilder *)withCustomBool:(NSString *)inputKey value:(BOOL)value;
- (void)customBool:(nonnull NSString *)inputKey value:(BOOL)value;

/**
* Provide custom NSNumber data for the dictionary associated with
* the user. (Optional)
*
* @param inputKey key for the data
* @param value value for the data
* @return the user builder
*/
- (LDUserBuilder *)withCustomNumber:(NSString *)inputKey value:(NSNumber *)value;
- (void)customNumber:(nonnull NSString *)inputKey value:(nonnull NSNumber *)value;

/**
* Provide custom NSArray data for the dictionary associated with
* the user. (Optional)
*
* @param inputKey key for the data
* @param value value for the data
* @return the user builder
*/
- (LDUserBuilder *)withCustomArray:(NSString *)inputKey value:(NSArray *)value;
/**
* Provide custom NSMutableDictionary data for the dictionary associated with
* the user. (Optional)
*
* @param inputKey key for the data
* @param value value for the data
* @return the user builder
*/
- (LDUserBuilder *)withCustomDictionary:(NSMutableDictionary *)inputDictionary;
/**
* Provide whether the user is anonymous. Note, if a key is
* auto-generated for the user, then anonymous is set to YES. Default
* is NO. (Optional)
*
* @param anonymous whether user is anonymous
* @return the user builder
*/
- (LDUserBuilder *)withAnonymous:(BOOL)anonymous;
- (void)customArray:(nonnull NSString *)inputKey value:(nonnull NSArray *)value;


-(nonnull LDUserModel *)build;

-(id)build;
+ (nonnull LDUserModel *)compareNewBuilder:(nonnull LDUserBuilder *)iBuilder withUser:(nonnull LDUserModel *)iUser;
+ (nonnull LDUserBuilder *)currentBuilder:(nonnull LDUserModel *)iUser;

@end
@end
Loading

0 comments on commit 84a36c1

Please sign in to comment.