-
Notifications
You must be signed in to change notification settings - Fork 315
OCTClient Methods
This is the designated initializer for the OCTClient class. Initializes the receiver to make requests to the given GitHub server.
- (id)initWithServer:(OCTServer *)server;
When using this initializer, the user property will not be set. +authenticatedClientWithUser:token: or +unauthenticatedClientWithUser: should typically be used instead.
Parameters
-
server- The GitHub server to connect to. This argument must not be nil.
Creates a client which will attempt to authenticate as the given user, using the given authorization token.
+ (instancetype)authenticatedClientWithUser:(OCTUser *)user token:(NSString *)token;
Note that this method does not actually perform a login or make a request to the server – it only sets an authorization header for future requests.
Parameters
-
user- The user to authenticate as. Theuserproperty of the returned client will be set to this object. This argument must not be nil. -
token- The authorization token for the given user.
Return Value
A new client.
Creates a client which can access any endpoints that don't require authentication.
+ (instancetype)unauthenticatedClientWithUser:(OCTUser *)user;
Parameters
-
userThe active user. Theuserproperty of the returned client will be set to this object. This argument must not be nil.
Return Value
A new client.
Creates a mutable URL request, which when sent will conditionally fetch the latest data from the server. If the latest data matches etag, nothing is downloaded and the call does not count toward the API rate limit.
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method path:(NSString *)path parameters:(NSDictionary *)parameters notMatchingEtag:(NSString *)etag;
Parameters
-
method- The HTTP method to use in the request (e.g., "GET" or "POST"). -
path- The path to request, relative to the base API endpoint. This path should not begin with a forward slash. -
parameters- HTTP parameters to encode and send with the request. -
notMatchingEtag- An ETag to compare the server data against, previously retrieved from an instance of OCTResponse. If the content has not changed since, no new data will be fetched when this request is sent. This argument may be nil to always fetch the latest data.
Return Value
An NSMutableURLRequest that you can enqueue using -enqueueRequest:resultClass:.