COBINHOOD-objc is a Cocoa and Cocoa Touch framework for interacting with COBINHOOD restful API, built using AFNetworking.
In order to begin interacting with the API, you must instantiate a COBClient
.
You can instantiate an unauthenticated client:
COBClient *client = [[COBClient alloc] init];
or an authenticated client:
COBClientOptions *options = [[COBClientOptions alloc] init];
options.authToken = "YOUR_AUTHORIZATION_TOKEN";
COBClient *client = [[COBClient alloc] initWithOptions:options];
After we've got a client, we can start performing request. Each request method will call either success block or failure block. All requests are asynchronous.
[client getAllCurrencies:^(NSArray<COBCurrency *> *currencies) {
// do something with result
} failure:^(NSError *error) {
// do error handling
}];
[client getTradingStats:^(NSDictionary<NSString *,COBTradingStat *> *tradingStats
) {
// do something with result
} failure:^(NSError *error) {
// do error handling
}];
[client placeOrderWithTradingPairId:@"BTC-USDT" side:kCOBOrderSideBid type:kCOBOrderTypeLimit price:@(5000.01) size:@(1.01) success:^(COBOrder *order) {
// do something with result
} failure:^(NSError *error) {
// do error handling
}];
[client cancelOrderWithOrderId:@"ORDER_ID" success:^{
// do something with result
} failure:^(NSError *error) {
// do error handling
}];
Other request methods are listed in COBINHOOD API documents: https://cobinhood.github.io/api-public/
Each failure of request will provide a NSError
error.
If the failure reason is due to COBINHOOD server, the error's domain must be COBClientErrorDomain
and provide the reason in userInfo[COBClientErrorCodeKey]
.