Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

GitHub API v2 to v3 in the ObjectionExample #21

Merged
merged 1 commit into from

2 participants

@rvil

No description provided.

@dewind
Owner

Thanks,

Could you verify that all of the tests are passing after your change?

@rvil

Sure, I'll let you know when it's verified

@dewind
Owner

rvil,

Don't worry about the tests for now. It appears I just spend some time fixing the example test target. I need to migrate it over to a different test framework anyhow.

@dewind dewind merged commit e98e0b2 into atomicobject:master
@rvil

Thanks Justin! Let me know if you need any help once you migrate to the new framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 20, 2012
  1. Used the GitHub API v3 instead of the deprecated v2 in the ObjectionE…

    rvillarreal authored
    …xample target
This page is out of date. Refresh to see the latest.
View
19 Examples/ObjectionExample/ObjectionExample/GitHubAPI/OEGitHubAPI.m
@@ -11,15 +11,18 @@ @implementation OEGitHubAPI
@synthesize networkQueue = _networkQueue;
- (void)commitsWithAuthor:(NSString *)author inRepository:(NSString *)repo onBranch:(NSString *)branch completed:(void (^)(NSArray *))completedBlock {
- ASIHTTPRequest *request = [self.requestFactory requestWithRelativeURL:[NSString stringWithFormat:@"%@/%@/%@", author, repo, branch]];
+ // There's no documentation in the GitHub API v3 to get the commits from a branch
+ // TODO: Use the repo parameter when the documentation includes getting the commits from a branch
+ // http://developer.github.com/v3/repos/commits/
+ ASIHTTPRequest *request = [self.requestFactory requestWithRelativeURL:[NSString stringWithFormat:@"%@/%@/commits", author, repo]];
[request setCompletionBlock:^{
- NSArray *commitDictionaries = [[[request responseData] objectFromJSONData] objectForKey:@"commits"];
- NSMutableArray *commits = [[[NSMutableArray alloc] init] autorelease];
- for (NSDictionary *commitDictionary in commitDictionaries) {
- [commits addObject:[self.builder buildCommit:commitDictionary]];
- }
- completedBlock(commits);
+ NSArray *commitDictionaries = [[request responseData] objectFromJSONData];
+ NSMutableArray *commits = [[[NSMutableArray alloc] init] autorelease];
+ for (NSDictionary *commitDictionary in commitDictionaries) {
+ [commits addObject:[self.builder buildCommit:[commitDictionary objectForKey:@"commit"]]];
+ }
+ completedBlock(commits);
}];
[request setFailedBlock:^{
NSLog(@"Network Error: %@", [request error]);
@@ -29,7 +32,7 @@ - (void)commitsWithAuthor:(NSString *)author inRepository:(NSString *)repo onBra
}
- (void)dealloc {
- [_networkQueue release];
+ [_networkQueue release];
[_requestFactory release];
[_builder release];
[super dealloc];
View
10 Examples/ObjectionExample/ObjectionExample/GitHubAPI/OEGitHubObjectBuilder.m
@@ -5,11 +5,11 @@ @implementation OEGitHubObjectBuilder
objection_register(OEGitHubObjectBuilder)
- (OECommit *)buildCommit:(NSDictionary *)commitDictionary {
- OECommit *commit = [[[OECommit alloc] init] autorelease];
- commit.authorName = [[commitDictionary objectForKey:@"author"] objectForKey:@"name"];
- commit.authoredDate = [self parseGitHubDateString:[commitDictionary objectForKey:@"authored_date"]];
- commit.message = [commitDictionary objectForKey:@"message"];
- return commit;
+ OECommit *commit = [[[OECommit alloc] init] autorelease];
+ commit.authorName = [[commitDictionary objectForKey:@"author"] objectForKey:@"name"];
+ commit.authoredDate = [self parseGitHubDateString:[[commitDictionary objectForKey:@"author"] objectForKey:@"date"]];
+ commit.message = [commitDictionary objectForKey:@"message"];
+ return commit;
}
- (NSDate *)parseGitHubDateString:(NSString *)dateString {
View
3  Examples/ObjectionExample/ObjectionExample/GitHubAPI/OERequestFactory.m
@@ -1,6 +1,6 @@
#import "OERequestFactory.h"
-NSString *const kBaseURL = @"http://github.com/api/v2/json/commits/list/";
+NSString *const kBaseURL = @"https://api.github.com/repos/";
NSString *const kContentType = @"application/json";
NSString *const kContentEncoding = @"UTF-8";
@@ -11,6 +11,7 @@ - (ASIHTTPRequest *)requestWithRelativeURL:(NSString *)relativeURL {
NSURL *url = [NSURL URLWithString:relativeURL relativeToURL:[NSURL URLWithString:kBaseURL]];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
+ NSLog(@"Requesting Commits: %@", [url absoluteString]);
// Extra headers - ensure correct values
[request addRequestHeader:@"Accept" value:kContentType];
[request addRequestHeader:@"Accept-Charset" value:kContentEncoding];
Something went wrong with that request. Please try again.