Class: Spree::Api::V2::Storefront::TripSearchController

Inherits:
ResourceController
  • Object
show all
Defined in:
app/controllers/spree/api/v2/storefront/trip_search_controller.rb

Constant Summary collapse

CACHE_EXPIRES_IN =
5.minutes

Instance Method Summary collapse

Instance Method Details

#indexObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/spree/api/v2/storefront/trip_search_controller.rb', line 8

def index
  render_serialized_payload do
    Rails.cache.fetch(collection_cache_key, collection_cache_opts) do
      trips = SpreeCmCommissioner::TripQuery.new(
        origin_id: params[:origin_id],
        destination_id: params[:destination_id],
        date: params[:date],
        route_type: params[:route_type],
        vendor_id: params[:vendor_id],
        number_of_guests: params[:number_of_guests],
        params: params
      ).call

      serialize_collection(trips)
    end
  end
end