View Source ExPipedrive.Fields (ex_pipedrive v0.1.0)

Resolves Pipedrive custom-field hashes and human-readable labels.

Fetch definitions with ExPipedrive.DealFields.list_page/2, ExPipedrive.PersonFields.list_page/2, or ExPipedrive.OrganizationFields.list_page/2. API v2 calls the hash a field_code; it is the key used in an entity's custom_fields map.

For example:

{:ok, page} = ExPipedrive.DealFields.list_page(client)
{:ok, "a31aaf5e2c4843027e1e183d7001686afb9781d0"} =
  ExPipedrive.Fields.key_for(page, "Customer tier")

{:ok, "Customer tier"} =
  ExPipedrive.Fields.label_for(
    page,
    "a31aaf5e2c4843027e1e183d7001686afb9781d0"
  )

resolve/2 accepts a %ExPipedrive.Page{}, legacy %ExPipedrive.PagedResult{}, a list, or a map whose values are field definitions. It returns the matching definition for either its field_code (legacy key) or field_name (legacy name).

Summary

Functions

Returns the custom-field hash (field_code) for a field label or code.

Returns the human-readable field label for a field hash/code or label.

Finds a field definition by its field hash/code or human-readable label.

Types

@type collection() ::
  ExPipedrive.Page.t()
  | ExPipedrive.PagedResult.t()
  | [field()]
  | %{optional(term()) => field()}
@type field() :: ExPipedrive.Field.t() | map()

Functions

@spec key_for(collection(), String.t() | atom()) :: {:ok, String.t()} | :error

Returns the custom-field hash (field_code) for a field label or code.

Link to this function

label_for(fields, value)

View Source
@spec label_for(collection(), String.t() | atom()) :: {:ok, String.t()} | :error

Returns the human-readable field label for a field hash/code or label.

@spec resolve(collection(), String.t() | atom()) :: {:ok, field()} | :error

Finds a field definition by its field hash/code or human-readable label.

Field codes take precedence over labels when the same string could identify both. Returns :error when no definition matches.