Latest 0.1.0
Homepage https://github.com/yonekawa/td-client-objc
License MIT
Platforms ios 6.0, osx 10.8, requires ARC
Dependencies AFNetworking, ReactiveCocoa, ISO8601DateFormatter, Mantle
Authors

Treasure Data REST API Client for Objective-C

Build Status Gitter chat

Objective-C Client Library for Treasure Data REST API, built using AFNetworking, Mantle, and ReactiveCocoa.

Install

Installation with CocoaPods

Podfile

platform :ios, '7.0'
pod "TreasureData", "~> 0.1.0"

Usage

Each request method on TRDClient returns a ReactiveCocoa signal.

Authenticate

Treasure Data REST API uses API key for authentication key. See API document.

You can create a client with api key directly.

TRDApiKey *apiKey = [TRDApiKey apiKeyWithValue:@"TD_API_KEY"];
TRDClient *client = [[TRDClient alloc] initWithApiKey:apiKey];

If you want to authenticate with email & password, authenticateWithUsername:password can be used.

[[TRDCLient authenticateWithUsername:@"email" password:@"pass"] subscribeNext:^(TRDClient *client) {
    NSLog("apiKey: %@" client.apiKey.value);
}];

Receiving result

one-by-one

It often makes sense to handle each result object independently, so you can spread any processing out instead of doing it all at once:

RACSingal *request = [cleint fetchAllDatabases];
[request subscribeNext:^(TRDDatabaes *database) {
    // This block is invoked for _each_ result received, so you can deal with
    // them one-by-one as they arrive.
} error:^(NSError *error) {
    // Invoked when an error occurs.
    //
    // Your `next` and `completed` blocks won't be invoked after this point.
} completed:^{
    // Invoked when the request completes and we've received/processed all the
    // results.
    //
    // Your `next` and `error` blocks won't be invoked after this point.
}];

all result at once

If you can’t do anything until you have all of the results, you can collect them into a single array:

RACSingal *request = [cleint fetchAllDatabases];
[[request collect] subscribeNext:^(NSArray *databases) {
    // Thanks to -collect, this block is invoked after the request completes,
    // with _all_ the results that were received.
} error:^(NSError *error) {
    // Invoked when an error occurs. You won't receive any results if this
    // happens.
}];

License

MIT license.

Latest podspec

{
    "name": "TreasureData",
    "version": "0.1.0",
    "summary": "Treasure Data Client Library for Objective-C.",
    "homepage": "https://github.com/yonekawa/td-client-objc",
    "license": "MIT",
    "authors": {
        "Kenichi Yonekawa": "[email protected]"
    },
    "source": {
        "git": "https://github.com/yonekawa/td-client-objc.git",
        "tag": "0.1.0"
    },
    "source_files": "TreasureData/**/*.{h,m}",
    "requires_arc": true,
    "platforms": {
        "ios": "6.0",
        "osx": "10.8"
    },
    "dependencies": {
        "AFNetworking": [
            "2.1.0"
        ],
        "ReactiveCocoa": [
            "2.2.3"
        ],
        "ISO8601DateFormatter": [
            "0.7"
        ],
        "Mantle": [
            "1.3.1"
        ]
    }
}

Pin It on Pinterest

Share This