Class: SpreeCmCommissioner::WaitingRoom::Guests::Find

Inherits:
Object
  • Object
show all
Includes:
Spree::ServiceModule::Base, FirestoreConnection
Defined in:
app/services/spree_cm_commissioner/waiting_room/guests/find.rb

Overview

Single-doc lookup by id, for the admin "Guests" tab's search box. Deliberately a direct get rather than filtering List's result: a doc can exist outside List's queued_at-ordered MAX_DOCS window (or the request predates that cache), and a single-doc read costs the same whichever way it's found.

Instance Method Summary collapse

Methods included from FirestoreConnection

#firestore, #firestore_available?, #service_account

Instance Method Details

#call(date:, doc_id:, firestore: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'app/services/spree_cm_commissioner/waiting_room/guests/find.rb', line 12

def call(date:, doc_id:, firestore: nil)
  @firestore = firestore if firestore.present?

  guest = firestore_available? ? fetch(date, doc_id) : nil

  success(guest: guest)
rescue StandardError => e
  failure(nil, e.message)
end