class Bing::Ads::API::SOAPClient
Attributes
account_id[RW]
authentication_token[RW]
client_settings[RW]
customer_id[RW]
developer_token[RW]
namespace_identifier[RW]
password[RW]
savon_client[RW]
username[RW]
wsdl_url[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/bing/ads/api/soap_client.rb, line 10 def initialize(options) @customer_id = options[:customer_id] @account_id = options[:account_id] @developer_token = options[:developer_token] @wsdl_url = options[:wsdl_url] @namespace_identifier = options[:namespace_identifier] @authentication_token = options[:authentication_token] @username = options[:username] @password = options[:password] @client_settings = options[:client_settings] @log_level = options[:log_level] || :error end
Public Instance Methods
call(operation:, payload: {})
click to toggle source
# File lib/bing/ads/api/soap_client.rb, line 23 def call(operation:, payload: {}) client(client_settings).call(operation, message: payload) end
client(settings)
click to toggle source
# File lib/bing/ads/api/soap_client.rb, line 27 def client(settings) return savon_client if savon_client settings = { convert_request_keys_to: :camelcase, wsdl: wsdl_url, namespace_identifier: namespace_identifier, soap_header: soap_header, log: true, log_level: @log_level, pretty_print_xml: true } settings.merge!(client_settings) if client_settings @savon_client = Savon.client(settings) end
Private Instance Methods
ns(string)
click to toggle source
# File lib/bing/ads/api/soap_client.rb, line 62 def ns(string) "#{namespace_identifier}:#{string}" end
soap_header()
click to toggle source
# File lib/bing/ads/api/soap_client.rb, line 43 def soap_header headers = {} if authentication_token headers[ns('AuthenticationToken')] = authentication_token headers[ns('CustomerAccountId')] = account_id headers[ns('CustomerId')] = customer_id headers[ns('DeveloperToken')] = developer_token elsif username && password headers[ns('CustomerAccountId')] = account_id headers[ns('CustomerId')] = customer_id headers[ns('DeveloperToken')] = developer_token headers[ns('UserName')] = username headers[ns('Password')] = password else raise Errors::AuthenticationParamsMissing, 'no authentication params provided' end headers end