Services

All services are singletons accessed via .shared, using SupabaseManager.shared.client for database operations.

AuthService

File: Services/AuthService.swift

MethodParametersReturnsDescription
getCurrentUser()—User?Get current authenticated user
getSession()—Session?Get current session
signOut()—VoidSign out
signUp(email:password:fullName:birthday:)String, String, String?, String?SessionCreate account
signIn(email:password:)String, StringSessionEmail sign in
signInWithGoogle()—VoidOAuth with Google
signInWithApple()—VoidOAuth with Apple
getProfile(userId:)StringProfile?Fetch profile
updateProfile(userId:fullName:phone:)String, String?, String?ProfileUpdate profile
observeAuthStateChanges()—AsyncStream<AuthChangeEvent>Auth state stream

File: Services/MenuService.swift

MethodParametersReturnsDescription
getCategories()—[MenuCategory]Active categories, sorted
getMenuItems(category:)String?[MenuItem]Available items, optional filter
getFeaturedItems()—[MenuItem]Featured items
getItemDetails(id:)StringMenuItemWithModifiersFull item with modifiers
searchItems(query:)String[MenuItem]Search by name/description

Uses MenuCache and ModifierCache for local caching.


OrderService

File: Services/OrderService.swift

MethodParametersReturnsDescription
createOrder(items:subtotal:tax:discount:tip:total:paymentMethod:squarePaymentId:squareOrderId:locationName:)MultipleOrderCreate full order
getUserOrders()—[OrderWithItems]Current user’s orders
getOrder(id:)StringOrderWithItemsSingle order with items
syncToSquare(orderId:items:subtotal:tax:tip:total:orderNumber:idempotencyKey:)MultipleStringSync to Square, returns Square order ID

Errors: notAuthenticated, noLocationFound, invalidResponse, serverError, squareSyncFailed


LoyaltyService

File: Services/LoyaltyService.swift

MethodParametersReturnsDescription
getLoyaltyData()—LoyaltyResponseAccount + transactions + rewards
getAvailableRewards(tier:)LoyaltyTier[Reward]Rewards accessible at tier
redeemReward(rewardId:)StringRedeemRewardResponseRedeem a reward

Errors: notAuthenticated, noLoyaltyAccount, insufficientStars, tierRequirementNotMet


SquarePaymentService

File: Services/SquarePaymentService.swift

MethodParametersReturnsDescription
processPayment(sourceId:amount:currency:idempotencyKey:note:)MultiplePaymentResultProcess card payment
processApplePayPayment(paymentData:amount:)Data, IntPaymentResultProcess Apple Pay
createPayAtCounterPayment(amount:)IntPaymentResultCounter payment stub
isApplePayAvailable—BoolDevice Apple Pay support

Payment Methods: payAtCounter, applePay, card


ApplePayService

File: Services/ApplePayService.swift

Handles Apple Pay via PassKit framework. Creates PKPaymentRequest with itemized summary, supported networks (Visa, Mastercard, Amex, Discover), and merchant ID merchant.com.staccato.coffee.


CartStorageService

File: Services/CartStorageService.swift

MethodParametersReturnsDescription
saveCart(_:)[CartItem]VoidPersist to UserDefaults
loadCart()—[CartItem]Load from UserDefaults
clearCart()—VoidClear saved cart

Storage key: staccato-cart


OrderQueueService

File: Services/OrderQueueService.swift

MethodParametersReturnsDescription
getActiveOrders()—[OrderWithItems]Pending + in_progress + ready
getOrders(status:)OrderStatus[Order]Orders by status
claimOrder(orderId:)StringVoidClaim for current user
markReady(orderId:)StringVoidMark as ready
completeOrder(orderId:)StringVoidMark as completed
unclaimOrder(orderId:)StringVoidRelease back to queue

Errors: notAuthenticated, orderAlreadyClaimed, notAssignedToYou, invalidStatusTransition


AnalyticsService

File: Services/AnalyticsService.swift

MethodParametersReturns
getDailySales(days:)Int[DailySales]
getSalesSummary(days:)IntSalesSummary
getHourlyDistribution()—[HourlyDistribution]
getTopItems(limit:)Int[TopItem]
getPopularModifiers(limit:)Int[PopularModifier]
getLoyaltyTierDistribution()—[LoyaltyTierStats]
getStarTransactionsSummary(days:)IntStarTransactionsSummary
getOrderStatusBreakdown()—[OrderStatusStats]
getEmployeePerformance()—[EmployeePerformance]
getNewCustomers(days:)IntInt
getTotalCustomers()—Int