Class: Inventory::InvCheckerBaseService

Inherits:
Object
  • Object
show all
Defined in:
app/services/inventory/inv_checker_base_service.rb

Overview

Base class for inventory checker services.

Direct Known Subclasses

InvCheckerHungryHubService

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(restaurant_id, time_zone) ⇒ InvCheckerBaseService

Returns a new instance of InvCheckerBaseService.



8
9
10
11
# File 'app/services/inventory/inv_checker_base_service.rb', line 8

def initialize(restaurant_id, time_zone)
  @restaurant_id = restaurant_id
  @time_zone = time_zone
end

Instance Attribute Details

#restaurant_idObject (readonly)

Returns the value of attribute restaurant_id.



6
7
8
# File 'app/services/inventory/inv_checker_base_service.rb', line 6

def restaurant_id
  @restaurant_id
end

#time_zoneObject (readonly)

Returns the value of attribute time_zone.



6
7
8
# File 'app/services/inventory/inv_checker_base_service.rb', line 6

def time_zone
  @time_zone
end

Class Method Details

.update_cache_value(restaurant_id:, restaurant_package_id: nil, restaurant_package_ids: [], reservation_level: false, restaurant_level: false, restaurant_package_level: false, dates: [], datetimes: [], reset_mode: false) ⇒ Object

Raises:

  • (NotImplementedError)


18
19
20
21
22
23
24
25
# File 'app/services/inventory/inv_checker_base_service.rb', line 18

def self.update_cache_value(restaurant_id:, restaurant_package_id: nil,
                            restaurant_package_ids: [],
                            reservation_level: false, restaurant_level: false, 
                            restaurant_package_level: false,
                            dates: [], datetimes: [],
                            reset_mode: false)
  raise NotImplementedError, 'Subclasses must implement this method'
end

.warm_up_cache(restaurant_id, dates) ⇒ Object

subclass has to implement this class method to warm up the cache

Raises:

  • (NotImplementedError)


14
15
16
# File 'app/services/inventory/inv_checker_base_service.rb', line 14

def self.warm_up_cache(restaurant_id, dates)
  raise NotImplementedError, 'Subclasses must implement this method'
end

Instance Method Details

#add_on_bookable?(date:, start_time:, r_add_on_id:) ⇒ Boolean

Determines if an add-on is bookable on a specific date and time.

Parameters:

  • date (Date)

    The date for which the add-on is being checked.

  • start_time (Time)

    The start time for which the add-on is being checked.

  • r_add_on_id (Integer)

    The ID of the restaurant add-on.

Returns:

  • (Boolean)

    Returns true if the add-on is bookable, false otherwise.

Raises:

  • (NotImplementedError)


152
153
154
# File 'app/services/inventory/inv_checker_base_service.rb', line 152

def add_on_bookable?(date:, start_time:, r_add_on_id:)
  raise NotImplementedError, 'Subclasses must implement this method'
end

#available_add_ons(date:, start_time:, r_add_on_ids:) ⇒ Array

Find available add-ons for a given date, start time, number of adults, and number of kids.

Parameters:

  • date (Date)

    The date for which to find available add-ons.

  • start_time (Time)

    The start time for which to find available add-ons.

  • r_add_on_ids (Array<Integer>)

    The IDs of the restaurant add-ons.

Returns:

  • (Array)

    An array of available add-ons.

Raises:

  • (NotImplementedError)


142
143
144
# File 'app/services/inventory/inv_checker_base_service.rb', line 142

def available_add_ons(date:, start_time:, r_add_on_ids:)
  raise NotImplementedError, 'Subclasses must implement this method'
end

#available_packages(date:, start_time:, adult:, kids:) ⇒ Array

Calculates the available packages for a given date, start time, number of adults, and number of kids.

Parameters:

  • date (Date)

    The date for which to check the availability of packages.

  • start_time (Time)

    The start time for which to check the availability of packages.

  • adult (Integer)

    The number of adults.

  • kids (Integer)

    The number of kids.

Returns:

  • (Array)

    An array of available packages.

Raises:

  • (NotImplementedError)


87
88
89
# File 'app/services/inventory/inv_checker_base_service.rb', line 87

def available_packages(date:, start_time:, adult:, kids:)
  raise NotImplementedError, 'Subclasses must implement this method'
end

#bookable?(date:, start_time:, adult:, kids:) ⇒ Boolean

Determines if a booking is possible for the specified parameters.

Parameters:

  • date (Date)

    The date of the booking.

  • start_time (Time)

    The start time of the booking.

  • adult (Integer)

    The number of adult guests.

  • kids (Integer)

    The number of children guests.

Returns:

  • (Boolean)

    True if booking is possible, false otherwise.

Raises:

  • (NotImplementedError)

    If the method is not implemented by subclasses.



44
45
46
# File 'app/services/inventory/inv_checker_base_service.rb', line 44

def bookable?(date:, start_time:, adult:, kids:)
  raise NotImplementedError, 'Subclasses must implement this method'
