Wechat v0.4.7 Wechat.Client

Client represents an API client.

Link to this section Summary

Functions

Encrypt message with encoding_aes_key.

Create client to consume Wechat API with config.

Sign jsapi with url.

Link to this section Types

Link to this type

t()

t() :: %Wechat.Client{
  access_token: binary() | nil,
  appid: binary() | nil,
  encoding_aes_key: binary() | nil,
  endpoint: binary(),
  secret: binary() | nil,
  token: binary() | nil
}

Link to this section Functions

Link to this function

access_token(map)

access_token(t()) :: binary()
Link to this function

encrypt_message(client, msg)

Encrypt message with encoding_aes_key.

Link to this function

get_token(client)

get_token(t()) :: {:ok, t()} | {:error, Wechat.Error.t()}
Link to this function

get_token!(client)

Link to this function

new(opts)

new(Keyword.t()) :: t()

Create client to consume Wechat API with config.

Example

iex> Wechat.Client.new(appid: "my_appid", secret: "my_secret")
%Wechat.Client{
  appid: "my_appid",
  secret: "my_secret",
  endpoint: "https://api.weixin.qq.com/"
}

iex> Wechat.Client.new(appid: "my_appid", secret: "my_secret", endpoint: "http://localhost")
%Wechat.Client{
  appid: "my_appid",
  secret: "my_secret",
  endpoint: "http://localhost/"
}
Link to this function

sign_jsapi(client, url)

sign_jsapi(t(), :binary) :: map()

Sign jsapi with url.

Link to this function

wechat_config_js(client, url, opts)

Configure JS-SDK.