Class: BingAdsApi::CampaignPerformanceReportRequest
- Inherits:
-
PerformanceReportRequest
- Object
- DataObject
- ReportRequest
- PerformanceReportRequest
- BingAdsApi::CampaignPerformanceReportRequest
- Defined in:
- lib/bing-ads-api/data/reporting/campaign_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::CampaignPerformanceReportRequest.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 => {
# specifies the Bing expected String value
:ad_distribution => "Search",
# specifies criteria as a snake case symbol
:device_os => :android,
:device_type => :tablet,
# criteria nil is similar to not specify it at all
:status => nil },
:scope => {
:account_ids => [123456, 234567],
:campaigns => [<BingAdsApi::CampaignReportScope>] },
# predefined date
:time => :this_week)
request2 = BingAdsApi::CampaignPerformanceReportRequest.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['campaign_performance_report']['columns']
- FILTERS =
Valid Filters for this report request
BingAdsApi::Config.instance. reporting_constants['campaign_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 = {}) ⇒ CampaignPerformanceReportRequest
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 = {}) ⇒ CampaignPerformanceReportRequest
Public : Constructor. Adds a validations for the columns, filter and scope attributes
- Author
Parameters
-
attributes
- Hash with the report request attributes
Example
request = BingAdsApi::CampaignPerformanceReportRequest.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 => {
# specifies the Bing expected String value
:ad_distribution => "Search",
# specifies criteria as a snake case symbol
:device_os => :android,
:device_type => :tablet,
# criteria nil is similar to not specify it at all
:status => nil },
:scope => {
:account_ids => [123456, 234567],
:campaigns => [<BingAdsApi::CampaignReportScope>] },
# predefined date
:time => :this_week)
request2 = BingAdsApi::CampaignPerformanceReportRequest.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} }
)
109 110 111 112 113 114 |
# File 'lib/bing-ads-api/data/reporting/campaign_performance_report_request.rb', line 109 def initialize(attributes={}) raise Exception.new("Invalid columns") if !valid_columns(COLUMNS, attributes[:columns]) raise Exception.new("Invalid filters") if !valid_filter(FILTERS, attributes[:filter]) raise Exception.new("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
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/bing-ads-api/data/reporting/campaign_performance_report_request.rb', line 125 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 |