Class: BingAdsApi::CustomerManagement

Inherits:
Service
  • Object
show all
Defined in:
lib/bing-ads-api/service/customer_management.rb

Overview

Public : This class represents the Customer Management Services defined in the Bing Ads API, to manage customer accounts

Author

[email protected]

Examples

options = {
  :environment => :sandbox,
  :username => "username",
  :password => "pass",
  :developer_token => "SOME_TOKEN",
  :customer_id => "1234567",
  :account_id => "9876543" }
service = BingAdsApi::CustomerManagement.new(options)

Constant Summary

Constants inherited from Service

Service::LOGGER

Instance Attribute Summary

Attributes inherited from Service

#client_proxy, #environment

Instance Method Summary collapse

Methods inherited from Service

#call, #get_response_hash

Constructor Details

#initialize(options = {}) ⇒ CustomerManagement

Public : Constructor

Author

[email protected]

options - Hash with the parameters for the client proxy and the environment

Examples

options = {
  :environment => :sandbox,
  :username => "username",
  :password => "password",
  :developer_token => "DEV_TOKEN",
  :customer_id => "123456",
  :account_id => "654321"
}
service = BingAdsApi::CustomerManagement.new(options)


38
39
40
# File 'lib/bing-ads-api/service/customer_management.rb', line 38

def initialize(options={})
  super(options)
end

Instance Method Details

#get_accounts_info(customer_id = nil, only_parent_accounts = false) ⇒ Object

Public : Gets a list of objects that contains account identification information, for example the name and identifier of the account, for the specified customer.

Author

[email protected]

Parameters

customer_id - identifier for the customer who owns the accounts. If nil, then the authentication customer id is used only_parent_accounts - boolean to determine whether to return only the accounts that belong to the customer or to also return the accounts that the customer manages for other customers. Default false

Examples

customer_management_service.get_accounts_info 
# => Array[BingAdsApi::AccountsInfo]
Returns

Array of BingAdsApi::AccountsInfo

Raises

exception



64
65
66
67
68
69
70
71
72
73
# File 'lib/bing-ads-api/service/customer_management.rb', line 64

def get_accounts_info(customer_id=nil, only_parent_accounts=false)
  response = call(:get_accounts_info, 
    {customer_id: customer_id || self.client_proxy.customer_id, 
    only_parent_accounts: only_parent_accounts.to_s})
  response_hash = get_response_hash(response, __method__)
  accounts = response_hash[:accounts_info][:account_info].map do ||
    BingAdsApi::AccountInfo.new()
  end
  return accounts
end