Ussd.Configurator behaviour (Ussd v0.2.0)

Copy Markdown View Source

Groups repeated Ussd.use_*/2 setup so it can be shared across controllers/entry points instead of copy-pasted.

defmodule MyApp.UssdConfigurator do
  @behaviour Ussd.Configurator

  @impl Ussd.Configurator
  def configure(ussd) do
    ussd
    |> Ussd.use_response(&Ussd.Responses.AfricasTalking.respond/3)
    |> Ussd.use_exception_handler(&MyApp.UssdErrors.handle/1)
  end
end

Ussd.build(context)
|> Ussd.use_configurator(MyApp.UssdConfigurator)
|> Ussd.use_initial_state(MyApp.States.Welcome)
|> Ussd.run()

Summary

Callbacks

Applies this configurator's setup to ussd and returns the updated builder.

Callbacks

configure(t)

@callback configure(Ussd.t()) :: Ussd.t()

Applies this configurator's setup to ussd and returns the updated builder.