CampaignFlow.MockServer.Responses (CampaignFlow Client v2.2.0)

View Source

Standardized response builders for the mock Campaign Flow API.

Summary

Functions

Converts an Ecto.Changeset into the standard mock-server validation error list (one %{"field", "issue"} map per failure).

Sends a JSON response with the given status and data.

Sends a referral creation success response (201).

Sends a referral retrieval success response (200).

Sends a validation error response (422).

Functions

changeset_errors(changeset)

@spec changeset_errors(Ecto.Changeset.t()) :: [map()]

Converts an Ecto.Changeset into the standard mock-server validation error list (one %{"field", "issue"} map per failure).

error(conn, status, code, message \\ nil)

@spec error(Plug.Conn.t(), integer(), String.t(), String.t() | nil) :: Plug.Conn.t()

Sends an error response.

json(conn, status, data)

@spec json(Plug.Conn.t(), integer(), map() | list()) :: Plug.Conn.t()

Sends a JSON response with the given status and data.

referral_created(conn, referral)

@spec referral_created(Plug.Conn.t(), map()) :: Plug.Conn.t()

Sends a referral creation success response (201).

referral_success(conn, result)

@spec referral_success(Plug.Conn.t(), map()) :: Plug.Conn.t()

Sends a referral retrieval success response (200).

validation_error(conn, errors)

@spec validation_error(Plug.Conn.t(), list()) :: Plug.Conn.t()

Sends a validation error response (422).