View Source CozyLark.EventSubscription (cozy_lark v0.4.1)
Provides utilities of handling event subscription.
- resolving the challenge request when configuring the request URL.
- transforming V2.0 events into
CozyLark.EventSubscription.Event
.
Read more at Subscribe to events.
WARNING
Only the V2.0 events are supported.
basic-concepts
Basic concepts
the-process-of-subscription
the process of subscription
- setup
verification_token
andencrypt_key
- configure the request URL
- add events
- apply for scopes
- receive and process events
Utilities provided by this module can be used at:
- step 2
- step 5
supported-events
supported events
The full list of events can be found at Getting Started - Event list.
usage
Usage
defmodule Demo.EventHandler do
alias CozyLark.EventSubscription
alias CozyLark.EventSubscriptionConfig
def process_event(payload) do
EventSubscription.receive_event(config(), payload,
security_verification_method: :verification_token
)
end
def config() do
:demo
|> Application.fetch_env!(__MODULE__)
|> Enum.into(%{})
|> Config.new!()
end
end
# config/runtime.exs
config :demo, Demo.EventHandler,
verification_token: System.fetch_env!("FEISHU_EVENT_SUBSCRIPTION_VERIFICATION_TOKEN")
encrypt_key: System.fetch_env!("FEISHU_EVENT_SUBSCRIPTION_ENCRYPT_KEY")
more-details
More details
Link to this section Summary
Link to this section Types
@type payload() :: map()
@type response() :: {:ok, {:challenge, String.t()}} | {:ok, {:event, CozyLark.EventSubscription.Event.t()}} | {:error, {:unknown_event, term()}} | {:error, :bad_verification_token} | {:error, :bad_signature}
Link to this section Functions
@spec receive_event( CozyLark.EventSubscription.Config.t(), payload(), CozyLark.EventSubscription.Opts.opts() ) :: response()