Class: BingAdsRubySdk::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/bing_ads_ruby_sdk/header.rb

Overview

Contains the SOAP Request header informations

Instance Method Summary collapse

Constructor Details

#initialize(developer_token:, client_id:, store:, client_secret: nil) ⇒ Header

Returns a new instance of Header.

Parameters:

  • developer_token
  • client_id
  • store

    instance of a store



9
10
11
12
13
14
15
# File 'lib/bing_ads_ruby_sdk/header.rb', line 9

def initialize(developer_token:, client_id:, store:, client_secret: nil)
  @developer_token = developer_token
  @client_id = client_id
  @client_secret = client_secret
  @oauth_store = store
  @customer = {}
end

Instance Method Details

#contentHash

Returns Authorization and identification data that will be added to the SOAP header.

Returns:

  • (Hash)

    Authorization and identification data that will be added to the SOAP header



18
19
20
21
22
23
24
25
26
27
# File 'lib/bing_ads_ruby_sdk/header.rb', line 18

def content
  {
    "AuthenticationToken" => auth_handler.fetch_or_refresh,
    "DeveloperToken" => developer_token,
    "CustomerId" => customer[:customer_id],
    "CustomerAccountId" => customer[:account_id]
  }.tap do |hash|
    hash["ClientSecret"] = client_secret if client_secret
  end
end

#set_customer(account_id:, customer_id:) ⇒ Object



29
30
31
32
33
# File 'lib/bing_ads_ruby_sdk/header.rb', line 29

def set_customer(account_id:, customer_id:)
  customer[:account_id] = 
  customer[:customer_id] = customer_id
  self
end