Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #87 from ramonvic/foursquare-web
Browse files Browse the repository at this point in the history
Added some fields in foursquare response.
  • Loading branch information
calebd committed Mar 31, 2015
2 parents ab4a9ae + 5696cd4 commit 23d6d55
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions Pod/Providers/FoursquareWeb/SimpleAuthFoursquareWebProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,28 +134,51 @@ - (NSDictionary *)dictionaryWithAccount:(NSDictionary *)account accessToken:(NSS

// Credentials
dictionary[@"credentials"] = @{
@"token" : accessToken
};
@"token" : accessToken
};

// User ID
dictionary[@"uid"] = userData[@"id"];

// Raw response
dictionary[@"extra"] = @{
@"raw_info" : userData
};
@"raw_info" : userData
};

// User info
NSMutableDictionary *user = [NSMutableDictionary new];
if (userData[@"contact"][@"email"]) {
user[@"email"] = userData[@"contact"][@"email"];
}

if (userData[@"firstName"]) {
user[@"first_name"] = userData[@"firstName"];
}

if (userData[@"lastName"]) {
user[@"last_name"] = userData[@"lastName"];
}

user[@"name"] = [NSString stringWithFormat:@"%@ %@", user[@"first_name"], user[@"last_name"]];

user[@"gender"] = userData[@"gender"];

if ([userData[@"photo"] isKindOfClass:NSDictionary.class]) {
user[@"image"] = [NSString stringWithFormat:@"%@500x500%@", userData[@"photo"][@"prefix"], userData[@"photo"][@"suffix"]];
} else if ([userData[@"photo"] isKindOfClass:NSString.class]) {
user[@"image"] = userData[@"photo"];
}

if (userData[@"photo"]) {
user[@"photo"] = userData[@"photo"];
}
if (userData[@"homeCity"]) {
NSString *homecity = [[userData[@"homeCity"] componentsSeparatedByString:@","] firstObject];
user[@"location"] = homecity;
}
user[@"urls"] = @{
@"Foursquare" : [NSString stringWithFormat:@"https://foursquare.com/user/%@", userData[@"id"]],
};
dictionary[@"info"] = user;

return dictionary;
Expand Down

0 comments on commit 23d6d55

Please sign in to comment.