Class: Spree::Api::V2::Operator::CheckInsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Api::V2::Operator::CheckInsController
- Defined in:
- app/controllers/spree/api/v2/operator/check_ins_controller.rb
Constant Summary collapse
- CACHE_EXPIRES_IN =
Check-in history data requires fresh/recent data for operator dashboards Short cache duration ensures operators see near real-time check-in activity
1.minute
Instance Method Summary collapse
Instance Method Details
#collection ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/spree/api/v2/operator/check_ins_controller.rb', line 12 def collection @collection ||= if restricted? SpreeCmCommissioner::CheckIn.none else SpreeCmCommissioner::CheckIn .where(checkinable_type: 'Spree::Taxon', checkinable_id: params[:taxon_id]) .page(params[:page]) .per(params[:per_page]) end end |
#collection_cache_opts ⇒ Object
override
24 25 26 27 28 29 |
# File 'app/controllers/spree/api/v2/operator/check_ins_controller.rb', line 24 def collection_cache_opts { namespace: Spree::Api::Config[:api_v2_collection_cache_namespace], expires_in: CACHE_EXPIRES_IN } end |
#create ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/spree/api/v2/operator/check_ins_controller.rb', line 31 def create :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 |