object @order
extends "spree/api/orders/order"

if lookup_context.find_all("spree/api/orders/#{root_object.state}").present?
  extends "spree/api/orders/#{root_object.state}"
end

child :billing_address => :bill_address do
  extends "spree/api/addresses/show"
end

child :shipping_address => :ship_address do
  extends "spree/api/addresses/show"
end

child :line_items => :line_items do
  extends "spree/api/line_items/show"
end

child :payments => :payments do
  attributes *payment_attributes

  child :payment_method => :payment_method do
    attributes :id, :name, :environment
  end

  child :source => :source do
    attributes *payment_source_attributes
  end
end

child :shipments => :shipments do
  extends "spree/api/shipments/small"
end

child :adjustments => :adjustments do
  extends "spree/api/adjustments/show"
end

object @order
extends "spree/api/orders/order"

if lookup_context.find_all("spree/api/orders/#{root_object.state}").present?
  extends "spree/api/orders/#{root_object.state}"
end

child :billing_address => :bill_address do
  extends "spree/api/addresses/show"
end

child :shipping_address => :ship_address do
  extends "spree/api/addresses/show"
end

child :line_items => :line_items do
  extends "spree/api/line_items/show"
end

child :payments => :payments do
  attributes *payment_attributes

  child :payment_method => :payment_method do
    attributes :id, :name, :environment
  end

  child :source => :source do
    attributes *payment_source_attributes
  end
end

child :shipments => :shipments do
  extends "spree/api/shipments/small"
end

child :adjustments => :adjustments do
  extends "spree/api/adjustments/show"
end

# Necessary for backend's order interface
node :permissions do
  { can_update: current_ability.can?(:update, root_object) }
end
Return permissions for orders within the API results
Return permissions for orders within the API results

This allows us to determine what information / buttons to display on the interface for an order
