Class: BingAdsApi::PerformanceReportRequest

Inherits:
ReportRequest show all
Includes:
Helpers::ColumnHelper, Helpers::FilterHelper, Helpers::TimeHelper
Defined in:
lib/bing-ads-api/data/reporting/performance_report_request.rb

Overview

Public : Defines the base class for ‘performance report requests’. Do not instantiate this object. Instead, use BingAdsApi::AccountPerformanceReportRequest, BingAdsApi::CampaignPerformanceReportRequest, BingAdsApi::AdGroupPerformanceReportRequest or BingAdsApi::AdPerformanceReportRequest

Reference: msdn.microsoft.com/en-us/library/bing-ads-reporting-bing-ads-reportrequest.aspx

Author

[email protected]

Constant Summary collapse

AGGREGATIONS =

Valid aggregations for reports

BingAdsApi::Config.instance.
reporting_constants['aggregation']

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 collapse

Attributes inherited from ReportRequest

#format, #language, #report_name, #return_only_complete_data

Instance Method Summary collapse

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

#time_to_hash, #valid_time

Methods inherited from DataObject

#to_s

Constructor Details

#initialize(attributes = {}) ⇒ PerformanceReportRequest

Public : Constructor. Adds validations to aggregations and time

Author

[email protected]

Parameters

attributes - Hash with Performance report request

Raises:

  • (Exception)


41
42
43
44
45
# File 'lib/bing-ads-api/data/reporting/performance_report_request.rb', line 41

def initialize(attributes={})
	raise Exception.new("Invalid aggregation '#{attributes[:aggregation]}'") if !valid_aggregation(attributes[:aggregation])
	raise Exception.new("Invalid time") if !valid_time(attributes[:time])
	super(attributes)
end

Instance Attribute Details

#aggregationObject

Returns the value of attribute aggregation.



31
32
33
# File 'lib/bing-ads-api/data/reporting/performance_report_request.rb', line 31

def aggregation
  @aggregation
end

#columnsObject

Returns the value of attribute columns.



31
32
33
# File 'lib/bing-ads-api/data/reporting/performance_report_request.rb', line 31

def columns
  @columns
end

#filterObject

Returns the value of attribute filter.



31
32
33
# File 'lib/bing-ads-api/data/reporting/performance_report_request.rb', line 31

def filter
  @filter
end

#scopeObject

Returns the value of attribute scope.



31
32
33
# File 'lib/bing-ads-api/data/reporting/performance_report_request.rb', line 31

def scope
  @scope
end

#timeObject

Returns the value of attribute time.



31
32
33
# File 'lib/bing-ads-api/data/reporting/performance_report_request.rb', line 31

def time
  @time
end

Instance Method Details

#to_hash(keys_case = :underscore) ⇒ Object

Public

Returns this object as a Hash for SOAP Requests

Author

[email protected]

Parameters

  • keys_case - specifies the case for the hash keys

keys_case

  • :camelcase - CamelCase

  • :underscore - underscore_case

Examples

performance_report_request.to_hash(:camelcase) 
# => {"Format"=>"Xml", "Language"=>"English", "ReportName"=>"My Report", "Aggregation"=>"Hourly", "Time"=>"Today", "ReturnOnlyCompleteData"=>false}
Returns

Hash



63
64
65
66
67
68
# File 'lib/bing-ads-api/data/reporting/performance_report_request.rb', line 63

def to_hash(keys_case = :underscore)
	hash = super(keys_case)
	hash[get_attribute_key('aggregation', keys_case)] = AGGREGATIONS[self.aggregation.to_s]
	hash[get_attribute_key('time', keys_case)] = time_to_hash(keys_case)
	return hash
end