Class: Marketing::Audiences::PinterestAdapter
- Inherits:
-
Object
- Object
- Marketing::Audiences::PinterestAdapter
- Defined in:
- app/services/marketing/audiences/pinterest_adapter.rb
Overview
Pinterest Customer-List Audiences adapter. Two-step model: a customer_list
(hashed emails) wrapped by a CUSTOMER_LIST audience. Idempotent by NAME —
find-or-create the list, then ensure an audience wraps it.
EMAIL-only: a Pinterest customer list takes ONE identifier type and has no
phone type (it matches on email + mobile ad IDs, which we don't hold).
Dormant until opted in: #enabled? requires pinterest.audience_sync_enabled
(plus creds). The daily reconcile is LIVE and the standard Pinterest token
is ads:read — customer-list writes need ads:write.
ponytail: ADD-only refresh — a daily run APPENDS the current consented
snapshot to the list (Pinterest dedups). Opt-out REMOVAL is deferred: it
needs the prior-member set to diff (Pinterest has no replace primitive). Add
a purge_suppressed that REMOVEs suppressed hashes when compliance needs it.
Pinterest also requires ≥100 members and processes asynchronously (≤48h).
Constant Summary collapse
- MIN_MEMBERS =
Pinterest's minimum customer-list size; smaller audiences are skipped.
100
Instance Method Summary collapse
-
#enabled? ⇒ Boolean
True when opted in and creds are present.
-
#initialize(validate_only: true, client: nil) ⇒ PinterestAdapter
constructor
A new instance of PinterestAdapter.
-
#label ⇒ String
Platform key, matching
ad_platformsvalues. -
#reconcile(audience) ⇒ Hash
A small result summary.
Constructor Details
#initialize(validate_only: true, client: nil) ⇒ PinterestAdapter
Returns a new instance of PinterestAdapter.
31 32 33 34 |
# File 'app/services/marketing/audiences/pinterest_adapter.rb', line 31 def initialize(validate_only: true, client: nil) @validate_only = validate_only @client = client end |
Instance Method Details
#enabled? ⇒ Boolean
Returns true when opted in and creds are present.
40 41 42 43 |
# File 'app/services/marketing/audiences/pinterest_adapter.rb', line 40 def enabled? config(:audience_sync_enabled).to_b && config(:ad_account_id).present? && config(:advertiser_access_token).present? end |
#label ⇒ String
Returns platform key, matching ad_platforms values.
37 |
# File 'app/services/marketing/audiences/pinterest_adapter.rb', line 37 def label = 'pinterest' |
#reconcile(audience) ⇒ Hash
Returns a small result summary.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/services/marketing/audiences/pinterest_adapter.rb', line 47 def reconcile(audience) hashes = email_hashes(audience) return { audience: audience.key, members: 0, skipped: 'no hashable emails' } if hashes.empty? return { audience: audience.key, members: hashes.size, validate_only: true } if @validate_only if hashes.size < MIN_MEMBERS return { audience: audience.key, members: hashes.size, skipped: "below Pinterest #{MIN_MEMBERS}-member minimum" } end records = hashes.join(',') list_id = ensure_customer_list(audience, records) ensure_audience(audience, list_id) { audience: audience.key, customer_list_id: list_id, members: hashes.size } end |