Module: AdcenterApi::ApiConfig

Extended by:
AdsCommonForAdcenter::ApiConfig
Defined in:
lib/adcenter_api/api_config.rb,
lib/adcenter_api/version.rb

Overview

Contains helper methods for loading and managing the available services.

Constant Summary collapse

CLIENT_LIB_VERSION =
"0.0.4"
DEFAULT_VERSION =

Set defaults

:v8
DEFAULT_ENVIRONMENT =
:PRODUCTION
LATEST_VERSION =
:v8
API_NAME =

Set other constants

'AdcenterApi'
DEFAULT_CONFIG_FILENAME =
'adcenter_api.yml'
@@service_config =

Configure the services available to each version

{
  :v7 => [
      :AdministrationService,
      :CampaignManagementService,
      :CustomerBillingService,
      :CustomerManagementService,
      :NotificationService,
      :ReportingService
        ],
  :v8 => [
      :AdIntelligenceService,
      :AdministrationService,
      :BulkService,
      :CampaignManagementService,
      :CustomerBillingService,
      :CustomerManagementService,
      :NotificationService,
      :OptimizerService,
      :ReportingService
  ]
}
@@environment_config =

Configure the different environments, with the base URL for each one

{
  :PRODUCTION => {
    :oauth_scope => '',
    :header_ns => 'https://adcenter.microsoft.com/api/adcenter/',
    :v7 => '',
    :v8 => ''
  },
  :SANDBOX => {
    :oauth_scope => '',
    :header_ns => 'https://adcenter.microsoft.com/api/adcenter/',
    :v7 => '',
    :v8 => ''
  }
}
@@subdir_config =

Configure the subdirectories for each version / service pair. A missing pair means that only the base URL is used.

{}
@@address_config =
{
  :v8 => {
    :AdIntelligenceService     => {:PRODUCTION => "https://adcenterapi.microsoft.com/Api/Advertiser/v8/CampaignManagement/AdIntelligenceService.svc?wsdl", :SANDBOX => ""},
    :AdministrationService     => {:PRODUCTION => "https://adcenterapi.microsoft.com/Api/Advertiser/v8/Administration/AdministrationService.svc?wsdl",     :SANDBOX => ""},
    :BulkService               => {:PRODUCTION => "https://adcenterapi.microsoft.com/Api/Advertiser/v8/CampaignManagement/BulkService.svc?wsdl",           :SANDBOX => ""},
    :CampaignManagementService => {:PRODUCTION => "https://adcenterapi.microsoft.com/Api/Advertiser/v8/CampaignManagement/CampaignManagementService.svc?wsdl", :SANDBOX => ""},
    :CustomerBillingService    => {:PRODUCTION => "https://sharedservices.adcenterapi.microsoft.com/Api/Billing/v8/CustomerBillingService.svc?wsdl",       :SANDBOX => ""},
    :CustomerManagementService => {:PRODUCTION => "https://sharedservices.adcenterapi.microsoft.com/Api/CustomerManagement/v8/CustomerManagementService.svc?wsdl", :SANDBOX => ""},
    :NotificationService       => {:PRODUCTION => "https://sharedservices.adcenterapi.microsoft.com/Api/Notification/v8/NotificationService.svc?wsdl",     :SANDBOX => ""},
    :OptimizerService          => {:PRODUCTION => "https://adcenterapi.microsoft.com/Api/Advertiser/v8/Optimizer/OptimizerService.svc?wsdl",               :SANDBOX => ""},
    :ReportingService          => {:PRODUCTION => "https://adcenterapi.microsoft.com/Api/Advertiser/v8/Reporting/ReportingService.svc?wsdl",               :SANDBOX => ""}
  },
  :v7 => {
    :AdministrationService     => {:PRODUCTION => "https://adcenterapi.microsoft.com/Api/Advertiser/v7/Administration/AdministrationService.svc?wsdl",           :SANDBOX => "https://sandboxapi.adcenter.microsoft.com/Api/Advertiser/v7/Administration/AdministrationService.svc?wsdl"},
    :CampaignManagementService => {:PRODUCTION => "https://adcenterapi.microsoft.com/Api/Advertiser/v7/CampaignManagement/CampaignManagementService.svc?wsdl",   :SANDBOX => "https://sandboxapi.adcenter.microsoft.com/Api/Advertiser/v7/CampaignManagement/CampaignManagementService.svc?wsdl"},
    :CustomerBillingService    => {:PRODUCTION => "https://sharedservices.adcenterapi.microsoft.com/Api/Billing/v7/CustomerBillingService.svc?wsdl",             :SANDBOX => "https://sharedservices-sbx.adcenterapi.microsoft.com/Api/Billing/v7/CustomerBillingService.svc?wsdl"},
    :CustomerManagementService => {:PRODUCTION => "https://sharedservices.adcenterapi.microsoft.com/Api/CustomerManagement/v7/CustomerManagementService.svc?wsdl", :SANDBOX => "https://sharedservices-sbx.adcenterapi.microsoft.com/Api/CustomerManagement/v7/CustomerManagementService.svc?wsdl"},
    :NotificationService       => {:PRODUCTION => "https://sharedservices.adcenterapi.microsoft.com/Api/Notification/v8/NotificationService.svc?wsdl",           :SANDBOX => ""},
    :ReportingService          => {:PRODUCTION => "https://adcenterapi.microsoft.com/Api/Advertiser/v7/Reporting/ReportingService.svc?wsdl",                     :SANDBOX => "https://sandboxapi.adcenter.microsoft.com/Api/Advertiser/v7/Reporting/ReportingService.svc?wsdl"}
  }
}
@@client_login_config =

