Class: Google4R::Checkout::OrderStateChangeNotification
- Inherits:
-
Object
- Object
- 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
-
#frontend ⇒ Object
The frontend this notification belongs to.
-
#google_order_number ⇒ Object
The order number in Google’s database (String).
-
#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).
-
#serial_number ⇒ Object
The serial number of the notification (String).
-
#tax_tables ⇒ Object
readonly
The tax tables for the items in the order notification.
-
#timestamp ⇒ Object
The timestamp of the notification.
Class Method Summary collapse
-
.create_from_element(element, frontend) ⇒ Object
Factory methdo that creates a new OrderStateChangeNotification from an REXML::Element instance.
Instance Method Summary collapse
-
#initialize(frontend) ⇒ OrderStateChangeNotification
constructor
Sets the frontend attribute to the value of the frontend parameter.
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
#frontend ⇒ Object
The frontend this notification belongs to.
183 184 185 |
# File 'lib/google4r/checkout/notifications.rb', line 183 def frontend @frontend end |
#google_order_number ⇒ Object
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_state ⇒ Object
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_state ⇒ Object
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_state ⇒ Object
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_state ⇒ Object
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 |
#reason ⇒ Object
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_number ⇒ Object
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_tables ⇒ Object (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 |
#timestamp ⇒ Object
The timestamp of the notification. Also see #timestamp=
207 208 209 |
# File 'lib/google4r/checkout/notifications.rb', line 207 def @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. = 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 |