Knock (Knock v0.4.0) View Source

Official SDK for interacting with Knock.

Example usage

As a module

The recommended way to configure Knock is as a module in your application. Doing so will allow you to customize the options via configuration in your app.

# lib/my_app/knock.ex

defmodule MyApp.Knock do
  use Knock, otp_app: :my_app

# config/runtime.exs

config :my_app, MyApp.KnockClient,
  api_key: System.get_env("KNOCK_API_KEY")

In your application you can now execute commands on your configured Knock instance.

client = MyApp.Knock.client()
{:ok, user} = Knock.Users.get_user(client, "user_1")

Invoking directly

Optionally you can forgo implementing your own Knock module and create client instances manually:

client = "sk_test_12345")

Customizing options

Out of the box the client will specify Tesla and Jason as the HTTP adapter and JSON client, respectively. However, you can customize this at will:

config :my_app, Knock,
  adapter: Tesla.Adapter.Finch,
  json_client: JSX

You can read more about the availble adapters in the Tesla documentation

Link to this section Summary


Issues a notify call, triggering a workflow with the given key.

Link to this section Functions

Link to this function

notify(client, key, properties)

View Source

Issues a notify call, triggering a workflow with the given key.