Skip to content

takuji/typetalk-elixir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.ClientCredential.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)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages