Class: Google4R::Checkout::CommandXmlGenerator

Inherits:
XmlGenerator
  • Object
show all
Defined in:
lib/google4r/checkout/xml_generation.rb

Overview

Abstract super class for all CommandXmlGenerators It should never be instantiated directly

Constant Summary collapse

COMMAND_TO_TAG =

The list of command tag names

{
  ChargeAndShipOrderCommand => "charge-and-ship-order",
  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',
  OrderReportCommand => 'order-list-request',
  NotificationHistoryRequestCommand => 'notification-history-request',
  NotificationDataTokenRequestCommand => 'notification-data-token-request',
  NotificationDataRequestCommand => 'notification-data-request'
}

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ CommandXmlGenerator

Returns a new instance of CommandXmlGenerator.



84
85
86
87
88
89
90
# File 'lib/google4r/checkout/xml_generation.rb', line 84

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

#generateObject

Base method to generate the XML for a particular command



93
94
95
96
97
98
99
# File 'lib/google4r/checkout/xml_generation.rb', line 93

def generate
  super
  self.process_command(@command)
  io = StringIO.new
  @document.write(io, -1)
  return io.string
end

#tag_name_for_command(klass) ⇒ Object



101
102
103
# File 'lib/google4r/checkout/xml_generation.rb', line 101

def tag_name_for_command(klass)
  COMMAND_TO_TAG[klass]
end