Class: Spree::Api::V2::Storefront::IntercityTaxi::DraftOrdersController

Inherits:
ResourceController
  • Object
show all
Includes:
OrderConcern, SpreeCmCommissioner::OrderConcern
Defined in:
app/controllers/spree/api/v2/storefront/intercity_taxi/draft_orders_controller.rb

Instance Method Summary collapse

Methods included from SpreeCmCommissioner::OrderConcern

#find_spree_current_order, #spree_current_order

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/spree/api/v2/storefront/intercity_taxi/draft_orders_controller.rb', line 11

def create
  order = SpreeCmCommissioner::IntercityTaxiOrder::Create.call(
    trip_id: params[:trip_id],
    from_date: params[:from_date],
    to_date: params[:to_date],
    user: spree_current_user,
    quantity: params[:quantity]
  )

  render_serialized_payload { serialize_resource(order) }
rescue StandardError => e
  render_error_payload(e.message)
end

#updateObject



25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/spree/api/v2/storefront/intercity_taxi/draft_orders_controller.rb', line 25

def update
  order = SpreeCmCommissioner::IntercityTaxiOrder::Update.call(
    order: spree_current_order,
    order_params: intercity_taxi_update_order_params
  )

  render_serialized_payload { serialize_resource(order) }
rescue StandardError => e
  render_error_payload(e.message)
end