diff --git a/generators/swift/base/src/context/AbstractSwiftGeneratorContext.ts b/generators/swift/base/src/context/AbstractSwiftGeneratorContext.ts index 6beba9b12d7e..4611420464d0 100644 --- a/generators/swift/base/src/context/AbstractSwiftGeneratorContext.ts +++ b/generators/swift/base/src/context/AbstractSwiftGeneratorContext.ts @@ -101,7 +101,9 @@ export abstract class AbstractSwiftGeneratorContext< }); nameRegistry.registerEnvironmentSymbol({ configEnvironmentEnumName: this.customConfig.environmentEnumName, - registeredSourceModuleName: registeredSourceModuleSymbol.name + registeredSourceModuleName: registeredSourceModuleSymbol.name, + environmentType: + ir.environments?.environments.type === "multipleBaseUrls" ? "multipleBaseUrls" : "singleBaseUrl" }); // Must first register top-level symbols diff --git a/generators/swift/base/src/template/Sources/ClientConfig.Template.swift b/generators/swift/base/src/template/Sources/ClientConfig.Template.swift index 30800ee3f54f..9a774b5a8f1e 100644 --- a/generators/swift/base/src/template/Sources/ClientConfig.Template.swift +++ b/generators/swift/base/src/template/Sources/ClientConfig.Template.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/generators/swift/base/src/template/Sources/HTTPClient.Template.swift b/generators/swift/base/src/template/Sources/HTTPClient.Template.swift index f0167b91ae22..9006d60cb286 100644 --- a/generators/swift/base/src/template/Sources/HTTPClient.Template.swift +++ b/generators/swift/base/src/template/Sources/HTTPClient.Template.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/generators/swift/codegen/src/name-registry/name-registry.ts b/generators/swift/codegen/src/name-registry/name-registry.ts index bf7287ea5a0a..8f2eb91e166b 100644 --- a/generators/swift/codegen/src/name-registry/name-registry.ts +++ b/generators/swift/codegen/src/name-registry/name-registry.ts @@ -183,10 +183,12 @@ export class NameRegistry { */ public registerEnvironmentSymbol({ configEnvironmentEnumName, - registeredSourceModuleName + registeredSourceModuleName, + environmentType }: { configEnvironmentEnumName: string | undefined; registeredSourceModuleName: string; + environmentType: "singleBaseUrl" | "multipleBaseUrls"; }): swift.Symbol { const candidates: [string, ...string[]] = [ `${registeredSourceModuleName}Environment`, @@ -197,7 +199,12 @@ export class NameRegistry { candidates.unshift(configEnvironmentEnumName); } const symbolName = this.sourceModuleNamespace.addEnvironmentSymbolName(candidates); - return this.symbolRegistry.registerSourceModuleType(symbolName, { type: "enum-with-raw-values" }); + // Environments with multiple base URLs are generated as a struct (one property per base URL), + // whereas environments with a single base URL are generated as a String-backed enum. + return this.symbolRegistry.registerSourceModuleType( + symbolName, + environmentType === "multipleBaseUrls" ? { type: "struct" } : { type: "enum-with-raw-values" } + ); } public getEnvironmentSymbolOrThrow(): swift.Symbol { diff --git a/generators/swift/dynamic-snippets/src/context/DynamicSnippetsGeneratorContext.ts b/generators/swift/dynamic-snippets/src/context/DynamicSnippetsGeneratorContext.ts index f7dbd5947349..b33dc5c6a8bc 100644 --- a/generators/swift/dynamic-snippets/src/context/DynamicSnippetsGeneratorContext.ts +++ b/generators/swift/dynamic-snippets/src/context/DynamicSnippetsGeneratorContext.ts @@ -78,7 +78,9 @@ export class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGene }); nameRegistry.registerEnvironmentSymbol({ configEnvironmentEnumName: this.customConfig?.environmentEnumName, - registeredSourceModuleName: registeredSourceModuleSymbol.name + registeredSourceModuleName: registeredSourceModuleSymbol.name, + environmentType: + ir.environments?.environments.type === "multipleBaseUrls" ? "multipleBaseUrls" : "singleBaseUrl" }); // Must first register top-level symbols diff --git a/generators/swift/sdk/changes/unreleased/server-url-templating.yml b/generators/swift/sdk/changes/unreleased/server-url-templating.yml new file mode 100644 index 000000000000..48c1564885af --- /dev/null +++ b/generators/swift/sdk/changes/unreleased/server-url-templating.yml @@ -0,0 +1,5 @@ +# yaml-language-server: $schema=../../../../../fern-changes-yml.schema.json + +- summary: | + Add support for APIs with multiple base URLs (server URL templating). The environment type is now generated as a struct exposing one URL per base URL ID, and each endpoint resolves its configured base URL at request time. + type: fix diff --git a/generators/swift/sdk/src/SdkGeneratorCli.ts b/generators/swift/sdk/src/SdkGeneratorCli.ts index 021a187c6ec5..e70362a7a31a 100644 --- a/generators/swift/sdk/src/SdkGeneratorCli.ts +++ b/generators/swift/sdk/src/SdkGeneratorCli.ts @@ -18,6 +18,7 @@ import { FernIr } from "@fern-fern/ir-sdk"; import { template as templateFn } from "lodash-es"; import { + MultipleBaseUrlsEnvironmentGenerator, PackageSwiftGenerator, RootClientGenerator, SingleUrlEnvironmentGenerator, @@ -640,8 +641,19 @@ export class SdkGeneratorCLI extends AbstractSwiftGeneratorCli b.id === endpoint.baseUrl); + if (baseUrl == null) { + return undefined; + } + return swift.functionArgument({ + label: "baseUrlId", + value: swift.Expression.stringLiteral(baseUrl.id) + }); + } + private getResolvedSwiftTypeForTypeReference(typeReference: FernIr.TypeReference): swift.TypeReference { if (typeReference.type === "named") { const { typeId } = typeReference; diff --git a/generators/swift/sdk/src/generators/client/RootClientGenerator.ts b/generators/swift/sdk/src/generators/client/RootClientGenerator.ts index e99a9c5d1de7..06f4a119a4d6 100644 --- a/generators/swift/sdk/src/generators/client/RootClientGenerator.ts +++ b/generators/swift/sdk/src/generators/client/RootClientGenerator.ts @@ -53,6 +53,102 @@ export class RootClientGenerator { }); } + private get environmentParam() { + const environmentSymbol = this.sdkGeneratorContext.project.nameRegistry.getEnvironmentSymbolOrThrow(); + return swift.functionParameter({ + argumentLabel: "environment", + unsafeName: "environment", + type: this.referencer.referenceType(environmentSymbol), + defaultValue: this.getDefaultEnvironmentExpression(), + docsContent: + "The environment to use for requests from the client. If not provided, the default environment will be used." + }); + } + + private get isMultipleBaseUrls(): boolean { + return this.sdkGeneratorContext.ir.environments?.environments.type === "multipleBaseUrls"; + } + + /** + * The base-URL-related initializer parameters. APIs with a single base URL expose a `baseURL` + * string, whereas APIs with multiple base URLs (server URL templating) expose an `environment` + * parameter typed as the generated environment struct. + */ + private getBaseUrlParams(): swift.FunctionParameter[] { + return this.isMultipleBaseUrls ? [this.environmentParam] : [this.baseUrlParam]; + } + + /** + * The arguments forwarded from a convenience initializer to the designated initializer for the + * base-URL-related parameters. + */ + private getBaseUrlForwardingArgs(): swift.FunctionArgument[] { + if (this.isMultipleBaseUrls) { + return [swift.functionArgument({ label: "environment", value: swift.Expression.reference("environment") })]; + } + return [swift.functionArgument({ label: "baseURL", value: swift.Expression.reference("baseURL") })]; + } + + /** + * The arguments passed to `ClientConfig` for the base-URL-related parameters. For multiple base + * URLs we both set a fallback `baseURL` (the first base URL) and a `baseUrls` map keyed by base + * URL ID so that individual endpoints can resolve the correct URL at request time. + */ + private getBaseUrlClientConfigArgs(): swift.FunctionArgument[] { + const environments = this.sdkGeneratorContext.ir.environments?.environments; + if (environments == null || environments.type !== "multipleBaseUrls") { + return [swift.functionArgument({ label: "baseURL", value: swift.Expression.reference("baseURL") })]; + } + const baseUrlProperty = (baseUrl: FernIr.EnvironmentBaseUrlWithId) => + swift.Expression.memberAccess({ + target: swift.Expression.reference("environment"), + memberName: this.sdkGeneratorContext.caseConverter.camelUnsafe(baseUrl.name) + }); + const args: swift.FunctionArgument[] = []; + const firstBaseUrl = environments.baseUrls[0]; + if (firstBaseUrl != null) { + args.push(swift.functionArgument({ label: "baseURL", value: baseUrlProperty(firstBaseUrl) })); + } + args.push( + swift.functionArgument({ + label: "baseUrls", + value: swift.Expression.dictionaryLiteral({ + entries: environments.baseUrls.map((baseUrl) => [ + swift.Expression.stringLiteral(baseUrl.id), + baseUrlProperty(baseUrl) + ]), + multiline: true + }) + }) + ); + return args; + } + + private getDefaultEnvironmentExpression(): swift.Expression | undefined { + const envConfig = this.sdkGeneratorContext.ir.environments; + if (envConfig == null || envConfig.environments.type !== "multipleBaseUrls") { + return undefined; + } + const defaultEnvId = envConfig.defaultEnvironment; + + // If no default environment is specified, use the first environment (mirrors single-base-URL behavior). + const defaultEnvironment = envConfig.environments.environments.find((e, idx) => + defaultEnvId == null ? idx === 0 : e.id === defaultEnvId + ); + if (defaultEnvironment == null) { + return undefined; + } + const environmentSymbol = this.sdkGeneratorContext.project.nameRegistry.getEnvironmentSymbolOrThrow(); + const environmentRef = this.sdkGeneratorContext.project.nameRegistry.reference({ + fromSymbol: this.symbol, + toSymbol: environmentSymbol + }); + return swift.Expression.memberAccess({ + target: swift.Expression.reference(environmentRef), + memberName: this.sdkGeneratorContext.caseConverter.camelUnsafe(defaultEnvironment.name) + }); + } + private get headersParam() { return swift.functionParameter({ argumentLabel: "headers", @@ -166,10 +262,7 @@ export class RootClientGenerator { : swift.Expression.reference("headers"); const designatedInitializerArgs: swift.FunctionArgument[] = [ - swift.functionArgument({ - label: "baseURL", - value: swift.Expression.reference("baseURL") - }), + ...this.getBaseUrlForwardingArgs(), swift.functionArgument({ label: "headerAuth", value: authSchemes.header @@ -389,7 +482,7 @@ export class RootClientGenerator { }: { bearerTokenParamType: BearerTokenParamType; }): swift.FunctionParameter[] { - const params: swift.FunctionParameter[] = [this.baseUrlParam]; + const params: swift.FunctionParameter[] = [...this.getBaseUrlParams()]; const authSchemes = this.getAuthSchemeParameters(); if (authSchemes.header) { params.push(authSchemes.header.param); @@ -413,12 +506,7 @@ export class RootClientGenerator { } private generateDesignatedInitializer(): swift.Initializer { - const initializerParams: swift.FunctionParameter[] = [ - swift.functionParameter({ - argumentLabel: "baseURL", - unsafeName: "baseURL", - type: this.referencer.referenceSwiftType("String") - }), + const otherParams: swift.FunctionParameter[] = [ swift.functionParameter({ argumentLabel: "headerAuth", unsafeName: "headerAuth", @@ -485,6 +573,8 @@ export class RootClientGenerator { }) ]; + const initializerParams: swift.FunctionParameter[] = [...this.getBaseUrlParams(), ...otherParams]; + return swift.initializer({ parameters: initializerParams, body: swift.CodeBlock.withStatements([ @@ -493,7 +583,8 @@ export class RootClientGenerator { value: swift.Expression.classInitialization({ unsafeName: "ClientConfig", arguments_: [ - ...initializerParams.map((p) => + ...this.getBaseUrlClientConfigArgs(), + ...otherParams.map((p) => swift.functionArgument({ label: p.unsafeName, value: swift.Expression.reference(p.unsafeName) diff --git a/generators/swift/sdk/src/generators/environment/MultipleBaseUrlsEnvironmentGenerator.ts b/generators/swift/sdk/src/generators/environment/MultipleBaseUrlsEnvironmentGenerator.ts new file mode 100644 index 000000000000..f12e805399d9 --- /dev/null +++ b/generators/swift/sdk/src/generators/environment/MultipleBaseUrlsEnvironmentGenerator.ts @@ -0,0 +1,92 @@ +import { swift } from "@fern-api/swift-codegen"; +import { FernIr } from "@fern-fern/ir-sdk"; + +import { SdkGeneratorContext } from "../../SdkGeneratorContext.js"; + +export declare namespace MultipleBaseUrlsEnvironmentGenerator { + interface Args { + structName: string; + environments: FernIr.MultipleBaseUrlsEnvironments; + sdkGeneratorContext: SdkGeneratorContext; + } +} + +/** + * Generates the environment type for APIs that expose multiple base URLs (server URL templating). + * + * Unlike single-base-URL APIs (which generate a `String`-backed enum), each environment here owns + * one URL per base URL ID, so we generate a struct with one `String` property per base URL plus a + * static property for each named environment. + */ +export class MultipleBaseUrlsEnvironmentGenerator { + private readonly structName: string; + private readonly environments: FernIr.MultipleBaseUrlsEnvironments; + private readonly sdkGeneratorContext: SdkGeneratorContext; + + public constructor({ structName, environments, sdkGeneratorContext }: MultipleBaseUrlsEnvironmentGenerator.Args) { + this.structName = structName; + this.environments = environments; + this.sdkGeneratorContext = sdkGeneratorContext; + } + + public generate(): swift.Struct { + const environmentSymbol = this.sdkGeneratorContext.project.nameRegistry.getEnvironmentSymbolOrThrow(); + const referencer = this.sdkGeneratorContext.createReferencer(environmentSymbol); + const stringType = referencer.referenceSwiftType("String"); + + const properties = this.environments.baseUrls.map((baseUrl) => + swift.property({ + unsafeName: this.sdkGeneratorContext.caseConverter.camelUnsafe(baseUrl.name), + accessLevel: swift.AccessLevel.Public, + declarationType: swift.DeclarationType.Let, + type: stringType + }) + ); + + const memberwiseInitializer = swift.initializer({ + accessLevel: swift.AccessLevel.Public, + parameters: this.environments.baseUrls.map((baseUrl) => + swift.functionParameter({ + argumentLabel: this.sdkGeneratorContext.caseConverter.camelUnsafe(baseUrl.name), + unsafeName: this.sdkGeneratorContext.caseConverter.camelUnsafe(baseUrl.name), + type: stringType + }) + ), + body: swift.codeBlock((writer) => { + this.environments.baseUrls.forEach((baseUrl) => { + const propertyName = this.sdkGeneratorContext.caseConverter.camelUnsafe(baseUrl.name); + writer.writeLine(`self.${propertyName} = ${propertyName}`); + }); + }) + }); + + const staticEnvironmentProperties = this.environments.environments.map((environment) => + swift.property({ + unsafeName: this.sdkGeneratorContext.caseConverter.camelUnsafe(environment.name), + accessLevel: swift.AccessLevel.Public, + static_: true, + declarationType: swift.DeclarationType.Let, + type: referencer.referenceType(environmentSymbol), + defaultValue: swift.Expression.structInitialization({ + unsafeName: this.structName, + arguments_: this.environments.baseUrls.map((baseUrl) => + swift.functionArgument({ + label: this.sdkGeneratorContext.caseConverter.camelUnsafe(baseUrl.name), + value: swift.Expression.stringLiteral(environment.urls[baseUrl.id] ?? "") + }) + ), + multiline: true + }), + docs: environment.docs ? swift.docComment({ summary: environment.docs }) : undefined + }) + ); + + return swift.struct({ + name: this.structName, + accessLevel: swift.AccessLevel.Public, + conformances: [swift.Protocol.Equatable, swift.Protocol.Sendable], + properties: [...properties, ...staticEnvironmentProperties], + initializers: [memberwiseInitializer] + }); + } +} diff --git a/generators/swift/sdk/src/generators/environment/index.ts b/generators/swift/sdk/src/generators/environment/index.ts index d0ad9ecd5e37..5e7f8b65a63e 100644 --- a/generators/swift/sdk/src/generators/environment/index.ts +++ b/generators/swift/sdk/src/generators/environment/index.ts @@ -1 +1,2 @@ +export * from "./MultipleBaseUrlsEnvironmentGenerator.js"; export * from "./SingleUrlEnvironmentGenerator.js"; diff --git a/seed/swift-sdk/accept-header/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/accept-header/Sources/Core/Networking/HTTPClient.swift index b04c9e1c91f4..8a0672a9e2ee 100644 --- a/seed/swift-sdk/accept-header/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/accept-header/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/accept-header/Sources/Public/ClientConfig.swift b/seed/swift-sdk/accept-header/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/accept-header/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/accept-header/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/alias-extends/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/alias-extends/Sources/Core/Networking/HTTPClient.swift index d2247660af37..9c5aadad1f7a 100644 --- a/seed/swift-sdk/alias-extends/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/alias-extends/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/alias-extends/Sources/Public/ClientConfig.swift b/seed/swift-sdk/alias-extends/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/alias-extends/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/alias-extends/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/alias/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/alias/Sources/Core/Networking/HTTPClient.swift index 236e1925db5e..bdf2ee4b2ed0 100644 --- a/seed/swift-sdk/alias/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/alias/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/alias/Sources/Public/ClientConfig.swift b/seed/swift-sdk/alias/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/alias/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/alias/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/allof-inline/Sources/ApiClient.swift b/seed/swift-sdk/allof-inline/Sources/ApiClient.swift index 4c4861c3b599..38cc44d57472 100644 --- a/seed/swift-sdk/allof-inline/Sources/ApiClient.swift +++ b/seed/swift-sdk/allof-inline/Sources/ApiClient.swift @@ -31,7 +31,7 @@ public final class ApiClient: Sendable { } init( - baseURL: String, + baseURL: String = ApiEnvironment.default.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/allof-inline/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/allof-inline/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/allof-inline/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/allof-inline/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/allof-inline/Sources/Public/ClientConfig.swift b/seed/swift-sdk/allof-inline/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/allof-inline/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/allof-inline/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/allof/Sources/ApiClient.swift b/seed/swift-sdk/allof/Sources/ApiClient.swift index 4c4861c3b599..38cc44d57472 100644 --- a/seed/swift-sdk/allof/Sources/ApiClient.swift +++ b/seed/swift-sdk/allof/Sources/ApiClient.swift @@ -31,7 +31,7 @@ public final class ApiClient: Sendable { } init( - baseURL: String, + baseURL: String = ApiEnvironment.default.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/allof/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/allof/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/allof/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/allof/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/allof/Sources/Public/ClientConfig.swift b/seed/swift-sdk/allof/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/allof/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/allof/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/any-auth/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/any-auth/Sources/Core/Networking/HTTPClient.swift index 76c048e58e8d..1c8024dee789 100644 --- a/seed/swift-sdk/any-auth/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/any-auth/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/any-auth/Sources/Public/ClientConfig.swift b/seed/swift-sdk/any-auth/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/any-auth/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/any-auth/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/api-wide-base-path-with-default/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/api-wide-base-path-with-default/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/api-wide-base-path-with-default/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/api-wide-base-path-with-default/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/api-wide-base-path-with-default/Sources/Public/ClientConfig.swift b/seed/swift-sdk/api-wide-base-path-with-default/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/api-wide-base-path-with-default/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/api-wide-base-path-with-default/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/api-wide-base-path/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/api-wide-base-path/Sources/Core/Networking/HTTPClient.swift index 49e388386677..4644a7c1afcb 100644 --- a/seed/swift-sdk/api-wide-base-path/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/api-wide-base-path/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/api-wide-base-path/Sources/Public/ClientConfig.swift b/seed/swift-sdk/api-wide-base-path/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/api-wide-base-path/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/api-wide-base-path/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/audiences/Sources/AudiencesClient.swift b/seed/swift-sdk/audiences/Sources/AudiencesClient.swift index 6f48be5eae40..1f6de041db59 100644 --- a/seed/swift-sdk/audiences/Sources/AudiencesClient.swift +++ b/seed/swift-sdk/audiences/Sources/AudiencesClient.swift @@ -37,7 +37,7 @@ public final class AudiencesClient: Sendable { } init( - baseURL: String, + baseURL: String = AudiencesEnvironment.environmentA.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/audiences/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/audiences/Sources/Core/Networking/HTTPClient.swift index 93cfede2351f..c4927361fffa 100644 --- a/seed/swift-sdk/audiences/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/audiences/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/audiences/Sources/Public/ClientConfig.swift b/seed/swift-sdk/audiences/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/audiences/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/audiences/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/basic-auth-environment-variables/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/basic-auth-environment-variables/Sources/Core/Networking/HTTPClient.swift index fa8f4087c5cb..644e4ee2001a 100644 --- a/seed/swift-sdk/basic-auth-environment-variables/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/basic-auth-environment-variables/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/basic-auth-environment-variables/Sources/Public/ClientConfig.swift b/seed/swift-sdk/basic-auth-environment-variables/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/basic-auth-environment-variables/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/basic-auth-environment-variables/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/basic-auth-pw-omitted/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/basic-auth-pw-omitted/Sources/Core/Networking/HTTPClient.swift index ba0d9bcf150e..ec84bffe9303 100644 --- a/seed/swift-sdk/basic-auth-pw-omitted/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/basic-auth-pw-omitted/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/basic-auth-pw-omitted/Sources/Public/ClientConfig.swift b/seed/swift-sdk/basic-auth-pw-omitted/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/basic-auth-pw-omitted/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/basic-auth-pw-omitted/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/basic-auth/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/basic-auth/Sources/Core/Networking/HTTPClient.swift index e936104b18f0..d7c15eb215b3 100644 --- a/seed/swift-sdk/basic-auth/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/basic-auth/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/basic-auth/Sources/Public/ClientConfig.swift b/seed/swift-sdk/basic-auth/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/basic-auth/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/basic-auth/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/bearer-token-environment-variable/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/bearer-token-environment-variable/Sources/Core/Networking/HTTPClient.swift index b011729adb2f..bd4dfe323887 100644 --- a/seed/swift-sdk/bearer-token-environment-variable/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/bearer-token-environment-variable/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/bearer-token-environment-variable/Sources/Public/ClientConfig.swift b/seed/swift-sdk/bearer-token-environment-variable/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/bearer-token-environment-variable/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/bearer-token-environment-variable/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/bytes-download/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/bytes-download/Sources/Core/Networking/HTTPClient.swift index 3f6aca9b80eb..9d4e40f545d6 100644 --- a/seed/swift-sdk/bytes-download/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/bytes-download/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/bytes-download/Sources/Public/ClientConfig.swift b/seed/swift-sdk/bytes-download/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/bytes-download/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/bytes-download/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/bytes-upload/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/bytes-upload/Sources/Core/Networking/HTTPClient.swift index 5db81f34ce3a..81489b6d39a6 100644 --- a/seed/swift-sdk/bytes-upload/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/bytes-upload/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/bytes-upload/Sources/Public/ClientConfig.swift b/seed/swift-sdk/bytes-upload/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/bytes-upload/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/bytes-upload/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/circular-references-advanced/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/circular-references-advanced/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/circular-references-advanced/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/circular-references-advanced/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/circular-references-advanced/Sources/Public/ClientConfig.swift b/seed/swift-sdk/circular-references-advanced/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/circular-references-advanced/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/circular-references-advanced/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/circular-references-extends/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/circular-references-extends/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/circular-references-extends/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/circular-references-extends/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/circular-references-extends/Sources/Public/ClientConfig.swift b/seed/swift-sdk/circular-references-extends/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/circular-references-extends/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/circular-references-extends/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/circular-references/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/circular-references/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/circular-references/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/circular-references/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/circular-references/Sources/Public/ClientConfig.swift b/seed/swift-sdk/circular-references/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/circular-references/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/circular-references/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/cli-multi-spec-namespaced/Sources/ApiClient.swift b/seed/swift-sdk/cli-multi-spec-namespaced/Sources/ApiClient.swift index 159c971f8fee..ade5d81a9e58 100644 --- a/seed/swift-sdk/cli-multi-spec-namespaced/Sources/ApiClient.swift +++ b/seed/swift-sdk/cli-multi-spec-namespaced/Sources/ApiClient.swift @@ -73,7 +73,7 @@ public final class ApiClient: Sendable { } init( - baseURL: String, + baseURL: String = ApiEnvironment.default.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/cli-multi-spec-namespaced/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/cli-multi-spec-namespaced/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/cli-multi-spec-namespaced/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/cli-multi-spec-namespaced/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/cli-multi-spec-namespaced/Sources/Public/ClientConfig.swift b/seed/swift-sdk/cli-multi-spec-namespaced/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/cli-multi-spec-namespaced/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/cli-multi-spec-namespaced/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/cli-multi-spec/Sources/ApiClient.swift b/seed/swift-sdk/cli-multi-spec/Sources/ApiClient.swift index 0c9aa3fc1c9b..5a92f8f510db 100644 --- a/seed/swift-sdk/cli-multi-spec/Sources/ApiClient.swift +++ b/seed/swift-sdk/cli-multi-spec/Sources/ApiClient.swift @@ -31,7 +31,7 @@ public final class ApiClient: Sendable { } init( - baseURL: String, + baseURL: String = ApiEnvironment.default.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/cli-multi-spec/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/cli-multi-spec/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/cli-multi-spec/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/cli-multi-spec/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/cli-multi-spec/Sources/Public/ClientConfig.swift b/seed/swift-sdk/cli-multi-spec/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/cli-multi-spec/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/cli-multi-spec/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/client-side-params/no-custom-config/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/client-side-params/no-custom-config/Sources/Core/Networking/HTTPClient.swift index 6c2aab6be396..e8aafa5e5e96 100644 --- a/seed/swift-sdk/client-side-params/no-custom-config/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/client-side-params/no-custom-config/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/client-side-params/no-custom-config/Sources/Public/ClientConfig.swift b/seed/swift-sdk/client-side-params/no-custom-config/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/client-side-params/no-custom-config/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/client-side-params/no-custom-config/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/client-side-params/with-custom-config/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/client-side-params/with-custom-config/Sources/Core/Networking/HTTPClient.swift index 7ca809222776..d05318978d53 100644 --- a/seed/swift-sdk/client-side-params/with-custom-config/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/client-side-params/with-custom-config/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/client-side-params/with-custom-config/Sources/Public/ClientConfig.swift b/seed/swift-sdk/client-side-params/with-custom-config/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/client-side-params/with-custom-config/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/client-side-params/with-custom-config/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/content-type/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/content-type/Sources/Core/Networking/HTTPClient.swift index 541e49fb7836..924c329e13dd 100644 --- a/seed/swift-sdk/content-type/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/content-type/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/content-type/Sources/Public/ClientConfig.swift b/seed/swift-sdk/content-type/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/content-type/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/content-type/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/cross-package-type-names/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/cross-package-type-names/Sources/Core/Networking/HTTPClient.swift index 06107e1e5451..8243782321ad 100644 --- a/seed/swift-sdk/cross-package-type-names/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/cross-package-type-names/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/cross-package-type-names/Sources/Public/ClientConfig.swift b/seed/swift-sdk/cross-package-type-names/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/cross-package-type-names/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/cross-package-type-names/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/dollar-string-examples/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/dollar-string-examples/Sources/Core/Networking/HTTPClient.swift index 50cd785791f5..e773227de922 100644 --- a/seed/swift-sdk/dollar-string-examples/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/dollar-string-examples/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/dollar-string-examples/Sources/Public/ClientConfig.swift b/seed/swift-sdk/dollar-string-examples/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/dollar-string-examples/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/dollar-string-examples/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/empty-clients/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/empty-clients/Sources/Core/Networking/HTTPClient.swift index 268171019043..f978a00481ba 100644 --- a/seed/swift-sdk/empty-clients/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/empty-clients/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/empty-clients/Sources/Public/ClientConfig.swift b/seed/swift-sdk/empty-clients/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/empty-clients/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/empty-clients/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/endpoint-security-auth/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/endpoint-security-auth/Sources/Core/Networking/HTTPClient.swift index aa8db63a04b6..70ae1c209e57 100644 --- a/seed/swift-sdk/endpoint-security-auth/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/endpoint-security-auth/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/endpoint-security-auth/Sources/Public/ClientConfig.swift b/seed/swift-sdk/endpoint-security-auth/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/endpoint-security-auth/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/endpoint-security-auth/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/enum/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/enum/Sources/Core/Networking/HTTPClient.swift index 6b11d2b1a700..4a7e9a3ce2df 100644 --- a/seed/swift-sdk/enum/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/enum/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/enum/Sources/Public/ClientConfig.swift b/seed/swift-sdk/enum/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/enum/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/enum/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/error-property/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/error-property/Sources/Core/Networking/HTTPClient.swift index 5207537ad613..8bc626801575 100644 --- a/seed/swift-sdk/error-property/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/error-property/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/error-property/Sources/Public/ClientConfig.swift b/seed/swift-sdk/error-property/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/error-property/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/error-property/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/errors/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/errors/Sources/Core/Networking/HTTPClient.swift index 3457604b94a2..868f721f2f72 100644 --- a/seed/swift-sdk/errors/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/errors/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/errors/Sources/Public/ClientConfig.swift b/seed/swift-sdk/errors/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/errors/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/errors/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/examples/no-custom-config/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/examples/no-custom-config/Sources/Core/Networking/HTTPClient.swift index eb012dceb1db..54ce1e15f5de 100644 --- a/seed/swift-sdk/examples/no-custom-config/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/examples/no-custom-config/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/examples/no-custom-config/Sources/ExamplesClient.swift b/seed/swift-sdk/examples/no-custom-config/Sources/ExamplesClient.swift index 3f74fb572089..4e341fda90ad 100644 --- a/seed/swift-sdk/examples/no-custom-config/Sources/ExamplesClient.swift +++ b/seed/swift-sdk/examples/no-custom-config/Sources/ExamplesClient.swift @@ -70,7 +70,7 @@ public final class ExamplesClient: Sendable { } init( - baseURL: String, + baseURL: String = ExamplesEnvironment.production.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/examples/no-custom-config/Sources/Public/ClientConfig.swift b/seed/swift-sdk/examples/no-custom-config/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/examples/no-custom-config/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/examples/no-custom-config/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/examples/readme-config/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/examples/readme-config/Sources/Core/Networking/HTTPClient.swift index eb012dceb1db..54ce1e15f5de 100644 --- a/seed/swift-sdk/examples/readme-config/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/examples/readme-config/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/examples/readme-config/Sources/ExamplesClient.swift b/seed/swift-sdk/examples/readme-config/Sources/ExamplesClient.swift index 3f74fb572089..4e341fda90ad 100644 --- a/seed/swift-sdk/examples/readme-config/Sources/ExamplesClient.swift +++ b/seed/swift-sdk/examples/readme-config/Sources/ExamplesClient.swift @@ -70,7 +70,7 @@ public final class ExamplesClient: Sendable { } init( - baseURL: String, + baseURL: String = ExamplesEnvironment.production.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/examples/readme-config/Sources/Public/ClientConfig.swift b/seed/swift-sdk/examples/readme-config/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/examples/readme-config/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/examples/readme-config/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/exhaustive/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/exhaustive/Sources/Core/Networking/HTTPClient.swift index 50eafe989390..08afa3c71cde 100644 --- a/seed/swift-sdk/exhaustive/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/exhaustive/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/exhaustive/Sources/Public/ClientConfig.swift b/seed/swift-sdk/exhaustive/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/exhaustive/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/exhaustive/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/extends/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/extends/Sources/Core/Networking/HTTPClient.swift index b6016a9ca58f..950e2fe8506c 100644 --- a/seed/swift-sdk/extends/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/extends/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/extends/Sources/Public/ClientConfig.swift b/seed/swift-sdk/extends/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/extends/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/extends/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/extra-properties/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/extra-properties/Sources/Core/Networking/HTTPClient.swift index 6d6accde19c0..a8c15484d207 100644 --- a/seed/swift-sdk/extra-properties/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/extra-properties/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/extra-properties/Sources/Public/ClientConfig.swift b/seed/swift-sdk/extra-properties/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/extra-properties/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/extra-properties/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/file-download/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/file-download/Sources/Core/Networking/HTTPClient.swift index 3ad345adcf88..ee41a54cf967 100644 --- a/seed/swift-sdk/file-download/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/file-download/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/file-download/Sources/Public/ClientConfig.swift b/seed/swift-sdk/file-download/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/file-download/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/file-download/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/file-upload-openapi/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/file-upload-openapi/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/file-upload-openapi/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/file-upload-openapi/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/file-upload-openapi/Sources/Public/ClientConfig.swift b/seed/swift-sdk/file-upload-openapi/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/file-upload-openapi/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/file-upload-openapi/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/file-upload/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/file-upload/Sources/Core/Networking/HTTPClient.swift index 962906cf5287..5894759c5a83 100644 --- a/seed/swift-sdk/file-upload/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/file-upload/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/file-upload/Sources/Public/ClientConfig.swift b/seed/swift-sdk/file-upload/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/file-upload/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/file-upload/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/folders/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/folders/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/folders/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/folders/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/folders/Sources/Public/ClientConfig.swift b/seed/swift-sdk/folders/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/folders/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/folders/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/header-auth-environment-variable/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/header-auth-environment-variable/Sources/Core/Networking/HTTPClient.swift index 2d78af86b9c4..cb2d56c7f65d 100644 --- a/seed/swift-sdk/header-auth-environment-variable/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/header-auth-environment-variable/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/header-auth-environment-variable/Sources/Public/ClientConfig.swift b/seed/swift-sdk/header-auth-environment-variable/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/header-auth-environment-variable/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/header-auth-environment-variable/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/header-auth/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/header-auth/Sources/Core/Networking/HTTPClient.swift index 7dfeb4c1288f..ff1f05d2ee86 100644 --- a/seed/swift-sdk/header-auth/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/header-auth/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/header-auth/Sources/Public/ClientConfig.swift b/seed/swift-sdk/header-auth/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/header-auth/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/header-auth/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/http-head/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/http-head/Sources/Core/Networking/HTTPClient.swift index 862c2b1eedfe..ef8d4ab51cb9 100644 --- a/seed/swift-sdk/http-head/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/http-head/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/http-head/Sources/Public/ClientConfig.swift b/seed/swift-sdk/http-head/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/http-head/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/http-head/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/idempotency-headers/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/idempotency-headers/Sources/Core/Networking/HTTPClient.swift index fd3cb557de49..f9c6697e00ca 100644 --- a/seed/swift-sdk/idempotency-headers/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/idempotency-headers/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/idempotency-headers/Sources/Public/ClientConfig.swift b/seed/swift-sdk/idempotency-headers/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/idempotency-headers/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/idempotency-headers/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/imdb/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/imdb/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/imdb/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/imdb/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/imdb/Sources/Public/ClientConfig.swift b/seed/swift-sdk/imdb/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/imdb/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/imdb/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/inferred-auth-explicit/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/inferred-auth-explicit/Sources/Core/Networking/HTTPClient.swift index 3aee49e0e602..9c61efd264b5 100644 --- a/seed/swift-sdk/inferred-auth-explicit/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/inferred-auth-explicit/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/inferred-auth-explicit/Sources/Public/ClientConfig.swift b/seed/swift-sdk/inferred-auth-explicit/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/inferred-auth-explicit/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/inferred-auth-explicit/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/inferred-auth-implicit-api-key/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/inferred-auth-implicit-api-key/Sources/Core/Networking/HTTPClient.swift index 26be1313174c..d528a2ab2c90 100644 --- a/seed/swift-sdk/inferred-auth-implicit-api-key/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/inferred-auth-implicit-api-key/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/inferred-auth-implicit-api-key/Sources/Public/ClientConfig.swift b/seed/swift-sdk/inferred-auth-implicit-api-key/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/inferred-auth-implicit-api-key/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/inferred-auth-implicit-api-key/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Sources/Core/Networking/HTTPClient.swift index b1454df4d52c..38709d8d9973 100644 --- a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Sources/Public/ClientConfig.swift b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/inferred-auth-implicit-reference/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/inferred-auth-implicit-reference/Sources/Core/Networking/HTTPClient.swift index 66c7f38b8a43..273d5c58b75a 100644 --- a/seed/swift-sdk/inferred-auth-implicit-reference/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/inferred-auth-implicit-reference/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/inferred-auth-implicit-reference/Sources/Public/ClientConfig.swift b/seed/swift-sdk/inferred-auth-implicit-reference/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/inferred-auth-implicit-reference/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/inferred-auth-implicit-reference/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/inferred-auth-implicit/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/inferred-auth-implicit/Sources/Core/Networking/HTTPClient.swift index 66c7f38b8a43..273d5c58b75a 100644 --- a/seed/swift-sdk/inferred-auth-implicit/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/inferred-auth-implicit/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/inferred-auth-implicit/Sources/Public/ClientConfig.swift b/seed/swift-sdk/inferred-auth-implicit/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/inferred-auth-implicit/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/inferred-auth-implicit/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/license/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/license/Sources/Core/Networking/HTTPClient.swift index 84197b50e9d1..a14896c55af2 100644 --- a/seed/swift-sdk/license/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/license/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/license/Sources/Public/ClientConfig.swift b/seed/swift-sdk/license/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/license/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/license/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/literal-user-agent/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/literal-user-agent/Sources/Core/Networking/HTTPClient.swift index bd79ba76c459..e09cbde64923 100644 --- a/seed/swift-sdk/literal-user-agent/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/literal-user-agent/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/literal-user-agent/Sources/Public/ClientConfig.swift b/seed/swift-sdk/literal-user-agent/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/literal-user-agent/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/literal-user-agent/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/literal/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/literal/Sources/Core/Networking/HTTPClient.swift index 656a476b48e3..b383341a203a 100644 --- a/seed/swift-sdk/literal/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/literal/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/literal/Sources/Public/ClientConfig.swift b/seed/swift-sdk/literal/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/literal/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/literal/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/literals-unions/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/literals-unions/Sources/Core/Networking/HTTPClient.swift index a3adaf1c6c7e..771e2cdb51b9 100644 --- a/seed/swift-sdk/literals-unions/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/literals-unions/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/literals-unions/Sources/Public/ClientConfig.swift b/seed/swift-sdk/literals-unions/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/literals-unions/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/literals-unions/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/mixed-case/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/mixed-case/Sources/Core/Networking/HTTPClient.swift index 4a813af8fc4b..248d2dc9a423 100644 --- a/seed/swift-sdk/mixed-case/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/mixed-case/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/mixed-case/Sources/Public/ClientConfig.swift b/seed/swift-sdk/mixed-case/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/mixed-case/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/mixed-case/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/mixed-file-directory/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/mixed-file-directory/Sources/Core/Networking/HTTPClient.swift index 273e2dfff445..aa8ad8f347a6 100644 --- a/seed/swift-sdk/mixed-file-directory/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/mixed-file-directory/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/mixed-file-directory/Sources/Public/ClientConfig.swift b/seed/swift-sdk/mixed-file-directory/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/mixed-file-directory/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/mixed-file-directory/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/multi-line-docs/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/multi-line-docs/Sources/Core/Networking/HTTPClient.swift index e161ca315849..e9945138b401 100644 --- a/seed/swift-sdk/multi-line-docs/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/multi-line-docs/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/multi-line-docs/Sources/Public/ClientConfig.swift b/seed/swift-sdk/multi-line-docs/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/multi-line-docs/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/multi-line-docs/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/multi-url-environment-no-default/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/multi-url-environment-no-default/Sources/Core/Networking/HTTPClient.swift index a48b6524f9f4..5cf231f91712 100644 --- a/seed/swift-sdk/multi-url-environment-no-default/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/multi-url-environment-no-default/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/multi-url-environment-no-default/Sources/MultiUrlEnvironmentNoDefaultClient.swift b/seed/swift-sdk/multi-url-environment-no-default/Sources/MultiUrlEnvironmentNoDefaultClient.swift index 26b0124c22f0..0d11c366972e 100644 --- a/seed/swift-sdk/multi-url-environment-no-default/Sources/MultiUrlEnvironmentNoDefaultClient.swift +++ b/seed/swift-sdk/multi-url-environment-no-default/Sources/MultiUrlEnvironmentNoDefaultClient.swift @@ -8,14 +8,14 @@ public final class MultiUrlEnvironmentNoDefaultClient: Sendable { /// Initialize the client with the specified configuration and a static bearer token. /// - /// - Parameter baseURL: The base URL to use for requests from the client. If not provided, the default base URL will be used. + /// - Parameter environment: The environment to use for requests from the client. If not provided, the default environment will be used. /// - Parameter token: Bearer token for authentication. If provided, will be sent as "Bearer {token}" in Authorization header. /// - Parameter headers: Additional headers to send with each request. /// - Parameter timeout: Request timeout in seconds. Defaults to 60 seconds. Ignored if a custom `urlSession` is provided. /// - Parameter maxRetries: Maximum number of retries for failed requests. Defaults to 2. /// - Parameter urlSession: Custom `URLSession` to use for requests. If not provided, a default session will be created with the specified timeout. public convenience init( - baseURL: String, + environment: MultiUrlEnvironmentNoDefaultEnvironment = MultiUrlEnvironmentNoDefaultEnvironment.production, token: String, headers: [String: String]? = nil, timeout: Int? = nil, @@ -23,7 +23,7 @@ public final class MultiUrlEnvironmentNoDefaultClient: Sendable { urlSession: Networking.URLSession? = nil ) { self.init( - baseURL: baseURL, + environment: environment, headerAuth: nil, bearerAuth: .init(token: .staticToken(token)), basicAuth: nil, @@ -36,14 +36,14 @@ public final class MultiUrlEnvironmentNoDefaultClient: Sendable { /// Initialize the client with the specified configuration and an async bearer token provider. /// - /// - Parameter baseURL: The base URL to use for requests from the client. If not provided, the default base URL will be used. + /// - Parameter environment: The environment to use for requests from the client. If not provided, the default environment will be used. /// - Parameter token: An async function that returns the bearer token for authentication. If provided, will be sent as "Bearer {token}" in Authorization header. /// - Parameter headers: Additional headers to send with each request. /// - Parameter timeout: Request timeout in seconds. Defaults to 60 seconds. Ignored if a custom `urlSession` is provided. /// - Parameter maxRetries: Maximum number of retries for failed requests. Defaults to 2. /// - Parameter urlSession: Custom `URLSession` to use for requests. If not provided, a default session will be created with the specified timeout. public convenience init( - baseURL: String, + environment: MultiUrlEnvironmentNoDefaultEnvironment = MultiUrlEnvironmentNoDefaultEnvironment.production, token: @escaping ClientConfig.CredentialProvider, headers: [String: String]? = nil, timeout: Int? = nil, @@ -51,7 +51,7 @@ public final class MultiUrlEnvironmentNoDefaultClient: Sendable { urlSession: Networking.URLSession? = nil ) { self.init( - baseURL: baseURL, + environment: environment, headerAuth: nil, bearerAuth: .init(token: .provider(token)), basicAuth: nil, @@ -63,7 +63,7 @@ public final class MultiUrlEnvironmentNoDefaultClient: Sendable { } init( - baseURL: String, + environment: MultiUrlEnvironmentNoDefaultEnvironment = MultiUrlEnvironmentNoDefaultEnvironment.production, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, @@ -73,7 +73,11 @@ public final class MultiUrlEnvironmentNoDefaultClient: Sendable { urlSession: Networking.URLSession? = nil ) { let config = ClientConfig( - baseURL: baseURL, + baseURL: environment.ec2, + baseUrls: [ + "ec2": environment.ec2, + "s3": environment.s3 + ], headerAuth: headerAuth, bearerAuth: bearerAuth, basicAuth: basicAuth, diff --git a/seed/swift-sdk/multi-url-environment-no-default/Sources/MultiUrlEnvironmentNoDefaultEnvironment.swift b/seed/swift-sdk/multi-url-environment-no-default/Sources/MultiUrlEnvironmentNoDefaultEnvironment.swift new file mode 100644 index 000000000000..aa79ef653c02 --- /dev/null +++ b/seed/swift-sdk/multi-url-environment-no-default/Sources/MultiUrlEnvironmentNoDefaultEnvironment.swift @@ -0,0 +1,19 @@ +import Foundation + +public struct MultiUrlEnvironmentNoDefaultEnvironment: Equatable, Sendable { + public let ec2: String + public let s3: String + public static let production: MultiUrlEnvironmentNoDefaultEnvironment = MultiUrlEnvironmentNoDefaultEnvironment( + ec2: "https://ec2.aws.com", + s3: "https://s3.aws.com" + ) + public static let staging: MultiUrlEnvironmentNoDefaultEnvironment = MultiUrlEnvironmentNoDefaultEnvironment( + ec2: "https://staging.ec2.aws.com", + s3: "https://staging.s3.aws.com" + ) + + public init(ec2: String, s3: String) { + self.ec2 = ec2 + self.s3 = s3 + } +} \ No newline at end of file diff --git a/seed/swift-sdk/multi-url-environment-no-default/Sources/Public/ClientConfig.swift b/seed/swift-sdk/multi-url-environment-no-default/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/multi-url-environment-no-default/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/multi-url-environment-no-default/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/multi-url-environment-no-default/Sources/Resources/Ec2/Ec2Client.swift b/seed/swift-sdk/multi-url-environment-no-default/Sources/Resources/Ec2/Ec2Client.swift index 82e627e64311..0cdee5692cae 100644 --- a/seed/swift-sdk/multi-url-environment-no-default/Sources/Resources/Ec2/Ec2Client.swift +++ b/seed/swift-sdk/multi-url-environment-no-default/Sources/Resources/Ec2/Ec2Client.swift @@ -11,6 +11,7 @@ public final class Ec2Client: Sendable { return try await httpClient.performRequest( method: .post, path: "/ec2/boot", + baseUrlId: "ec2", body: request, requestOptions: requestOptions ) diff --git a/seed/swift-sdk/multi-url-environment-no-default/Sources/Resources/S3/S3Client.swift b/seed/swift-sdk/multi-url-environment-no-default/Sources/Resources/S3/S3Client.swift index 0437fe3ac217..f17625aa6152 100644 --- a/seed/swift-sdk/multi-url-environment-no-default/Sources/Resources/S3/S3Client.swift +++ b/seed/swift-sdk/multi-url-environment-no-default/Sources/Resources/S3/S3Client.swift @@ -11,6 +11,7 @@ public final class S3Client: Sendable { return try await httpClient.performRequest( method: .post, path: "/s3/presigned-url", + baseUrlId: "s3", body: request, requestOptions: requestOptions, responseType: String.self diff --git a/seed/swift-sdk/multi-url-environment-reference/Sources/ApiClient.swift b/seed/swift-sdk/multi-url-environment-reference/Sources/ApiClient.swift index 78a89a9bebc9..039400cbcb86 100644 --- a/seed/swift-sdk/multi-url-environment-reference/Sources/ApiClient.swift +++ b/seed/swift-sdk/multi-url-environment-reference/Sources/ApiClient.swift @@ -9,14 +9,14 @@ public final class ApiClient: Sendable { /// Initialize the client with the specified configuration and a static bearer token. /// - /// - Parameter baseURL: The base URL to use for requests from the client. If not provided, the default base URL will be used. + /// - Parameter environment: The environment to use for requests from the client. If not provided, the default environment will be used. /// - Parameter token: Bearer token for authentication. If provided, will be sent as "Bearer {token}" in Authorization header. /// - Parameter headers: Additional headers to send with each request. /// - Parameter timeout: Request timeout in seconds. Defaults to 60 seconds. Ignored if a custom `urlSession` is provided. /// - Parameter maxRetries: Maximum number of retries for failed requests. Defaults to 2. /// - Parameter urlSession: Custom `URLSession` to use for requests. If not provided, a default session will be created with the specified timeout. public convenience init( - baseURL: String, + environment: ApiEnvironment = ApiEnvironment.production, token: String? = nil, headers: [String: String]? = nil, timeout: Int? = nil, @@ -24,7 +24,7 @@ public final class ApiClient: Sendable { urlSession: Networking.URLSession? = nil ) { self.init( - baseURL: baseURL, + environment: environment, headerAuth: nil, bearerAuth: token.map { .init(token: .staticToken($0)) @@ -39,14 +39,14 @@ public final class ApiClient: Sendable { /// Initialize the client with the specified configuration and an async bearer token provider. /// - /// - Parameter baseURL: The base URL to use for requests from the client. If not provided, the default base URL will be used. + /// - Parameter environment: The environment to use for requests from the client. If not provided, the default environment will be used. /// - Parameter token: An async function that returns the bearer token for authentication. If provided, will be sent as "Bearer {token}" in Authorization header. /// - Parameter headers: Additional headers to send with each request. /// - Parameter timeout: Request timeout in seconds. Defaults to 60 seconds. Ignored if a custom `urlSession` is provided. /// - Parameter maxRetries: Maximum number of retries for failed requests. Defaults to 2. /// - Parameter urlSession: Custom `URLSession` to use for requests. If not provided, a default session will be created with the specified timeout. public convenience init( - baseURL: String, + environment: ApiEnvironment = ApiEnvironment.production, token: ClientConfig.CredentialProvider? = nil, headers: [String: String]? = nil, timeout: Int? = nil, @@ -54,7 +54,7 @@ public final class ApiClient: Sendable { urlSession: Networking.URLSession? = nil ) { self.init( - baseURL: baseURL, + environment: environment, headerAuth: nil, bearerAuth: token.map { .init(token: .provider($0)) @@ -68,7 +68,7 @@ public final class ApiClient: Sendable { } init( - baseURL: String, + environment: ApiEnvironment = ApiEnvironment.production, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, @@ -78,7 +78,12 @@ public final class ApiClient: Sendable { urlSession: Networking.URLSession? = nil ) { let config = ClientConfig( - baseURL: baseURL, + baseURL: environment.base, + baseUrls: [ + "Base": environment.base, + "Auth": environment.auth, + "Upload": environment.upload + ], headerAuth: headerAuth, bearerAuth: bearerAuth, basicAuth: basicAuth, diff --git a/seed/swift-sdk/multi-url-environment-reference/Sources/ApiEnvironment.swift b/seed/swift-sdk/multi-url-environment-reference/Sources/ApiEnvironment.swift new file mode 100644 index 000000000000..77d8721406b2 --- /dev/null +++ b/seed/swift-sdk/multi-url-environment-reference/Sources/ApiEnvironment.swift @@ -0,0 +1,18 @@ +import Foundation + +public struct ApiEnvironment: Equatable, Sendable { + public let base: String + public let auth: String + public let upload: String + public static let production: ApiEnvironment = ApiEnvironment( + base: "https://api.example.com/2.0", + auth: "https://auth.example.com/oauth2", + upload: "https://upload.example.com/2.0" + ) + + public init(base: String, auth: String, upload: String) { + self.base = base + self.auth = auth + self.upload = upload + } +} \ No newline at end of file diff --git a/seed/swift-sdk/multi-url-environment-reference/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/multi-url-environment-reference/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/multi-url-environment-reference/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/multi-url-environment-reference/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/multi-url-environment-reference/Sources/Public/ClientConfig.swift b/seed/swift-sdk/multi-url-environment-reference/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/multi-url-environment-reference/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/multi-url-environment-reference/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/multi-url-environment-reference/Sources/Resources/Auth/AuthClient.swift b/seed/swift-sdk/multi-url-environment-reference/Sources/Resources/Auth/AuthClient.swift index f443a0117931..561fe8025718 100644 --- a/seed/swift-sdk/multi-url-environment-reference/Sources/Resources/Auth/AuthClient.swift +++ b/seed/swift-sdk/multi-url-environment-reference/Sources/Resources/Auth/AuthClient.swift @@ -11,6 +11,7 @@ public final class AuthClient: Sendable { return try await httpClient.performRequest( method: .post, path: "/oauth/token", + baseUrlId: "Auth", body: request, requestOptions: requestOptions, responseType: AuthGetTokenResponse.self diff --git a/seed/swift-sdk/multi-url-environment-reference/Sources/Resources/Files/FilesClient.swift b/seed/swift-sdk/multi-url-environment-reference/Sources/Resources/Files/FilesClient.swift index 188ea20e2df3..3f6252bf03b0 100644 --- a/seed/swift-sdk/multi-url-environment-reference/Sources/Resources/Files/FilesClient.swift +++ b/seed/swift-sdk/multi-url-environment-reference/Sources/Resources/Files/FilesClient.swift @@ -11,6 +11,7 @@ public final class FilesClient: Sendable { return try await httpClient.performRequest( method: .post, path: "/files/content", + baseUrlId: "Upload", body: request, requestOptions: requestOptions, responseType: String.self diff --git a/seed/swift-sdk/multi-url-environment-reference/Sources/Resources/Items/ItemsClient.swift b/seed/swift-sdk/multi-url-environment-reference/Sources/Resources/Items/ItemsClient.swift index b1c8f543dce0..84c70245eb33 100644 --- a/seed/swift-sdk/multi-url-environment-reference/Sources/Resources/Items/ItemsClient.swift +++ b/seed/swift-sdk/multi-url-environment-reference/Sources/Resources/Items/ItemsClient.swift @@ -11,6 +11,7 @@ public final class ItemsClient: Sendable { return try await httpClient.performRequest( method: .get, path: "/items", + baseUrlId: "Base", requestOptions: requestOptions, responseType: String.self ) diff --git a/seed/swift-sdk/multi-url-environment/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/multi-url-environment/Sources/Core/Networking/HTTPClient.swift index d937fb2f901b..f294dbd84732 100644 --- a/seed/swift-sdk/multi-url-environment/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/multi-url-environment/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/multi-url-environment/Sources/MultiUrlEnvironmentClient.swift b/seed/swift-sdk/multi-url-environment/Sources/MultiUrlEnvironmentClient.swift index a6b3088e8c4c..fc5babe1f1ab 100644 --- a/seed/swift-sdk/multi-url-environment/Sources/MultiUrlEnvironmentClient.swift +++ b/seed/swift-sdk/multi-url-environment/Sources/MultiUrlEnvironmentClient.swift @@ -8,14 +8,14 @@ public final class MultiUrlEnvironmentClient: Sendable { /// Initialize the client with the specified configuration and a static bearer token. /// - /// - Parameter baseURL: The base URL to use for requests from the client. If not provided, the default base URL will be used. + /// - Parameter environment: The environment to use for requests from the client. If not provided, the default environment will be used. /// - Parameter token: Bearer token for authentication. If provided, will be sent as "Bearer {token}" in Authorization header. /// - Parameter headers: Additional headers to send with each request. /// - Parameter timeout: Request timeout in seconds. Defaults to 60 seconds. Ignored if a custom `urlSession` is provided. /// - Parameter maxRetries: Maximum number of retries for failed requests. Defaults to 2. /// - Parameter urlSession: Custom `URLSession` to use for requests. If not provided, a default session will be created with the specified timeout. public convenience init( - baseURL: String, + environment: MultiUrlEnvironmentEnvironment = MultiUrlEnvironmentEnvironment.production, token: String, headers: [String: String]? = nil, timeout: Int? = nil, @@ -23,7 +23,7 @@ public final class MultiUrlEnvironmentClient: Sendable { urlSession: Networking.URLSession? = nil ) { self.init( - baseURL: baseURL, + environment: environment, headerAuth: nil, bearerAuth: .init(token: .staticToken(token)), basicAuth: nil, @@ -36,14 +36,14 @@ public final class MultiUrlEnvironmentClient: Sendable { /// Initialize the client with the specified configuration and an async bearer token provider. /// - /// - Parameter baseURL: The base URL to use for requests from the client. If not provided, the default base URL will be used. + /// - Parameter environment: The environment to use for requests from the client. If not provided, the default environment will be used. /// - Parameter token: An async function that returns the bearer token for authentication. If provided, will be sent as "Bearer {token}" in Authorization header. /// - Parameter headers: Additional headers to send with each request. /// - Parameter timeout: Request timeout in seconds. Defaults to 60 seconds. Ignored if a custom `urlSession` is provided. /// - Parameter maxRetries: Maximum number of retries for failed requests. Defaults to 2. /// - Parameter urlSession: Custom `URLSession` to use for requests. If not provided, a default session will be created with the specified timeout. public convenience init( - baseURL: String, + environment: MultiUrlEnvironmentEnvironment = MultiUrlEnvironmentEnvironment.production, token: @escaping ClientConfig.CredentialProvider, headers: [String: String]? = nil, timeout: Int? = nil, @@ -51,7 +51,7 @@ public final class MultiUrlEnvironmentClient: Sendable { urlSession: Networking.URLSession? = nil ) { self.init( - baseURL: baseURL, + environment: environment, headerAuth: nil, bearerAuth: .init(token: .provider(token)), basicAuth: nil, @@ -63,7 +63,7 @@ public final class MultiUrlEnvironmentClient: Sendable { } init( - baseURL: String, + environment: MultiUrlEnvironmentEnvironment = MultiUrlEnvironmentEnvironment.production, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, @@ -73,7 +73,11 @@ public final class MultiUrlEnvironmentClient: Sendable { urlSession: Networking.URLSession? = nil ) { let config = ClientConfig( - baseURL: baseURL, + baseURL: environment.ec2, + baseUrls: [ + "ec2": environment.ec2, + "s3": environment.s3 + ], headerAuth: headerAuth, bearerAuth: bearerAuth, basicAuth: basicAuth, diff --git a/seed/swift-sdk/multi-url-environment/Sources/MultiUrlEnvironmentEnvironment.swift b/seed/swift-sdk/multi-url-environment/Sources/MultiUrlEnvironmentEnvironment.swift new file mode 100644 index 000000000000..c82c4379698f --- /dev/null +++ b/seed/swift-sdk/multi-url-environment/Sources/MultiUrlEnvironmentEnvironment.swift @@ -0,0 +1,19 @@ +import Foundation + +public struct MultiUrlEnvironmentEnvironment: Equatable, Sendable { + public let ec2: String + public let s3: String + public static let production: MultiUrlEnvironmentEnvironment = MultiUrlEnvironmentEnvironment( + ec2: "https://ec2.aws.com", + s3: "https://s3.aws.com" + ) + public static let staging: MultiUrlEnvironmentEnvironment = MultiUrlEnvironmentEnvironment( + ec2: "https://staging.ec2.aws.com", + s3: "https://staging.s3.aws.com" + ) + + public init(ec2: String, s3: String) { + self.ec2 = ec2 + self.s3 = s3 + } +} \ No newline at end of file diff --git a/seed/swift-sdk/multi-url-environment/Sources/Public/ClientConfig.swift b/seed/swift-sdk/multi-url-environment/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/multi-url-environment/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/multi-url-environment/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/multi-url-environment/Sources/Resources/Ec2/Ec2Client.swift b/seed/swift-sdk/multi-url-environment/Sources/Resources/Ec2/Ec2Client.swift index 82e627e64311..0cdee5692cae 100644 --- a/seed/swift-sdk/multi-url-environment/Sources/Resources/Ec2/Ec2Client.swift +++ b/seed/swift-sdk/multi-url-environment/Sources/Resources/Ec2/Ec2Client.swift @@ -11,6 +11,7 @@ public final class Ec2Client: Sendable { return try await httpClient.performRequest( method: .post, path: "/ec2/boot", + baseUrlId: "ec2", body: request, requestOptions: requestOptions ) diff --git a/seed/swift-sdk/multi-url-environment/Sources/Resources/S3/S3Client.swift b/seed/swift-sdk/multi-url-environment/Sources/Resources/S3/S3Client.swift index 0437fe3ac217..f17625aa6152 100644 --- a/seed/swift-sdk/multi-url-environment/Sources/Resources/S3/S3Client.swift +++ b/seed/swift-sdk/multi-url-environment/Sources/Resources/S3/S3Client.swift @@ -11,6 +11,7 @@ public final class S3Client: Sendable { return try await httpClient.performRequest( method: .post, path: "/s3/presigned-url", + baseUrlId: "s3", body: request, requestOptions: requestOptions, responseType: String.self diff --git a/seed/swift-sdk/multiple-request-bodies/Sources/ApiClient.swift b/seed/swift-sdk/multiple-request-bodies/Sources/ApiClient.swift index e0e2e7e1003d..8c0c9234b65b 100644 --- a/seed/swift-sdk/multiple-request-bodies/Sources/ApiClient.swift +++ b/seed/swift-sdk/multiple-request-bodies/Sources/ApiClient.swift @@ -61,7 +61,7 @@ public final class ApiClient: Sendable { } init( - baseURL: String, + baseURL: String = ApiEnvironment.default.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/multiple-request-bodies/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/multiple-request-bodies/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/multiple-request-bodies/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/multiple-request-bodies/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/multiple-request-bodies/Sources/Public/ClientConfig.swift b/seed/swift-sdk/multiple-request-bodies/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/multiple-request-bodies/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/multiple-request-bodies/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/no-content-response/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/no-content-response/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/no-content-response/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/no-content-response/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/no-content-response/Sources/Public/ClientConfig.swift b/seed/swift-sdk/no-content-response/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/no-content-response/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/no-content-response/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/no-environment/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/no-environment/Sources/Core/Networking/HTTPClient.swift index 36356ccd6827..93d4ca23286d 100644 --- a/seed/swift-sdk/no-environment/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/no-environment/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/no-environment/Sources/Public/ClientConfig.swift b/seed/swift-sdk/no-environment/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/no-environment/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/no-environment/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/no-retries/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/no-retries/Sources/Core/Networking/HTTPClient.swift index d689f8519532..caf4b698aa5b 100644 --- a/seed/swift-sdk/no-retries/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/no-retries/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/no-retries/Sources/Public/ClientConfig.swift b/seed/swift-sdk/no-retries/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/no-retries/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/no-retries/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/null-type/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/null-type/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/null-type/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/null-type/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/null-type/Sources/Public/ClientConfig.swift b/seed/swift-sdk/null-type/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/null-type/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/null-type/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/nullable-allof-extends/Sources/ApiClient.swift b/seed/swift-sdk/nullable-allof-extends/Sources/ApiClient.swift index df9d567c8f86..b13502ef5bbe 100644 --- a/seed/swift-sdk/nullable-allof-extends/Sources/ApiClient.swift +++ b/seed/swift-sdk/nullable-allof-extends/Sources/ApiClient.swift @@ -31,7 +31,7 @@ public final class ApiClient: Sendable { } init( - baseURL: String, + baseURL: String = ApiEnvironment.default.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/nullable-allof-extends/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/nullable-allof-extends/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/nullable-allof-extends/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/nullable-allof-extends/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/nullable-allof-extends/Sources/Public/ClientConfig.swift b/seed/swift-sdk/nullable-allof-extends/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/nullable-allof-extends/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/nullable-allof-extends/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/nullable-optional/no-custom-config/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/nullable-optional/no-custom-config/Sources/Core/Networking/HTTPClient.swift index 94221906b45d..37ec92aa74a4 100644 --- a/seed/swift-sdk/nullable-optional/no-custom-config/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/nullable-optional/no-custom-config/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/nullable-optional/no-custom-config/Sources/Public/ClientConfig.swift b/seed/swift-sdk/nullable-optional/no-custom-config/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/nullable-optional/no-custom-config/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/nullable-optional/no-custom-config/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/nullable-optional/nullable-as-optional/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/nullable-optional/nullable-as-optional/Sources/Core/Networking/HTTPClient.swift index 94221906b45d..37ec92aa74a4 100644 --- a/seed/swift-sdk/nullable-optional/nullable-as-optional/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/nullable-optional/nullable-as-optional/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/nullable-optional/nullable-as-optional/Sources/Public/ClientConfig.swift b/seed/swift-sdk/nullable-optional/nullable-as-optional/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/nullable-optional/nullable-as-optional/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/nullable-optional/nullable-as-optional/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/nullable-request-body/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/nullable-request-body/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/nullable-request-body/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/nullable-request-body/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/nullable-request-body/Sources/Public/ClientConfig.swift b/seed/swift-sdk/nullable-request-body/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/nullable-request-body/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/nullable-request-body/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/nullable/no-custom-config/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/nullable/no-custom-config/Sources/Core/Networking/HTTPClient.swift index c379dcf5a4fd..172f6c0e8914 100644 --- a/seed/swift-sdk/nullable/no-custom-config/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/nullable/no-custom-config/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/nullable/no-custom-config/Sources/Public/ClientConfig.swift b/seed/swift-sdk/nullable/no-custom-config/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/nullable/no-custom-config/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/nullable/no-custom-config/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/nullable/nullable-as-optional/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/nullable/nullable-as-optional/Sources/Core/Networking/HTTPClient.swift index c379dcf5a4fd..172f6c0e8914 100644 --- a/seed/swift-sdk/nullable/nullable-as-optional/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/nullable/nullable-as-optional/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/nullable/nullable-as-optional/Sources/Public/ClientConfig.swift b/seed/swift-sdk/nullable/nullable-as-optional/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/nullable/nullable-as-optional/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/nullable/nullable-as-optional/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/oauth-client-credentials-custom/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/oauth-client-credentials-custom/Sources/Core/Networking/HTTPClient.swift index ce4e8b9565d0..3d7759e22a4e 100644 --- a/seed/swift-sdk/oauth-client-credentials-custom/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/oauth-client-credentials-custom/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/oauth-client-credentials-custom/Sources/Public/ClientConfig.swift b/seed/swift-sdk/oauth-client-credentials-custom/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/oauth-client-credentials-custom/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/oauth-client-credentials-custom/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/oauth-client-credentials-default/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/oauth-client-credentials-default/Sources/Core/Networking/HTTPClient.swift index 61bfc0d44ee4..986bc75baba8 100644 --- a/seed/swift-sdk/oauth-client-credentials-default/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/oauth-client-credentials-default/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/oauth-client-credentials-default/Sources/Public/ClientConfig.swift b/seed/swift-sdk/oauth-client-credentials-default/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/oauth-client-credentials-default/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/oauth-client-credentials-default/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/oauth-client-credentials-environment-variables/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/oauth-client-credentials-environment-variables/Sources/Core/Networking/HTTPClient.swift index 34a0291a737a..00a2937c36b6 100644 --- a/seed/swift-sdk/oauth-client-credentials-environment-variables/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/oauth-client-credentials-environment-variables/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/oauth-client-credentials-environment-variables/Sources/Public/ClientConfig.swift b/seed/swift-sdk/oauth-client-credentials-environment-variables/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/oauth-client-credentials-environment-variables/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/oauth-client-credentials-environment-variables/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/oauth-client-credentials-mandatory-auth/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/oauth-client-credentials-mandatory-auth/Sources/Core/Networking/HTTPClient.swift index 7905236fbeb4..b47d9c7f9170 100644 --- a/seed/swift-sdk/oauth-client-credentials-mandatory-auth/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/oauth-client-credentials-mandatory-auth/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/oauth-client-credentials-mandatory-auth/Sources/Public/ClientConfig.swift b/seed/swift-sdk/oauth-client-credentials-mandatory-auth/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/oauth-client-credentials-mandatory-auth/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/oauth-client-credentials-mandatory-auth/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/oauth-client-credentials-nested-root/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/oauth-client-credentials-nested-root/Sources/Core/Networking/HTTPClient.swift index ce4e8b9565d0..3d7759e22a4e 100644 --- a/seed/swift-sdk/oauth-client-credentials-nested-root/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/oauth-client-credentials-nested-root/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/oauth-client-credentials-nested-root/Sources/Public/ClientConfig.swift b/seed/swift-sdk/oauth-client-credentials-nested-root/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/oauth-client-credentials-nested-root/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/oauth-client-credentials-nested-root/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/oauth-client-credentials-openapi/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/oauth-client-credentials-openapi/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/oauth-client-credentials-openapi/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/oauth-client-credentials-openapi/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/oauth-client-credentials-openapi/Sources/Public/ClientConfig.swift b/seed/swift-sdk/oauth-client-credentials-openapi/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/oauth-client-credentials-openapi/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/oauth-client-credentials-openapi/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/oauth-client-credentials-reference/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/oauth-client-credentials-reference/Sources/Core/Networking/HTTPClient.swift index bb30570b435a..bf0f436f69ba 100644 --- a/seed/swift-sdk/oauth-client-credentials-reference/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/oauth-client-credentials-reference/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/oauth-client-credentials-reference/Sources/Public/ClientConfig.swift b/seed/swift-sdk/oauth-client-credentials-reference/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/oauth-client-credentials-reference/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/oauth-client-credentials-reference/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/oauth-client-credentials-with-variables/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/oauth-client-credentials-with-variables/Sources/Core/Networking/HTTPClient.swift index 67a74dc4eb8a..6eec4ba7d301 100644 --- a/seed/swift-sdk/oauth-client-credentials-with-variables/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/oauth-client-credentials-with-variables/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/oauth-client-credentials-with-variables/Sources/Public/ClientConfig.swift b/seed/swift-sdk/oauth-client-credentials-with-variables/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/oauth-client-credentials-with-variables/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/oauth-client-credentials-with-variables/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/oauth-client-credentials/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/oauth-client-credentials/Sources/Core/Networking/HTTPClient.swift index ce4e8b9565d0..3d7759e22a4e 100644 --- a/seed/swift-sdk/oauth-client-credentials/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/oauth-client-credentials/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/oauth-client-credentials/Sources/Public/ClientConfig.swift b/seed/swift-sdk/oauth-client-credentials/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/oauth-client-credentials/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/oauth-client-credentials/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/object/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/object/Sources/Core/Networking/HTTPClient.swift index c2726c22c021..8acbd3822ed6 100644 --- a/seed/swift-sdk/object/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/object/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/object/Sources/Public/ClientConfig.swift b/seed/swift-sdk/object/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/object/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/object/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/objects-with-imports/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/objects-with-imports/Sources/Core/Networking/HTTPClient.swift index 4acab5c93ebc..e36085fc3606 100644 --- a/seed/swift-sdk/objects-with-imports/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/objects-with-imports/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/objects-with-imports/Sources/Public/ClientConfig.swift b/seed/swift-sdk/objects-with-imports/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/objects-with-imports/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/objects-with-imports/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/openapi-request-body-ref/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/openapi-request-body-ref/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/openapi-request-body-ref/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/openapi-request-body-ref/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/openapi-request-body-ref/Sources/Public/ClientConfig.swift b/seed/swift-sdk/openapi-request-body-ref/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/openapi-request-body-ref/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/openapi-request-body-ref/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/openapi-subtitle/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/openapi-subtitle/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/openapi-subtitle/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/openapi-subtitle/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/openapi-subtitle/Sources/Public/ClientConfig.swift b/seed/swift-sdk/openapi-subtitle/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/openapi-subtitle/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/openapi-subtitle/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/optional/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/optional/Sources/Core/Networking/HTTPClient.swift index 4acab5c93ebc..e36085fc3606 100644 --- a/seed/swift-sdk/optional/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/optional/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/optional/Sources/Public/ClientConfig.swift b/seed/swift-sdk/optional/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/optional/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/optional/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/package-yml/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/package-yml/Sources/Core/Networking/HTTPClient.swift index 7dac317fe73e..9f3a191598b0 100644 --- a/seed/swift-sdk/package-yml/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/package-yml/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/package-yml/Sources/Public/ClientConfig.swift b/seed/swift-sdk/package-yml/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/package-yml/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/package-yml/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/pagination-custom/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/pagination-custom/Sources/Core/Networking/HTTPClient.swift index e85bd8595bfe..06d80fb3968e 100644 --- a/seed/swift-sdk/pagination-custom/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/pagination-custom/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/pagination-custom/Sources/Public/ClientConfig.swift b/seed/swift-sdk/pagination-custom/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/pagination-custom/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/pagination-custom/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/pagination-uri-path/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/pagination-uri-path/Sources/Core/Networking/HTTPClient.swift index 9cc4ccbae17d..e81ba722766d 100644 --- a/seed/swift-sdk/pagination-uri-path/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/pagination-uri-path/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/pagination-uri-path/Sources/Public/ClientConfig.swift b/seed/swift-sdk/pagination-uri-path/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/pagination-uri-path/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/pagination-uri-path/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Sources/Core/Networking/HTTPClient.swift index e85bd8595bfe..06d80fb3968e 100644 --- a/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Sources/Public/ClientConfig.swift b/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/pagination/custom-pager/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/pagination/custom-pager/Sources/Core/Networking/HTTPClient.swift index e85bd8595bfe..06d80fb3968e 100644 --- a/seed/swift-sdk/pagination/custom-pager/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/pagination/custom-pager/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/pagination/custom-pager/Sources/Public/ClientConfig.swift b/seed/swift-sdk/pagination/custom-pager/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/pagination/custom-pager/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/pagination/custom-pager/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/pagination/no-custom-config/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/pagination/no-custom-config/Sources/Core/Networking/HTTPClient.swift index e85bd8595bfe..06d80fb3968e 100644 --- a/seed/swift-sdk/pagination/no-custom-config/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/pagination/no-custom-config/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/pagination/no-custom-config/Sources/Public/ClientConfig.swift b/seed/swift-sdk/pagination/no-custom-config/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/pagination/no-custom-config/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/pagination/no-custom-config/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/path-parameters/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/path-parameters/Sources/Core/Networking/HTTPClient.swift index a652b3174030..9b6a042ba593 100644 --- a/seed/swift-sdk/path-parameters/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/path-parameters/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/path-parameters/Sources/Public/ClientConfig.swift b/seed/swift-sdk/path-parameters/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/path-parameters/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/path-parameters/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/plain-text/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/plain-text/Sources/Core/Networking/HTTPClient.swift index bc7a6f8ed4c8..ed3c521cc1da 100644 --- a/seed/swift-sdk/plain-text/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/plain-text/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/plain-text/Sources/Public/ClientConfig.swift b/seed/swift-sdk/plain-text/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/plain-text/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/plain-text/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/property-access/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/property-access/Sources/Core/Networking/HTTPClient.swift index 00706fa3a075..9e848f0618e0 100644 --- a/seed/swift-sdk/property-access/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/property-access/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/property-access/Sources/Public/ClientConfig.swift b/seed/swift-sdk/property-access/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/property-access/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/property-access/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/public-object/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/public-object/Sources/Core/Networking/HTTPClient.swift index ca0d7d47527d..1d684db626ec 100644 --- a/seed/swift-sdk/public-object/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/public-object/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/public-object/Sources/Public/ClientConfig.swift b/seed/swift-sdk/public-object/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/public-object/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/public-object/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/query-param-name-conflict/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/query-param-name-conflict/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/query-param-name-conflict/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/query-param-name-conflict/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/query-param-name-conflict/Sources/Public/ClientConfig.swift b/seed/swift-sdk/query-param-name-conflict/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/query-param-name-conflict/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/query-param-name-conflict/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Public/ClientConfig.swift b/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/query-parameters-openapi/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/query-parameters-openapi/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/query-parameters-openapi/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/query-parameters-openapi/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/query-parameters-openapi/Sources/Public/ClientConfig.swift b/seed/swift-sdk/query-parameters-openapi/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/query-parameters-openapi/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/query-parameters-openapi/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/query-parameters/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/query-parameters/Sources/Core/Networking/HTTPClient.swift index 1e140a437ac0..3fa0d5e7cf3c 100644 --- a/seed/swift-sdk/query-parameters/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/query-parameters/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/query-parameters/Sources/Public/ClientConfig.swift b/seed/swift-sdk/query-parameters/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/query-parameters/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/query-parameters/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/request-parameters/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/request-parameters/Sources/Core/Networking/HTTPClient.swift index 734a65221ea7..3fb801a0fc71 100644 --- a/seed/swift-sdk/request-parameters/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/request-parameters/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/request-parameters/Sources/Public/ClientConfig.swift b/seed/swift-sdk/request-parameters/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/request-parameters/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/request-parameters/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/required-nullable/no-custom-config/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/required-nullable/no-custom-config/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/required-nullable/no-custom-config/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/required-nullable/no-custom-config/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/required-nullable/no-custom-config/Sources/Public/ClientConfig.swift b/seed/swift-sdk/required-nullable/no-custom-config/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/required-nullable/no-custom-config/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/required-nullable/no-custom-config/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/required-nullable/nullable-as-optional/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/required-nullable/nullable-as-optional/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/required-nullable/nullable-as-optional/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/required-nullable/nullable-as-optional/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/required-nullable/nullable-as-optional/Sources/Public/ClientConfig.swift b/seed/swift-sdk/required-nullable/nullable-as-optional/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/required-nullable/nullable-as-optional/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/required-nullable/nullable-as-optional/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/reserved-keywords/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/reserved-keywords/Sources/Core/Networking/HTTPClient.swift index b1fb0d382b15..f0967d6d3fab 100644 --- a/seed/swift-sdk/reserved-keywords/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/reserved-keywords/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/reserved-keywords/Sources/Public/ClientConfig.swift b/seed/swift-sdk/reserved-keywords/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/reserved-keywords/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/reserved-keywords/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/response-property/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/response-property/Sources/Core/Networking/HTTPClient.swift index a411dbb991f6..a233a1c249e7 100644 --- a/seed/swift-sdk/response-property/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/response-property/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/response-property/Sources/Public/ClientConfig.swift b/seed/swift-sdk/response-property/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/response-property/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/response-property/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/schemaless-request-body-examples/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/schemaless-request-body-examples/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/schemaless-request-body-examples/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/schemaless-request-body-examples/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/schemaless-request-body-examples/Sources/Public/ClientConfig.swift b/seed/swift-sdk/schemaless-request-body-examples/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/schemaless-request-body-examples/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/schemaless-request-body-examples/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/seed.yml b/seed/swift-sdk/seed.yml index 9f3fdfab1539..b651ef1823b4 100644 --- a/seed/swift-sdk/seed.yml +++ b/seed/swift-sdk/seed.yml @@ -131,5 +131,3 @@ allowedFailures: - multi-url-environment - multi-url-environment-no-default - multi-url-environment-reference - # Server URL templating not yet supported in Swift SDK - - server-url-templating diff --git a/seed/swift-sdk/server-sent-event-examples/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/server-sent-event-examples/Sources/Core/Networking/HTTPClient.swift index 2a025f9d980e..fed901878779 100644 --- a/seed/swift-sdk/server-sent-event-examples/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/server-sent-event-examples/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/server-sent-event-examples/Sources/Public/ClientConfig.swift b/seed/swift-sdk/server-sent-event-examples/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/server-sent-event-examples/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/server-sent-event-examples/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/server-sent-events-openapi/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/server-sent-events-openapi/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/server-sent-events-openapi/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/server-sent-events-openapi/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/server-sent-events-openapi/Sources/Public/ClientConfig.swift b/seed/swift-sdk/server-sent-events-openapi/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/server-sent-events-openapi/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/server-sent-events-openapi/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/server-sent-events-resumable/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/server-sent-events-resumable/Sources/Core/Networking/HTTPClient.swift index b177f343802c..ae59e9bb64aa 100644 --- a/seed/swift-sdk/server-sent-events-resumable/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/server-sent-events-resumable/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/server-sent-events-resumable/Sources/Public/ClientConfig.swift b/seed/swift-sdk/server-sent-events-resumable/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/server-sent-events-resumable/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/server-sent-events-resumable/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/server-sent-events/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/server-sent-events/Sources/Core/Networking/HTTPClient.swift index 2a025f9d980e..fed901878779 100644 --- a/seed/swift-sdk/server-sent-events/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/server-sent-events/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/server-sent-events/Sources/Public/ClientConfig.swift b/seed/swift-sdk/server-sent-events/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/server-sent-events/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/server-sent-events/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/server-url-templating/Sources/ApiClient.swift b/seed/swift-sdk/server-url-templating/Sources/ApiClient.swift index 16b753f1e290..b0a849cc4fc2 100644 --- a/seed/swift-sdk/server-url-templating/Sources/ApiClient.swift +++ b/seed/swift-sdk/server-url-templating/Sources/ApiClient.swift @@ -6,20 +6,20 @@ public final class ApiClient: Sendable { /// Initialize the client with the specified configuration. /// - /// - Parameter baseURL: The base URL to use for requests from the client. If not provided, the default base URL will be used. + /// - Parameter environment: The environment to use for requests from the client. If not provided, the default environment will be used. /// - Parameter headers: Additional headers to send with each request. /// - Parameter timeout: Request timeout in seconds. Defaults to 60 seconds. Ignored if a custom `urlSession` is provided. /// - Parameter maxRetries: Maximum number of retries for failed requests. Defaults to 2. /// - Parameter urlSession: Custom `URLSession` to use for requests. If not provided, a default session will be created with the specified timeout. public convenience init( - baseURL: String, + environment: ApiEnvironment = ApiEnvironment.regionalApiServer, headers: [String: String]? = nil, timeout: Int? = nil, maxRetries: Int? = nil, urlSession: Networking.URLSession? = nil ) { self.init( - baseURL: baseURL, + environment: environment, headerAuth: nil, bearerAuth: nil, basicAuth: nil, @@ -31,7 +31,7 @@ public final class ApiClient: Sendable { } init( - baseURL: String, + environment: ApiEnvironment = ApiEnvironment.regionalApiServer, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, @@ -41,7 +41,11 @@ public final class ApiClient: Sendable { urlSession: Networking.URLSession? = nil ) { let config = ClientConfig( - baseURL: baseURL, + baseURL: environment.base, + baseUrls: [ + "Base": environment.base, + "Auth": environment.auth + ], headerAuth: headerAuth, bearerAuth: bearerAuth, basicAuth: basicAuth, @@ -57,6 +61,7 @@ public final class ApiClient: Sendable { return try await httpClient.performRequest( method: .get, path: "/users", + baseUrlId: "Base", requestOptions: requestOptions, responseType: [User].self ) @@ -66,6 +71,7 @@ public final class ApiClient: Sendable { return try await httpClient.performRequest( method: .get, path: "/users/\(userId)", + baseUrlId: "Base", requestOptions: requestOptions, responseType: User.self ) @@ -75,6 +81,7 @@ public final class ApiClient: Sendable { return try await httpClient.performRequest( method: .post, path: "/auth/token", + baseUrlId: "Auth", body: request, requestOptions: requestOptions, responseType: TokenResponse.self diff --git a/seed/swift-sdk/server-url-templating/Sources/ApiEnvironment.swift b/seed/swift-sdk/server-url-templating/Sources/ApiEnvironment.swift new file mode 100644 index 000000000000..28fe246f9981 --- /dev/null +++ b/seed/swift-sdk/server-url-templating/Sources/ApiEnvironment.swift @@ -0,0 +1,15 @@ +import Foundation + +public struct ApiEnvironment: Equatable, Sendable { + public let base: String + public let auth: String + public static let regionalApiServer: ApiEnvironment = ApiEnvironment( + base: "https://api.example.com/v1", + auth: "https://auth.example.com" + ) + + public init(base: String, auth: String) { + self.base = base + self.auth = auth + } +} \ No newline at end of file diff --git a/seed/swift-sdk/server-url-templating/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/server-url-templating/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/server-url-templating/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/server-url-templating/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/server-url-templating/Sources/Public/ClientConfig.swift b/seed/swift-sdk/server-url-templating/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/server-url-templating/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/server-url-templating/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/simple-api/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/simple-api/Sources/Core/Networking/HTTPClient.swift index fece38737d4a..ab74b08e1822 100644 --- a/seed/swift-sdk/simple-api/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/simple-api/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/simple-api/Sources/Public/ClientConfig.swift b/seed/swift-sdk/simple-api/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/simple-api/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/simple-api/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/simple-api/Sources/SimpleApiClient.swift b/seed/swift-sdk/simple-api/Sources/SimpleApiClient.swift index 4f8bbd51cb9a..4dc67b9d41b3 100644 --- a/seed/swift-sdk/simple-api/Sources/SimpleApiClient.swift +++ b/seed/swift-sdk/simple-api/Sources/SimpleApiClient.swift @@ -62,7 +62,7 @@ public final class SimpleApiClient: Sendable { } init( - baseURL: String, + baseURL: String = SimpleApiEnvironment.production.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/simple-fhir/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/simple-fhir/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/simple-fhir/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/simple-fhir/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/simple-fhir/Sources/Public/ClientConfig.swift b/seed/swift-sdk/simple-fhir/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/simple-fhir/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/simple-fhir/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/single-url-environment-default/no-custom-config/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/single-url-environment-default/no-custom-config/Sources/Core/Networking/HTTPClient.swift index 1ea2685d15c4..2835c37b627e 100644 --- a/seed/swift-sdk/single-url-environment-default/no-custom-config/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/single-url-environment-default/no-custom-config/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/single-url-environment-default/no-custom-config/Sources/Public/ClientConfig.swift b/seed/swift-sdk/single-url-environment-default/no-custom-config/Sources/Public/ClientConfig.swift index 50201005f440..241cb0e1ae17 100644 --- a/seed/swift-sdk/single-url-environment-default/no-custom-config/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/single-url-environment-default/no-custom-config/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/single-url-environment-default/no-custom-config/Sources/SingleUrlEnvironmentDefaultClient.swift b/seed/swift-sdk/single-url-environment-default/no-custom-config/Sources/SingleUrlEnvironmentDefaultClient.swift index 56e915c2a4b4..8cccabe6bfc7 100644 --- a/seed/swift-sdk/single-url-environment-default/no-custom-config/Sources/SingleUrlEnvironmentDefaultClient.swift +++ b/seed/swift-sdk/single-url-environment-default/no-custom-config/Sources/SingleUrlEnvironmentDefaultClient.swift @@ -62,7 +62,7 @@ public final class SingleUrlEnvironmentDefaultClient: Sendable { } init( - baseURL: String, + baseURL: String = SingleUrlEnvironmentDefaultEnvironment.production.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/single-url-environment-default/with-custom-config/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/single-url-environment-default/with-custom-config/Sources/Core/Networking/HTTPClient.swift index 1ea2685d15c4..2835c37b627e 100644 --- a/seed/swift-sdk/single-url-environment-default/with-custom-config/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/single-url-environment-default/with-custom-config/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/single-url-environment-default/with-custom-config/Sources/Public/ClientConfig.swift b/seed/swift-sdk/single-url-environment-default/with-custom-config/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/single-url-environment-default/with-custom-config/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/single-url-environment-default/with-custom-config/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/single-url-environment-default/with-custom-config/Sources/SingleUrlEnvironmentDefaultClient.swift b/seed/swift-sdk/single-url-environment-default/with-custom-config/Sources/SingleUrlEnvironmentDefaultClient.swift index 6049434279fd..eb7e375d7bd0 100644 --- a/seed/swift-sdk/single-url-environment-default/with-custom-config/Sources/SingleUrlEnvironmentDefaultClient.swift +++ b/seed/swift-sdk/single-url-environment-default/with-custom-config/Sources/SingleUrlEnvironmentDefaultClient.swift @@ -62,7 +62,7 @@ public final class SingleUrlEnvironmentDefaultClient: Sendable { } init( - baseURL: String, + baseURL: String = MyCustomEnvironment.production.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/single-url-environment-no-default/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/single-url-environment-no-default/Sources/Core/Networking/HTTPClient.swift index f930ad44a114..e84b61c9a13b 100644 --- a/seed/swift-sdk/single-url-environment-no-default/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/single-url-environment-no-default/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/single-url-environment-no-default/Sources/Public/ClientConfig.swift b/seed/swift-sdk/single-url-environment-no-default/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/single-url-environment-no-default/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/single-url-environment-no-default/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/single-url-environment-no-default/Sources/SingleUrlEnvironmentNoDefaultClient.swift b/seed/swift-sdk/single-url-environment-no-default/Sources/SingleUrlEnvironmentNoDefaultClient.swift index 38ae5f518512..9594d6e2f716 100644 --- a/seed/swift-sdk/single-url-environment-no-default/Sources/SingleUrlEnvironmentNoDefaultClient.swift +++ b/seed/swift-sdk/single-url-environment-no-default/Sources/SingleUrlEnvironmentNoDefaultClient.swift @@ -62,7 +62,7 @@ public final class SingleUrlEnvironmentNoDefaultClient: Sendable { } init( - baseURL: String, + baseURL: String = SingleUrlEnvironmentNoDefaultEnvironment.production.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/streaming-parameter/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/streaming-parameter/Sources/Core/Networking/HTTPClient.swift index a85893dd844f..ecb6366431f6 100644 --- a/seed/swift-sdk/streaming-parameter/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/streaming-parameter/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/streaming-parameter/Sources/Public/ClientConfig.swift b/seed/swift-sdk/streaming-parameter/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/streaming-parameter/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/streaming-parameter/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/streaming/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/streaming/Sources/Core/Networking/HTTPClient.swift index a85893dd844f..ecb6366431f6 100644 --- a/seed/swift-sdk/streaming/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/streaming/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/streaming/Sources/Public/ClientConfig.swift b/seed/swift-sdk/streaming/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/streaming/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/streaming/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/trace/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/trace/Sources/Core/Networking/HTTPClient.swift index cd59ef970a78..b019bc7f32ac 100644 --- a/seed/swift-sdk/trace/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/trace/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/trace/Sources/Public/ClientConfig.swift b/seed/swift-sdk/trace/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/trace/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/trace/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/trace/Sources/TraceClient.swift b/seed/swift-sdk/trace/Sources/TraceClient.swift index 02800bfb444f..31b1731d9438 100644 --- a/seed/swift-sdk/trace/Sources/TraceClient.swift +++ b/seed/swift-sdk/trace/Sources/TraceClient.swift @@ -85,7 +85,7 @@ public final class TraceClient: Sendable { } init( - baseURL: String, + baseURL: String = TraceEnvironment.prod.rawValue, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, diff --git a/seed/swift-sdk/undiscriminated-union-with-response-property/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/undiscriminated-union-with-response-property/Sources/Core/Networking/HTTPClient.swift index 2bd6888faa3b..226be4a44706 100644 --- a/seed/swift-sdk/undiscriminated-union-with-response-property/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/undiscriminated-union-with-response-property/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/undiscriminated-union-with-response-property/Sources/Public/ClientConfig.swift b/seed/swift-sdk/undiscriminated-union-with-response-property/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/undiscriminated-union-with-response-property/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/undiscriminated-union-with-response-property/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/undiscriminated-unions/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/undiscriminated-unions/Sources/Core/Networking/HTTPClient.swift index 91ecb203b81b..ea10b2a4bd3a 100644 --- a/seed/swift-sdk/undiscriminated-unions/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/undiscriminated-unions/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/undiscriminated-unions/Sources/Public/ClientConfig.swift b/seed/swift-sdk/undiscriminated-unions/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/undiscriminated-unions/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/undiscriminated-unions/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/union-query-parameters/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/union-query-parameters/Sources/Core/Networking/HTTPClient.swift index 9e41532caacf..b6a4ab8a4cd5 100644 --- a/seed/swift-sdk/union-query-parameters/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/union-query-parameters/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/union-query-parameters/Sources/Public/ClientConfig.swift b/seed/swift-sdk/union-query-parameters/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/union-query-parameters/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/union-query-parameters/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/unions-with-local-date/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/unions-with-local-date/Sources/Core/Networking/HTTPClient.swift index 8cbf5b80a431..217698f68cf5 100644 --- a/seed/swift-sdk/unions-with-local-date/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/unions-with-local-date/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/unions-with-local-date/Sources/Public/ClientConfig.swift b/seed/swift-sdk/unions-with-local-date/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/unions-with-local-date/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/unions-with-local-date/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/unions/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/unions/Sources/Core/Networking/HTTPClient.swift index 8cbf5b80a431..217698f68cf5 100644 --- a/seed/swift-sdk/unions/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/unions/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/unions/Sources/Public/ClientConfig.swift b/seed/swift-sdk/unions/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/unions/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/unions/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/unknown/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/unknown/Sources/Core/Networking/HTTPClient.swift index ad08b3fc1f6e..d4a402f02424 100644 --- a/seed/swift-sdk/unknown/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/unknown/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/unknown/Sources/Public/ClientConfig.swift b/seed/swift-sdk/unknown/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/unknown/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/unknown/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/url-form-encoded/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/url-form-encoded/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/url-form-encoded/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/url-form-encoded/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/url-form-encoded/Sources/Public/ClientConfig.swift b/seed/swift-sdk/url-form-encoded/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/url-form-encoded/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/url-form-encoded/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/validation/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/validation/Sources/Core/Networking/HTTPClient.swift index 10ed1f46aef6..0a63574a9537 100644 --- a/seed/swift-sdk/validation/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/validation/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/validation/Sources/Public/ClientConfig.swift b/seed/swift-sdk/validation/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/validation/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/validation/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/variables/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/variables/Sources/Core/Networking/HTTPClient.swift index fae4b06d2b32..06416f77ee64 100644 --- a/seed/swift-sdk/variables/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/variables/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/variables/Sources/Public/ClientConfig.swift b/seed/swift-sdk/variables/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/variables/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/variables/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/version-no-default/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/version-no-default/Sources/Core/Networking/HTTPClient.swift index 843cdd2e2942..5b3d4e4d53de 100644 --- a/seed/swift-sdk/version-no-default/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/version-no-default/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/version-no-default/Sources/Public/ClientConfig.swift b/seed/swift-sdk/version-no-default/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/version-no-default/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/version-no-default/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/version/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/version/Sources/Core/Networking/HTTPClient.swift index 843cdd2e2942..5b3d4e4d53de 100644 --- a/seed/swift-sdk/version/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/version/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/version/Sources/Public/ClientConfig.swift b/seed/swift-sdk/version/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/version/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/version/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/webhook-audience/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/webhook-audience/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/webhook-audience/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/webhook-audience/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/webhook-audience/Sources/Public/ClientConfig.swift b/seed/swift-sdk/webhook-audience/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/webhook-audience/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/webhook-audience/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/webhooks/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/webhooks/Sources/Core/Networking/HTTPClient.swift index d6cd8283e862..ce320a2b586b 100644 --- a/seed/swift-sdk/webhooks/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/webhooks/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/webhooks/Sources/Public/ClientConfig.swift b/seed/swift-sdk/webhooks/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/webhooks/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/webhooks/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/websocket-bearer-auth/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/websocket-bearer-auth/Sources/Core/Networking/HTTPClient.swift index 8fea893695eb..57e259d77766 100644 --- a/seed/swift-sdk/websocket-bearer-auth/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/websocket-bearer-auth/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/websocket-bearer-auth/Sources/Public/ClientConfig.swift b/seed/swift-sdk/websocket-bearer-auth/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/websocket-bearer-auth/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/websocket-bearer-auth/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/websocket-inferred-auth/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/websocket-inferred-auth/Sources/Core/Networking/HTTPClient.swift index d8f0452b76ef..f623d92aa444 100644 --- a/seed/swift-sdk/websocket-inferred-auth/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/websocket-inferred-auth/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/websocket-inferred-auth/Sources/Public/ClientConfig.swift b/seed/swift-sdk/websocket-inferred-auth/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/websocket-inferred-auth/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/websocket-inferred-auth/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/websocket-multi-url/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/websocket-multi-url/Sources/Core/Networking/HTTPClient.swift index 6321f8e54bc7..4e771bbac282 100644 --- a/seed/swift-sdk/websocket-multi-url/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/websocket-multi-url/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/websocket-multi-url/Sources/Public/ClientConfig.swift b/seed/swift-sdk/websocket-multi-url/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/websocket-multi-url/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/websocket-multi-url/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/websocket-multi-url/Sources/WebsocketMultiUrlClient.swift b/seed/swift-sdk/websocket-multi-url/Sources/WebsocketMultiUrlClient.swift index 8ecd11a752ad..09a119d0aa4f 100644 --- a/seed/swift-sdk/websocket-multi-url/Sources/WebsocketMultiUrlClient.swift +++ b/seed/swift-sdk/websocket-multi-url/Sources/WebsocketMultiUrlClient.swift @@ -7,14 +7,14 @@ public final class WebsocketMultiUrlClient: Sendable { /// Initialize the client with the specified configuration and a static bearer token. /// - /// - Parameter baseURL: The base URL to use for requests from the client. If not provided, the default base URL will be used. + /// - Parameter environment: The environment to use for requests from the client. If not provided, the default environment will be used. /// - Parameter token: Bearer token for authentication. If provided, will be sent as "Bearer {token}" in Authorization header. /// - Parameter headers: Additional headers to send with each request. /// - Parameter timeout: Request timeout in seconds. Defaults to 60 seconds. Ignored if a custom `urlSession` is provided. /// - Parameter maxRetries: Maximum number of retries for failed requests. Defaults to 2. /// - Parameter urlSession: Custom `URLSession` to use for requests. If not provided, a default session will be created with the specified timeout. public convenience init( - baseURL: String, + environment: WebsocketMultiUrlEnvironment = WebsocketMultiUrlEnvironment.production, token: String, headers: [String: String]? = nil, timeout: Int? = nil, @@ -22,7 +22,7 @@ public final class WebsocketMultiUrlClient: Sendable { urlSession: Networking.URLSession? = nil ) { self.init( - baseURL: baseURL, + environment: environment, headerAuth: nil, bearerAuth: .init(token: .staticToken(token)), basicAuth: nil, @@ -35,14 +35,14 @@ public final class WebsocketMultiUrlClient: Sendable { /// Initialize the client with the specified configuration and an async bearer token provider. /// - /// - Parameter baseURL: The base URL to use for requests from the client. If not provided, the default base URL will be used. + /// - Parameter environment: The environment to use for requests from the client. If not provided, the default environment will be used. /// - Parameter token: An async function that returns the bearer token for authentication. If provided, will be sent as "Bearer {token}" in Authorization header. /// - Parameter headers: Additional headers to send with each request. /// - Parameter timeout: Request timeout in seconds. Defaults to 60 seconds. Ignored if a custom `urlSession` is provided. /// - Parameter maxRetries: Maximum number of retries for failed requests. Defaults to 2. /// - Parameter urlSession: Custom `URLSession` to use for requests. If not provided, a default session will be created with the specified timeout. public convenience init( - baseURL: String, + environment: WebsocketMultiUrlEnvironment = WebsocketMultiUrlEnvironment.production, token: @escaping ClientConfig.CredentialProvider, headers: [String: String]? = nil, timeout: Int? = nil, @@ -50,7 +50,7 @@ public final class WebsocketMultiUrlClient: Sendable { urlSession: Networking.URLSession? = nil ) { self.init( - baseURL: baseURL, + environment: environment, headerAuth: nil, bearerAuth: .init(token: .provider(token)), basicAuth: nil, @@ -62,7 +62,7 @@ public final class WebsocketMultiUrlClient: Sendable { } init( - baseURL: String, + environment: WebsocketMultiUrlEnvironment = WebsocketMultiUrlEnvironment.production, headerAuth: ClientConfig.HeaderAuth? = nil, bearerAuth: ClientConfig.BearerAuth? = nil, basicAuth: ClientConfig.BasicAuth? = nil, @@ -72,7 +72,11 @@ public final class WebsocketMultiUrlClient: Sendable { urlSession: Networking.URLSession? = nil ) { let config = ClientConfig( - baseURL: baseURL, + baseURL: environment.rest, + baseUrls: [ + "rest": environment.rest, + "wss": environment.wss + ], headerAuth: headerAuth, bearerAuth: bearerAuth, basicAuth: basicAuth, diff --git a/seed/swift-sdk/websocket-multi-url/Sources/WebsocketMultiUrlEnvironment.swift b/seed/swift-sdk/websocket-multi-url/Sources/WebsocketMultiUrlEnvironment.swift new file mode 100644 index 000000000000..71ac426ae8ec --- /dev/null +++ b/seed/swift-sdk/websocket-multi-url/Sources/WebsocketMultiUrlEnvironment.swift @@ -0,0 +1,19 @@ +import Foundation + +public struct WebsocketMultiUrlEnvironment: Equatable, Sendable { + public let rest: String + public let wss: String + public static let production: WebsocketMultiUrlEnvironment = WebsocketMultiUrlEnvironment( + rest: "https://api.production.com", + wss: "wss://ws.production.com" + ) + public static let staging: WebsocketMultiUrlEnvironment = WebsocketMultiUrlEnvironment( + rest: "https://api.staging.com", + wss: "wss://ws.staging.com" + ) + + public init(rest: String, wss: String) { + self.rest = rest + self.wss = wss + } +} \ No newline at end of file diff --git a/seed/swift-sdk/websocket/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/websocket/Sources/Core/Networking/HTTPClient.swift index bd660bf39b21..73282028fa94 100644 --- a/seed/swift-sdk/websocket/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/websocket/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/websocket/Sources/Public/ClientConfig.swift b/seed/swift-sdk/websocket/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/websocket/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/websocket/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth diff --git a/seed/swift-sdk/x-fern-default/Sources/Core/Networking/HTTPClient.swift b/seed/swift-sdk/x-fern-default/Sources/Core/Networking/HTTPClient.swift index 5052f16706e1..a54c97f9c74e 100644 --- a/seed/swift-sdk/x-fern-default/Sources/Core/Networking/HTTPClient.swift +++ b/seed/swift-sdk/x-fern-default/Sources/Core/Networking/HTTPClient.swift @@ -17,6 +17,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -26,6 +27,7 @@ final class HTTPClient: Swift.Sendable { _ = try await performRequest( method: method, path: path, + baseUrlId: baseUrlId, contentType: requestContentType, headers: requestHeaders, queryParams: requestQueryParams, @@ -39,6 +41,7 @@ final class HTTPClient: Swift.Sendable { func performRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, contentType requestContentType: HTTP.ContentType = .applicationJson, headers requestHeaders: [Swift.String: Swift.String?] = [:], queryParams requestQueryParams: [Swift.String: QueryParameter?] = [:], @@ -61,6 +64,7 @@ final class HTTPClient: Swift.Sendable { let request = try await buildRequest( method: method, path: path, + baseUrlId: baseUrlId, requestContentType: requestContentType, requestHeaders: requestHeaders, requestQueryParams: requestQueryParams, @@ -99,6 +103,7 @@ final class HTTPClient: Swift.Sendable { private func buildRequest( method: HTTP.Method, path: Swift.String, + baseUrlId: Swift.String? = nil, requestContentType: HTTP.ContentType, requestHeaders: [Swift.String: Swift.String?], requestQueryParams: [Swift.String: QueryParameter?], @@ -107,7 +112,7 @@ final class HTTPClient: Swift.Sendable { ) async throws -> Networking.URLRequest { // Init with URL let url = buildRequestURL( - path: path, requestQueryParams: requestQueryParams, requestOptions: requestOptions + path: path, baseUrlId: baseUrlId, requestQueryParams: requestQueryParams, requestOptions: requestOptions ) var request = Networking.URLRequest(url: url) @@ -143,10 +148,12 @@ final class HTTPClient: Swift.Sendable { private func buildRequestURL( path: Swift.String, + baseUrlId: Swift.String? = nil, requestQueryParams: [Swift.String: QueryParameter?], requestOptions: RequestOptions? = nil ) -> URL { - let endpointURL = "\(clientConfig.baseURL)\(path)" + let baseURL = baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL + let endpointURL = "\(baseURL)\(path)" guard var components = Foundation.URLComponents(string: endpointURL) else { preconditionFailure( "Invalid URL '\(endpointURL)' - this indicates an unexpected error in the SDK." diff --git a/seed/swift-sdk/x-fern-default/Sources/Public/ClientConfig.swift b/seed/swift-sdk/x-fern-default/Sources/Public/ClientConfig.swift index 01ab9ae13b67..09ba6855aeee 100644 --- a/seed/swift-sdk/x-fern-default/Sources/Public/ClientConfig.swift +++ b/seed/swift-sdk/x-fern-default/Sources/Public/ClientConfig.swift @@ -46,6 +46,7 @@ public final class ClientConfig: Swift.Sendable { } let baseURL: Swift.String + let baseUrls: [Swift.String: Swift.String]? let headerAuth: HeaderAuth? let bearerAuth: BearerAuth? let basicAuth: BasicAuth? @@ -56,6 +57,7 @@ public final class ClientConfig: Swift.Sendable { init( baseURL: Swift.String, + baseUrls: [Swift.String: Swift.String]? = nil, headerAuth: HeaderAuth? = nil, bearerAuth: BearerAuth? = nil, basicAuth: BasicAuth? = nil, @@ -65,6 +67,7 @@ public final class ClientConfig: Swift.Sendable { urlSession: Networking.URLSession? = nil ) { self.baseURL = baseURL + self.baseUrls = baseUrls self.headerAuth = headerAuth self.bearerAuth = bearerAuth self.basicAuth = basicAuth