Creatio.OData (creatio v0.3.1)

Copy Markdown

Client implementation for Creatio OData 4 protocol endpoints (/0/odata/).

Provides CRUD operations, field-level access, streams, pagination, and batching.

Summary

Functions

Executes an OData batch request.

Gets the total count of an entity collection.

Same as count/3, but raises Creatio.Error on failure.

Creates a new entity record (POST /0/odata/{Entity}).

Deletes an entity record (DELETE /0/odata/{Entity}({id})).

Deletes a specific field of an entity (DELETE /0/odata/{Entity}({id})/{Field}).

Executes an OData query or entity listing. Alias for list/3.

Retrieves a single entity by its primary ID (GET /0/odata/{Entity}({id})).

Same as get/4, but raises Creatio.Error on failure.

Retrieves a specific field value by ID (GET /0/odata/{Entity}({id})/{Field}).

Retrieves the raw scalar or stream value of a field (GET /0/odata/{Entity}({id})/{Field}/$value).

Retrieves related records via a navigation property (GET /0/odata/{Entity}({id})/{Property}).

Queries an entity collection (GET /0/odata/{Entity}).

Returns a lazy Stream that paginates through records of the given entity or query.

Updates an existing entity record (PATCH /0/odata/{Entity}({id})).

Updates a specific field or binary stream (PUT /0/odata/{Entity}({id})/{Field}).

Functions

batch(client_or_req, batch_or_requests, opts \\ [])

Executes an OData batch request.

batch!(client, batch_or_requests, opts \\ [])

Same as batch/3, but raises Creatio.Error on failure.

count(client_or_req, entity, opts \\ [])

@spec count(Creatio.Client.t() | Req.Request.t(), String.t(), keyword()) ::
  {:ok, integer()} | {:error, Creatio.Error.t()}

Gets the total count of an entity collection.

Supports:

  • Option 1 (default): GET /0/odata/{Entity}/$count
  • Option 2: GET /0/odata/{Entity}?$count=true&$top=0 (when :strategy is :top_zero)

Accepts optional :filter.

count!(client, entity, opts \\ [])

Same as count/3, but raises Creatio.Error on failure.

create(client_or_req, entity, attrs, opts \\ [])

@spec create(Creatio.Client.t() | Req.Request.t(), String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, Creatio.Error.t()}

Creates a new entity record (POST /0/odata/{Entity}).

create!(client, entity, attrs, opts \\ [])

Same as create/4, but raises Creatio.Error on failure.

delete(client_or_req, entity, id, opts \\ [])

@spec delete(Creatio.Client.t() | Req.Request.t(), String.t(), String.t(), keyword()) ::
  :ok | {:error, Creatio.Error.t()}

Deletes an entity record (DELETE /0/odata/{Entity}({id})).

delete!(client, entity, id, opts \\ [])

Same as delete/4, but raises Creatio.Error on failure.

delete_field(client_or_req, entity, id, field_name, opts \\ [])

@spec delete_field(
  Creatio.Client.t() | Req.Request.t(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  :ok | {:error, Creatio.Error.t()}

Deletes a specific field of an entity (DELETE /0/odata/{Entity}({id})/{Field}).

delete_field!(client, entity, id, field_name, opts \\ [])

Same as delete_field/5, but raises Creatio.Error on failure.

execute(client_or_req, entity_or_query, opts \\ [])

Executes an OData query or entity listing. Alias for list/3.

execute!(client_or_req, entity_or_query, opts \\ [])

Same as execute/3, but raises Creatio.Error on failure.

get(client_or_req, entity, id, opts \\ [])

@spec get(Creatio.Client.t() | Req.Request.t(), String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Creatio.Error.t()}

Retrieves a single entity by its primary ID (GET /0/odata/{Entity}({id})).

Options

  • :select - Fields to select.
  • :expand - Relations to expand.

get!(client, entity, id, opts \\ [])

Same as get/4, but raises Creatio.Error on failure.

get_field(client_or_req, entity, id, field_name, opts \\ [])

@spec get_field(
  Creatio.Client.t() | Req.Request.t(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, any()} | {:error, Creatio.Error.t()}

Retrieves a specific field value by ID (GET /0/odata/{Entity}({id})/{Field}).

get_field!(client, entity, id, field_name, opts \\ [])

Same as get_field/5, but raises Creatio.Error on failure.

get_field_value(client_or_req, entity, id, field_name)

@spec get_field_value(
  Creatio.Client.t() | Req.Request.t(),
  String.t(),
  String.t(),
  String.t()
) ::
  {:ok, binary()} | {:error, Creatio.Error.t()}

Retrieves the raw scalar or stream value of a field (GET /0/odata/{Entity}({id})/{Field}/$value).

get_field_value!(client, entity, id, field_name)

Same as get_field_value/4, but raises Creatio.Error on failure.

get_navigation(client_or_req, entity, id, nav_property, opts \\ [])

@spec get_navigation(
  Creatio.Client.t() | Req.Request.t(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) :: {:ok, any()} | {:error, Creatio.Error.t()}

Retrieves related records via a navigation property (GET /0/odata/{Entity}({id})/{Property}).

get_navigation!(client, entity, id, nav_property, opts \\ [])

Same as get_navigation/5, but raises Creatio.Error on failure.

list(client_or_req, entity_or_query, opts \\ [])

@spec list(
  Creatio.Client.t() | Req.Request.t(),
  String.t() | Creatio.OData.Query.t(),
  keyword() | map()
) :: {:ok, list() | map()} | {:error, Creatio.Error.t()}

Queries an entity collection (GET /0/odata/{Entity}).

Accepts either a %Creatio.OData.Query{} or a keyword list of options.

Options

  • :select - List or comma-separated string of fields to retrieve.
  • :filter - OData filter string.
  • :orderby - Ordering string or list.
  • :top - Limit integer.
  • :skip - Offset integer.
  • :expand - Related entities to expand.
  • :count - When true, requests @odata.count inline.
  • :params - Map of additional query params.

list!(client_or_req, entity_or_query, opts \\ [])

Same as list/3, but raises Creatio.Error on failure.

stream(client_or_req, entity_or_query, opts \\ [])

Returns a lazy Stream that paginates through records of the given entity or query.

Options

  • :page_size - Number of records per page (default: 100).
  • :skip - Initial offset to begin streaming from (default: 0).
  • :select - Fields to select.
  • :filter - Filter expression.
  • :orderby - Ordering expression.
  • :expand - Expanded relations.

update(client_or_req, entity, id, attrs, opts \\ [])

@spec update(
  Creatio.Client.t() | Req.Request.t(),
  String.t(),
  String.t(),
  map(),
  keyword()
) ::
  :ok | {:ok, map()} | {:error, Creatio.Error.t()}

Updates an existing entity record (PATCH /0/odata/{Entity}({id})).

update!(client, entity, id, attrs, opts \\ [])

Same as update/5, but raises Creatio.Error on failure.

update_field(client_or_req, entity, id, field_name, value, opts \\ [])

@spec update_field(
  Creatio.Client.t() | Req.Request.t(),
  String.t(),
  String.t(),
  String.t(),
  any(),
  keyword()
) :: :ok | {:error, Creatio.Error.t()}

Updates a specific field or binary stream (PUT /0/odata/{Entity}({id})/{Field}).

update_field!(client, entity, id, field_name, value, opts \\ [])

Same as update_field/6, but raises Creatio.Error on failure.