Creatio.Client (creatio v0.3.1)

Copy Markdown

Client struct and configuration for communicating with Creatio CRM APIs.

Wraps a Req.Request pre-configured with the base URL, authentication headers, read-only safety guards, and content negotiation required by Creatio.

Summary

Functions

Ensures that the input is a %Creatio.Client{}, converting a %Req.Request{} if necessary.

Sets an OAuth 2.0 Bearer token on the client.

Sets Forms authentication cookies and BPMCSRF token on the client.

Sets a custom header on the client's underlying Req.Request.

Returns the underlying configured Req.Request from the client.

Types

t()

@type t() :: %Creatio.Client{
  auth_mode: :none | :bearer | :forms | nil,
  auth_token: String.t() | nil,
  base_url: String.t(),
  bpmcsrf: String.t() | nil,
  client_id: String.t() | nil,
  client_secret: String.t() | nil,
  cookie: String.t() | nil,
  identity_service_url: String.t() | nil,
  options: keyword(),
  read_only: boolean(),
  req: Req.Request.t()
}

Functions

ensure_client(client)

@spec ensure_client(t() | Req.Request.t()) :: t()

Ensures that the input is a %Creatio.Client{}, converting a %Req.Request{} if necessary.

from_req(req, opts \\ [])

@spec from_req(Req.Request.t(), keyword() | map()) :: t()

Builds a Creatio.Client from an existing Req.Request.

new(opts \\ [])

@spec new(keyword() | map() | Req.Request.t()) :: t()

Creates a new Creatio.Client.

Can accept a keyword list of options, a map of options, or an existing Req.Request.

Options

  • :base_url - The base URL of your Creatio instance (e.g., "https://myinstance.creatio.com").
  • :auth_token - An OAuth 2.0 Bearer access token.
  • :cookie - Cookie string for Forms authentication (e.g. ".ASPXAUTH=...; BPMLOADER=...").
  • :bpmcsrf - The BPMCSRF token for Forms authentication.
  • :identity_service_url - Identity service base URL for OAuth 2.0.
  • :client_id - OAuth 2.0 client ID.
  • :client_secret - OAuth 2.0 client secret.
  • :read_only - If true, enables defense-in-depth read-only mode to prevent mutation requests (defaults to false, or Application.get_env(:creatio, :read_only), or CREATIO_READ_ONLY env var).
  • :req_options - Extra keyword options forwarded to Req.new/1 (e.g. :plug, :retry, etc.).

put_bearer_token(client, token)

@spec put_bearer_token(t(), String.t()) :: t()

Sets an OAuth 2.0 Bearer token on the client.

put_forms_auth(client, cookie, bpmcsrf \\ nil)

@spec put_forms_auth(t(), String.t(), String.t() | nil) :: t()

Sets Forms authentication cookies and BPMCSRF token on the client.

put_header(client, name, value)

@spec put_header(t(), String.t(), String.t()) :: t()

Sets a custom header on the client's underlying Req.Request.

to_req(client)

@spec to_req(t()) :: Req.Request.t()

Returns the underlying configured Req.Request from the client.