Auth constants for ClientLogin method. TODO: remove client_login_config

{
  :AUTH_SERVER => 'https://www.microsoft.com',
  :LOGIN_SERVICE_NAME => 'adcenter'
}

Class Method Summary collapse

Methods included from AdsCommonForAdcenter::ApiConfig

endpoint, get_wsdls

Class Method Details

.address_configObject



125
126
127
# File 'lib/adcenter_api/api_config.rb', line 125

def self.address_config
  @@address_config
end

.adhoc_report_download_url(environment, version) ⇒ Object

Get the download URL for Ad Hoc reports.

Args:

  • environment: the service environment to be used

  • version: the API version (as a symbol)

Returns:

  • The endpoint URL (as a string)



154
155
156
157
158
159
160
# File 'lib/adcenter_api/api_config.rb', line 154

def self.adhoc_report_download_url(environment, version)
  base = get_wsdl_base(environment, version)
  if base
    base += 'reportdownload/%s' % version.to_s
  end
  return base
end

.api_nameObject



112
113
114
# File 'lib/adcenter_api/api_config.rb', line 112

def self.api_name
  API_NAME
end

.client_login_config(key) ⇒ Object



133
134
135
# File 'lib/adcenter_api/api_config.rb', line 133

def self.(key)
  return @@client_login_config[key]
end

.default_config_filenameObject



137
138
139
# File 'lib/adcenter_api/api_config.rb', line 137

def self.default_config_filename
  DEFAULT_CONFIG_FILENAME
end

.default_environmentObject



104
105
106
# File 'lib/adcenter_api/api_config.rb', line 104

def self.default_environment
  DEFAULT_ENVIRONMENT
end

.default_versionObject

Getters for constants and module variables.



100
101
102
# File 'lib/adcenter_api/api_config.rb', line 100

def self.default_version
  DEFAULT_VERSION
end

.environment_config(environment, key) ⇒ Object



120
121
122
123
# File 'lib/adcenter_api/api_config.rb', line 120

def self.environment_config(environment, key)
  return @@environment_config.include?(environment) ?
      @@environment_config[environment][key] : nil
end

.headers_configObject



141
142
143
# File 'lib/adcenter_api/api_config.rb', line 141

def self.headers_config
  @@headers_config
end

.latest_versionObject



108
109
110
# File 'lib/adcenter_api/api_config.rb', line 108

def self.latest_version
  LATEST_VERSION
end

.service_configObject



116
117
118
# File 'lib/adcenter_api/api_config.rb', line 116

def self.service_config
  @@service_config
end

.subdir_configObject



129
130
131
# File 'lib/adcenter_api/api_config.rb', line 129

def self.subdir_config
  @@subdir_config
end