Picnic.Resources.Deliveries (Picnic v0.1.0)

Copy Markdown View Source

Past and upcoming deliveries.

{:ok, all} = Picnic.deliveries(client)
{:ok, done} = Picnic.deliveries(client, filters: ["COMPLETED"])

Listing is a POST and the status filter travels in the request body, not as a query parameter — a quirk of the API, not of this library.

The list returns summaries: the same shape as a full delivery but with some fields left out, so they come back nil. Use get/3 on an id from the list when you need the complete record.

Deliveries are also where placed orders live — get/3 returns them under "orders". Picnic has no endpoint that fetches an order by its own id, so this is the route to one.

Summary

Functions

Fetches one delivery by id, in full rather than as a summary. Pass as: :struct to decode into a Picnic.Schema.Delivery.

Lists deliveries, as summaries.

Fetches the live position of a delivery. Always a plain map — the shape of this payload changes too often to be worth a struct.

Types

result()

@type result() :: {:ok, term()} | {:error, Picnic.Error.t()}

Functions

get(client, delivery_id, opts \\ [])

@spec get(Picnic.Client.t(), String.t(), keyword()) :: result()

Fetches one delivery by id, in full rather than as a summary. Pass as: :struct to decode into a Picnic.Schema.Delivery.

list(client, opts \\ [])

@spec list(
  Picnic.Client.t(),
  keyword()
) :: result()

Lists deliveries, as summaries.

Options: :filters — a list of status strings (e.g. ["COMPLETED"]) sent as the request body; empty for all — plus :as and request options.

position(client, delivery_id, opts \\ [])

@spec position(Picnic.Client.t(), String.t(), keyword()) :: result()

Fetches the live position of a delivery. Always a plain map — the shape of this payload changes too often to be worth a struct.