summaryrefslogtreecommitdiff
path: root/Juick/Model/User.m
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-12-02 23:23:31 +0300
committerGravatar Vitaly Takmazov2018-12-02 23:23:31 +0300
commita293a8e049fea49b8c2b8262fb92a29f73d66989 (patch)
tree2201a139fc19fcac59714e915f08b0aa7e816517 /Juick/Model/User.m
parent3bc3a38be7ccaf9622bdc86ffac37827af36f0f1 (diff)
Drop YYModel
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);
}];