Class: Marketing::CustomerMatch::AudienceSync
- Inherits:
-
Object
- Object
- Marketing::CustomerMatch::AudienceSync
- Defined in:
- app/services/marketing/customer_match/audience_sync.rb
Overview
Syncs one audience's consent-eligible members into its Google Customer
Match user list via the Data Manager API: ensure-the-list → ingest-in-
batches. Takes a resolved audience — a stable key, a display name,
and an already consent-gated customer_scope — supplied by the Google
adapter from a Audiences::Target. Defaults to validate_only
(no real upload); a live run is BULK-OP GATED and the caller must opt in.
Defined Under Namespace
Classes: Result
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Result
-
#initialize(key:, name:, customer_scope:, validate_only: true, client: Client.new) ⇒ AudienceSync
constructor
A new instance of AudienceSync.
Constructor Details
#initialize(key:, name:, customer_scope:, validate_only: true, client: Client.new) ⇒ AudienceSync
Returns a new instance of AudienceSync.
29 30 31 32 33 34 35 |
# File 'app/services/marketing/customer_match/audience_sync.rb', line 29 def initialize(key:, name:, customer_scope:, validate_only: true, client: Client.new) @key = key.to_s @name = name.to_s @customer_scope = customer_scope @validate_only = validate_only @client = client end |
Class Method Details
.call ⇒ Result
22 |
# File 'app/services/marketing/customer_match/audience_sync.rb', line 22 def self.call(**) = new(**).call |
Instance Method Details
#call ⇒ Result
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/services/marketing/customer_match/audience_sync.rb', line 38 def call list_id = ensure_user_list request_ids = [] members = 0 MemberBuilder.new(@customer_scope).each_batch do |batch| request_ids << @client.ingest(user_list_id: list_id, members: batch, validate_only: @validate_only) members += batch.size end record.update!(last_synced_at: Time.current, last_member_count: members, last_request_id: request_ids.last) Result.new(key: @key, user_list_id: list_id, member_count: members, batches: request_ids.size, request_ids:, validate_only: @validate_only) end |