Class: Google4R::Checkout::OrderStateChangeNotification
- Inherits:
-
Notification
- Object
- Notification
- Google4R::Checkout::OrderStateChangeNotification
- 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
-
#new_financial_order_state ⇒ Object
The new financial state of the order (String, one of FinancialOrderState::*).
-
#new_fulfillment_order_state ⇒ Object
The new fulfillment state of the order (String, one of FulfillmentOrderState::*).
-
#previous_financial_order_state ⇒ Object
The previous financial state of the order (String, one of FinancialOrderState::*).
-
#previous_fulfillment_order_state ⇒ Object
The previous fulfillment state of the order (String, one of FulfillmentOrderState::*).
-
#reason ⇒ Object
The reason for the change (String, can be nil).
-
#tax_tables ⇒ Object
readonly
The tax tables for the items in the order notification.
Attributes inherited from Notification
#frontend, #google_order_number, #serial_number, #timestamp
Class Method Summary collapse
-
.create_from_element(element, frontend) ⇒ Object
Factory method that creates a new OrderStateChangeNotification from an REXML::Element instance.
Instance Method Summary collapse
-
#timestamp=(time) ⇒ Object
Set the order’s timestamp (Time).
Methods inherited from Notification
Constructor Details
This class inherits a constructor from Google4R::Checkout::Notification
Instance Attribute Details
#new_financial_order_state ⇒ Object
The new financial state of the order (String, one of FinancialOrderState::*).
255 256 257 |
# File 'lib/google4r/checkout/notifications.rb', line 255 def new_financial_order_state @new_financial_order_state end |
#new_fulfillment_order_state ⇒ Object
The new fulfillment state of the order (String, one of FulfillmentOrderState::*).
261 262 263 |
# File 'lib/google4r/checkout/notifications.rb', line 261 def new_fulfillment_order_state @new_fulfillment_order_state end |
#previous_financial_order_state ⇒ Object
The previous financial state of the order (String, one of FinancialOrderState::*).
252 253 254 |
# File 'lib/google4r/checkout/notifications.rb', line 252 def previous_financial_order_state @previous_financial_order_state end |
#previous_fulfillment_order_state ⇒ Object
The previous fulfillment state of the order (String, one of FulfillmentOrderState::*).
258 259 260 |
# File 'lib/google4r/checkout/notifications.rb', line 258 def previous_fulfillment_order_state @previous_fulfillment_order_state end |
#reason ⇒ Object
The reason for the change (String, can be nil).
264 265 266 |
# File 'lib/google4r/checkout/notifications.rb', line 264 def reason @reason end |
#tax_tables ⇒ Object (readonly)
The tax tables for the items in the order notification.
267 268 269 |
# File 'lib/google4r/checkout/notifications.rb', line 267 def tax_tables @tax_tables end |
Class Method Details
.create_from_element(element, frontend) ⇒ Object
Factory method 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.
284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/google4r/checkout/notifications.rb', line 284 def self.create_from_element(element, frontend) result = OrderStateChangeNotification.new(frontend) result. = Time.parse(element.elements['timestamp'].text) result.serial_number = element.attributes['serial-number'] 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 |
Instance Method Details
#timestamp=(time) ⇒ Object
Set the order’s timestamp (Time). When the timestamp is set then the tax tables valid at the given point of time are set into the attribute tax tables from the frontend’s tax_table_factory.
272 273 274 275 276 277 |
# File 'lib/google4r/checkout/notifications.rb', line 272 def (time) @timestamp = time if frontend.tax_table_factory @tax_tables = frontend.tax_table_factory.effective_tax_tables_at(time) end end |