Class: BingAdsApi::ClientProxy

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

Overview

Public : ClientProxy es un objeto para encapsular la conexión y request

de servicios a la API de Bing. En su inicialización requiere los datos 
de autenticación y el WSDL al servicio que se requiere.
Author

[email protected]

Examples

# => hash con datos autenticación y WSDL 
options = {
  :username => "username",
  :password => "password",
  :developer_token => "THE_TOKEN",
  :customer_id => "123456",
  :account_id => "123456",
  :wsdl_url => "https://api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v9/CampaignManagementService.svc?singleWsdl"
}
# => Instancia de ClientProxy
client = BingAdsApi::ClientProxy.new(options)
# => Llamada a servicio 'GetCampaignsByAccountId'
response = client.service.call(:get_campaigns_by_account_id,
  message: { Account_id: client.})

Constant Summary collapse

NAMESPACE =

Public : Namespace para atributos bing. Hace referencia a la versión de API usada

:v9
KEYS_CASE =

Public : Case empleado los nombres de atributos en los XML

:camelcase

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ ClientProxy

Public : Constructor

Author

[email protected]

Parameters

options - Hash con valores de autenticación y WSDL

Options

  • username - Bing Ads username

  • passwrod - Bing Ads user’s sign-in password

  • developer_token - client application’s developer access token

  • customer_id - identifier for the customer that owns the account

  • account_id - identifier of the account that own the entities in the request

  • wsdl_url - URL for the WSDL to be called

  • proxy - Hash with any Savon Client additional options (such as header, logger or enconding)

Examples

options = {
  :username => "username",
  :password => "password",
  :developer_token => "THE_TOKEN",
  :customer_id => "123456",
  :account_id => "123456",
  :wsdl_url => "https://api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v9/CampaignManagementService.svc?singleWsdl"
}
# => Instancia de ClientProxy
client = BingAdsApi::ClientProxy.new(options)
Returns

ClientProxy instance



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/bing-ads-api/client_proxy.rb', line 68

def initialize(options=nil)
	if options
		if options[:authentication_token]
			@authentication_token ||= options[:authentication_token]
		else
			@username    ||= options[:username]
			@password    ||= options[:password]
		end
		@developer_token ||= options[:developer_token]
		@wsdl_url        ||= options[:wsdl_url]
		@account_id      ||= options[:account_id]
		@customer_id     ||= options[:customer_id]
		@namespace       ||= options[:namespace]
	end
	self.service = get_proxy(options[:proxy])
end

Instance Attribute Details

#account_idObject

Atributos del client proxy



36
37
38
# File 'lib/bing-ads-api/client_proxy.rb', line 36

def 
  @account_id
end

#authentication_tokenObject

Atributos del client proxy



36
37
38
# File 'lib/bing-ads-api/client_proxy.rb', line 36

def authentication_token
  @authentication_token
end

#customer_idObject

Atributos del client proxy



36
37
38
# File 'lib/bing-ads-api/client_proxy.rb', line 36

def customer_id
  @customer_id
end

#developer_tokenObject

Atributos del client proxy



36
37
38
# File 'lib/bing-ads-api/client_proxy.rb', line 36

def developer_token
  @developer_token
end

#namespaceObject

Atributos del client proxy



36
37
38
# File 'lib/bing-ads-api/client_proxy.rb', line 36

def namespace
  @namespace
end

#passwordObject

Atributos del client proxy



36
37
38
# File 'lib/bing-ads-api/client_proxy.rb', line 36

def password
  @password
end

#serviceObject

Atributos del client proxy



36
37
38
# File 'lib/bing-ads-api/client_proxy.rb', line 36

def service
  @service
end

#usernameObject

Atributos del client proxy



36
37
38
# File 'lib/bing-ads-api/client_proxy.rb', line 36

def username
  @username
end

#wsdl_urlObject

Atributos del client proxy



36
37
38
# File 'lib/bing-ads-api/client_proxy.rb', line 36

def wsdl_url
  @wsdl_url
end

Instance Method Details

#call(service_name, message, options = {}) ⇒ Object

Public : Delegate for Savon::Client.call method

Author

[email protected]

Parameters

service_name - Service to be called message - Message for the service options - Additional options for the service

Examples

client.call_service(:some_service_name, {key: value}) 
# => <Response>
Returns

Response from the Savon::Client

Raises

Savon::SOAPFault Savon::HTTPError Savon::InvalidResponseError



101
102
103
# File 'lib/bing-ads-api/client_proxy.rb', line 101

def call(service_name, message, options={})
	self.service.call(service_name, message)
end