Class: Lipstick::Api::OrderViewResponse
- Defined in:
- lib/lipstick/api/order_view_response.rb
Constant Summary
Constants inherited from Response
Instance Attribute Summary
Attributes inherited from Response
Instance Method Summary collapse
-
#initialize(fields) ⇒ OrderViewResponse
constructor
A new instance of OrderViewResponse.
Methods inherited from Response
csv_field, int_csv_field, #underscore
Constructor Details
#initialize(fields) ⇒ OrderViewResponse
Returns a new instance of OrderViewResponse.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/lipstick/api/order_view_response.rb', line 8 def initialize(fields) fields.keys.each do |key| fields[underscore(key.to_s).to_sym] = fields.delete(key) end fields[:customer] = OpenStruct.new( id: fields.delete(:customer_id).to_i, first_name: fields.delete(:first_name), last_name: fields.delete(:last_name), telephone: fields.delete(:customers_telephone), email_address: fields.delete(:email_address) ) fields[:shipping] = OpenStruct.new( first_name: fields.delete(:shipping_first_name), last_name: fields.delete(:shipping_last_name), street_address: fields.delete(:shipping_street_address), street_address2: fields.delete(:shipping_street_address2), city: fields.delete(:shipping_city), state: fields.delete(:shipping_state), state_id: fields.delete(:shipping_state_id), postcode: fields.delete(:shipping_postcode), country: fields.delete(:shipping_country), ) fields[:billing] = OpenStruct.new( first_name: fields.delete(:billing_first_name), last_name: fields.delete(:billing_last_name), street_address: fields.delete(:billing_street_address), street_address2: fields.delete(:billing_street_address2), city: fields.delete(:billing_city), state: fields.delete(:billing_state), state_id: fields.delete(:billing_state_id), postcode: fields.delete(:billing_postcode), country: fields.delete(:billing_country), ) fields[:order] = OpenStruct.new( customer: fields[:customer], ancestor_id: fields.delete(:ancestor_id).to_i, child_id: fields.delete(:child_id).to_i, status: fields.delete(:order_status).to_i, is_recurring: fields.delete(:is_recurring)=='1', shipping: fields[:shipping], shipping_method_name: fields.delete(:shipping_method_name), billing: fields[:billing], created_at: DateTime.strptime(fields.delete(:time_stamp),'%Y-%m-%d %H:%M:%S'), cc_number: fields.delete(:cc_number), cc_expires: fields.delete(:cc_expires), campaign_id: fields.delete(:campaign_id).to_i, order_total: BigDecimal.new(fields.delete(:order_total)), parent_id: fields.delete(:parent_id).to_i, transaction_id: fields.delete(:transaction_id), auth_id: fields.delete(:auth_id), ) # PP.pp fields # TODO: parse remaining fields super end |