class SoapyBing::Service
Constants
- DEFAULT_GLOBALS
Attributes
account[R]
customer[R]
oauth_credentials[R]
savon_client[R]
Public Class Methods
ad_insight(options = {})
click to toggle source
Prefer to define methods for each service explicitly rubocop:disable all
# File lib/soapy_bing/service.rb, line 15 def ad_insight (options = {}); build(:ad_insight, options); end
build(bing_ads_service, options)
click to toggle source
rubocop:enable all
# File lib/soapy_bing/service.rb, line 23 def build(bing_ads_service, options) new( options.merge( savon_globals: DEFAULT_GLOBALS.merge( wsdl: local_wsdl_path_for(bing_ads_service) ).merge(options.fetch(:savon_globals, {})) ) ) end
bulk(options = {})
click to toggle source
# File lib/soapy_bing/service.rb, line 16 def bulk (options = {}); build(:bulk, options); end
campaign_management(options = {})
click to toggle source
# File lib/soapy_bing/service.rb, line 17 def campaign_management(options = {}); build(:campaign_management, options); end
customer_billing(options = {})
click to toggle source
# File lib/soapy_bing/service.rb, line 18 def customer_billing (options = {}); build(:customer_billing, options); end
customer_management(options = {})
click to toggle source
# File lib/soapy_bing/service.rb, line 19 def customer_management(options = {}); build(:customer_management, options); end
local_wsdl_path_for(service, sandbox: false)
click to toggle source
# File lib/soapy_bing/service.rb, line 33 def local_wsdl_path_for(service, sandbox: false) if sandbox || ENV['BING_ADS_SANDBOX'] == '1' File.expand_path(File.join(__dir__, '..', '..', 'spec', 'wsdl', "#{service}.wsdl")) else File.expand_path(File.join(__dir__, 'wsdl', "#{service}.wsdl")) end end
new(oauth_credentials: {}, customer: {}, account: {}, savon_globals: {}, &block)
click to toggle source
# File lib/soapy_bing/service.rb, line 44 def initialize(oauth_credentials: {}, customer: {}, account: {}, savon_globals: {}, &block) @oauth_credentials = SoapyBing::OauthCredentials.new(oauth_credentials) @customer = SoapyBing::Customer.new(customer) @account = SoapyBing::Account.new(account) if account_id?(account) @savon_client = Savon::Client.new(savon_globals, &block) end
reporting(options = {})
click to toggle source
# File lib/soapy_bing/service.rb, line 20 def reporting (options = {}); build(:reporting, options); end
Public Instance Methods
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/soapy_bing/service.rb, line 51 def method_missing(method, *args, &block) operation?(method) ? call(method, args.first, &block) : super end
respond_to_missing?(method, *_)
click to toggle source
Calls superclass method
# File lib/soapy_bing/service.rb, line 55 def respond_to_missing?(method, *_) operation?(method) || super end
Private Instance Methods
account_id?(account)
click to toggle source
# File lib/soapy_bing/service.rb, line 65 def account_id?(account) account.fetch(:account_id, ENV['BING_ADS_ACCOUNT_ID']) end
call(operation_name, message, &block)
click to toggle source
# File lib/soapy_bing/service.rb, line 69 def call(operation_name, message, &block) ServiceOperation.new(self, operation_name).call(message, &block) end
operation?(method)
click to toggle source
# File lib/soapy_bing/service.rb, line 61 def operation?(method) savon_client.operations.include?(method) end