class AdManagerApi::Api

Wrapper class that serves as the main point of access for all the API usage.

Holds all the services, as well as login credentials.

Attributes

utils_reporter[R]

Public Class Methods

new(provided_config = nil) click to toggle source

Constructor for API.

Calls superclass method
# File lib/ad_manager_api.rb, line 41
def initialize(provided_config = nil)
  super(provided_config)
  @credential_handler = AdManagerApi::CredentialHandler.new(@config)
  @utils_reporter = AdManagerApi::UtilsReporter.new(@credential_handler)
end

Public Instance Methods

api_config() click to toggle source

Getter for the API service configurations.

# File lib/ad_manager_api.rb, line 48
def api_config
  AdManagerApi::ApiConfig
end
date(*args) click to toggle source

Returns an instance of AdManagerDate.

# File lib/ad_manager_api.rb, line 67
def date(*args)
  return AdManagerApi::AdManagerDate.new(self, *args)
end
datetime(*args) click to toggle source

Returns an instance of AdManagerDateTime.

# File lib/ad_manager_api.rb, line 77
def datetime(*args)
  return AdManagerApi::AdManagerDateTime.new(self, *args)
end
new_report_statement_builder(&block) click to toggle source
# File lib/ad_manager_api.rb, line 57
def new_report_statement_builder(&block)
  statement = AdManagerApi::StatementBuilder.new(self) do |sb|
    sb.limit = nil
    sb.offset = nil
  end
  statement.configure(&block)
  return statement
end
new_statement_builder(&block) click to toggle source

Returns an instance of StatementBuilder object.

# File lib/ad_manager_api.rb, line 53
def new_statement_builder(&block)
  return AdManagerApi::StatementBuilder.new(self, &block)
end
now(*args) click to toggle source

Returns an instance of AdManagerDateTime representing the current time.

# File lib/ad_manager_api.rb, line 82
def now(*args)
  return AdManagerApi::AdManagerDateTime.now(self, *args)
end
today(*args) click to toggle source

Returns an instance of AdManagerDate representing the current day.

# File lib/ad_manager_api.rb, line 72
def today(*args)
  return AdManagerApi::AdManagerDate.today(self, *args)
end
utc(*args) click to toggle source

Returns an instance of AdManagerDateTime in the UTC timezone.

# File lib/ad_manager_api.rb, line 87
def utc(*args)
  return AdManagerApi::AdManagerDateTime.utc(self, *args)
end

Private Instance Methods

soap_header_handler(auth_handler, version, header_ns, default_ns) click to toggle source

Retrieve Ad Manager HeaderHandler per credential.

# File lib/ad_manager_api.rb, line 94
def soap_header_handler(auth_handler, version, header_ns, default_ns)
  auth_method = @config.read('authentication.method', :OAUTH2)
  handler_class  = case auth_method
    when :OAUTH2, :OAUTH2_SERVICE_ACCOUNT
      AdsCommon::SavonHeaders::OAuthHeaderHandler
    else
      raise AdsCommon::Errors::AuthError,
          "Unknown auth method: %s" % auth_method
  end
  return handler_class.new(@credential_handler, auth_handler, header_ns,
                           default_ns, version)
end