View Source ExPipedrive.DealProducts (ex_pipedrive v0.2.0)

Pipedrive deal-products resource — products attached to a deal.

Nested under a deal id on API v2: /api/v2/deals/:id/products. Distinct from the catalog ExPipedrive.Products API.

Example

{:ok, page} = ExPipedrive.DealProducts.list_page(client, deal_id)

{:ok, attachment} =
  ExPipedrive.DealProducts.create(client, deal_id, %{
    product_id: 1,
    item_price: 90,
    quantity: 1
  })

{:ok, attachment} =
  ExPipedrive.DealProducts.update(client, deal_id, attachment.id, %{quantity: 2})

{:ok, :ok} = ExPipedrive.DealProducts.delete(client, deal_id, attachment.id)

Summary

Functions

Attaches a product to a deal via POST /api/v2/deals/:id/products.

Deletes one deal-product via DELETE /api/v2/deals/:id/products/:product_attachment_id.

Deletes many deal-products via DELETE /api/v2/deals/:id/products.

Fetches one deal-product by attachment id (client-side over stream/3).

Lists one page of products attached to a deal via GET /api/v2/deals/:id/products.

Lazily streams deal-products across v2 cursor pages.

Updates a deal-product via PATCH /api/v2/deals/:id/products/:product_attachment_id.

Functions

Link to this function

create(client, deal_id, attrs)

View Source
@spec create(Tesla.Client.t(), term(), map()) ::
  {:ok, ExPipedrive.DealProduct.t()} | {:error, ExPipedrive.Error.t()}

Attaches a product to a deal via POST /api/v2/deals/:id/products.

Requires :product_id, :item_price, and :quantity.

Link to this function

delete(client, deal_id, attachment_id)

View Source
@spec delete(Tesla.Client.t(), term(), term()) ::
  {:ok, :ok} | {:error, ExPipedrive.Error.t()}

Deletes one deal-product via DELETE /api/v2/deals/:id/products/:product_attachment_id.

Link to this function

delete_many(client, deal_id, opts \\ [])

View Source
@spec delete_many(Tesla.Client.t(), term(), keyword()) ::
  {:ok, [pos_integer()]} | {:error, ExPipedrive.Error.t()}

Deletes many deal-products via DELETE /api/v2/deals/:id/products.

Options: :ids — list of attachment ids (or comma-separated string). When omitted, Pipedrive deletes up to 100 attachments on the deal.

Returns {:ok, [id]} of deleted attachment ids.

Link to this function

get(client, deal_id, attachment_id)

View Source
@spec get(Tesla.Client.t(), term(), term()) ::
  {:ok, ExPipedrive.DealProduct.t()} | {:error, ExPipedrive.Error.t()}

Fetches one deal-product by attachment id (client-side over stream/3).

Pipedrive has no single-get endpoint for deal-products.

Link to this function

list_page(client, deal_id, opts \\ [])

View Source
@spec list_page(Tesla.Client.t(), term(), keyword()) ::
  {:ok, ExPipedrive.Page.t()} | {:error, ExPipedrive.Error.t()}

Lists one page of products attached to a deal via GET /api/v2/deals/:id/products.

Options: :cursor, :limit (clamped to 500), :sort_by, :sort_direction.

Link to this function

stream(client, deal_id, opts \\ [])

View Source
@spec stream(Tesla.Client.t(), term(), keyword()) :: Enumerable.t()

Lazily streams deal-products across v2 cursor pages.

Link to this function

update(client, deal_id, attachment_id, attrs)

View Source
@spec update(Tesla.Client.t(), term(), term(), map()) ::
  {:ok, ExPipedrive.DealProduct.t()} | {:error, ExPipedrive.Error.t()}

Updates a deal-product via PATCH /api/v2/deals/:id/products/:product_attachment_id.