summaryrefslogtreecommitdiff
path: root/Juick/Model/User.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/Model/User.m')
-rw-r--r--Juick/Model/User.m10
1 files changed, 9 insertions, 1 deletions
diff --git a/Juick/Model/User.m b/Juick/Model/User.m
index 36a9b4c..a2f874c 100644
--- a/Juick/Model/User.m
+++ b/Juick/Model/User.m
@@ -11,6 +11,14 @@
@implementation User
++ (User *) fromJSON:(NSDictionary *)jsonData {
+ User *user = [User new];
+ user.uid = jsonData[@"uid"];
+ user.uname = jsonData[@"uname"];
+ user.avatar = jsonData[@"avatar"];
+ return user;
+}
+
+(BOOL) isAuthenticated {
return [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"] != nil;
}
@@ -46,7 +54,7 @@
AFHTTPSessionManager *manager = [APIClient sharedClient].manager;
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:name, @"uname", nil];
[manager GET:@"users" parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
- callback([User yy_modelWithJSON:[(NSArray *)responseObject firstObject]]);
+ callback([User fromJSON:[(NSArray *)responseObject firstObject]]);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
callback(nil);
}];