-
Notifications
You must be signed in to change notification settings - Fork 243
/
CountlyUserDetails.h
331 lines (282 loc) · 15.4 KB
/
CountlyUserDetails.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
// CountlyUserDetails.h
//
// This code is provided under the MIT License.
//
// Please visit www.count.ly for more information.
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
* A placeholder type specifier which accepts only @c NSString or @c NSNull for @c CountlyUserDetails default properties.
*/
@protocol CountlyUserDetailsNullableString <NSObject>
@end
@interface NSString (NSStringWithCountlyUserDetailsNullableString) <CountlyUserDetailsNullableString>
@end
@interface NSNull (NSNullWithCountlyUserDetailsNullableString) <CountlyUserDetailsNullableString>
@end
/**
* A placeholder type specifier which accepts only @c NSDictionary or @c NSNull for @c CountlyUserDetails default properties.
*/
@protocol CountlyUserDetailsNullableDictionary <NSObject>
@end
@interface NSDictionary (NSDictionaryWithCountlyUserDetailsNullableDictionary) <CountlyUserDetailsNullableDictionary>
@end
@interface NSNull (NSNullWithCountlyUserDetailsNullableDictionary) <CountlyUserDetailsNullableDictionary>
@end
/**
* A placeholder type specifier which accepts only @c NSNumber or @c NSNull for @c CountlyUserDetails default properties.
*/
@protocol CountlyUserDetailsNullableNumber <NSObject>
@end
@interface NSNumber (NSNumberWithCountlyUserDetailsNullableNumber) <CountlyUserDetailsNullableNumber>
@end
@interface NSNull (NSNullWithCountlyUserDetailsNullableNumber) <CountlyUserDetailsNullableNumber>
@end
extern NSString* const kCountlyLocalPicturePath;
@interface CountlyUserDetails : NSObject
/**
* Default @c name property for user's name in User Profiles.
* @discussion It can be set to an @c NSString, or @c NSNull for clearing it on server.
* It will be sent to server when @c recordUserDetails method is called.
*/
@property (nonatomic, copy) id<CountlyUserDetailsNullableString> _Nullable name;
/**
* Default @c username property for user's username in User Profiles.
* @discussion It can be set to an @c NSString, or @c NSNull for clearing it on server.
* It will be sent to server when @c recordUserDetails method is called.
*/
@property (nonatomic, copy) id<CountlyUserDetailsNullableString> _Nullable username;
/**
* Default @c email property for user's e-mail in User Profiles.
* @discussion It can be set to an @c NSString, or @c NSNull for clearing it on server.
* It will be sent to server when @c recordUserDetails method is called.
*/
@property (nonatomic, copy) id<CountlyUserDetailsNullableString> _Nullable email;
/**
* Default @c organization property for user's organization/company in User Profiles.
* @discussion It can be set to an @c NSString, or @c NSNull for clearing it on server.
* It will be sent to server when @c recordUserDetails method is called.
*/
@property (nonatomic, copy) id<CountlyUserDetailsNullableString> _Nullable organization;
/**
* Default @c phone property for user's phone number in User Profiles.
* @discussion It can be set to an @c NSString, or @c NSNull for clearing it on server.
* It will be sent to server when @c recordUserDetails method is called.
*/
@property (nonatomic, copy) id<CountlyUserDetailsNullableString> _Nullable phone;
/**
* Default @c gender property for user's gender in User Profiles.
* @discussion It can be set to an @c NSString, or @c NSNull for clearing it on server.
* It will be sent to server when @c recordUserDetails method is called.
* @discussion If it is set to case-insensitive @c m or @c f, it is displayed as @c Male or @c Female. Otherwise it will displayed as @c Unknown.
*/
@property (nonatomic, copy) id<CountlyUserDetailsNullableString> _Nullable gender;
/**
* Default @c pictureURL property for user's profile photo in User Profiles.
* @discussion It can be set to an @c NSString, or @c NSNull for clearing it on server.
* It will be sent to server when @c recordUserDetails method is called.
* @discussion It should be a publicly accessible URL string to user's profile photo, so server can download it.
*/
@property (nonatomic, copy) id<CountlyUserDetailsNullableString> _Nullable pictureURL;
/**
* Default @c pictureLocalPath property for user's profile photo in User Profiles.
* @discussion It can be set to an @c NSString, or @c NSNull for clearing it on server.
* It will be sent to server when @c recordUserDetails method is called.
* @discussion It should be a valid local path string to user's profile photo on the device, so it can be uploaded to server.
* If @c pictureURL is also set at the same time, @c pictureLocalPath will be ignored and @c pictureURL will be used.
*/
@property (nonatomic, copy) id<CountlyUserDetailsNullableString> _Nullable pictureLocalPath;
/**
* Default @c birthYear property for user's birth year in User Profiles.
* @discussion It can be set to an @c NSNumber, or @c NSNull for clearing it on server.
* It will be sent to server when @c recordUserDetails method is called.
*/
@property (nonatomic, copy) id<CountlyUserDetailsNullableNumber> _Nullable birthYear;
/**
* @c custom property for user's custom information as key-value pairs in User Profiles.
* @discussion It can be set to an @c NSDictionary, or @c NSNull for clearing it on server.
* It will be sent to server when @c recordUserDetails method is called.
* @discussion Key-value pairs in @c custom property can also be modified using custom property modifier methods.
*/
@property (nonatomic, copy) id<CountlyUserDetailsNullableDictionary> _Nullable custom;
/**
* Returns @c CountlyUserDetails singleton to be used throughout the app.
* @return The shared @c CountlyUserDetails object
* @discussion @c Countly.user convenience accessor can also be used.
*/
+ (instancetype)sharedInstance;
#pragma mark -
/**
* Custom user details property modifier for setting a key-value pair where the value is a string.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property key-value pair
* @param value String value for custom property key-value pair
*/
- (void)set:(NSString *)key value:(NSString *)value;
/**
* Custom user details property modifier for setting a key-value pair where the value is a number.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property key-value pair
* @param value Number value for custom property key-value pair
*/
- (void)set:(NSString *)key numberValue:(NSNumber *)value;
/**
* Custom user details property modifier for setting a key-value pair where the value is a boolean.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property key-value pair
* @param value Boolean value for custom property key-value pair
*/
- (void)set:(NSString *)key boolValue:(BOOL)value;
/**
* Custom user details property modifier for setting a key-value pair if not set before.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property key-value pair
* @param value String value for custom property key-value pair
*/
- (void)setOnce:(NSString *)key value:(NSString *)value;
/**
* Custom user details property modifier for setting a key-value pair if not set before.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property key-value pair
* @param value Number value for custom property key-value pair
*/
- (void)setOnce:(NSString *)key numberValue:(NSNumber *)value;
/**
* Custom user details property modifier for setting a key-value pair if not set before.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property key-value pair
* @param value Boolean value for custom property key-value pair
*/
- (void)setOnce:(NSString *)key boolValue:(BOOL)value;
/**
* Custom user details property modifier for unsetting a key-value pair.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property key-value pair
*/
- (void)unSet:(NSString *)key;
/**
* Custom user details property modifier for incrementing a key-value pair's value by 1.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property key-value pair
*/
- (void)increment:(NSString *)key;
/**
* Custom user details property modifier for incrementing a key-value pair's value by specified amount.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property key-value pair
* @param value Amount of increment
*/
- (void)incrementBy:(NSString *)key value:(NSNumber *)value;
/**
* Custom user details property modifier for multiplying a key-value pair's value by specified multiplier.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property key-value pair
* @param value Multiplier
*/
- (void)multiply:(NSString *)key value:(NSNumber *)value;
/**
* Custom user details property modifier for setting a key-value pair's value if it is less than specified value.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property key-value pair
* @param value Value to be compared against current value
*/
- (void)max:(NSString *)key value:(NSNumber *)value;
/**
* Custom user details property modifier for setting a key-value pair's value if it is more than specified value.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property key-value pair
* @param value Value to be compared against current value
*/
- (void)min:(NSString *)key value:(NSNumber *)value;
/**
* Custom user details property modifier for adding specified string value to the array for specified key.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property of array type
* @param value String value to be added to the array
*/
- (void)push:(NSString *)key value:(NSString *)value;
/**
* Custom user details property modifier for adding specified number value to the array for specified key.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property of array type
* @param value Number value to be added to the array
*/
- (void)push:(NSString *)key numberValue:(NSNumber *)value;
/**
* Custom user details property modifier for adding specified boolean value to the array for specified key.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property of array type
* @param value Boolean value to be added to the array
*/
- (void)push:(NSString *)key boolValue:(BOOL)value;
/**
* Custom user details property modifier for adding specified values to the array for specified key.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property of array type
* @param value An array of values to be added to the array
*/
- (void)push:(NSString *)key values:(NSArray *)value;
/**
* Custom user details property modifier for adding specified string value to the array for specified key, if it does not exist.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property of array type
* @param value String value to be added to the array
*/
- (void)pushUnique:(NSString *)key value:(NSString *)value;
/**
* Custom user details property modifier for adding specified number value to the array for specified key, if it does not exist.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property of array type
* @param value Number value to be added to the array
*/
- (void)pushUnique:(NSString *)key numberValue:(NSNumber *)value;
/**
* Custom user details property modifier for adding specified boolean value to the array for specified key, if it does not exist.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property of array type
* @param value Boolean value to be added to the array
*/
- (void)pushUnique:(NSString *)key boolValue:(BOOL)value;
/**
* Custom user details property modifier for adding specified values to the array for specified key, if they do not exist.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property of array type
* @param value An array of values to be added to the array
*/
- (void)pushUnique:(NSString *)key values:(NSArray *)value;
/**
* Custom user details property modifier for removing specified string value from the array for specified key.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property of array type
* @param value String value to be removed from the array
*/
- (void)pull:(NSString *)key value:(NSString *)value;
/**
* Custom user details property modifier for removing specified number value from the array for specified key.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property of array type
* @param value Number value to be removed from the array
*/
- (void)pull:(NSString *)key numberValue:(NSNumber *)value;
/**
* Custom user details property modifier for removing specified boolean value from the array for specified key.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property of array type
* @param value Boolean value to be removed from the array
*/
- (void)pull:(NSString *)key boolValue:(BOOL)value;
/**
* Custom user details property modifier for removing specified values from the array for specified key.
* @discussion When called, this modifier is added to a non-persistent queue and sent to server only when @c save method is called.
* @param key Key for custom property of array type
* @param value An array of values to be removed from the array
*/
- (void)pull:(NSString *)key values:(NSArray *)value;
/**
* Records user details and sends them to server.
* @discussion Once called, default user details properties and custom user details property modifiers are reset. If sending them to server fails, they are stored peristently in request queue, to be tried again later.
*/
- (void)save;
- (BOOL) hasUnsyncedChanges;
NS_ASSUME_NONNULL_END
@end