Journey.Examples.CreditCardApplication (Journey v0.10.30)

This module demonstrates building a simple credit card application workflow using the Journey library.

You might find it interesting to read the actual source code of this example (the definition of the graph, and the "business logic" functions), but here is a doctest illustrating executing a credit card application workflow.

Examples:

iex> # The customer starts the application process and provides their personal information.
iex> import Journey.Node
iex> graph = Journey.Examples.CreditCardApplication.graph()
iex> execution = Journey.start_execution(graph)
iex>
iex> # This is only needed in a test, to perform background processing that happens automatically outside of tests.
iex> background_sweeps_task = Journey.Scheduler.Background.Periodic.start_background_sweeps_in_test(execution.id)
iex>
iex> execution = execution |> Journey.set_value(:full_name, "Mario")
iex> execution = execution |> Journey.set_value(:birth_date, "10/11/1981")
iex> execution = execution |> Journey.set_value(:ssn, "123-45-6789")
iex> execution = execution |> Journey.set_value(:email_address, "mario@example.com")
iex>
iex> # This kicks off the pre-approval process, which eventually completes.
iex> execution |> Journey.get_value(:preapproval_process_completed, wait_any: true)
{:ok, true}
iex> # We haven't heard from the customer, so we'll send a reminder in a few days (seconds;).
iex> execution |> Journey.get_value(:send_preapproval_reminder, wait_any: true)
{:ok, true}
iex>
iex> # Reminded, the customer requests an actual credit card.
iex> _execution = execution |> Journey.set_value(:credit_card_requested, true)
iex> # ... which triggers issuing the card.
iex>
iex> execution |> Journey.get_value(:initiate_credit_card_issuance, wait_any: true)
{:ok, true}
iex> execution |> Journey.values() |> redact([:schedule_request_credit_card_reminder, :execution_id, :last_updated_at])
%{
    preapproval_process_completed: true,
    birth_date: "10/11/1981",
    congratulate: "email_sent_congrats",
    preapproval_decision: "approved",
    credit_score: 800,
    email_address: "mario@example.com",
    full_name: "Mario",
    ssn: "<redacted>",
    ssn_redacted: "updated :ssn",
    credit_card_requested: true,
    initiate_credit_card_issuance: true,
    schedule_request_credit_card_reminder: 1234567890,
    execution_id: "...",
    last_updated_at: 1234567890
  }
iex>
iex> # Eventually, the fulfillment department marks the credit card as mailed.
iex> # Which triggers an email notifying the customer that the card has been mailed.
iex> execution = execution |> Journey.set_value(:credit_card_mailed, true)
iex> execution |> Journey.get_value(:credit_card_mailed_notification, wait_any: true)
{:ok, true}
iex> {:ok, _} = execution |> Journey.get_value(:archive, wait_any: true)
iex> # This is only needed in tests.
iex> Journey.Scheduler.Background.Periodic.stop_background_sweeps_in_test(background_sweeps_task)

Summary

Functions

This function defines the graph for the credit card application workflow.

Functions

graph()

This function defines the graph for the credit card application workflow.

The graph is defined as a list of nodes. Input nodes have a name. Computation nodes also have upstream dependencies and a function to compute the node's value, and a few other options.