Class: GoogleCheckout::AddTrackingData

Inherits:
OrderCommand show all
Defined in:
lib/google-checkout/command.rb

Overview

Tells Google tracking data for the order.

Constant Summary

Constants inherited from Command

Command::PRODUCTION_REQUEST_URL, Command::SANDBOX_REQUEST_URL

Instance Attribute Summary

Attributes inherited from OrderCommand

#amount, #google_order_number

Attributes inherited from Command

#currency, #merchant_id, #merchant_key

Instance Method Summary collapse

Methods inherited from Command

#post, #url, x509_store

Constructor Details

#initialize(merchant_id, merchant_key, google_order_number, carrier, tracking_number) ⇒ AddTrackingData

Returns a new instance of AddTrackingData.



169
170
171
172
173
174
175
# File 'lib/google-checkout/command.rb', line 169

def initialize(merchant_id, merchant_key, google_order_number, carrier, tracking_number)
  raise "Unknown carrier. Valid values are DHL, FedEx, UPS, USPS, and Other." unless ["DHL","FedEx","UPS","USPS","Other"].include? carrier

  @carrier = carrier
  @tracking_number = tracking_number
  super(merchant_id, merchant_key, google_order_number)
end

Instance Method Details

#to_xmlObject



177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/google-checkout/command.rb', line 177

def to_xml
  xml = Builder::XmlMarkup.new
  xml.instruct!
  @xml = xml.tag!('add-tracking-data', {
    :xmlns => "http://checkout.google.com/schema/2",
    "google-order-number" => @google_order_number
  }) do
    xml.tag!('tracking-data') do
      xml.tag!('carrier', @carrier)
      xml.tag!('tracking-number', @tracking_number)
    end
  end
  @xml
end