Class: Google4R::Checkout::OrderStateChangeNotification

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

Overview

GoogleCheckout sends <order-change-notification> messages to the web service when the order’s state changes. They will get parsed into OrderStateChangeNotification objects.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(frontend) ⇒ OrderStateChangeNotification

Sets the frontend attribute to the value of the frontend parameter.



221
222
223
# File 'lib/google4r/checkout/notifications.rb', line 221

def initialize(frontend)
  @frontend = frontend
end

Instance Attribute Details

#frontendObject

The frontend this notification belongs to.



183
184
185
# File 'lib/google4r/checkout/notifications.rb', line 183

def frontend
  @frontend
end

#google_order_numberObject

The order number in Google’s database (String).



189
190
191
# File 'lib/google4r/checkout/notifications.rb', line 189

def google_order_number
  @google_order_number
end

#new_financial_order_stateObject

The new financial state of the order (String, one of FinancialOrderState::*).



195
196
197
# File 'lib/google4r/checkout/notifications.rb', line 195

def new_financial_order_state
  @new_financial_order_state
end

#new_fulfillment_order_stateObject

The new fulfillment state of the order (String, one of FulfillmentOrderState::*).



201
202
203
# File 'lib/google4r/checkout/notifications.rb', line 201

def new_fulfillment_order_state
  @new_fulfillment_order_state
end

#previous_financial_order_stateObject

The previous financial state of the order (String, one of FinancialOrderState::*).



192
193
194
# File 'lib/google4r/checkout/notifications.rb', line 192

def previous_financial_order_state
  @previous_financial_order_state
end

#previous_fulfillment_order_stateObject

The previous fulfillment state of the order (String, one of FulfillmentOrderState::*).



198
199
200
# File 'lib/google4r/checkout/notifications.rb', line 198

def previous_fulfillment_order_state
  @previous_fulfillment_order_state
end

#reasonObject

The reason for the change (String, can be nil).



204
205
206
# File 'lib/google4r/checkout/notifications.rb', line 204

def reason
  @reason
end

#serial_numberObject

The serial number of the notification (String).



186
187
188
# File 'lib/google4r/checkout/notifications.rb', line 186

def serial_number
  @serial_number
end

#tax_tablesObject (readonly)

The tax tables for the items in the order notification.



218
219
220
# File 'lib/google4r/checkout/notifications.rb', line 218

def tax_tables
  @tax_tables
end

#timestampObject

The timestamp of the notification. Also see #timestamp=



207
208
209
# File 'lib/google4r/checkout/notifications.rb', line 207

def timestamp
  @timestamp
end

Class Method Details

.create_from_element(element, frontend) ⇒ Object

Factory methdo that creates a new OrderStateChangeNotification from an REXML::Element instance. Use this to create instances of OrderStateChangeNotification.

Raises NoMethodError and RuntimeError exceptions if the given element misses required elements.



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/google4r/checkout/notifications.rb', line 230

def self.create_from_element(element, frontend)
  result = OrderStateChangeNotification.new(frontend)

  result.timestamp = Time.parse(element.elements['timestamp'].text)

  result.serial_number = element.elements['@serial-number'].value
  result.google_order_number = element.elements['google-order-number'].text
  result.new_financial_order_state = element.elements['new-financial-order-state'].text
  result.previous_financial_order_state = element.elements['previous-financial-order-state'].text
  result.new_fulfillment_order_state = element.elements['new-fulfillment-order-state'].text
  result.previous_fulfillment_order_state = element.elements['previous-fulfillment-order-state'].text
  result.reason = element.elements['reason'].text rescue nil
  
  return result
end