Class: Sem4r::ManualCPMAdGroupBids

Inherits:
AdGroupBids show all
Defined in:
lib/sem4r/ad_group/ad_group_bids.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AdGroupBids

#initialize, #to_s

Methods included from Sem4rSoap::SoapAttributes

#_from_element, #_to_s, #_to_xml, included

Constructor Details

This class inherits a constructor from Sem4r::AdGroupBids

Class Method Details

.from_element(el) ⇒ Object



159
160
161
162
163
164
165
166
167
# File 'lib/sem4r/ad_group/ad_group_bids.rb', line 159

def self.from_element(el)
  new do
    kel = el.xpath("maxCpm").first
    if kel
      el_amount = kel.xpath("amount").first
      max_cpm     el_amount.xpath("microAmount").first.text.strip.to_i
    end
  end
end

Instance Method Details

#to_xml(builder = nil) ⇒ Object



154
155
156
157
# File 'lib/sem4r/ad_group/ad_group_bids.rb', line 154

def to_xml(builder = nil)
  builder = Builder::XmlMarkup.new unless builder
  xml(builder)
end

#xml(t) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/sem4r/ad_group/ad_group_bids.rb', line 141

def xml(t)
  return "" unless @max_cpm
  t.tag!('bids', 'xsi:type' => 'ManualCPMAdGroupBids') { |xml|
    xml.tag!('AdGroupBids.Type') { xml.text! 'ManualCPMAdGroupBids' }
    xml.maxCpm {
      xml.amount {
        xml.tag!('ComparableValue.Type') { xml.text! 'Money' }
        xml.microAmount max_cpm
      }
    }
  }
end