Skip to content
No description, website, or topics provided.
Elixir
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
test
.gitignore
LICENSE
README.md
mix.exs
mix.lock

README.md

Typetalk API client for Elixir

A Typetalk client library for Elixir language.

API Document: https://hexdocs.pm/typetalk/api-reference.html

Installation

This package can be installed by adding typetalk to your list of dependencies in mix.exs:

def deps do
  [{:typetalk, "~> 0.1.0"}]
end

Usage

Using Typetalk token (Bot)

token = System.get_env("TYPETALK_TOKEN")
topic_id = System.get_env("TYPETALK_TOPIC_ID")
{:ok, res} = Typetalk.post_message(token, topic_id, "hey")

Using client credential

client_id = System.get_env("TYPETALK_CLIENT_ID")
client_secret = System.get_env("TYPETALK_CLIENT_SECRET")
scope = "my,topic.read,topic.post"
{:ok, access_token} = Typetalk.ClientCredentail.access_token(client_id, client_secret, scope)
{:ok, spaces} = Typetalk.get_spaces(access_token)

Using authorization code

Take the user to the authorization page.

client_id = System.get_env("TYPETALK_CLIENT_ID")
redirect_url = "https://example.com/oauth_callback"
scope = "my,topic.read,topic.post"
url = Typetalk.AuthorizationCode.authorization_url(client_id, redirect_url, scope)

Use the published authorization token (auth_code in the example below) to get an access token.

client_id = System.get_env("TYPETALK_CLIENT_ID")
client_secret = System.get_env("TYPETALK_CLIENT_SECRET")
{:ok, access_token} = Typetalk.AuthorizationCode.access_token(client_id, client_secret, auth_code)
{:ok, spaces} = Typetalk.get_spaces(access_token)
You can’t perform that action at this time.