Inttegro.PurchaseIntents (inttegro v0.2.0)

Copy Markdown View Source

Creates and manages public purchasing opportunities.

A purchase intent describes what may be bought and can produce an order when a buyer accepts it. It is distinct from the resulting order: update or cancel the intent before acceptance, then use the Orders API for payment and fulfillment state.

Summary

Functions

Stops a Buy link from creating new orders immediately. Cancellation is an explicit merchant action and is distinct from time-driven expiry. Repeating cancellation for an already inactive intent returns its current state, but a single-use intent that already created an order cannot be canceled. This operation supports idempotency. Reuse the same Idempotency-Key and request body when retrying an uncertain request.

Creates a controlled, shareable Buy link for a catalog product without requiring you to build a product page, cart, or checkout UI. The returned sale_... ID becomes https://pages.inttegro.com/buy/{purchase_intent_id}. An order is created only when a customer checks out from that link. This operation supports idempotency. Reuse the same Idempotency-Key and request body when retrying an uncertain request.

Resolves the offer behind a hosted Buy link using only its opaque ID. Public lookup requires no API key and returns active or expired intents; canceled and used single-use intents are returned as not found. When the owning application authenticates the request, lookup is application-scoped, returns all lifecycle states, and may include recent activity.

Lists purchase intents for the authenticated application, newest first. Pagination is numbered. The response page.size is the number of records actually returned, not the requested limit, and no total count or next-page token is included.

Changes quantity bounds or expiry without changing what an already-shared Buy link sells. reactivate: true clears cancellation state and any existing elapsed expiry. Product, price, usage mode, and variant selection remain immutable after creation. This operation supports idempotency. Reuse the same Idempotency-Key and request body when retrying an uncertain request.

Functions

cancel(client, request, options \\ [])

Stops a Buy link from creating new orders immediately. Cancellation is an explicit merchant action and is distinct from time-driven expiry. Repeating cancellation for an already inactive intent returns its current state, but a single-use intent that already created an order cannot be canceled. This operation supports idempotency. Reuse the same Idempotency-Key and request body when retrying an uncertain request.

Parameters

Returns

Returns {:ok, Inttegro.PurchaseIntents.PurchaseIntent.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.PurchaseIntents.CancelRequest.new!(request_attributes)

case Inttegro.PurchaseIntents.cancel(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end

create(client, request, options \\ [])

Creates a controlled, shareable Buy link for a catalog product without requiring you to build a product page, cart, or checkout UI. The returned sale_... ID becomes https://pages.inttegro.com/buy/{purchase_intent_id}. An order is created only when a customer checks out from that link. This operation supports idempotency. Reuse the same Idempotency-Key and request body when retrying an uncertain request.

Parameters

Returns

Returns {:ok, Inttegro.PurchaseIntents.PurchaseIntent.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.PurchaseIntents.CreateRequest.new!(request_attributes)

case Inttegro.PurchaseIntents.create(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end

lookup(client, request, options \\ [])

Resolves the offer behind a hosted Buy link using only its opaque ID. Public lookup requires no API key and returns active or expired intents; canceled and used single-use intents are returned as not found. When the owning application authenticates the request, lookup is application-scoped, returns all lifecycle states, and may include recent activity.

Parameters

Returns

Returns {:ok, Inttegro.PurchaseIntents.PurchaseIntent.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.PurchaseIntents.LookupRequest.new!(request_attributes)

case Inttegro.PurchaseIntents.lookup(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end

page(client, request, options \\ [])

Lists purchase intents for the authenticated application, newest first. Pagination is numbered. The response page.size is the number of records actually returned, not the requested limit, and no total count or next-page token is included.

Parameters

Returns

Returns {:ok, Inttegro.PurchaseIntents.Page.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.PurchaseIntents.PageRequest.new!(request_attributes)

case Inttegro.PurchaseIntents.page(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end

update(client, request, options \\ [])

Changes quantity bounds or expiry without changing what an already-shared Buy link sells. reactivate: true clears cancellation state and any existing elapsed expiry. Product, price, usage mode, and variant selection remain immutable after creation. This operation supports idempotency. Reuse the same Idempotency-Key and request body when retrying an uncertain request.

Parameters

Returns

Returns {:ok, Inttegro.PurchaseIntents.PurchaseIntent.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.PurchaseIntents.UpdateRequest.new!(request_attributes)

case Inttegro.PurchaseIntents.update(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end