Class: Spree::Api::V2::Operator::CheckInsController

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

Instance Method Summary collapse

Instance Method Details

#collectionObject



8
9
10
11
12
# File 'app/controllers/spree/api/v2/operator/check_ins_controller.rb', line 8

def collection
  @collection = SpreeCmCommissioner::CheckIn.where(checkinable: params[:taxon_id])

  @collection = @collection.page(params[:page]).per(params[:per_page])
end

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/spree/api/v2/operator/check_ins_controller.rb', line 14

def create
  spree_authorize! :create, model_class

  result = SpreeCmCommissioner::CheckIns::CreateBulk.call(
    check_ins_attributes: [{ guest_id: params[:guest_id], check_in_session_id: params[:check_in_session_id] }],
    check_in_by: spree_current_user
  )

  if result.success?
    render_serialized_payload(201) { serialize_resource(result.value[:check_ins][0]) }
  else
    render_error_payload(result.error)
  end
end