forked from b123400/TootRain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccount.m
51 lines (46 loc) · 1.36 KB
/
Account.m
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
//
// AuthedUser.m
// Canvas
//
// Created by b123400 Chan on 9/4/12.
// Copyright (c) 2012 home. All rights reserved.
//
#import "Account.h"
#import "StatusesManager.h"
#import "TwitterConnector.h"
@implementation Account
@synthesize accessToken;
+(Account*)userWithDictionary:(NSDictionary *)dict{
Account *thisAccount=[[Account alloc]init];
thisAccount=(Account*)[thisAccount insertDataIntoUser:thisAccount WithDictionary:dict];
NSString *key=[[dict objectForKey:@"oauthtoken"] objectForKey:@"key"];
NSString *secret=[[dict objectForKey:@"oauthtoken"] objectForKey:@"secret"];
thisAccount.accessToken=[[OAToken alloc] initWithKey:key secret:secret];
return thisAccount;
}
-(NSDictionary*)dictionaryRepresentationWithAuthInformation:(BOOL)withAuth{
if(!withAuth){
return [super dictionaryRepresentation];
}
NSDictionary *accessTokenDict=[NSDictionary dictionaryWithObjectsAndKeys:
[accessToken key],@"key",
[accessToken secret],@"secret",nil];
NSMutableDictionary *dict=[NSMutableDictionary dictionaryWithDictionary:[super dictionaryRepresentation]];
[dict setObject:accessTokenDict forKey:@"oauthtoken"];
return dict;
}
-(id)engine{
if(!engine){
switch (type) {
case BRUserTypeTwitter:
{
engine=[[TwitterConnector sharedConnector] engineForAccount:self];
}
break;
default:
break;
}
}
return engine;
}
@end