| OLD | NEW |
| (Empty) |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 6 #error "This file requires ARC support." | |
| 7 #endif | |
| 8 | |
| 9 #import "remoting/client/ios/domain/user_info.h" | |
| 10 | |
| 11 @implementation UserInfo | |
| 12 | |
| 13 @synthesize userId = _userId; | |
| 14 @synthesize userFullName = _userFullName; | |
| 15 @synthesize userEmail = _userEmail; | |
| 16 @synthesize refreshToken = _refreshToken; | |
| 17 | |
| 18 // Parse jsonData into Host list. | |
| 19 + (UserInfo*)parseListFromJSON:(NSMutableData*)data { | |
| 20 NSError* error; | |
| 21 | |
| 22 NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data | |
| 23 options:kNilOptions | |
| 24 error:&error]; | |
| 25 | |
| 26 UserInfo* user = [[UserInfo alloc] init]; | |
| 27 user.userId = [json objectForKey:@"userId"]; | |
| 28 user.userFullName = [json objectForKey:@"userFullName"]; | |
| 29 user.userEmail = [json objectForKey:@"userEmail"]; | |
| 30 user.refreshToken = [json objectForKey:@"refreshToken"]; | |
| 31 | |
| 32 return user; | |
| 33 } | |
| 34 | |
| 35 - (BOOL)isAuthenticated { | |
| 36 if (_userEmail && _userEmail.length > 0 && _refreshToken && | |
| 37 _refreshToken.length > 0) { | |
| 38 return YES; | |
| 39 } | |
| 40 return NO; | |
| 41 } | |
| 42 | |
| 43 - (NSComparisonResult)compare:(UserInfo*)user { | |
| 44 return [self.userId compare:user.userId]; | |
| 45 } | |
| 46 | |
| 47 - (NSString*)description { | |
| 48 return [NSString stringWithFormat:@"UserInfo: userEmail=%@ refreshToken=%@", | |
| 49 _userEmail, _refreshToken]; | |
| 50 } | |
| 51 | |
| 52 @end | |
| OLD | NEW |