Class: Api::Vendor::V1::Klook::BookingsFilter

Inherits:
Object
  • Object
show all
Defined in:
app/filters/api/vendor/v1/klook/bookings_filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel_id, params) ⇒ BookingsFilter

Returns a new instance of BookingsFilter.



6
7
8
9
10
11
# File 'app/filters/api/vendor/v1/klook/bookings_filter.rb', line 6

def initialize(channel_id, params)
  @channel_id = channel_id
  @filter_params = params.slice(:uuid, :productId, :optionId, :resellerReference, :supplierReference,
                                :localDate, :localDateStart, :localDateEnd)
  @collections = default_collections
end

Instance Attribute Details

#collectionsObject

Returns the value of attribute collections.



3
4
5
# File 'app/filters/api/vendor/v1/klook/bookings_filter.rb', line 3

def collections
  @collections
end

#filter_paramsObject (readonly)

Returns the value of attribute filter_params.



4
5
6
# File 'app/filters/api/vendor/v1/klook/bookings_filter.rb', line 4

def filter_params
  @filter_params
end

Instance Method Details

#apply_filtersObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/filters/api/vendor/v1/klook/bookings_filter.rb', line 17

def apply_filters
  filter_by_uuid
  filter_by_product_id
  filter_by_option_id
  filter_by_reseller_reference
  filter_by_supplier_reference
  filter_by_local_date
  filter_by_date_range
  sort_by_date
  limit_collections
  collections
end

#default_collectionsObject



13
14
15
# File 'app/filters/api/vendor/v1/klook/bookings_filter.rb', line 13

def default_collections
  Reservation.joins(:vendor_reservation).where(channel: @channel_id)
end