Class: Spree::Api::Chatrace::CheckInsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/chatrace/check_ins_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#validate_token_client

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/spree/api/chatrace/check_ins_controller.rb', line 9

def create
  result = SpreeCmCommissioner::CheckIns::CreateBulk.call(
    check_ins_attributes: [{ guest_id: guest.id, check_in_session_id: params[:check_in_session_id] }]
  )

  if result.success?
    render json: { checked_in_at: result.value[:check_ins][0].confirmed_at }, status: :ok
  else
    render_error_payload(result.error)
  end
end

#guestObject



5
6
7
# File 'app/controllers/spree/api/chatrace/check_ins_controller.rb', line 5

def guest
  @guest ||= SpreeCmCommissioner::Guest.complete.find_by!(token: params[:guest_token])
end