import Foundation enum ApiModule: Sendable { case app case customer case store case resource case none } enum ApiConfig { // Atomenta directly — customer/store/cards/orders/addresses/etc. Only // the public locator (session, locations, categories, stores-by-location, // store detail) goes through pediFoodsBFFURL below via explicit // baseURLOverride on those specific requests, per // docs/plans/app-migrate-atomenta-calls-to-pedifoods-bff.md. static var baseURL: URL { let raw = ProcessInfo.processInfo.environment["ATOMENTA_API_URL"] ?? "https://atomenta.com.br" return URL(string: raw) ?? URL(string: "https://atomenta.com.br")! } static var featureControlBffURL: URL { let raw = ProcessInfo.processInfo.environment["FEATURE_CONTROL_BFF_URL"] ?? "http://localhost:8787" return URL(string: raw) ?? URL(string: "http://localhost:8787")! } /// BFF (`PediFoods_web`) base URL. The public store locator (guest session, /// states/cities/stores-by-location, store detail) must go through here — /// never call `baseURL` (Atomenta) directly for these, per /// docs/plans/app-migrate-atomenta-calls-to-pedifoods-bff.md. static var pediFoodsBFFURL: URL { let raw = ProcessInfo.processInfo.environment["PEDIFOODS_BFF_URL"] ?? "https://pedifoods.com.br" return URL(string: raw) ?? URL(string: "https://pedifoods.com.br")! } static var featureControlEnvironment: String { let raw = ProcessInfo.processInfo.environment["FEATURE_CONTROL_ENVIRONMENT"] ?? "production" let clean = raw.trimmingCharacters(in: .whitespacesAndNewlines) return clean.isEmpty ? "production" : clean } // Tokens provided by backend modules static let storeToken = "550e8400-e29b-41d4-a716-446655440008" static let customerToken = "550e8400-e29b-41d4-a716-44665544000a" static let resourceToken = "550e8400-e29b-41d4-a716-446655440009" static func token(for module: ApiModule) -> String? { switch module { case .store: return storeToken case .customer: return customerToken case .resource: return resourceToken case .app, .none: return nil } } } enum LegalDocument: Sendable { case terms case privacyPolicy private var path: String { switch self { case .terms: return "api/public/pedi-foods-customer/terms" case .privacyPolicy: return "api/public/pedi-foods-customer/privacy-policy" } } var url: URL { ApiConfig.baseURL.appendingPathComponent(path) } }