end

#bookable_without_adult?(date:, start_time:) ⇒ Boolean

Determines if a booking can be made without an adult.

Parameters:

  • date (Date)

    The date of the booking.

  • start_time (Time)

    The start time of the booking.

Returns:

  • (Boolean)

    Returns true if the booking can be made without an adult, false otherwise.

Raises:

  • (NotImplementedError)


76
77
78
# File 'app/services/inventory/inv_checker_base_service.rb', line 76

def bookable_without_adult?(date:, start_time:)
  raise NotImplementedError, 'Subclasses must implement this method'
end

#error_messageString

Returns the error message for the inventory checker service.

Returns:

  • (String)

    the error message.

Raises:

  • (NotImplementedError)

    if the method is not implemented in the subclass.



32
33
34
# File 'app/services/inventory/inv_checker_base_service.rb', line 32

def error_message
  raise NotImplementedError, 'Subclasses must implement this method'
end

#find_available_dates(adult:, start_date:, end_date:, kids:) ⇒ Array<Date>

Finds available dates for booking based on the given parameters.

Parameters:

  • adult (Integer)

    the number of adults

  • start_date (Date)

    the start date of the booking

  • kids (Integer)

    the number of kids

Returns:

  • (Array<Date>)

    an array of available dates for booking

Raises:

  • (NotImplementedError)


97
98
99
# File 'app/services/inventory/inv_checker_base_service.rb', line 97

def find_available_dates(adult:, start_date:, end_date:, kids:)
  raise NotImplementedError, 'Subclasses must implement this method'
end

#find_available_single_date(adult:, date:, kids:) ⇒ Object

Finds available inventory for a single date.

Parameters:

  • adult: The number of adult guests.

  • date: The date for which to find available inventory.

  • kids: The number of children guests.

Raises:

  • NotImplementedError: Subclasses must implement this method.

Returns: None.

Raises:

  • (NotImplementedError)


112
113
114
# File 'app/services/inventory/inv_checker_base_service.rb', line 112

def find_available_single_date(adult:, date:, kids:)
  raise NotImplementedError, 'Subclasses must implement this method'
end

#find_available_start_times(adult:, kids:, date:) ⇒ Array

Finds the available start times for a given date, number of adults, and number of kids.

Parameters:

  • adult (Integer)

    the number of adults

  • kids (Integer)

    the number of kids

  • date (Date)

    the date for which to find available start times

Returns:

  • (Array)

    an array of available start times

Raises:

  • (NotImplementedError)


122
123
124
# File 'app/services/inventory/inv_checker_base_service.rb', line 122

def find_available_start_times(adult:, kids:, date:)
  raise NotImplementedError, 'Subclasses must implement this method'
end

#find_available_start_times_v4(adult:, kids:, date:) ⇒ Array

Finds the available start times for a given date, number of adults, and number of kids.

Parameters:

  • adult (Integer)

    the number of adults

  • kids (Integer)

    the number of kids

  • date (Date)

    the date for which to find available start times

Returns:

  • (Array)

    an array of available start times

Raises:

  • (NotImplementedError)


132
133
134
# File 'app/services/inventory/inv_checker_base_service.rb', line 132

def find_available_start_times_v4(adult:, kids:, date:)
  raise NotImplementedError, 'Subclasses must implement this method'
end

#inventory_bookable?(date:, start_time:, adult:, kids:) ⇒ Boolean

Checks if the inventory is bookable for the given date, start time, number of adults, and number of kids.

Parameters:

  • date (Date)

    The date for which the inventory is being checked.

  • start_time (Time)

    The start time for which the inventory is being checked.

  • adult (Integer)

    The number of adults for which the inventory is being checked.

  • kids (Integer)

    The number of kids for which the inventory is being checked.

Returns:

  • (Boolean)

    Returns true if the inventory is bookable, false otherwise.

Raises:

  • (NotImplementedError)


55
56
57
# File 'app/services/inventory/inv_checker_base_service.rb', line 55

def inventory_bookable?(date:, start_time:, adult:, kids:)
  raise NotImplementedError, 'Subclasses must implement this method'
end

#package_bookable?(date:, start_time:, adult:, kids:, slug:) ⇒ Boolean

Checks if a package is bookable on a specific date and time, with given number of adults, kids, and slug.

Parameters:

  • date (Date)

    The date of the booking.

  • start_time (Time)

    The start time of the booking.

  • adult (Integer)

    The number of adults for the booking.

  • kids (Integer)

    The number of kids for the booking.

  • slug (String)

    The slug of the package.

Returns:

  • (Boolean)

    Returns true if the package is bookable, false otherwise.

Raises:

  • (NotImplementedError)


67
68
69
# File 'app/services/inventory/inv_checker_base_service.rb', line 67

def package_bookable?(date:, start_time:, adult:, kids:, slug:)
  raise NotImplementedError, 'Subclasses must implement this method'
end