Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Merge pull request #240 from octokit/moondragon
Browse files Browse the repository at this point in the history
Moondragon
  • Loading branch information
jspahrsummers committed Feb 19, 2015
2 parents 76c8f6c + 86c563a commit 1a6667f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions OctoKit/OCTClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
NSString * const OCTClientErrorMessagesKey = @"OCTClientErrorMessagesKey";

NSString * const OCTClientAPIVersion = @"v3";
NSString * const OCTClientPreviewAPIVersion = @"mirage-preview";

/// See https://developer.github.com/changes/2014-12-08-removing-authorizations-token/
NSString * const OCTClientMiragePreviewAPIVersion = @"mirage-preview";

/// See https://developer.github.com/changes/2014-12-08-organization-permissions-api-preview/
NSString * const OCTClientMoondragonPreviewAPIVersion = @"moondragon";

static const NSInteger OCTClientNotModifiedStatusCode = 304;
static NSString * const OCTClientOneTimePasswordHeaderField = @"X-GitHub-OTP";
Expand Down Expand Up @@ -241,11 +246,13 @@ - (id)initWithServer:(OCTServer *)server {

[AFHTTPRequestOperation addAcceptableStatusCodes:[NSIndexSet indexSetWithIndex:OCTClientNotModifiedStatusCode]];

NSString *stableContentType = [NSString stringWithFormat:@"application/vnd.github.%@+json", OCTClientAPIVersion];
NSString *previewContentType = [NSString stringWithFormat:@"application/vnd.github.%@+json", OCTClientPreviewAPIVersion];
NSString *baseContentType = @"application/vnd.github.%@+json";
NSString *stableContentType = [NSString stringWithFormat:baseContentType, OCTClientAPIVersion];
NSString *previewContentType = [NSString stringWithFormat:baseContentType, OCTClientMiragePreviewAPIVersion];
NSString *moondragonPreviewContentType = [NSString stringWithFormat:baseContentType, OCTClientMoondragonPreviewAPIVersion];

[self setDefaultHeader:@"Accept" value:stableContentType];
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObjects:stableContentType, previewContentType, nil]];
[self setDefaultHeader:@"Accept" value:moondragonPreviewContentType];
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObjects:stableContentType, previewContentType, moondragonPreviewContentType, nil]];

self.parameterEncoding = AFJSONParameterEncoding;
[self registerHTTPOperationClass:AFJSONRequestOperation.class];
Expand Down Expand Up @@ -331,7 +338,7 @@ + (RACSignal *)signInAsUser:(OCTUser *)user password:(NSString *)password oneTim
request.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
if (oneTimePassword != nil) [request setValue:oneTimePassword forHTTPHeaderField:OCTClientOneTimePasswordHeaderField];

NSString *previewContentType = [NSString stringWithFormat:@"application/vnd.github.%@+json", OCTClientPreviewAPIVersion];
NSString *previewContentType = [NSString stringWithFormat:@"application/vnd.github.%@+json", OCTClientMiragePreviewAPIVersion];
[request setValue:previewContentType forHTTPHeaderField:@"Accept"];

RACSignal *tokenSignal = [client enqueueRequest:request resultClass:OCTAuthorization.class];
Expand Down

0 comments on commit 1a6667f

Please sign in to comment.