Class: Google4R::Checkout::CommandXmlGenerator
- Inherits:
-
XmlGenerator
- Object
- XmlGenerator
- Google4R::Checkout::CommandXmlGenerator
- Defined in:
- lib/google4r/checkout/xml_generation.rb
Overview
Abstract super class for all CommandXmlGenerators It should never be instantiated directly
Direct Known Subclasses
AddMerchantOrderNumberCommandXmlGenerator, AddTrackingDataCommandXmlGenerator, ArchiveOrderCommandXmlGenerator, AuthorizeOrderCommandXmlGenerator, CancelOrderCommandXmlGenerator, ChargeOrderCommandXmlGenerator, CheckoutCommandXmlGenerator, DeliverOrderCommandXmlGenerator, ItemsCommandXmlGenerator, ProcessOrderCommandXmlGenerator, RefundOrderCommandXmlGenerator, SendBuyerMessageCommandXmlGenerator, UnarchiveOrderCommandXmlGenerator
Constant Summary collapse
- COMMAND_TO_TAG =
The list of command tag names
{ ChargeOrderCommand => 'charge-order', RefundOrderCommand => 'refund-order', CancelOrderCommand => 'cancel-order', AuthorizeOrderCommand => 'authorize-order', ProcessOrderCommand => 'process-order', AddMerchantOrderNumberCommand => 'add-merchant-order-number', DeliverOrderCommand => 'deliver-order', AddTrackingDataCommand => 'add-tracking-data', SendBuyerMessageCommand => 'send-buyer-message', ArchiveOrderCommand => 'archive-order', UnarchiveOrderCommand => 'unarchive-order', CreateOrderRecurrenceRequestCommand => 'create-order-recurrence-request', ShipItemsCommand => 'ship-items', BackorderItemsCommand => 'backorder-items', CancelItemsCommand => 'cancel-items', ReturnItemsCommand => 'return-items', ResetItemsShippingInformationCommand => 'reset-items-shipping-information' }
Instance Method Summary collapse
-
#generate ⇒ Object
Base method to generate the XML for a particular command.
-
#initialize(command) ⇒ CommandXmlGenerator
constructor
A new instance of CommandXmlGenerator.
- #tag_name_for_command(klass) ⇒ Object
Constructor Details
#initialize(command) ⇒ CommandXmlGenerator
Returns a new instance of CommandXmlGenerator.
79 80 81 82 83 84 85 |
# File 'lib/google4r/checkout/xml_generation.rb', line 79 def initialize(command) if COMMAND_TO_TAG.has_key?(command.class) @command = command else raise 'Cannot instantiate an abstract class.' end end |
Instance Method Details
#generate ⇒ Object
Base method to generate the XML for a particular command
88 89 90 91 92 93 94 |
# File 'lib/google4r/checkout/xml_generation.rb', line 88 def generate super self.process_command(@command) io = StringIO.new @document.write(io, 0) # TODO: Maybe replace 0 by -1 so no spaces are inserted? return io.string end |
#tag_name_for_command(klass) ⇒ Object
96 97 98 |
# File 'lib/google4r/checkout/xml_generation.rb', line 96 def tag_name_for_command(klass) COMMAND_TO_TAG[klass] end |