Class: Api::Vendor::V1::GoogleReserve::TimeConversionsController

Inherits:
BaseController show all
Includes:
Concerns::Helpers
Defined in:
app/controllers/api/vendor/v1/google_reserve/time_conversions_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#vendor

Instance Method Summary collapse

Methods included from ResponseCacheConcern

#my_response_cache

Methods inherited from ApplicationController

#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=

Methods included from LogrageCustomLogger

#append_info_to_payload

Methods included from ControllerHelpers

#check_boolean_param, #get_banners, #inventory_params, #reservation_params

Instance Method Details

#convert_epoch_to_restaurantObject

POST /v3/time_conversion/epoch_to_restaurant



6
7
8
9
10
11
12
13
14
# File 'app/controllers/api/vendor/v1/google_reserve/time_conversions_controller.rb', line 6

def convert_epoch_to_restaurant
  restaurant_id = params.require(:restaurant_id)
  start_sec = params.require(:start_sec).to_i

  restaurant = Restaurant.find(restaurant_id)
  datetime = epoch_to_time(start_sec, restaurant.time_zone)

  render json: { date: datetime.to_date, start_time: datetime.strftime('%H:%M'), time_zone: restaurant.time_zone }
end

#convert_restaurant_to_epochObject

POST /v3/time_conversion/restaurant_to_epoch



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/api/vendor/v1/google_reserve/time_conversions_controller.rb', line 17

def convert_restaurant_to_epoch
  restaurant_id = params.require(:restaurant_id)
  date = params.require(:date)
  start_time = params.require(:start_time)

  restaurant = Restaurant.fetch(restaurant_id)
  start_sec = convert_to_utc_timestamp(date, start_time, restaurant.time_zone)

  render json: { start_sec: start_sec }
end