Class: BingAdsApi::AdGroup

Inherits:
DataObject show all
Includes:
AdDistribution, AdGroupStatus, AdLanguage, AdRotationType, BiddingModel, PricingModel
Defined in:
lib/bing-ads-api/data/ad_group.rb

Overview

Public : Defines an ad group.

Author

[email protected]

Examples

ad_group = BingAdsApi::AdGroup.new(
  :ad_distribution => BingAdsApi::AdGroup::SEARCH,
  :language => BingAdsApi::AdGroup::SPANISH,
  :name => "Ad Group name",
  :pricing_model => BingAdsApi::AdGroup::CPC,
  :bidding_model => BingAdsApi::AdGroup::KEYWORD) 
# => <BingAdsApi::AdGroup>

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DataObject

#to_s

Methods included from SOAPHasheable

#date_to_hash, #get_attribute_key, #normalize_hash_keys, #object_to_hash

Constructor Details

#initialize(attributes = {}) ⇒ AdGroup

Public : Constructor in a ActiveRecord style, with a hash of attributes as input

Author

[email protected]

attributes - Hash with the objects attributes



52
53
54
55
# File 'lib/bing-ads-api/data/ad_group.rb', line 52

def initialize(attributes={})
	super(attributes)
	set_custom_attributes(attributes)
end

Instance Attribute Details

#ad_distributionObject

Returns the value of attribute ad_distribution.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def ad_distribution
  @ad_distribution
end

#ad_rotationObject

Returns the value of attribute ad_rotation.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def ad_rotation
  @ad_rotation
end

#bidding_modelObject

Returns the value of attribute bidding_model.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def bidding_model
  @bidding_model
end

#broad_match_bidObject

Returns the value of attribute broad_match_bid.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def broad_match_bid
  @broad_match_bid
end

#content_match_bidObject

Returns the value of attribute content_match_bid.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def content_match_bid
  @content_match_bid
end

#end_dateObject

Returns the value of attribute end_date.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def end_date
  @end_date
end

#exact_match_bidObject

Returns the value of attribute exact_match_bid.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def exact_match_bid
  @exact_match_bid
end

#idObject

Returns the value of attribute id.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def id
  @id
end

#languageObject

Returns the value of attribute language.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def language
  @language
end

#nameObject

Returns the value of attribute name.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def name
  @name
end

#phrase_match_bidObject

Returns the value of attribute phrase_match_bid.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def phrase_match_bid
  @phrase_match_bid
end

#pricing_modelObject

Returns the value of attribute pricing_model.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def pricing_model
  @pricing_model
end

#start_dateObject

Returns the value of attribute start_date.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def start_date
  @start_date
end

#statusObject

Returns the value of attribute status.



26
27
28
# File 'lib/bing-ads-api/data/ad_group.rb', line 26

def status
  @status
end

Instance Method Details

#to_hash(keys = :underscore) ⇒ Object

Public : Returns this object as a hash to SOAP requests This methods is a specialization for the DataObject#to_hash method that ads specific hash keys for the AdGroup object

Author

[email protected]

keys - specifies the keys case: CamelCase or underscore_case

Returns

Hash



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/bing-ads-api/data/ad_group.rb', line 67

def to_hash(keys = :underscore)
	hash = super(keys)
	
	amount_key = get_attribute_key("amount", keys)
	if self.content_match_bid
		#hash.delete(:content_match_bid)
		hash[get_attribute_key("content_match_bid", keys)] = {amount_key => self.content_match_bid}
	end 
	
	if self.exact_match_bid
		hash[get_attribute_key("exact_match_bid", keys)] = {amount_key => self.exact_match_bid}
	end
	
	if self.phrase_match_bid
		hash[get_attribute_key("phrase_match_bid", keys)] = {amount_key => self.phrase_match_bid}
	end
	
	if self.broad_match_bid
		hash[get_attribute_key("broad_match_bid", keys)] = {amount_key => self.broad_match_bid}
	end
	
	if self.start_date
		hash[get_attribute_key("start_date", keys)] = date_to_hash(self.start_date, keys)
	end
	
	if self.end_date
		hash[get_attribute_key("end_date", keys)] = date_to_hash(self.end_date, keys)
	end
	
	return hash
end