View Source ExPipedrive.Filters (ex_pipedrive v0.2.0)

API v1 client for Pipedrive filters.

Filters remain on /api/v1/filters; there is no /api/v2 equivalent yet. All functions here explicitly route to api_version: :v1.

Conditions

:conditions is passed through as a plain map (not a typed struct) matching Pipedrive's nested AND/OR condition-group JSON shape. It requires a minimum structure of one first-level group glued with "and", containing exactly two second-level groups — one glued "and", the other "or":

%{
  "glue" => "and",
  "conditions" => [
    %{
      "glue" => "and",
      "conditions" => [
        %{
          "object" => "deal",
          "field_id" => 12_456,
          "operator" => ">",
          "value" => 1000,
          "extra_value" => nil
        }
      ]
    },
    %{"glue" => "or", "conditions" => []}
  ]
}

Example

{:ok, filter} =
  ExPipedrive.Filters.create(client, %{
    name: "High value deals",
    type: "deals",
    conditions: conditions
  })

{:ok, filters} = ExPipedrive.Filters.list(client, type: "deals")
{:ok, filter} = ExPipedrive.Filters.get(client, filter.id)
{:ok, filter} = ExPipedrive.Filters.update(client, filter.id, %{name: "Renamed"})
{:ok, :ok} = ExPipedrive.Filters.delete(client, filter.id)

Summary

Functions

Creates a filter via POST /api/v1/filters.

Deletes a filter via DELETE /api/v1/filters/:id.

Fetches a filter by id via GET /api/v1/filters/:id.

Lists filters via GET /api/v1/filters.

Updates a filter via PUT /api/v1/filters/:id.

Functions

@spec create(Tesla.Client.t(), map()) ::
  {:ok, ExPipedrive.Filter.t()} | {:error, ExPipedrive.Error.t()}

Creates a filter via POST /api/v1/filters.

Accepts a map with :name, :conditions, and :type (required by Pipedrive). Returns {:ok, %Filter{}}.

Link to this function

delete(client, filter_id)

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

Deletes a filter via DELETE /api/v1/filters/:id.

Returns {:ok, :ok}.

@spec get(Tesla.Client.t(), pos_integer()) ::
  {:ok, ExPipedrive.Filter.t()} | {:error, ExPipedrive.Error.t()}

Fetches a filter by id via GET /api/v1/filters/:id.

Returns {:ok, %Filter{}}.

Link to this function

list(client, opts \\ [])

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

Lists filters via GET /api/v1/filters.

Accepts an optional :type option ("deals", "leads", "org", "people", "products", "activity", "projects") to scope results.

Returns {:ok, [%Filter{}]}.

Link to this function

update(client, filter_id, attrs)

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

Updates a filter via PUT /api/v1/filters/:id.

Accepts a map of :name and/or :conditions. Returns {:ok, %Filter{}}.