Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.
/ TypetalkKit Public archive

An unofficial web API client for Typetalk, a web service for team disscussions.

License

Notifications You must be signed in to change notification settings

safx/TypetalkKit

Repository files navigation

TypetalkKit

TravisCI codecov.io Platform License Version Carthage

TypetalkKit is an unofficial web API client for Typetalk.

Basic Usage

The following code gets user's topics and prints these.

TypetalkAPI.sendRequest(GetTopics(spaceKey: spaceKey)) { result in
    switch result {
    case .Success(let ts):
        for i in ts {
            print(i)
        }
    case .Failure(let error):
        // error
    }
}

TypetalkKit supports almost all Typetalk API.

If you want to know further information about API, please visit official page.

Features

  • Pure Swift API
  • Full REST API support with APIKit
  • Streaming API support with Starscream

Authorization

To use TypetalkKit, you need to register your app at the Official Developer page first.

When you register your app, choose "Authorization Code" for Grant Type and set URI including custom URL scheme, which should be unique to complete authorization process.

In your app, set developer settings:

TypetalkAPI.setDeveloperSettings(
    clientId:     "Your ClientID",
    clientSecret: "Your SecretID",
    redirectURI:  "Your custome scheme",    // e.g. typetalkkit <YOUR_APP_ID>://auth/success
    scopes: [Scope.my, Scope.topic_read])

And then call authorize.

TypetalkAPI.authorize { (error) -> Void in
   ...
}

TypetalkKit use Safari for Typetalk's authorization process. You, thearefore, have to add a custom URL scheme for "redirect URI" to your Info.plist in order to switch back to your app from Safari.

When your app is back from Safari, call TypetalkAPI.authorizationDone in your application(openURL, sourceApplication, annotation) as follows:

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
    if TypetalkAPI.isRedirectURL(url) && sourceApplication? == "com.apple.mobilesafari" {
        return TypetalkAPI.authorizationDone(URL: url)
    }
    return false
}

If you don't call authorizationDone, the callback of authorize never be called.

In OS X, you can use TypetalkAPI.authorizationDone in handleGetURLEvent as follows:

func handleGetURLEvent(event: NSAppleEventDescriptor?, replyEvent: NSAppleEventDescriptor?) {
    if let ev = event,
        url_str = ev.descriptorForKeyword(AEKeyword(keyDirectObject))?.stringValue,
        url = NSURL(string: url_str) where TypetalkAPI.isRedirectURL(url) {
            TypetalkAPI.authorizationDone(URL: url)
    }
}

For more information of Typetalk's authorization, please see official page.

Install

CocoaPods

pod 'TypetalkKit'

Carthage

github "safx/TypetalkKit"

Manual Install

  1. Add TypetalkKit as a submodule:

     git submodule add https://github.com/safx/TypetalkKit.git
    
  2. Add TypetalkKit.xcodeproj to your project.

  3. Add TypetalkKit to "Target Dependencies" of "Build Phases" tab of your app's target.

  4. Add "Copy Files" to copy TypetalkKit.framework:

    1. Click " " button, and select "New Copy Files Phase" to add "Copy Files" to choose.
    2. Set the "Destination" to "Frameworks", and add TypetalkKit.framework.

About

An unofficial web API client for Typetalk, a web service for team disscussions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages