View Source ExPipedrive.Files (ex_pipedrive v0.2.0)

API v1 client for Pipedrive files (attachments).

Files remain on /api/v1/files (multipart upload). There is no /api/v2 equivalent yet — every function here uses api_version: :v1.

Uploads

Uploads use multipart/form-data via Tesla.Multipart. Associate a file with a deal, person, organization, activity, product, lead, or project by passing the corresponding id option to upload/4 / create/4.

Pipedrive enforces per-company file size limits (commonly up to ~50 MB per file — confirm in company settings). Request volume is subject to the usual API rate limits; clients already retry 429 via ExPipedrive.Middleware.Retry.

Downloads

download/2 calls GET /api/v1/files/:id/download and returns the raw body bytes. Metadata still includes a url that can be fetched with a plain HTTP GET when preferred.

Remote files (Google Drive)

create_remote/2 and remote_link/2 cover Pipedrive's Google Drive helpers (POST /files/remote and /files/remoteLink).

Example

{:ok, file} =
  ExPipedrive.Files.upload(client, "hello", "note.txt", deal_id: 1)

{:ok, files} = ExPipedrive.Files.list(client, deal_id: 1)
{:ok, file} = ExPipedrive.Files.get(client, file.id)
{:ok, binary} = ExPipedrive.Files.download(client, file.id)
{:ok, :ok} = ExPipedrive.Files.delete(client, file.id)

Summary

Functions

Uploads a file via POST /api/v1/files (multipart/form-data).

Creates an empty Google Drive file and links it via POST /api/v1/files/remote.

Deletes a file via DELETE /api/v1/files/:id.

Downloads file bytes via GET /api/v1/files/:id/download.

Fetches file metadata via GET /api/v1/files/:id.

Lists files via GET /api/v1/files.

Links an existing remote (Google Drive) file via POST /api/v1/files/remoteLink.

Updates file details via PUT /api/v1/files/:id.

Uploads a file via POST /api/v1/files (multipart/form-data).

Functions

Link to this function

create(client, content, filename, opts \\ [])

View Source
@spec create(Tesla.Client.t(), iodata(), String.t(), keyword()) ::
  {:ok, ExPipedrive.File.t()} | {:error, ExPipedrive.Error.t()}

Uploads a file via POST /api/v1/files (multipart/form-data).

Same as upload/4.

Link to this function

create_remote(client, attrs)

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

Creates an empty Google Drive file and links it via POST /api/v1/files/remote.

Required map keys (string or atom): file_type, title, item_type, item_id, remote_location (typically "googledrive").

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

Deletes a file via DELETE /api/v1/files/:id.

Returns {:ok, :ok}.

Link to this function

download(client, file_id)

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

Downloads file bytes via GET /api/v1/files/:id/download.

Returns {:ok, binary} on success.

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

Fetches file metadata via GET /api/v1/files/:id.

Link to this function

list(client, opts \\ [])

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

Lists files via GET /api/v1/files.

Options: :start, :limit (max 100), :sort (id, update_time), and association filters when supported by your Pipedrive plan (:deal_id, :person_id, :org_id, :product_id, :activity_id, :lead_id, :project_id).

Returns {:ok, %PagedResult{}}.

Link to this function

remote_link(client, attrs)

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

Links an existing remote (Google Drive) file via POST /api/v1/files/remoteLink.

Required map keys: item_type, item_id, remote_id, remote_location.

Link to this function

update(client, file_id, attrs)

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

Updates file details via PUT /api/v1/files/:id.

Accepts :name and/or :description.

Link to this function

upload(client, content, filename, opts \\ [])

View Source
@spec upload(Tesla.Client.t(), iodata(), String.t(), keyword()) ::
  {:ok, ExPipedrive.File.t()} | {:error, ExPipedrive.Error.t()}

Uploads a file via POST /api/v1/files (multipart/form-data).

content is the file body; filename is the original name sent as the multipart filename. Link options: :deal_id, :person_id, :org_id, :product_id, :activity_id, :lead_id, :project_id.