Class: BingAdsApi::AccountPerformanceReportRequest
- Inherits:
-
PerformanceReportRequest
- Object
- DataObject
- ReportRequest
- PerformanceReportRequest
- BingAdsApi::AccountPerformanceReportRequest
- Defined in:
- lib/bing-ads-api/data/reporting/account_performance_report_request.rb
Overview
Public : Defines the base object for all report requests. Do not instantiate this object. Instead, you may instantiate one of the following report request objects which derives from this object to request a report.
Reference: msdn.microsoft.com/en-us/library/bing-ads-reporting-bing-ads-reportrequest.aspx
- Author
Usage
request = BingAdsApi::AccountPerformanceReportRequest.new(
:format => :xml,
:language => :english,
:report_name => "Me report",
:aggregation => :hourly,
:columns => [:account_name, :account_number, :time_period],
# The filter is specified as a hash
:filter => {
:ad_distribution => :search,
:device_os => :android,
:device_type => :tablet,
:status => :submited },
:scope => {
:account_ids => [123456, 234567],
:campaigns => [<BingAdsApi::CampaignReportScope>] },
# predefined date
:time => :this_week)
request2 = BingAdsApi::AccountPerformanceReportRequest.new(
:format => :csv,
:language => :french,
:report_name => "Me report",
:aggregation => :daily,
:columns => [:account_name, :account_number, :time_period],
# no filter is specified
:scope => {
:account_ids => [123456, 234567],
:campaigns => [<BingAdsApi::CampaignReportScope>] },
# Custom date range
:time => {
:custom_date_range_start => {:day => 1, :month => 12, :year => 2013},
:custom_date_range_end => {:day => 12, :month => 12, :year => 2013} }
)
Constant Summary collapse
- COLUMNS =
Valid Columns for this report request
BingAdsApi::Config.instance. reporting_constants['account_performance_report']['columns']
- FILTERS =
Valid Filters for this report request
BingAdsApi::Config.instance. reporting_constants['account_performance_report']['filter']
Constants inherited from PerformanceReportRequest
PerformanceReportRequest::AGGREGATIONS
Constants included from Helpers::FilterHelper
Helpers::FilterHelper::FILTERS_CRITERIA
Constants included from Helpers::TimeHelper
Helpers::TimeHelper::TIME_PERIODS
Constants inherited from ReportRequest
ReportRequest::FORMATS, ReportRequest::LANGUAGES, ReportRequest::REQUEST_STATUS
Instance Attribute Summary
Attributes inherited from PerformanceReportRequest
#aggregation, #columns, #filter, #scope, #time
Attributes inherited from ReportRequest
#format, #language, #report_name, #return_only_complete_data
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ AccountPerformanceReportRequest
constructor
Public : Constructor.
-
#to_hash(keys = :underscore) ⇒ Object
- Public
-
Returns the object as a Hash valid for SOAP requests .
Methods included from Helpers::FilterHelper
#filter_to_hash, #solve_filter_value, #valid_filter, #valid_filter_value
Methods included from SOAPHasheable
#date_to_hash, #get_attribute_key, #normalize_hash_keys, #object_to_hash
Methods included from Helpers::ColumnHelper
#columns_to_hash, #valid_columns
Methods included from Helpers::TimeHelper
Methods inherited from DataObject
Constructor Details
#initialize(attributes = {}) ⇒ AccountPerformanceReportRequest
Public : Constructor. Adds a validations for the columns, filter and scope attributes
- Author
Parameters
attributes - Hash with the report request attributes
Example
request = BingAdsApi::AccountPerformanceReportRequest.new(
:format => :xml,
:language => :english,
:report_name => "Me report",
:aggregation => :hourly,
:columns => [:account_name, :account_number, :time_period],
# The filter is specified as a hash
:filter => {
:ad_distribution => :search,
:device_os => :android,
:device_type => :tablet,
:status => :submited },
:scope => {
:account_ids => [123456, 234567],
:campaigns => [<BingAdsApi::CampaignReportScope>] },
# predefined date
:time => :this_week)
request2 = BingAdsApi::AccountPerformanceReportRequest.new(
:format => :csv,
:language => :french,
:report_name => "Me report",
:aggregation => :daily,
:columns => [:account_name, :account_number, :time_period],
# no filter is specified
:scope => {
:account_ids => [123456, 234567],
:campaigns => [<BingAdsApi::CampaignReportScope>] },
# Custom date range
:time => {
:custom_date_range_start => {:day => 1, :month => 12, :year => 2013},
:custom_date_range_end => {:day => 12, :month => 12, :year => 2013} }
)
103 104 105 106 107 108 |
# File 'lib/bing-ads-api/data/reporting/account_performance_report_request.rb', line 103 def initialize(attributes={}) raise "Invalid columns" if !valid_columns(COLUMNS, attributes[:columns]) raise "Invalid filters" if !valid_filter(FILTERS, attributes[:filter]) raise "Invalid scope" if !valid_scope(attributes[:scope]) super(attributes) end |
Instance Method Details
#to_hash(keys = :underscore) ⇒ Object
- Public
-
Returns the object as a Hash valid for SOAP requests
- Author
Parameters
-
keys_case
- case for the hashes keys: underscore or camelcase
- Returns
-
Hash
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/bing-ads-api/data/reporting/account_performance_report_request.rb', line 118 def to_hash(keys = :underscore) hash = super(keys) hash[get_attribute_key('columns', keys)] = columns_to_hash(COLUMNS, columns, keys) hash[get_attribute_key('filter', keys)] = filter_to_hash(FILTERS, keys) hash[get_attribute_key('scope', keys)] = scope_to_hash(keys) hash["@xsi:type"] = type_attribute_for_soap return hash end |