Class: Assistant::MicrosoftAdsChangePayload

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
app/services/assistant/microsoft_ads_change_payload.rb

Overview

Canonicalizes a Microsoft Ads mutation for approval binding and display.
Equivalent inputs (for example +0.40+ and +0.4+, or reordered keyword
lists) produce the same attributes and digest.

Defined Under Namespace

Classes: InvalidPayload, Result

Constant Summary collapse

WRITE_TOOLS =
%w[
  microsoft_ads_update_campaign
  microsoft_ads_update_ad_group
  microsoft_ads_add_negative_keywords
].freeze
PAYLOAD_KEYS =
{
  'microsoft_ads_update_campaign' => %i[campaign_id daily_budget max_cpc status],
  'microsoft_ads_update_ad_group' => %i[campaign_id ad_group_id cpc_bid status],
  'microsoft_ads_add_negative_keywords' => %i[campaign_id keywords match_type]
}.freeze

Instance Method Summary collapse

Methods included from Service

#attributes_used, #build_result, call, #logger

Methods included from Service::Initializer

#initialize

Instance Method Details

#callObject



32
33
34
35
36
37
38
39
# File 'app/services/assistant/microsoft_ads_change_payload.rb', line 32

def call
  normalized = normalize_payload
  Result.new(
    attributes: normalized,
    digest: Digest::SHA256.hexdigest(JSON.generate(normalized)),
    summary: summary(normalized)
  )
end