Class: EcwidApi::Order

Inherits:
Entity
  • Object
show all
Defined in:
lib/ecwid_api/order.rb

Overview

Public: This is an Ecwid Order

Constant Summary collapse

VALID_FULFILLMENT_STATUSES =
%w(
  AWAITING_PROCESSING
  PROCESSING
  SHIPPED
  DELIVERED
  WILL_NOT_DELIVER
  RETURNED
)

Instance Method Summary collapse

Methods inherited from Entity

#[], #assign_attributes, #assign_raw_attributes, define_accessor, #destroy!, ecwid_accessor, ecwid_reader, ecwid_writer, #initialize, #save, #to_hash, #to_json, #update_attributes, #update_raw_attributes, #url

Constructor Details

This class inherits a constructor from EcwidApi::Entity

Instance Method Details

#billing_personObject

Public: Returns the billing person

If there isn’t a billing_person, then it assumed to be the shipping_person



48
49
50
# File 'lib/ecwid_api/order.rb', line 48

def billing_person
  build_billing_person || build_shipping_person
end

#fulfillment_statusObject



74
75
76
# File 'lib/ecwid_api/order.rb', line 74

def fulfillment_status
  super && super.downcase.to_sym
end

#fulfillment_status=(status) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/ecwid_api/order.rb', line 66

def fulfillment_status=(status)
  status = status.to_s.upcase
  unless VALID_FULFILLMENT_STATUSES.include?(status)
    raise Error("#{status} is an invalid fullfillment status")
  end
  super(status)
end

#idObject

Public: Gets the unique ID of the order



40
41
42
# File 'lib/ecwid_api/order.rb', line 40

def id
  order_number
end

#itemsObject

Public: Returns a Array of ‘OrderItem` objects



62
63
64
# File 'lib/ecwid_api/order.rb', line 62

def items
  @items ||= data["items"].map { |item| OrderItem.new(item) }
end

#shipping_personObject

Public: Returns the shipping person

If there isn’t a shipping_person, then it is assumed to be the billing_person



57
58
59
# File 'lib/ecwid_api/order.rb', line 57

def shipping_person
  build_shipping_person || build_billing_person
end