Wechat v0.4.0 Wechat.Client

Client represents an API client.

Link to this section Summary

Link to this section Types

Link to this type

auth()
auth() :: %{appid: binary(), secret: binary()} | %{access_token: binary()}

Link to this type

t()
t() :: %Wechat.Client{auth: auth() | nil, endpoint: binary()}

Link to this section Functions

Link to this function

access_token(map)
access_token(auth()) :: binary()

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(auth)
new(auth()) :: t()

Create client to consume Wechat API with auth.

Examples

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

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

new(auth, endpoint)
new(auth(), binary()) :: t()