Class: BingAdsRubySdk::Services::Base

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(soap_client) ⇒ Base

Returns a new instance of Base.



11
12
13
# File 'lib/bing_ads_ruby_sdk/services/base.rb', line 11

def initialize(soap_client)
  @soap_client = soap_client
end

Class Method Details

.serviceObject



34
35
36
# File 'lib/bing_ads_ruby_sdk/services/base.rb', line 34

def self.service
  raise "implement me"
end

Instance Method Details

#call(operation_name, message = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bing_ads_ruby_sdk/services/base.rb', line 15

def call(operation_name, message = {})
  camelized_name = BingAdsRubySdk::StringUtils.camelize(operation_name.to_s)
  response = soap_client.call(
    camelized_name,
    preprocess(message, camelized_name)
  )
  processed_response = postprocess(response)
  BingAdsRubySdk::Errors::ErrorHandler.new(processed_response).call
  processed_response
rescue BingAdsRubySdk::Errors::GeneralError => e
  BingAdsRubySdk.log(:warn) { processed_response }
  raise e
end

#call_wrapper(action, message, *response_nesting) ⇒ Object



29
30
31
32
# File 'lib/bing_ads_ruby_sdk/services/base.rb', line 29

def call_wrapper(action, message, *response_nesting)
  response = call(action, message)
  wrap_array(dig_response(response, response_nesting))
end