View Source CozyLark.ServerSideAPI (cozy_lark v0.4.1)
Provides utilities of calling server-side API.
basic-concepts
Basic concepts
usage
Usage
First, setup a HTTP client by following:
Then, create a dedicated module according to your requirements:
defmodule Demo.GroupManager do
alias CozyLark.ServerSideAPI
alias CozyLark.ServerSideAPI.Config
def list_groups() do
config()
|> ServerSideAPI.build!(%{
access_token_type: :tenant_access_token,
method: "GET",
path: "/im/v1/chats"
})
|> ServerSideAPI.request()
end
defp config() do
:demo
|> Application.fetch_env!(__MODULE__)
|> Enum.into(%{})
|> Config.new!()
end
end
# config/runtime.exs
config :demo, Demo.GroupManager,
platform: :feishu,
app_type: :custom_app,
app_id: System.fetch_env!("FEISHU_APP_ID"),
app_secret: System.fetch_env!("FEISHU_APP_SECRET")
Link to this section Summary
Functions
Bulids a struct that represents a server-side API request.
Sends the server-side API request.
Link to this section Functions
@spec build!(CozyLark.ServerSideAPI.Config.t(), CozyLark.ServerSideAPI.Spec.config()) :: any()
Bulids a struct that represents a server-side API request.
See CozyLark.ServerSideAPI.Spec.build!/1
and CozyLark.ServerSideAPI.Request.build!/2
for more
information.
Sends the server-side API request.
Before sending the request, this function will try to set access token on the request automatically.