Class: Marketing::Audiences::GoogleAdapter

Inherits:
Object
  • Object
show all
Defined in:
app/services/marketing/audiences/google_adapter.rb

Overview

Google Customer Match adapter — a thin face over the prod-proven
CustomerMatch::AudienceSync (delta add/refresh) and
CustomerMatch::AudienceRemoval (delta remove). It hands AudienceSync the
audience's stable key + name + resolved customer scope (the same engine the
legacy per-segment worker still drives).

Stateful/delta platform: it implements #purge_suppressed, so opt-outs are
actively removed from every list. Both Data Manager operations are
idempotent, so a daily add-refresh + removal is safe.

Instance Method Summary collapse

Constructor Details

#initialize(validate_only: true) ⇒ GoogleAdapter

Returns a new instance of GoogleAdapter.

Parameters:

  • validate_only (Boolean) (defaults to: true)

    true (default) dry-runs both operations



20
21
22
# File 'app/services/marketing/audiences/google_adapter.rb', line 20

def initialize(validate_only: true)
  @validate_only = validate_only
end

Instance Method Details

#enabled?Boolean

Enabled iff :google_data_manager credentials are complete — reuse the
client's own validation rather than re-checking keys here.

Returns:

  • (Boolean)


29
30
31
32
33
34
# File 'app/services/marketing/audiences/google_adapter.rb', line 29

def enabled?
  CustomerMatch::Client.new
  true
rescue Marketing::DataManager::Client::ConfigurationError
  false
end

#labelString

Returns platform key, matching ad_platforms values.

Returns:

  • (String)

    platform key, matching ad_platforms values



25
# File 'app/services/marketing/audiences/google_adapter.rb', line 25

def label = 'google'

#purge_suppressedMarketing::CustomerMatch::AudienceRemoval::Result

Remove opted-out/closed/bankrupt/guest/inactive members from EVERY list.
Called once per adapter (not per segment) by the runner.



51
52
53
# File 'app/services/marketing/audiences/google_adapter.rb', line 51

def purge_suppressed
  CustomerMatch::AudienceRemoval.call(validate_only: @validate_only)
end

#reconcile(audience) ⇒ Marketing::CustomerMatch::AudienceSync::Result

Add/refresh one audience's consented members into its user list.



40
41
42
43
44
45
# File 'app/services/marketing/audiences/google_adapter.rb', line 40

def reconcile(audience)
  CustomerMatch::AudienceSync.call(
    key: audience.key, name: audience.name,
    customer_scope: audience.customer_scope, validate_only: @validate_only
  )
end