Creatio. Batch
(creatio v0.3.1)
Copy Markdown
Constructs and executes OData 4 batch requests (/0/odata/$batch).
Supports both JSON batch format (standard in OData 4) and multipart/mixed MIME format,
atomicity groups (changesets), and Prefer: continue-on-error.
Examples
JSON Batch (Default)
batch =
Creatio.Batch.new(continue_on_error: true)
|> Creatio.Batch.add_create("Contact", %{"Name" => "Alice"}, atomicity_group: "g1")
|> Creatio.Batch.add_update("Contact", "c31c7862-fe...", %{"JobTitle" => "VP"}, atomicity_group: "g1")
|> Creatio.Batch.add_delete("Contact", "b6a05348-55...")
{:ok, responses} = Creatio.Batch.execute(client, batch)Multipart/Mixed MIME Batch
{:ok, responses} = Creatio.Batch.execute(client, batch, format: :multipart)
Summary
Functions
Adds a generic request to the batch.
Adds an entity creation operation (POST /0/odata/{Entity}) to the batch.
Adds an entity deletion operation (DELETE /0/odata/{Entity}({id})) to the batch.
Adds an entity retrieval operation (GET /0/odata/...) to the batch.
Adds a single entity retrieval operation with options to the batch.
Adds an entity update operation (PATCH /0/odata/{Entity}({id})) to the batch.
Executes the batch request against the Creatio /0/odata/$batch endpoint.
Initializes a new batch request.
Parses a multipart/mixed MIME response body into a list of %Creatio.Batch.Response{} structs.
Serializes the batch to a multipart/mixed MIME body string.
Returns {boundary, body}.
Converts the batch to the JSON payload map expected by /0/odata/$batch.
Types
Functions
Adds a generic request to the batch.
Adds an entity creation operation (POST /0/odata/{Entity}) to the batch.
Adds an entity deletion operation (DELETE /0/odata/{Entity}({id})) to the batch.
Adds an entity retrieval operation (GET /0/odata/...) to the batch.
Can be used to retrieve:
- An entity collection or path:
add_get(batch, "Contact")oradd_get(batch, "Contact", headers: ...) - A single entity by ID:
add_get(batch, "Contact", "some-uuid")oradd_get(batch, "Contact", "some-uuid", headers: ...)
Adds a single entity retrieval operation with options to the batch.
Adds an entity update operation (PATCH /0/odata/{Entity}({id})) to the batch.
@spec execute( Creatio.Client.t() | Req.Request.t(), t() | map() | list() | binary(), keyword() ) :: {:ok, [Creatio.Batch.Response.t()]} | {:error, Creatio.Error.t()}
Executes the batch request against the Creatio /0/odata/$batch endpoint.
Options
:format-:json(default) or:multipart.:continue_on_error- boolean. Iftrue, setsPrefer: continue-on-error.:url- Overrides endpoint URL (defaults to"/0/odata/$batch").
When the client is in read-only mode (client.read_only == true), batches containing
mutation requests (POST, PATCH, PUT, DELETE) or binary batch payloads are rejected with
{:error, %Creatio.Error{status: 403, code: "ReadOnlyMode"}}.
Initializes a new batch request.
Options
:continue_on_error- boolean. Iftrue, adds headerPrefer: continue-on-error.
@spec parse_multipart_response(String.t(), String.t() | nil) :: {:ok, [Creatio.Batch.Response.t()]} | {:error, Creatio.Error.t()}
Parses a multipart/mixed MIME response body into a list of %Creatio.Batch.Response{} structs.
Serializes the batch to a multipart/mixed MIME body string.
Returns {boundary, body}.
Converts the batch to the JSON payload map expected by /0/odata/$batch.