View Source ExPipedrive.Webhook.Event (ex_pipedrive v0.2.0)

A normalized Pipedrive webhook event.

from_payload/1 accepts:

  • Webhooks v1 — top-level "event" ("updated.deal", "added.organization", …) with "current" / "previous" bodies
  • Webhooks v2"meta.action" + "meta.entity" with "data" / "previous" (no top-level event name; one is synthesized as "action.entity")
  • v2-ish aliases"event_type" / "event_name", and "resource.action" order ("person.updated")

Event type matrix

Actions

APIActions
v1added, updated, deleted, merged
v2create, change, delete
aliascreated (treated like a first-class action token)

Typed resources (decoded when a matching entity module exists)

Resource keyStruct
dealExPipedrive.Deal
personExPipedrive.Person
organizationExPipedrive.Organization
activityExPipedrive.Activity
leadExPipedrive.Lead
noteExPipedrive.Note
productExPipedrive.Product
pipelineExPipedrive.Pipeline
stageExPipedrive.Stage
userExPipedrive.User
activityTypeExPipedrive.ActivityType
deal_productExPipedrive.DealProduct
deal_installmentExPipedrive.DealInstallment
projectExPipedrive.Project
taskExPipedrive.Task
boardExPipedrive.ProjectBoard

Unknown resources (e.g. phase) keep current / previous as maps. The full delivery is always available on :raw. Deletes typically have current: nil and a populated previous (decoded when typed).

Event structs stay in core so API-only apps can decode webhook payloads without Plug. Mount ExPipedriveWeb.Incoming.Handler from the optional ex_pipedrive_web package to receive POSTs.

Summary

Functions

Normalizes a Pipedrive webhook payload into an event.

Resource keys that decode into entity structs.

Types

@type resource_payload() :: struct() | map() | nil
@type t() :: %ExPipedrive.Webhook.Event{
  action: String.t() | nil,
  current: resource_payload(),
  diff: map(),
  meta: map(),
  name: String.t(),
  previous: resource_payload(),
  raw: map(),
  resource: String.t() | nil
}

Functions

@spec from_payload(map()) :: {:ok, t()} | {:error, :invalid_payload}

Normalizes a Pipedrive webhook payload into an event.

@spec typed_resources() :: [String.t()]

Resource keys that decode into entity structs.

Other resources remain maps on :current / :previous.