Class: Spree::Api::V2::Tenant::IntercityTaxi::DistanceCalculatorController
- Inherits:
-
BaseController
- Object
- ResourceController
- BaseController
- Spree::Api::V2::Tenant::IntercityTaxi::DistanceCalculatorController
- Includes:
- Storefront::OrderConcern, SpreeCmCommissioner::OrderConcern
- Defined in:
- app/controllers/spree/api/v2/tenant/intercity_taxi/distance_calculator_controller.rb
Instance Method Summary collapse
Methods included from SpreeCmCommissioner::OrderConcern
#find_spree_current_order, #spree_current_order
Methods inherited from BaseController
#current_vendor, #render_serialized_payload, #require_tenant, #scope
Instance Method Details
#create ⇒ Object
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 |
# File 'app/controllers/spree/api/v2/tenant/intercity_taxi/distance_calculator_controller.rb', line 10 def create result = SpreeCmCommissioner::CalculateDistance.call( pickups_attributes: Array(params[:pickups_attributes]).map do |pickup| { lat: pickup[:lat], lng: pickup[:lng] } end, dropoffs_attributes: Array(params[:dropoffs_attributes]).map do |dropoff| { lat: dropoff[:lat], lng: dropoff[:lng] } end, pickup_oob_confirmed: params[:pickup_oob_confirmed], dropoff_oob_confirmed: params[:dropoff_oob_confirmed], trip_id: params[:trip_id] ) if result.success? render_serialized_payload { serialize_resource(result.value) } else render_error_payload(result.error) end end |