diff --git a/.fern/metadata.json b/.fern/metadata.json index eb5c29ba1..c7543e2df 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,7 +1,7 @@ { - "cliVersion": "2.2.5", + "cliVersion": "2.8.1", "generatorName": "fernapi/fern-typescript-sdk", - "generatorVersion": "3.33.0", + "generatorVersion": "3.34.0", "generatorConfig": { "namespaceExport": "Square", "allowCustomFetcher": true, diff --git a/package.json b/package.json index 3e168ab12..63972badd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "square", - "version": "43.2.1", + "version": "43.2.2", "private": false, "repository": "github:square/square-nodejs-sdk", "license": "MIT", diff --git a/src/BaseClient.ts b/src/BaseClient.ts index 796b29c04..af3e9759d 100644 --- a/src/BaseClient.ts +++ b/src/BaseClient.ts @@ -1,5 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +import { BearerAuthProvider } from "./auth/BearerAuthProvider.js"; import * as core from "./core"; import { mergeHeaders } from "./core/headers"; import type * as environments from "./environments"; @@ -39,13 +40,22 @@ export interface BaseRequestOptions { headers?: Record | null | undefined>; } -export function normalizeClientOptions(options: T): T { +export type NormalizedClientOptions = T & { + logging: core.logging.Logger; + authProvider?: core.AuthProvider; +}; + +export type NormalizedClientOptionsWithAuth = NormalizedClientOptions & { + authProvider: core.AuthProvider; +}; + +export function normalizeClientOptions(options: T): NormalizedClientOptions { const headers = mergeHeaders( { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "square", - "X-Fern-SDK-Version": "43.2.1", - "User-Agent": "square/43.2.1", + "X-Fern-SDK-Version": "43.2.2", + "User-Agent": "square/43.2.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "Square-Version": options?.version ?? "2025-10-16", @@ -57,5 +67,13 @@ export function normalizeClientOptions(options: T): ...options, logging: core.logging.createLogger(options?.logging), headers, - } as T; + } as NormalizedClientOptions; +} + +export function normalizeClientOptionsWithAuth( + options: T, +): NormalizedClientOptionsWithAuth { + const normalized = normalizeClientOptions(options) as NormalizedClientOptionsWithAuth; + normalized.authProvider ??= new BearerAuthProvider(options); + return normalized; } diff --git a/src/Client.ts b/src/Client.ts index f81557c60..da8da8507 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -37,7 +37,7 @@ import { V1TransactionsClient } from "./api/resources/v1Transactions/client/Clie import { VendorsClient } from "./api/resources/vendors/client/Client"; import { WebhooksClient } from "./api/resources/webhooks/client/Client"; import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient"; -import { normalizeClientOptions } from "./BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "./BaseClient"; export declare namespace SquareClient { export interface Options extends BaseClientOptions {} @@ -46,7 +46,7 @@ export declare namespace SquareClient { } export class SquareClient { - protected readonly _options: SquareClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _mobile: MobileClient | undefined; protected _oAuth: OAuthClient | undefined; protected _v1Transactions: V1TransactionsClient | undefined; @@ -85,7 +85,7 @@ export class SquareClient { protected _webhooks: WebhooksClient | undefined; constructor(options: SquareClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get mobile(): MobileClient { diff --git a/src/api/resources/applePay/client/Client.ts b/src/api/resources/applePay/client/Client.ts index 5579b3dad..a04761717 100644 --- a/src/api/resources/applePay/client/Client.ts +++ b/src/api/resources/applePay/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace ApplePayClient { } export class ApplePayClient { - protected readonly _options: ApplePayClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: ApplePayClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -57,12 +57,11 @@ export class ApplePayClient { request: Square.RegisterDomainRequest, requestOptions?: ApplePayClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -124,13 +123,4 @@ export class ApplePayClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/bankAccounts/client/Client.ts b/src/api/resources/bankAccounts/client/Client.ts index bacd34365..eddc59f1e 100644 --- a/src/api/resources/bankAccounts/client/Client.ts +++ b/src/api/resources/bankAccounts/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace BankAccountsClient { } export class BankAccountsClient { - protected readonly _options: BankAccountsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: BankAccountsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -54,12 +54,11 @@ export class BankAccountsClient { if (locationId !== undefined) { _queryParams.location_id = locationId; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -150,12 +149,11 @@ export class BankAccountsClient { requestOptions?: BankAccountsClient.RequestOptions, ): Promise> { const { v1BankAccountId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -238,12 +236,11 @@ export class BankAccountsClient { requestOptions?: BankAccountsClient.RequestOptions, ): Promise> { const { bankAccountId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -301,13 +298,4 @@ export class BankAccountsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/bookings/client/Client.ts b/src/api/resources/bookings/client/Client.ts index 423a86aba..2b8508014 100644 --- a/src/api/resources/bookings/client/Client.ts +++ b/src/api/resources/bookings/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -20,14 +20,14 @@ export declare namespace BookingsClient { } export class BookingsClient { - protected readonly _options: BookingsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _customAttributeDefinitions: CustomAttributeDefinitionsClient | undefined; protected _customAttributes: CustomAttributesClient | undefined; protected _locationProfiles: LocationProfilesClient | undefined; protected _teamMemberProfiles: TeamMemberProfilesClient | undefined; constructor(options: BookingsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get customAttributeDefinitions(): CustomAttributeDefinitionsClient { @@ -95,12 +95,11 @@ export class BookingsClient { if (startAtMax !== undefined) { _queryParams.start_at_max = startAtMax; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -203,12 +202,11 @@ export class BookingsClient { request: Square.CreateBookingRequest, requestOptions?: BookingsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -300,12 +298,11 @@ export class BookingsClient { request: Square.SearchAvailabilityRequest, requestOptions?: BookingsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -395,12 +392,11 @@ export class BookingsClient { request: Square.BulkRetrieveBookingsRequest, requestOptions?: BookingsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -480,12 +476,11 @@ export class BookingsClient { private async __getBusinessProfile( requestOptions?: BookingsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -567,12 +562,11 @@ export class BookingsClient { requestOptions?: BookingsClient.RequestOptions, ): Promise> { const { locationId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -655,12 +649,11 @@ export class BookingsClient { request: Square.BulkRetrieveTeamMemberBookingProfilesRequest, requestOptions?: BookingsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -751,12 +744,11 @@ export class BookingsClient { requestOptions?: BookingsClient.RequestOptions, ): Promise> { const { bookingId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -843,12 +835,11 @@ export class BookingsClient { requestOptions?: BookingsClient.RequestOptions, ): Promise> { const { bookingId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -940,12 +931,11 @@ export class BookingsClient { requestOptions?: BookingsClient.RequestOptions, ): Promise> { const { bookingId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1009,13 +999,4 @@ export class BookingsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/bookings/resources/customAttributeDefinitions/client/Client.ts b/src/api/resources/bookings/resources/customAttributeDefinitions/client/Client.ts index 33df4821f..d760d1fc2 100644 --- a/src/api/resources/bookings/resources/customAttributeDefinitions/client/Client.ts +++ b/src/api/resources/bookings/resources/customAttributeDefinitions/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CustomAttributeDefinitionsClient { } export class CustomAttributeDefinitionsClient { - protected readonly _options: CustomAttributeDefinitionsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CustomAttributeDefinitionsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -53,12 +53,11 @@ export class CustomAttributeDefinitionsClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -156,12 +155,11 @@ export class CustomAttributeDefinitionsClient { request: Square.bookings.CreateBookingCustomAttributeDefinitionRequest, requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -258,12 +256,11 @@ export class CustomAttributeDefinitionsClient { _queryParams.version = version?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -352,12 +349,11 @@ export class CustomAttributeDefinitionsClient { requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { const { key, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -451,12 +447,11 @@ export class CustomAttributeDefinitionsClient { requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { const { key } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -514,13 +509,4 @@ export class CustomAttributeDefinitionsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/bookings/resources/customAttributes/client/Client.ts b/src/api/resources/bookings/resources/customAttributes/client/Client.ts index c5dcaa4fb..2c9127f3f 100644 --- a/src/api/resources/bookings/resources/customAttributes/client/Client.ts +++ b/src/api/resources/bookings/resources/customAttributes/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CustomAttributesClient { } export class CustomAttributesClient { - protected readonly _options: CustomAttributesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CustomAttributesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -55,12 +55,11 @@ export class CustomAttributesClient { request: Square.bookings.BulkDeleteBookingCustomAttributesRequest, requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -158,12 +157,11 @@ export class CustomAttributesClient { request: Square.bookings.BulkUpsertBookingCustomAttributesRequest, requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -264,12 +262,11 @@ export class CustomAttributesClient { if (withDefinitions !== undefined) { _queryParams.with_definitions = withDefinitions?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -377,12 +374,11 @@ export class CustomAttributesClient { _queryParams.version = version?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -472,12 +468,11 @@ export class CustomAttributesClient { requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { const { bookingId, key, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -572,12 +567,11 @@ export class CustomAttributesClient { requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { const { bookingId, key } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -635,13 +629,4 @@ export class CustomAttributesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/bookings/resources/locationProfiles/client/Client.ts b/src/api/resources/bookings/resources/locationProfiles/client/Client.ts index 1ab1fa5ff..1c88595fe 100644 --- a/src/api/resources/bookings/resources/locationProfiles/client/Client.ts +++ b/src/api/resources/bookings/resources/locationProfiles/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace LocationProfilesClient { } export class LocationProfilesClient { - protected readonly _options: LocationProfilesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: LocationProfilesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -50,12 +50,11 @@ export class LocationProfilesClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -124,13 +123,4 @@ export class LocationProfilesClient { }, }); } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/bookings/resources/teamMemberProfiles/client/Client.ts b/src/api/resources/bookings/resources/teamMemberProfiles/client/Client.ts index d73681869..5fabdc90a 100644 --- a/src/api/resources/bookings/resources/teamMemberProfiles/client/Client.ts +++ b/src/api/resources/bookings/resources/teamMemberProfiles/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace TeamMemberProfilesClient { } export class TeamMemberProfilesClient { - protected readonly _options: TeamMemberProfilesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: TeamMemberProfilesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -58,12 +58,11 @@ export class TeamMemberProfilesClient { if (locationId !== undefined) { _queryParams.location_id = locationId; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -156,12 +155,11 @@ export class TeamMemberProfilesClient { requestOptions?: TeamMemberProfilesClient.RequestOptions, ): Promise> { const { teamMemberId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -219,13 +217,4 @@ export class TeamMemberProfilesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/cards/client/Client.ts b/src/api/resources/cards/client/Client.ts index 34127e617..1962e1e20 100644 --- a/src/api/resources/cards/client/Client.ts +++ b/src/api/resources/cards/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CardsClient { } export class CardsClient { - protected readonly _options: CardsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CardsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -64,12 +64,11 @@ export class CardsClient { omitUndefined: true, }); } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -173,12 +172,11 @@ export class CardsClient { request: Square.CreateCardRequest, requestOptions?: CardsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -264,12 +262,11 @@ export class CardsClient { requestOptions?: CardsClient.RequestOptions, ): Promise> { const { cardId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -350,12 +347,11 @@ export class CardsClient { requestOptions?: CardsClient.RequestOptions, ): Promise> { const { cardId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -411,13 +407,4 @@ export class CardsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/cashDrawers/client/Client.ts b/src/api/resources/cashDrawers/client/Client.ts index 0c62334dd..c1d07c15e 100644 --- a/src/api/resources/cashDrawers/client/Client.ts +++ b/src/api/resources/cashDrawers/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import { ShiftsClient } from "../resources/shifts/client/Client"; export declare namespace CashDrawersClient { @@ -9,11 +9,11 @@ export declare namespace CashDrawersClient { } export class CashDrawersClient { - protected readonly _options: CashDrawersClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _shifts: ShiftsClient | undefined; constructor(options: CashDrawersClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get shifts(): ShiftsClient { diff --git a/src/api/resources/cashDrawers/resources/shifts/client/Client.ts b/src/api/resources/cashDrawers/resources/shifts/client/Client.ts index 17a834cae..6e8ad7720 100644 --- a/src/api/resources/cashDrawers/resources/shifts/client/Client.ts +++ b/src/api/resources/cashDrawers/resources/shifts/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace ShiftsClient { } export class ShiftsClient { - protected readonly _options: ShiftsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: ShiftsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -68,12 +68,11 @@ export class ShiftsClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -170,12 +169,11 @@ export class ShiftsClient { const { shiftId, locationId } = request; const _queryParams: Record = {}; _queryParams.location_id = locationId; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -265,12 +263,11 @@ export class ShiftsClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -339,13 +336,4 @@ export class ShiftsClient { }, }); } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/catalog/client/Client.ts b/src/api/resources/catalog/client/Client.ts index 8c5e8f886..35a50e731 100644 --- a/src/api/resources/catalog/client/Client.ts +++ b/src/api/resources/catalog/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -18,12 +18,12 @@ export declare namespace CatalogClient { } export class CatalogClient { - protected readonly _options: CatalogClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _images: ImagesClient | undefined; protected _object: ObjectClient | undefined; constructor(options: CatalogClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get images(): ImagesClient { @@ -69,12 +69,11 @@ export class CatalogClient { request: Square.BatchDeleteCatalogObjectsRequest, requestOptions?: CatalogClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -165,12 +164,11 @@ export class CatalogClient { request: Square.BatchGetCatalogObjectsRequest, requestOptions?: CatalogClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -282,12 +280,11 @@ export class CatalogClient { request: Square.BatchUpsertCatalogObjectsRequest, requestOptions?: CatalogClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -366,12 +363,11 @@ export class CatalogClient { private async __info( requestOptions?: CatalogClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -465,12 +461,11 @@ export class CatalogClient { if (catalogVersion !== undefined) { _queryParams.catalog_version = catalogVersion?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -576,12 +571,11 @@ export class CatalogClient { request: Square.SearchCatalogObjectsRequest = {}, requestOptions?: CatalogClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -696,12 +690,11 @@ export class CatalogClient { request: Square.SearchCatalogItemsRequest = {}, requestOptions?: CatalogClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -792,12 +785,11 @@ export class CatalogClient { request: Square.UpdateItemModifierListsRequest, requestOptions?: CatalogClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -888,12 +880,11 @@ export class CatalogClient { request: Square.UpdateItemTaxesRequest, requestOptions?: CatalogClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -957,13 +948,4 @@ export class CatalogClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/catalog/resources/images/client/Client.ts b/src/api/resources/catalog/resources/images/client/Client.ts index 191aedf19..a5eefc90d 100644 --- a/src/api/resources/catalog/resources/images/client/Client.ts +++ b/src/api/resources/catalog/resources/images/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import { toJson } from "../../../../../../core/json"; @@ -17,10 +17,10 @@ export declare namespace ImagesClient { } export class ImagesClient { - protected readonly _options: ImagesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: ImagesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -67,10 +67,11 @@ export class ImagesClient { } const _maybeEncodedRequest = await _request.getRequest(); + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), "Square-Version": requestOptions?.version ?? "2025-10-16", ..._maybeEncodedRequest.headers, }), @@ -177,10 +178,11 @@ export class ImagesClient { } const _maybeEncodedRequest = await _request.getRequest(); + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), "Square-Version": requestOptions?.version ?? "2025-10-16", ..._maybeEncodedRequest.headers, }), @@ -242,13 +244,4 @@ export class ImagesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/catalog/resources/object/client/Client.ts b/src/api/resources/catalog/resources/object/client/Client.ts index 653ef2342..c961ef62f 100644 --- a/src/api/resources/catalog/resources/object/client/Client.ts +++ b/src/api/resources/catalog/resources/object/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace ObjectClient { } export class ObjectClient { - protected readonly _options: ObjectClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: ObjectClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -52,12 +52,11 @@ export class ObjectClient { request: Square.catalog.UpsertCatalogObjectRequest, requestOptions?: ObjectClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -165,12 +164,11 @@ export class ObjectClient { _queryParams.include_category_path_to_root = includeCategoryPathToRoot?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -261,12 +259,11 @@ export class ObjectClient { requestOptions?: ObjectClient.RequestOptions, ): Promise> { const { objectId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -324,13 +321,4 @@ export class ObjectClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/channels/client/Client.ts b/src/api/resources/channels/client/Client.ts index 0975335ce..160fe883f 100644 --- a/src/api/resources/channels/client/Client.ts +++ b/src/api/resources/channels/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace ChannelsClient { } export class ChannelsClient { - protected readonly _options: ChannelsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: ChannelsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -66,12 +66,11 @@ export class ChannelsClient { if (limit !== undefined) { _queryParams.limit = limit?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -161,12 +160,11 @@ export class ChannelsClient { request: Square.BulkRetrieveChannelsRequest, requestOptions?: ChannelsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -252,12 +250,11 @@ export class ChannelsClient { requestOptions?: ChannelsClient.RequestOptions, ): Promise> { const { channelId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -313,13 +310,4 @@ export class ChannelsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/checkout/client/Client.ts b/src/api/resources/checkout/client/Client.ts index 5825d213e..df5faa988 100644 --- a/src/api/resources/checkout/client/Client.ts +++ b/src/api/resources/checkout/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -17,11 +17,11 @@ export declare namespace CheckoutClient { } export class CheckoutClient { - protected readonly _options: CheckoutClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _paymentLinks: PaymentLinksClient | undefined; constructor(options: CheckoutClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get paymentLinks(): PaymentLinksClient { @@ -51,12 +51,11 @@ export class CheckoutClient { requestOptions?: CheckoutClient.RequestOptions, ): Promise> { const { locationId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -139,12 +138,11 @@ export class CheckoutClient { requestOptions?: CheckoutClient.RequestOptions, ): Promise> { const { locationId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -226,12 +224,11 @@ export class CheckoutClient { private async __retrieveMerchantSettings( requestOptions?: CheckoutClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -312,12 +309,11 @@ export class CheckoutClient { request: Square.UpdateMerchantSettingsRequest, requestOptions?: CheckoutClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -381,13 +377,4 @@ export class CheckoutClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/checkout/resources/paymentLinks/client/Client.ts b/src/api/resources/checkout/resources/paymentLinks/client/Client.ts index 7b1ab8db1..d4c9fd03e 100644 --- a/src/api/resources/checkout/resources/paymentLinks/client/Client.ts +++ b/src/api/resources/checkout/resources/paymentLinks/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace PaymentLinksClient { } export class PaymentLinksClient { - protected readonly _options: PaymentLinksClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: PaymentLinksClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -50,12 +50,11 @@ export class PaymentLinksClient { if (limit !== undefined) { _queryParams.limit = limit?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -155,12 +154,11 @@ export class PaymentLinksClient { request: Square.checkout.CreatePaymentLinkRequest = {}, requestOptions?: PaymentLinksClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -248,12 +246,11 @@ export class PaymentLinksClient { requestOptions?: PaymentLinksClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -343,12 +340,11 @@ export class PaymentLinksClient { requestOptions?: PaymentLinksClient.RequestOptions, ): Promise> { const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -436,12 +432,11 @@ export class PaymentLinksClient { requestOptions?: PaymentLinksClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -499,13 +494,4 @@ export class PaymentLinksClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/customers/client/Client.ts b/src/api/resources/customers/client/Client.ts index 748a6c5b0..6c7a8751f 100644 --- a/src/api/resources/customers/client/Client.ts +++ b/src/api/resources/customers/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -21,7 +21,7 @@ export declare namespace CustomersClient { } export class CustomersClient { - protected readonly _options: CustomersClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _customAttributeDefinitions: CustomAttributeDefinitionsClient | undefined; protected _groups: GroupsClient | undefined; protected _segments: SegmentsClient | undefined; @@ -29,7 +29,7 @@ export class CustomersClient { protected _customAttributes: CustomAttributesClient | undefined; constructor(options: CustomersClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get customAttributeDefinitions(): CustomAttributeDefinitionsClient { @@ -102,12 +102,11 @@ export class CustomersClient { if (count !== undefined) { _queryParams.count = count?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -219,12 +218,11 @@ export class CustomersClient { request: Square.CreateCustomerRequest = {}, requestOptions?: CustomersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -352,12 +350,11 @@ export class CustomersClient { request: Square.BulkCreateCustomersRequest, requestOptions?: CustomersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -444,12 +441,11 @@ export class CustomersClient { request: Square.BulkDeleteCustomersRequest, requestOptions?: CustomersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -536,12 +532,11 @@ export class CustomersClient { request: Square.BulkRetrieveCustomersRequest, requestOptions?: CustomersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -639,12 +634,11 @@ export class CustomersClient { request: Square.BulkUpdateCustomersRequest, requestOptions?: CustomersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -759,12 +753,11 @@ export class CustomersClient { request: Square.SearchCustomersRequest = {}, requestOptions?: CustomersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -850,12 +843,11 @@ export class CustomersClient { requestOptions?: CustomersClient.RequestOptions, ): Promise> { const { customerId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -941,12 +933,11 @@ export class CustomersClient { requestOptions?: CustomersClient.RequestOptions, ): Promise> { const { customerId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1040,12 +1031,11 @@ export class CustomersClient { _queryParams.version = version?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1103,13 +1093,4 @@ export class CustomersClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/customers/resources/cards/client/Client.ts b/src/api/resources/customers/resources/cards/client/Client.ts index 4e4e36436..feaba7a1b 100644 --- a/src/api/resources/customers/resources/cards/client/Client.ts +++ b/src/api/resources/customers/resources/cards/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CardsClient { } export class CardsClient { - protected readonly _options: CardsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CardsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -59,12 +59,11 @@ export class CardsClient { requestOptions?: CardsClient.RequestOptions, ): Promise> { const { customerId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -153,12 +152,11 @@ export class CardsClient { requestOptions?: CardsClient.RequestOptions, ): Promise> { const { customerId, cardId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -216,13 +214,4 @@ export class CardsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/customers/resources/customAttributeDefinitions/client/Client.ts b/src/api/resources/customers/resources/customAttributeDefinitions/client/Client.ts index ab2242066..649802866 100644 --- a/src/api/resources/customers/resources/customAttributeDefinitions/client/Client.ts +++ b/src/api/resources/customers/resources/customAttributeDefinitions/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CustomAttributeDefinitionsClient { } export class CustomAttributeDefinitionsClient { - protected readonly _options: CustomAttributeDefinitionsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CustomAttributeDefinitionsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -55,12 +55,11 @@ export class CustomAttributeDefinitionsClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -170,12 +169,11 @@ export class CustomAttributeDefinitionsClient { request: Square.customers.CreateCustomerCustomAttributeDefinitionRequest, requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -273,12 +271,11 @@ export class CustomAttributeDefinitionsClient { _queryParams.version = version?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -370,12 +367,11 @@ export class CustomAttributeDefinitionsClient { requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { const { key, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -468,12 +464,11 @@ export class CustomAttributeDefinitionsClient { requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { const { key } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -603,12 +598,11 @@ export class CustomAttributeDefinitionsClient { request: Square.customers.BatchUpsertCustomerCustomAttributesRequest, requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -672,13 +666,4 @@ export class CustomAttributeDefinitionsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/customers/resources/customAttributes/client/Client.ts b/src/api/resources/customers/resources/customAttributes/client/Client.ts index b7f710c5a..c972a44f9 100644 --- a/src/api/resources/customers/resources/customAttributes/client/Client.ts +++ b/src/api/resources/customers/resources/customAttributes/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CustomAttributesClient { } export class CustomAttributesClient { - protected readonly _options: CustomAttributesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CustomAttributesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -62,12 +62,11 @@ export class CustomAttributesClient { if (withDefinitions !== undefined) { _queryParams.with_definitions = withDefinitions?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -179,12 +178,11 @@ export class CustomAttributesClient { _queryParams.version = version?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -278,12 +276,11 @@ export class CustomAttributesClient { requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { const { customerId, key, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -376,12 +373,11 @@ export class CustomAttributesClient { requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { const { customerId, key } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -439,13 +435,4 @@ export class CustomAttributesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/customers/resources/groups/client/Client.ts b/src/api/resources/customers/resources/groups/client/Client.ts index 778f7d564..93ac37980 100644 --- a/src/api/resources/customers/resources/groups/client/Client.ts +++ b/src/api/resources/customers/resources/groups/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace GroupsClient { } export class GroupsClient { - protected readonly _options: GroupsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: GroupsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -50,12 +50,11 @@ export class GroupsClient { if (limit !== undefined) { _queryParams.limit = limit?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -149,12 +148,11 @@ export class GroupsClient { request: Square.customers.CreateCustomerGroupRequest, requestOptions?: GroupsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -240,12 +238,11 @@ export class GroupsClient { requestOptions?: GroupsClient.RequestOptions, ): Promise> { const { groupId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -330,12 +327,11 @@ export class GroupsClient { requestOptions?: GroupsClient.RequestOptions, ): Promise> { const { groupId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -423,12 +419,11 @@ export class GroupsClient { requestOptions?: GroupsClient.RequestOptions, ): Promise> { const { groupId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -514,12 +509,11 @@ export class GroupsClient { requestOptions?: GroupsClient.RequestOptions, ): Promise> { const { customerId, groupId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -605,12 +599,11 @@ export class GroupsClient { requestOptions?: GroupsClient.RequestOptions, ): Promise> { const { customerId, groupId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -668,13 +661,4 @@ export class GroupsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/customers/resources/segments/client/Client.ts b/src/api/resources/customers/resources/segments/client/Client.ts index adf6195eb..e33fa307d 100644 --- a/src/api/resources/customers/resources/segments/client/Client.ts +++ b/src/api/resources/customers/resources/segments/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace SegmentsClient { } export class SegmentsClient { - protected readonly _options: SegmentsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: SegmentsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -50,12 +50,11 @@ export class SegmentsClient { if (limit !== undefined) { _queryParams.limit = limit?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -148,12 +147,11 @@ export class SegmentsClient { requestOptions?: SegmentsClient.RequestOptions, ): Promise> { const { segmentId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -211,13 +209,4 @@ export class SegmentsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/devices/client/Client.ts b/src/api/resources/devices/client/Client.ts index 561d50912..95650d3b7 100644 --- a/src/api/resources/devices/client/Client.ts +++ b/src/api/resources/devices/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -17,11 +17,11 @@ export declare namespace DevicesClient { } export class DevicesClient { - protected readonly _options: DevicesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _codes: CodesClient | undefined; constructor(options: DevicesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get codes(): CodesClient { @@ -66,12 +66,11 @@ export class DevicesClient { if (locationId !== undefined) { _queryParams.location_id = locationId; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -162,12 +161,11 @@ export class DevicesClient { requestOptions?: DevicesClient.RequestOptions, ): Promise> { const { deviceId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -223,13 +221,4 @@ export class DevicesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/devices/resources/codes/client/Client.ts b/src/api/resources/devices/resources/codes/client/Client.ts index 49c724f12..ea05174e6 100644 --- a/src/api/resources/devices/resources/codes/client/Client.ts +++ b/src/api/resources/devices/resources/codes/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CodesClient { } export class CodesClient { - protected readonly _options: CodesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CodesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -64,12 +64,11 @@ export class CodesClient { omitUndefined: true, }); } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -165,12 +164,11 @@ export class CodesClient { request: Square.devices.CreateDeviceCodeRequest, requestOptions?: CodesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -256,12 +254,11 @@ export class CodesClient { requestOptions?: CodesClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -317,13 +314,4 @@ export class CodesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/disputes/client/Client.ts b/src/api/resources/disputes/client/Client.ts index c0872974c..a0af0bdb7 100644 --- a/src/api/resources/disputes/client/Client.ts +++ b/src/api/resources/disputes/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import { toJson } from "../../../../core/json"; @@ -18,11 +18,11 @@ export declare namespace DisputesClient { } export class DisputesClient { - protected readonly _options: DisputesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _evidence: EvidenceClient | undefined; constructor(options: DisputesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get evidence(): EvidenceClient { @@ -62,12 +62,11 @@ export class DisputesClient { if (locationId !== undefined) { _queryParams.location_id = locationId; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -158,12 +157,11 @@ export class DisputesClient { requestOptions?: DisputesClient.RequestOptions, ): Promise> { const { disputeId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -247,12 +245,11 @@ export class DisputesClient { requestOptions?: DisputesClient.RequestOptions, ): Promise> { const { disputeId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -353,10 +350,11 @@ export class DisputesClient { } const _maybeEncodedRequest = await _request.getRequest(); + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), "Square-Version": requestOptions?.version ?? "2025-10-16", ..._maybeEncodedRequest.headers, }), @@ -447,12 +445,11 @@ export class DisputesClient { requestOptions?: DisputesClient.RequestOptions, ): Promise> { const { disputeId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -546,12 +543,11 @@ export class DisputesClient { requestOptions?: DisputesClient.RequestOptions, ): Promise> { const { disputeId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -609,13 +605,4 @@ export class DisputesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/disputes/resources/evidence/client/Client.ts b/src/api/resources/disputes/resources/evidence/client/Client.ts index 8f51f0132..94e357e12 100644 --- a/src/api/resources/disputes/resources/evidence/client/Client.ts +++ b/src/api/resources/disputes/resources/evidence/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace EvidenceClient { } export class EvidenceClient { - protected readonly _options: EvidenceClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: EvidenceClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -47,12 +47,11 @@ export class EvidenceClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -148,12 +147,11 @@ export class EvidenceClient { requestOptions?: EvidenceClient.RequestOptions, ): Promise> { const { disputeId, evidenceId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -237,12 +235,11 @@ export class EvidenceClient { requestOptions?: EvidenceClient.RequestOptions, ): Promise> { const { disputeId, evidenceId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -300,13 +297,4 @@ export class EvidenceClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/employees/client/Client.ts b/src/api/resources/employees/client/Client.ts index e913ba5f2..223cca7d3 100644 --- a/src/api/resources/employees/client/Client.ts +++ b/src/api/resources/employees/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace EmployeesClient { } export class EmployeesClient { - protected readonly _options: EmployeesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: EmployeesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -61,12 +61,11 @@ export class EmployeesClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -157,12 +156,11 @@ export class EmployeesClient { requestOptions?: EmployeesClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -218,13 +216,4 @@ export class EmployeesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/events/client/Client.ts b/src/api/resources/events/client/Client.ts index c1ee6ea62..525583016 100644 --- a/src/api/resources/events/client/Client.ts +++ b/src/api/resources/events/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace EventsClient { } export class EventsClient { - protected readonly _options: EventsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: EventsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -42,12 +42,11 @@ export class EventsClient { request: Square.SearchEventsRequest = {}, requestOptions?: EventsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -129,12 +128,11 @@ export class EventsClient { private async __disableEvents( requestOptions?: EventsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -208,12 +206,11 @@ export class EventsClient { private async __enableEvents( requestOptions?: EventsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -298,12 +295,11 @@ export class EventsClient { _queryParams.api_version = apiVersion; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -359,13 +355,4 @@ export class EventsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/giftCards/client/Client.ts b/src/api/resources/giftCards/client/Client.ts index b1a85117c..0b2b7e342 100644 --- a/src/api/resources/giftCards/client/Client.ts +++ b/src/api/resources/giftCards/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -17,11 +17,11 @@ export declare namespace GiftCardsClient { } export class GiftCardsClient { - protected readonly _options: GiftCardsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _activities: ActivitiesClient | undefined; constructor(options: GiftCardsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get activities(): ActivitiesClient { @@ -69,12 +69,11 @@ export class GiftCardsClient { if (customerId !== undefined) { _queryParams.customer_id = customerId; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -172,12 +171,11 @@ export class GiftCardsClient { request: Square.CreateGiftCardRequest, requestOptions?: GiftCardsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -262,12 +260,11 @@ export class GiftCardsClient { request: Square.GetGiftCardFromGanRequest, requestOptions?: GiftCardsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -352,12 +349,11 @@ export class GiftCardsClient { request: Square.GetGiftCardFromNonceRequest, requestOptions?: GiftCardsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -444,12 +440,11 @@ export class GiftCardsClient { requestOptions?: GiftCardsClient.RequestOptions, ): Promise> { const { giftCardId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -538,12 +533,11 @@ export class GiftCardsClient { requestOptions?: GiftCardsClient.RequestOptions, ): Promise> { const { giftCardId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -631,12 +625,11 @@ export class GiftCardsClient { requestOptions?: GiftCardsClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -692,13 +685,4 @@ export class GiftCardsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/giftCards/resources/activities/client/Client.ts b/src/api/resources/giftCards/resources/activities/client/Client.ts index 26d1f4f83..94fbf1836 100644 --- a/src/api/resources/giftCards/resources/activities/client/Client.ts +++ b/src/api/resources/giftCards/resources/activities/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace ActivitiesClient { } export class ActivitiesClient { - protected readonly _options: ActivitiesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: ActivitiesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -77,12 +77,11 @@ export class ActivitiesClient { if (sortOrder !== undefined) { _queryParams.sort_order = sortOrder; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -184,12 +183,11 @@ export class ActivitiesClient { request: Square.giftCards.CreateGiftCardActivityRequest, requestOptions?: ActivitiesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -251,13 +249,4 @@ export class ActivitiesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/inventory/client/Client.ts b/src/api/resources/inventory/client/Client.ts index b9bb81d50..1b5e69e54 100644 --- a/src/api/resources/inventory/client/Client.ts +++ b/src/api/resources/inventory/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace InventoryClient { } export class InventoryClient { - protected readonly _options: InventoryClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: InventoryClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -46,12 +46,11 @@ export class InventoryClient { requestOptions?: InventoryClient.RequestOptions, ): Promise> { const { adjustmentId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -134,12 +133,11 @@ export class InventoryClient { requestOptions?: InventoryClient.RequestOptions, ): Promise> { const { adjustmentId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -234,12 +232,11 @@ export class InventoryClient { request: Square.BatchChangeInventoryRequest, requestOptions?: InventoryClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -330,12 +327,11 @@ export class InventoryClient { request: Square.BatchRetrieveInventoryChangesRequest, requestOptions?: InventoryClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -425,12 +421,11 @@ export class InventoryClient { request: Square.BatchGetInventoryCountsRequest, requestOptions?: InventoryClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -534,12 +529,11 @@ export class InventoryClient { request: Square.BatchChangeInventoryRequest, requestOptions?: InventoryClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -635,12 +629,11 @@ export class InventoryClient { async ( request: Square.BatchRetrieveInventoryChangesRequest, ): Promise> => { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -747,12 +740,11 @@ export class InventoryClient { async ( request: Square.BatchGetInventoryCountsRequest, ): Promise> => { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -852,12 +844,11 @@ export class InventoryClient { requestOptions?: InventoryClient.RequestOptions, ): Promise> { const { physicalCountId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -940,12 +931,11 @@ export class InventoryClient { requestOptions?: InventoryClient.RequestOptions, ): Promise> { const { physicalCountId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1028,12 +1018,11 @@ export class InventoryClient { requestOptions?: InventoryClient.RequestOptions, ): Promise> { const { transferId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1124,12 +1113,11 @@ export class InventoryClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1240,12 +1228,11 @@ export class InventoryClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1314,13 +1301,4 @@ export class InventoryClient { }, }); } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/invoices/client/Client.ts b/src/api/resources/invoices/client/Client.ts index ae1562f96..2c55bb37c 100644 --- a/src/api/resources/invoices/client/Client.ts +++ b/src/api/resources/invoices/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import { toJson } from "../../../../core/json"; @@ -17,10 +17,10 @@ export declare namespace InvoicesClient { } export class InvoicesClient { - protected readonly _options: InvoicesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: InvoicesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -53,12 +53,11 @@ export class InvoicesClient { if (limit !== undefined) { _queryParams.limit = limit?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -192,12 +191,11 @@ export class InvoicesClient { request: Square.CreateInvoiceRequest, requestOptions?: InvoicesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -298,12 +296,11 @@ export class InvoicesClient { request: Square.SearchInvoicesRequest, requestOptions?: InvoicesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -389,12 +386,11 @@ export class InvoicesClient { requestOptions?: InvoicesClient.RequestOptions, ): Promise> { const { invoiceId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -485,12 +481,11 @@ export class InvoicesClient { requestOptions?: InvoicesClient.RequestOptions, ): Promise> { const { invoiceId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -584,12 +579,11 @@ export class InvoicesClient { _queryParams.version = version?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -694,10 +688,11 @@ export class InvoicesClient { } const _maybeEncodedRequest = await _request.getRequest(); + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), "Square-Version": requestOptions?.version ?? "2025-10-16", ..._maybeEncodedRequest.headers, }), @@ -787,12 +782,11 @@ export class InvoicesClient { requestOptions?: InvoicesClient.RequestOptions, ): Promise> { const { invoiceId, attachmentId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -878,12 +872,11 @@ export class InvoicesClient { requestOptions?: InvoicesClient.RequestOptions, ): Promise> { const { invoiceId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -986,12 +979,11 @@ export class InvoicesClient { requestOptions?: InvoicesClient.RequestOptions, ): Promise> { const { invoiceId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1055,13 +1047,4 @@ export class InvoicesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/labor/client/Client.ts b/src/api/resources/labor/client/Client.ts index d10e8a1c8..e8cbb4c8f 100644 --- a/src/api/resources/labor/client/Client.ts +++ b/src/api/resources/labor/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -21,7 +21,7 @@ export declare namespace LaborClient { } export class LaborClient { - protected readonly _options: LaborClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _breakTypes: BreakTypesClient | undefined; protected _employeeWages: EmployeeWagesClient | undefined; protected _shifts: ShiftsClient | undefined; @@ -29,7 +29,7 @@ export class LaborClient { protected _workweekConfigs: WorkweekConfigsClient | undefined; constructor(options: LaborClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get breakTypes(): BreakTypesClient { @@ -92,12 +92,11 @@ export class LaborClient { request: Square.CreateScheduledShiftRequest, requestOptions?: LaborClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -190,12 +189,11 @@ export class LaborClient { request: Square.BulkPublishScheduledShiftsRequest, requestOptions?: LaborClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -293,12 +291,11 @@ export class LaborClient { request: Square.SearchScheduledShiftsRequest = {}, requestOptions?: LaborClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -386,12 +383,11 @@ export class LaborClient { requestOptions?: LaborClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -494,12 +490,11 @@ export class LaborClient { requestOptions?: LaborClient.RequestOptions, ): Promise> { const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -591,12 +586,11 @@ export class LaborClient { requestOptions?: LaborClient.RequestOptions, ): Promise> { const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -726,12 +720,11 @@ export class LaborClient { request: Square.CreateTimecardRequest, requestOptions?: LaborClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -841,12 +834,11 @@ export class LaborClient { request: Square.SearchTimecardsRequest = {}, requestOptions?: LaborClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -932,12 +924,11 @@ export class LaborClient { requestOptions?: LaborClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1052,12 +1043,11 @@ export class LaborClient { requestOptions?: LaborClient.RequestOptions, ): Promise> { const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1143,12 +1133,11 @@ export class LaborClient { requestOptions?: LaborClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1204,13 +1193,4 @@ export class LaborClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/labor/resources/breakTypes/client/Client.ts b/src/api/resources/labor/resources/breakTypes/client/Client.ts index 8e068679f..c96ab36b2 100644 --- a/src/api/resources/labor/resources/breakTypes/client/Client.ts +++ b/src/api/resources/labor/resources/breakTypes/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace BreakTypesClient { } export class BreakTypesClient { - protected readonly _options: BreakTypesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: BreakTypesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -54,12 +54,11 @@ export class BreakTypesClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -168,12 +167,11 @@ export class BreakTypesClient { request: Square.labor.CreateBreakTypeRequest, requestOptions?: BreakTypesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -259,12 +257,11 @@ export class BreakTypesClient { requestOptions?: BreakTypesClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -351,12 +348,11 @@ export class BreakTypesClient { requestOptions?: BreakTypesClient.RequestOptions, ): Promise> { const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -444,12 +440,11 @@ export class BreakTypesClient { requestOptions?: BreakTypesClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -505,13 +500,4 @@ export class BreakTypesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/labor/resources/employeeWages/client/Client.ts b/src/api/resources/labor/resources/employeeWages/client/Client.ts index 7c91bc303..122642d0b 100644 --- a/src/api/resources/labor/resources/employeeWages/client/Client.ts +++ b/src/api/resources/labor/resources/employeeWages/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace EmployeeWagesClient { } export class EmployeeWagesClient { - protected readonly _options: EmployeeWagesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: EmployeeWagesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -54,12 +54,11 @@ export class EmployeeWagesClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -152,12 +151,11 @@ export class EmployeeWagesClient { requestOptions?: EmployeeWagesClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -213,13 +211,4 @@ export class EmployeeWagesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/labor/resources/shifts/client/Client.ts b/src/api/resources/labor/resources/shifts/client/Client.ts index 4a82b4c74..ba5877d85 100644 --- a/src/api/resources/labor/resources/shifts/client/Client.ts +++ b/src/api/resources/labor/resources/shifts/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace ShiftsClient { } export class ShiftsClient { - protected readonly _options: ShiftsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: ShiftsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -87,12 +87,11 @@ export class ShiftsClient { request: Square.labor.CreateShiftRequest, requestOptions?: ShiftsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -202,12 +201,11 @@ export class ShiftsClient { request: Square.labor.SearchShiftsRequest = {}, requestOptions?: ShiftsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -293,12 +291,11 @@ export class ShiftsClient { requestOptions?: ShiftsClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -412,12 +409,11 @@ export class ShiftsClient { requestOptions?: ShiftsClient.RequestOptions, ): Promise> { const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -503,12 +499,11 @@ export class ShiftsClient { requestOptions?: ShiftsClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -564,13 +559,4 @@ export class ShiftsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/labor/resources/teamMemberWages/client/Client.ts b/src/api/resources/labor/resources/teamMemberWages/client/Client.ts index 872737f7b..718c1692b 100644 --- a/src/api/resources/labor/resources/teamMemberWages/client/Client.ts +++ b/src/api/resources/labor/resources/teamMemberWages/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace TeamMemberWagesClient { } export class TeamMemberWagesClient { - protected readonly _options: TeamMemberWagesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: TeamMemberWagesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -54,12 +54,11 @@ export class TeamMemberWagesClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -152,12 +151,11 @@ export class TeamMemberWagesClient { requestOptions?: TeamMemberWagesClient.RequestOptions, ): Promise> { const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -215,13 +213,4 @@ export class TeamMemberWagesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/labor/resources/workweekConfigs/client/Client.ts b/src/api/resources/labor/resources/workweekConfigs/client/Client.ts index 896eb1cf9..696e7cd73 100644 --- a/src/api/resources/labor/resources/workweekConfigs/client/Client.ts +++ b/src/api/resources/labor/resources/workweekConfigs/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace WorkweekConfigsClient { } export class WorkweekConfigsClient { - protected readonly _options: WorkweekConfigsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: WorkweekConfigsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -50,12 +50,11 @@ export class WorkweekConfigsClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -153,12 +152,11 @@ export class WorkweekConfigsClient { requestOptions?: WorkweekConfigsClient.RequestOptions, ): Promise> { const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -222,13 +220,4 @@ export class WorkweekConfigsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/locations/client/Client.ts b/src/api/resources/locations/client/Client.ts index aef3dcf22..fbd494738 100644 --- a/src/api/resources/locations/client/Client.ts +++ b/src/api/resources/locations/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -19,13 +19,13 @@ export declare namespace LocationsClient { } export class LocationsClient { - protected readonly _options: LocationsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _customAttributeDefinitions: CustomAttributeDefinitionsClient | undefined; protected _customAttributes: CustomAttributesClient | undefined; protected _transactions: TransactionsClient | undefined; constructor(options: LocationsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get customAttributeDefinitions(): CustomAttributeDefinitionsClient { @@ -58,12 +58,11 @@ export class LocationsClient { private async __list( requestOptions?: LocationsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -157,12 +156,11 @@ export class LocationsClient { request: Square.CreateLocationRequest = {}, requestOptions?: LocationsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -249,12 +247,11 @@ export class LocationsClient { requestOptions?: LocationsClient.RequestOptions, ): Promise> { const { locationId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -352,12 +349,11 @@ export class LocationsClient { requestOptions?: LocationsClient.RequestOptions, ): Promise> { const { locationId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -523,12 +519,11 @@ export class LocationsClient { requestOptions?: LocationsClient.RequestOptions, ): Promise> { const { locationId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -592,13 +587,4 @@ export class LocationsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/locations/resources/customAttributeDefinitions/client/Client.ts b/src/api/resources/locations/resources/customAttributeDefinitions/client/Client.ts index 46bc33be1..1eef07541 100644 --- a/src/api/resources/locations/resources/customAttributeDefinitions/client/Client.ts +++ b/src/api/resources/locations/resources/customAttributeDefinitions/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CustomAttributeDefinitionsClient { } export class CustomAttributeDefinitionsClient { - protected readonly _options: CustomAttributeDefinitionsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CustomAttributeDefinitionsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -60,12 +60,11 @@ export class CustomAttributeDefinitionsClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -171,12 +170,11 @@ export class CustomAttributeDefinitionsClient { request: Square.locations.CreateLocationCustomAttributeDefinitionRequest, requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -272,12 +270,11 @@ export class CustomAttributeDefinitionsClient { _queryParams.version = version?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -366,12 +363,11 @@ export class CustomAttributeDefinitionsClient { requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { const { key, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -462,12 +458,11 @@ export class CustomAttributeDefinitionsClient { requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { const { key } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -525,13 +520,4 @@ export class CustomAttributeDefinitionsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/locations/resources/customAttributes/client/Client.ts b/src/api/resources/locations/resources/customAttributes/client/Client.ts index 65a3191e6..20020fe20 100644 --- a/src/api/resources/locations/resources/customAttributes/client/Client.ts +++ b/src/api/resources/locations/resources/customAttributes/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CustomAttributesClient { } export class CustomAttributesClient { - protected readonly _options: CustomAttributesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CustomAttributesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -56,12 +56,11 @@ export class CustomAttributesClient { request: Square.locations.BulkDeleteLocationCustomAttributesRequest, requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -179,12 +178,11 @@ export class CustomAttributesClient { request: Square.locations.BulkUpsertLocationCustomAttributesRequest, requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -294,12 +292,11 @@ export class CustomAttributesClient { if (withDefinitions !== undefined) { _queryParams.with_definitions = withDefinitions?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -408,12 +405,11 @@ export class CustomAttributesClient { _queryParams.version = version?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -504,12 +500,11 @@ export class CustomAttributesClient { requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { const { locationId, key, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -600,12 +595,11 @@ export class CustomAttributesClient { requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { const { locationId, key } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -663,13 +657,4 @@ export class CustomAttributesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/locations/resources/transactions/client/Client.ts b/src/api/resources/locations/resources/transactions/client/Client.ts index 8c44874ac..2f57223d7 100644 --- a/src/api/resources/locations/resources/transactions/client/Client.ts +++ b/src/api/resources/locations/resources/transactions/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace TransactionsClient { } export class TransactionsClient { - protected readonly _options: TransactionsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: TransactionsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -74,12 +74,11 @@ export class TransactionsClient { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -162,12 +161,11 @@ export class TransactionsClient { requestOptions?: TransactionsClient.RequestOptions, ): Promise> { const { locationId, transactionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -255,12 +253,11 @@ export class TransactionsClient { requestOptions?: TransactionsClient.RequestOptions, ): Promise> { const { locationId, transactionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -348,12 +345,11 @@ export class TransactionsClient { requestOptions?: TransactionsClient.RequestOptions, ): Promise> { const { locationId, transactionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -411,13 +407,4 @@ export class TransactionsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/loyalty/client/Client.ts b/src/api/resources/loyalty/client/Client.ts index 3c1136eb3..962648263 100644 --- a/src/api/resources/loyalty/client/Client.ts +++ b/src/api/resources/loyalty/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -19,13 +19,13 @@ export declare namespace LoyaltyClient { } export class LoyaltyClient { - protected readonly _options: LoyaltyClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _accounts: AccountsClient | undefined; protected _programs: ProgramsClient | undefined; protected _rewards: RewardsClient | undefined; constructor(options: LoyaltyClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get accounts(): AccountsClient { @@ -76,12 +76,11 @@ export class LoyaltyClient { request: Square.SearchLoyaltyEventsRequest = {}, requestOptions?: LoyaltyClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -143,13 +142,4 @@ export class LoyaltyClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/loyalty/resources/accounts/client/Client.ts b/src/api/resources/loyalty/resources/accounts/client/Client.ts index 372059c4b..d150c6209 100644 --- a/src/api/resources/loyalty/resources/accounts/client/Client.ts +++ b/src/api/resources/loyalty/resources/accounts/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace AccountsClient { } export class AccountsClient { - protected readonly _options: AccountsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: AccountsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -50,12 +50,11 @@ export class AccountsClient { request: Square.loyalty.CreateLoyaltyAccountRequest, requestOptions?: AccountsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -149,12 +148,11 @@ export class AccountsClient { request: Square.loyalty.SearchLoyaltyAccountsRequest = {}, requestOptions?: AccountsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -240,12 +238,11 @@ export class AccountsClient { requestOptions?: AccountsClient.RequestOptions, ): Promise> { const { accountId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -345,12 +342,11 @@ export class AccountsClient { requestOptions?: AccountsClient.RequestOptions, ): Promise> { const { accountId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -447,12 +443,11 @@ export class AccountsClient { requestOptions?: AccountsClient.RequestOptions, ): Promise> { const { accountId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -516,13 +511,4 @@ export class AccountsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/loyalty/resources/programs/client/Client.ts b/src/api/resources/loyalty/resources/programs/client/Client.ts index ec5248058..6a5213856 100644 --- a/src/api/resources/loyalty/resources/programs/client/Client.ts +++ b/src/api/resources/loyalty/resources/programs/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -17,11 +17,11 @@ export declare namespace ProgramsClient { } export class ProgramsClient { - protected readonly _options: ProgramsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _promotions: PromotionsClient | undefined; constructor(options: ProgramsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get promotions(): PromotionsClient { @@ -49,12 +49,11 @@ export class ProgramsClient { private async __list( requestOptions?: ProgramsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -136,12 +135,11 @@ export class ProgramsClient { requestOptions?: ProgramsClient.RequestOptions, ): Promise> { const { programId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -239,12 +237,11 @@ export class ProgramsClient { requestOptions?: ProgramsClient.RequestOptions, ): Promise> { const { programId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -308,13 +305,4 @@ export class ProgramsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/loyalty/resources/programs/resources/promotions/client/Client.ts b/src/api/resources/loyalty/resources/programs/resources/promotions/client/Client.ts index 4b8aa03d4..14ac299b1 100644 --- a/src/api/resources/loyalty/resources/programs/resources/promotions/client/Client.ts +++ b/src/api/resources/loyalty/resources/programs/resources/promotions/client/Client.ts @@ -1,7 +1,10 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../../../BaseClient"; +import { + type NormalizedClientOptionsWithAuth, + normalizeClientOptionsWithAuth, +} from "../../../../../../../../BaseClient"; import * as core from "../../../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../../../core/headers"; import * as environments from "../../../../../../../../environments"; @@ -16,10 +19,10 @@ export declare namespace PromotionsClient { } export class PromotionsClient { - protected readonly _options: PromotionsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: PromotionsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -59,12 +62,11 @@ export class PromotionsClient { if (limit !== undefined) { _queryParams.limit = limit?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -184,12 +186,11 @@ export class PromotionsClient { requestOptions?: PromotionsClient.RequestOptions, ): Promise> { const { programId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -278,12 +279,11 @@ export class PromotionsClient { requestOptions?: PromotionsClient.RequestOptions, ): Promise> { const { programId, promotionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -371,12 +371,11 @@ export class PromotionsClient { requestOptions?: PromotionsClient.RequestOptions, ): Promise> { const { programId, promotionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -434,13 +433,4 @@ export class PromotionsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/loyalty/resources/rewards/client/Client.ts b/src/api/resources/loyalty/resources/rewards/client/Client.ts index c67ce6f31..504bcb1f7 100644 --- a/src/api/resources/loyalty/resources/rewards/client/Client.ts +++ b/src/api/resources/loyalty/resources/rewards/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace RewardsClient { } export class RewardsClient { - protected readonly _options: RewardsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: RewardsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -56,12 +56,11 @@ export class RewardsClient { request: Square.loyalty.CreateLoyaltyRewardRequest, requestOptions?: RewardsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -155,12 +154,11 @@ export class RewardsClient { request: Square.loyalty.SearchLoyaltyRewardsRequest = {}, requestOptions?: RewardsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -246,12 +244,11 @@ export class RewardsClient { requestOptions?: RewardsClient.RequestOptions, ): Promise> { const { rewardId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -341,12 +338,11 @@ export class RewardsClient { requestOptions?: RewardsClient.RequestOptions, ): Promise> { const { rewardId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -440,12 +436,11 @@ export class RewardsClient { requestOptions?: RewardsClient.RequestOptions, ): Promise> { const { rewardId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -509,13 +504,4 @@ export class RewardsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/merchants/client/Client.ts b/src/api/resources/merchants/client/Client.ts index c841f2685..c52b21366 100644 --- a/src/api/resources/merchants/client/Client.ts +++ b/src/api/resources/merchants/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -18,12 +18,12 @@ export declare namespace MerchantsClient { } export class MerchantsClient { - protected readonly _options: MerchantsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _customAttributeDefinitions: CustomAttributeDefinitionsClient | undefined; protected _customAttributes: CustomAttributesClient | undefined; constructor(options: MerchantsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get customAttributeDefinitions(): CustomAttributeDefinitionsClient { @@ -67,12 +67,11 @@ export class MerchantsClient { if (cursor !== undefined) { _queryParams.cursor = cursor?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -163,12 +162,11 @@ export class MerchantsClient { requestOptions?: MerchantsClient.RequestOptions, ): Promise> { const { merchantId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -224,13 +222,4 @@ export class MerchantsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/merchants/resources/customAttributeDefinitions/client/Client.ts b/src/api/resources/merchants/resources/customAttributeDefinitions/client/Client.ts index d220083af..b199ea60e 100644 --- a/src/api/resources/merchants/resources/customAttributeDefinitions/client/Client.ts +++ b/src/api/resources/merchants/resources/customAttributeDefinitions/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CustomAttributeDefinitionsClient { } export class CustomAttributeDefinitionsClient { - protected readonly _options: CustomAttributeDefinitionsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CustomAttributeDefinitionsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -60,12 +60,11 @@ export class CustomAttributeDefinitionsClient { if (cursor !== undefined) { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -171,12 +170,11 @@ export class CustomAttributeDefinitionsClient { request: Square.merchants.CreateMerchantCustomAttributeDefinitionRequest, requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -272,12 +270,11 @@ export class CustomAttributeDefinitionsClient { _queryParams.version = version?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -366,12 +363,11 @@ export class CustomAttributeDefinitionsClient { requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { const { key, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -462,12 +458,11 @@ export class CustomAttributeDefinitionsClient { requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { const { key } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -525,13 +520,4 @@ export class CustomAttributeDefinitionsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/merchants/resources/customAttributes/client/Client.ts b/src/api/resources/merchants/resources/customAttributes/client/Client.ts index 4284a3da1..6b58c8333 100644 --- a/src/api/resources/merchants/resources/customAttributes/client/Client.ts +++ b/src/api/resources/merchants/resources/customAttributes/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CustomAttributesClient { } export class CustomAttributesClient { - protected readonly _options: CustomAttributesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CustomAttributesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -53,12 +53,11 @@ export class CustomAttributesClient { request: Square.merchants.BulkDeleteMerchantCustomAttributesRequest, requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -169,12 +168,11 @@ export class CustomAttributesClient { request: Square.merchants.BulkUpsertMerchantCustomAttributesRequest, requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -284,12 +282,11 @@ export class CustomAttributesClient { if (withDefinitions !== undefined) { _queryParams.with_definitions = withDefinitions?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -398,12 +395,11 @@ export class CustomAttributesClient { _queryParams.version = version?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -494,12 +490,11 @@ export class CustomAttributesClient { requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { const { merchantId, key, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -590,12 +585,11 @@ export class CustomAttributesClient { requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { const { merchantId, key } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -653,13 +647,4 @@ export class CustomAttributesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/mobile/client/Client.ts b/src/api/resources/mobile/client/Client.ts index e2c4a0e6c..0de029fb5 100644 --- a/src/api/resources/mobile/client/Client.ts +++ b/src/api/resources/mobile/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace MobileClient { } export class MobileClient { - protected readonly _options: MobileClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: MobileClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -58,12 +58,11 @@ export class MobileClient { request: Square.CreateMobileAuthorizationCodeRequest = {}, requestOptions?: MobileClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -125,13 +124,4 @@ export class MobileClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/oAuth/client/Client.ts b/src/api/resources/oAuth/client/Client.ts index e5078aa95..a85fed99d 100644 --- a/src/api/resources/oAuth/client/Client.ts +++ b/src/api/resources/oAuth/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace OAuthClient { } export class OAuthClient { - protected readonly _options: OAuthClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: OAuthClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -58,12 +58,11 @@ export class OAuthClient { request: Square.RevokeTokenRequest = {}, requestOptions?: OAuthClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -266,12 +265,11 @@ export class OAuthClient { private async __retrieveTokenStatus( requestOptions?: OAuthClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -388,13 +386,4 @@ export class OAuthClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/orders/client/Client.ts b/src/api/resources/orders/client/Client.ts index f274686c4..ad546a952 100644 --- a/src/api/resources/orders/client/Client.ts +++ b/src/api/resources/orders/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -18,12 +18,12 @@ export declare namespace OrdersClient { } export class OrdersClient { - protected readonly _options: OrdersClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _customAttributeDefinitions: CustomAttributeDefinitionsClient | undefined; protected _customAttributes: CustomAttributesClient | undefined; constructor(options: OrdersClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get customAttributeDefinitions(): CustomAttributeDefinitionsClient { @@ -107,12 +107,11 @@ export class OrdersClient { request: Square.CreateOrderRequest, requestOptions?: OrdersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -200,12 +199,11 @@ export class OrdersClient { request: Square.BatchGetOrdersRequest, requestOptions?: OrdersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -312,12 +310,11 @@ export class OrdersClient { request: Square.CalculateOrderRequest, requestOptions?: OrdersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -405,12 +402,11 @@ export class OrdersClient { request: Square.CloneOrderRequest, requestOptions?: OrdersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -530,12 +526,11 @@ export class OrdersClient { request: Square.SearchOrdersRequest = {}, requestOptions?: OrdersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -621,12 +616,11 @@ export class OrdersClient { requestOptions?: OrdersClient.RequestOptions, ): Promise> { const { orderId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -735,12 +729,11 @@ export class OrdersClient { requestOptions?: OrdersClient.RequestOptions, ): Promise> { const { orderId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -841,12 +834,11 @@ export class OrdersClient { requestOptions?: OrdersClient.RequestOptions, ): Promise> { const { orderId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -908,13 +900,4 @@ export class OrdersClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/orders/resources/customAttributeDefinitions/client/Client.ts b/src/api/resources/orders/resources/customAttributeDefinitions/client/Client.ts index ae99a3bbe..e1b33698e 100644 --- a/src/api/resources/orders/resources/customAttributeDefinitions/client/Client.ts +++ b/src/api/resources/orders/resources/customAttributeDefinitions/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CustomAttributeDefinitionsClient { } export class CustomAttributeDefinitionsClient { - protected readonly _options: CustomAttributeDefinitionsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CustomAttributeDefinitionsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -62,12 +62,11 @@ export class CustomAttributeDefinitionsClient { if (limit !== undefined) { _queryParams.limit = limit?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -172,12 +171,11 @@ export class CustomAttributeDefinitionsClient { request: Square.orders.CreateOrderCustomAttributeDefinitionRequest, requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -275,12 +273,11 @@ export class CustomAttributeDefinitionsClient { _queryParams.version = version?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -370,12 +367,11 @@ export class CustomAttributeDefinitionsClient { requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { const { key, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -465,12 +461,11 @@ export class CustomAttributeDefinitionsClient { requestOptions?: CustomAttributeDefinitionsClient.RequestOptions, ): Promise> { const { key } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -528,13 +523,4 @@ export class CustomAttributeDefinitionsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/orders/resources/customAttributes/client/Client.ts b/src/api/resources/orders/resources/customAttributes/client/Client.ts index 7b66d1088..ca68a5615 100644 --- a/src/api/resources/orders/resources/customAttributes/client/Client.ts +++ b/src/api/resources/orders/resources/customAttributes/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CustomAttributesClient { } export class CustomAttributesClient { - protected readonly _options: CustomAttributesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CustomAttributesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -66,12 +66,11 @@ export class CustomAttributesClient { request: Square.orders.BulkDeleteOrderCustomAttributesRequest, requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -188,12 +187,11 @@ export class CustomAttributesClient { request: Square.orders.BulkUpsertOrderCustomAttributesRequest, requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -305,12 +303,11 @@ export class CustomAttributesClient { if (withDefinitions !== undefined) { _queryParams.with_definitions = withDefinitions?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -422,12 +419,11 @@ export class CustomAttributesClient { _queryParams.with_definition = withDefinition?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -523,12 +519,11 @@ export class CustomAttributesClient { requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { const { orderId, customAttributeKey, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -621,12 +616,11 @@ export class CustomAttributesClient { requestOptions?: CustomAttributesClient.RequestOptions, ): Promise> { const { orderId, customAttributeKey } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -684,13 +678,4 @@ export class CustomAttributesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/payments/client/Client.ts b/src/api/resources/payments/client/Client.ts index 0af30c97f..4f0c8950d 100644 --- a/src/api/resources/payments/client/Client.ts +++ b/src/api/resources/payments/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace PaymentsClient { } export class PaymentsClient { - protected readonly _options: PaymentsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: PaymentsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -124,12 +124,11 @@ export class PaymentsClient { omitUndefined: true, }); } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -240,12 +239,11 @@ export class PaymentsClient { request: Square.CreatePaymentRequest, requestOptions?: PaymentsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -340,12 +338,11 @@ export class PaymentsClient { request: Square.CancelPaymentByIdempotencyKeyRequest, requestOptions?: PaymentsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -431,12 +428,11 @@ export class PaymentsClient { requestOptions?: PaymentsClient.RequestOptions, ): Promise> { const { paymentId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -529,12 +525,11 @@ export class PaymentsClient { requestOptions?: PaymentsClient.RequestOptions, ): Promise> { const { paymentId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -621,12 +616,11 @@ export class PaymentsClient { requestOptions?: PaymentsClient.RequestOptions, ): Promise> { const { paymentId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -711,12 +705,11 @@ export class PaymentsClient { requestOptions?: PaymentsClient.RequestOptions, ): Promise> { const { paymentId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -780,13 +773,4 @@ export class PaymentsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/payouts/client/Client.ts b/src/api/resources/payouts/client/Client.ts index b45ec7dd2..d720f81b7 100644 --- a/src/api/resources/payouts/client/Client.ts +++ b/src/api/resources/payouts/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace PayoutsClient { } export class PayoutsClient { - protected readonly _options: PayoutsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: PayoutsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -76,12 +76,11 @@ export class PayoutsClient { if (limit !== undefined) { _queryParams.limit = limit?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -173,12 +172,11 @@ export class PayoutsClient { requestOptions?: PayoutsClient.RequestOptions, ): Promise> { const { payoutId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -272,12 +270,11 @@ export class PayoutsClient { if (limit !== undefined) { _queryParams.limit = limit?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -346,13 +343,4 @@ export class PayoutsClient { }, }); } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/refunds/client/Client.ts b/src/api/resources/refunds/client/Client.ts index d4fe1040d..93f47b7cf 100644 --- a/src/api/resources/refunds/client/Client.ts +++ b/src/api/resources/refunds/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace RefundsClient { } export class RefundsClient { - protected readonly _options: RefundsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: RefundsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -106,12 +106,11 @@ export class RefundsClient { omitUndefined: true, }); } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -214,12 +213,11 @@ export class RefundsClient { request: Square.RefundPaymentRequest, requestOptions?: RefundsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -305,12 +303,11 @@ export class RefundsClient { requestOptions?: RefundsClient.RequestOptions, ): Promise> { const { refundId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -366,13 +363,4 @@ export class RefundsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/sites/client/Client.ts b/src/api/resources/sites/client/Client.ts index f41fa2c00..3f3917678 100644 --- a/src/api/resources/sites/client/Client.ts +++ b/src/api/resources/sites/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace SitesClient { } export class SitesClient { - protected readonly _options: SitesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: SitesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -40,12 +40,11 @@ export class SitesClient { private async __list( requestOptions?: SitesClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -101,13 +100,4 @@ export class SitesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/snippets/client/Client.ts b/src/api/resources/snippets/client/Client.ts index 393e800b9..472436dcf 100644 --- a/src/api/resources/snippets/client/Client.ts +++ b/src/api/resources/snippets/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace SnippetsClient { } export class SnippetsClient { - protected readonly _options: SnippetsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: SnippetsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -50,12 +50,11 @@ export class SnippetsClient { requestOptions?: SnippetsClient.RequestOptions, ): Promise> { const { siteId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -144,12 +143,11 @@ export class SnippetsClient { requestOptions?: SnippetsClient.RequestOptions, ): Promise> { const { siteId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -240,12 +238,11 @@ export class SnippetsClient { requestOptions?: SnippetsClient.RequestOptions, ): Promise> { const { siteId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -303,13 +300,4 @@ export class SnippetsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/subscriptions/client/Client.ts b/src/api/resources/subscriptions/client/Client.ts index 41fea99d4..ba2107371 100644 --- a/src/api/resources/subscriptions/client/Client.ts +++ b/src/api/resources/subscriptions/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace SubscriptionsClient { } export class SubscriptionsClient { - protected readonly _options: SubscriptionsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: SubscriptionsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -64,12 +64,11 @@ export class SubscriptionsClient { request: Square.CreateSubscriptionRequest, requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -157,12 +156,11 @@ export class SubscriptionsClient { request: Square.BulkSwapPlanRequest, requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -268,12 +266,11 @@ export class SubscriptionsClient { request: Square.SearchSubscriptionsRequest = {}, requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -365,12 +362,11 @@ export class SubscriptionsClient { _queryParams.include = include; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -456,12 +452,11 @@ export class SubscriptionsClient { requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { const { subscriptionId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -550,12 +545,11 @@ export class SubscriptionsClient { requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { const { subscriptionId, actionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -639,12 +633,11 @@ export class SubscriptionsClient { requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { const { subscriptionId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -734,12 +727,11 @@ export class SubscriptionsClient { requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { const { subscriptionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -827,12 +819,11 @@ export class SubscriptionsClient { if (limit !== undefined) { _queryParams.limit = limit?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -925,12 +916,11 @@ export class SubscriptionsClient { requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { const { subscriptionId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1018,12 +1008,11 @@ export class SubscriptionsClient { requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { const { subscriptionId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1117,12 +1106,11 @@ export class SubscriptionsClient { requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { const { subscriptionId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -1186,13 +1174,4 @@ export class SubscriptionsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/team/client/Client.ts b/src/api/resources/team/client/Client.ts index 44884116b..8ddc3db23 100644 --- a/src/api/resources/team/client/Client.ts +++ b/src/api/resources/team/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace TeamClient { } export class TeamClient { - protected readonly _options: TeamClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: TeamClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -50,12 +50,11 @@ export class TeamClient { _queryParams.cursor = cursor; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -139,12 +138,11 @@ export class TeamClient { request: Square.CreateJobRequest, requestOptions?: TeamClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -230,12 +228,11 @@ export class TeamClient { requestOptions?: TeamClient.RequestOptions, ): Promise> { const { jobId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -323,12 +320,11 @@ export class TeamClient { requestOptions?: TeamClient.RequestOptions, ): Promise> { const { jobId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -392,13 +388,4 @@ export class TeamClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/teamMembers/client/Client.ts b/src/api/resources/teamMembers/client/Client.ts index f1a7c5af1..528061adc 100644 --- a/src/api/resources/teamMembers/client/Client.ts +++ b/src/api/resources/teamMembers/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -17,11 +17,11 @@ export declare namespace TeamMembersClient { } export class TeamMembersClient { - protected readonly _options: TeamMembersClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _wageSetting: WageSettingClient | undefined; constructor(options: TeamMembersClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get wageSetting(): WageSettingClient { @@ -86,12 +86,11 @@ export class TeamMembersClient { request: Square.CreateTeamMemberRequest, requestOptions?: TeamMembersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -207,12 +206,11 @@ export class TeamMembersClient { request: Square.BatchCreateTeamMembersRequest, requestOptions?: TeamMembersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -331,12 +329,11 @@ export class TeamMembersClient { request: Square.BatchUpdateTeamMembersRequest, requestOptions?: TeamMembersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -429,12 +426,11 @@ export class TeamMembersClient { request: Square.SearchTeamMembersRequest = {}, requestOptions?: TeamMembersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -521,12 +517,11 @@ export class TeamMembersClient { requestOptions?: TeamMembersClient.RequestOptions, ): Promise> { const { teamMemberId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -642,12 +637,11 @@ export class TeamMembersClient { requestOptions?: TeamMembersClient.RequestOptions, ): Promise> { const { teamMemberId, body: _body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -711,13 +705,4 @@ export class TeamMembersClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/teamMembers/resources/wageSetting/client/Client.ts b/src/api/resources/teamMembers/resources/wageSetting/client/Client.ts index 56f3ebe62..e5cdd2a21 100644 --- a/src/api/resources/teamMembers/resources/wageSetting/client/Client.ts +++ b/src/api/resources/teamMembers/resources/wageSetting/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace WageSettingClient { } export class WageSettingClient { - protected readonly _options: WageSettingClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: WageSettingClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -50,12 +50,11 @@ export class WageSettingClient { requestOptions?: WageSettingClient.RequestOptions, ): Promise> { const { teamMemberId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -163,12 +162,11 @@ export class WageSettingClient { requestOptions?: WageSettingClient.RequestOptions, ): Promise> { const { teamMemberId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -232,13 +230,4 @@ export class WageSettingClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/terminal/client/Client.ts b/src/api/resources/terminal/client/Client.ts index 8b0d70f68..fb2541cee 100644 --- a/src/api/resources/terminal/client/Client.ts +++ b/src/api/resources/terminal/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -19,13 +19,13 @@ export declare namespace TerminalClient { } export class TerminalClient { - protected readonly _options: TerminalClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _actions: ActionsClient | undefined; protected _checkouts: CheckoutsClient | undefined; protected _refunds: RefundsClient | undefined; constructor(options: TerminalClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get actions(): ActionsClient { @@ -65,12 +65,11 @@ export class TerminalClient { requestOptions?: TerminalClient.RequestOptions, ): Promise> { const { actionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -152,12 +151,11 @@ export class TerminalClient { requestOptions?: TerminalClient.RequestOptions, ): Promise> { const { checkoutId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -239,12 +237,11 @@ export class TerminalClient { requestOptions?: TerminalClient.RequestOptions, ): Promise> { const { terminalRefundId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -302,13 +299,4 @@ export class TerminalClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/terminal/resources/actions/client/Client.ts b/src/api/resources/terminal/resources/actions/client/Client.ts index 58fd69a33..15ae93cfb 100644 --- a/src/api/resources/terminal/resources/actions/client/Client.ts +++ b/src/api/resources/terminal/resources/actions/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace ActionsClient { } export class ActionsClient { - protected readonly _options: ActionsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: ActionsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -53,12 +53,11 @@ export class ActionsClient { request: Square.terminal.CreateTerminalActionRequest, requestOptions?: ActionsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -153,12 +152,11 @@ export class ActionsClient { request: Square.terminal.SearchTerminalActionsRequest = {}, requestOptions?: ActionsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -244,12 +242,11 @@ export class ActionsClient { requestOptions?: ActionsClient.RequestOptions, ): Promise> { const { actionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -331,12 +328,11 @@ export class ActionsClient { requestOptions?: ActionsClient.RequestOptions, ): Promise> { const { actionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -394,13 +390,4 @@ export class ActionsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/terminal/resources/checkouts/client/Client.ts b/src/api/resources/terminal/resources/checkouts/client/Client.ts index db5d41260..cdda7996b 100644 --- a/src/api/resources/terminal/resources/checkouts/client/Client.ts +++ b/src/api/resources/terminal/resources/checkouts/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace CheckoutsClient { } export class CheckoutsClient { - protected readonly _options: CheckoutsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: CheckoutsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -56,12 +56,11 @@ export class CheckoutsClient { request: Square.terminal.CreateTerminalCheckoutRequest, requestOptions?: CheckoutsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -151,12 +150,11 @@ export class CheckoutsClient { request: Square.terminal.SearchTerminalCheckoutsRequest = {}, requestOptions?: CheckoutsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -244,12 +242,11 @@ export class CheckoutsClient { requestOptions?: CheckoutsClient.RequestOptions, ): Promise> { const { checkoutId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -331,12 +328,11 @@ export class CheckoutsClient { requestOptions?: CheckoutsClient.RequestOptions, ): Promise> { const { checkoutId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -394,13 +390,4 @@ export class CheckoutsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/terminal/resources/refunds/client/Client.ts b/src/api/resources/terminal/resources/refunds/client/Client.ts index 509e7c40c..89ccfd214 100644 --- a/src/api/resources/terminal/resources/refunds/client/Client.ts +++ b/src/api/resources/terminal/resources/refunds/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace RefundsClient { } export class RefundsClient { - protected readonly _options: RefundsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: RefundsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -53,12 +53,11 @@ export class RefundsClient { request: Square.terminal.CreateTerminalRefundRequest, requestOptions?: RefundsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -148,12 +147,11 @@ export class RefundsClient { request: Square.terminal.SearchTerminalRefundsRequest = {}, requestOptions?: RefundsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -239,12 +237,11 @@ export class RefundsClient { requestOptions?: RefundsClient.RequestOptions, ): Promise> { const { terminalRefundId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -326,12 +323,11 @@ export class RefundsClient { requestOptions?: RefundsClient.RequestOptions, ): Promise> { const { terminalRefundId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -389,13 +385,4 @@ export class RefundsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/transferOrders/client/Client.ts b/src/api/resources/transferOrders/client/Client.ts index 2d10116b8..69dc27346 100644 --- a/src/api/resources/transferOrders/client/Client.ts +++ b/src/api/resources/transferOrders/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace TransferOrdersClient { } export class TransferOrdersClient { - protected readonly _options: TransferOrdersClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: TransferOrdersClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -78,12 +78,11 @@ export class TransferOrdersClient { request: Square.CreateTransferOrderRequest, requestOptions?: TransferOrdersClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -183,12 +182,11 @@ export class TransferOrdersClient { async ( request: Square.SearchTransferOrdersRequest, ): Promise> => { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -293,12 +291,11 @@ export class TransferOrdersClient { requestOptions?: TransferOrdersClient.RequestOptions, ): Promise> { const { transferOrderId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -402,12 +399,11 @@ export class TransferOrdersClient { requestOptions?: TransferOrdersClient.RequestOptions, ): Promise> { const { transferOrderId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -505,12 +501,11 @@ export class TransferOrdersClient { _queryParams.version = version?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -603,12 +598,11 @@ export class TransferOrdersClient { requestOptions?: TransferOrdersClient.RequestOptions, ): Promise> { const { transferOrderId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -725,12 +719,11 @@ export class TransferOrdersClient { requestOptions?: TransferOrdersClient.RequestOptions, ): Promise> { const { transferOrderId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -827,12 +820,11 @@ export class TransferOrdersClient { requestOptions?: TransferOrdersClient.RequestOptions, ): Promise> { const { transferOrderId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -896,13 +888,4 @@ export class TransferOrdersClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/v1Transactions/client/Client.ts b/src/api/resources/v1Transactions/client/Client.ts index d5513f1b8..95b39cec3 100644 --- a/src/api/resources/v1Transactions/client/Client.ts +++ b/src/api/resources/v1Transactions/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace V1TransactionsClient { } export class V1TransactionsClient { - protected readonly _options: V1TransactionsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: V1TransactionsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -64,12 +64,11 @@ export class V1TransactionsClient { _queryParams.batch_token = batchToken; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -150,12 +149,11 @@ export class V1TransactionsClient { requestOptions?: V1TransactionsClient.RequestOptions, ): Promise> { const { locationId, orderId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -239,12 +237,11 @@ export class V1TransactionsClient { requestOptions?: V1TransactionsClient.RequestOptions, ): Promise> { const { locationId, orderId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -308,13 +305,4 @@ export class V1TransactionsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/vendors/client/Client.ts b/src/api/resources/vendors/client/Client.ts index bf62ea1d1..6cd56f72d 100644 --- a/src/api/resources/vendors/client/Client.ts +++ b/src/api/resources/vendors/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import * as core from "../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers"; import * as environments from "../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace VendorsClient { } export class VendorsClient { - protected readonly _options: VendorsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: VendorsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -64,12 +64,11 @@ export class VendorsClient { request: Square.BatchCreateVendorsRequest, requestOptions?: VendorsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -154,12 +153,11 @@ export class VendorsClient { request: Square.BatchGetVendorsRequest = {}, requestOptions?: VendorsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -251,12 +249,11 @@ export class VendorsClient { request: Square.BatchUpdateVendorsRequest, requestOptions?: VendorsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -360,12 +357,11 @@ export class VendorsClient { request: Square.CreateVendorRequest, requestOptions?: VendorsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -448,12 +444,11 @@ export class VendorsClient { request: Square.SearchVendorsRequest = {}, requestOptions?: VendorsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -539,12 +534,11 @@ export class VendorsClient { requestOptions?: VendorsClient.RequestOptions, ): Promise> { const { vendorId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -633,12 +627,11 @@ export class VendorsClient { requestOptions?: VendorsClient.RequestOptions, ): Promise> { const { vendorId, body: _body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -700,13 +693,4 @@ export class VendorsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/webhooks/client/Client.ts b/src/api/resources/webhooks/client/Client.ts index 06c9693a0..9a8456d7a 100644 --- a/src/api/resources/webhooks/client/Client.ts +++ b/src/api/resources/webhooks/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions } from "../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient"; import { EventTypesClient } from "../resources/eventTypes/client/Client"; import { SubscriptionsClient } from "../resources/subscriptions/client/Client"; @@ -10,12 +10,12 @@ export declare namespace WebhooksClient { } export class WebhooksClient { - protected readonly _options: WebhooksClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; protected _eventTypes: EventTypesClient | undefined; protected _subscriptions: SubscriptionsClient | undefined; constructor(options: WebhooksClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } public get eventTypes(): EventTypesClient { diff --git a/src/api/resources/webhooks/resources/eventTypes/client/Client.ts b/src/api/resources/webhooks/resources/eventTypes/client/Client.ts index 4605f4a68..1e2982c28 100644 --- a/src/api/resources/webhooks/resources/eventTypes/client/Client.ts +++ b/src/api/resources/webhooks/resources/eventTypes/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace EventTypesClient { } export class EventTypesClient { - protected readonly _options: EventTypesClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: EventTypesClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -50,12 +50,11 @@ export class EventTypesClient { _queryParams.api_version = apiVersion; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -111,13 +110,4 @@ export class EventTypesClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/api/resources/webhooks/resources/subscriptions/client/Client.ts b/src/api/resources/webhooks/resources/subscriptions/client/Client.ts index 622abbddb..4b99c61ad 100644 --- a/src/api/resources/webhooks/resources/subscriptions/client/Client.ts +++ b/src/api/resources/webhooks/resources/subscriptions/client/Client.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient"; -import { normalizeClientOptions } from "../../../../../../BaseClient"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient"; import * as core from "../../../../../../core"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers"; import * as environments from "../../../../../../environments"; @@ -16,10 +16,10 @@ export declare namespace SubscriptionsClient { } export class SubscriptionsClient { - protected readonly _options: SubscriptionsClient.Options; + protected readonly _options: NormalizedClientOptionsWithAuth; constructor(options: SubscriptionsClient.Options = {}) { - this._options = normalizeClientOptions(options); + this._options = normalizeClientOptionsWithAuth(options); } /** @@ -61,12 +61,11 @@ export class SubscriptionsClient { if (limit !== undefined) { _queryParams.limit = limit?.toString() ?? null; } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -164,12 +163,11 @@ export class SubscriptionsClient { request: Square.webhooks.CreateWebhookSubscriptionRequest, requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -255,12 +253,11 @@ export class SubscriptionsClient { requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { const { subscriptionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -346,12 +343,11 @@ export class SubscriptionsClient { requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { const { subscriptionId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -439,12 +435,11 @@ export class SubscriptionsClient { requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { const { subscriptionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -527,12 +522,11 @@ export class SubscriptionsClient { requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { const { subscriptionId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -621,12 +615,11 @@ export class SubscriptionsClient { requestOptions?: SubscriptionsClient.RequestOptions, ): Promise> { const { subscriptionId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, this._options?.headers, - mergeOnlyDefinedHeaders({ - Authorization: await this._getAuthorizationHeader(), - "Square-Version": requestOptions?.version ?? "2025-10-16", - }), + mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }), requestOptions?.headers, ); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -690,13 +683,4 @@ export class SubscriptionsClient { }); } } - - protected async _getAuthorizationHeader(): Promise { - const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN; - if (bearer != null) { - return `Bearer ${bearer}`; - } - - return undefined; - } } diff --git a/src/auth/BearerAuthProvider.ts b/src/auth/BearerAuthProvider.ts new file mode 100644 index 000000000..3c3dd356c --- /dev/null +++ b/src/auth/BearerAuthProvider.ts @@ -0,0 +1,36 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as core from "../core"; +import * as errors from "../errors/index"; + +export namespace BearerAuthProvider { + export interface Options { + token?: core.Supplier; + } +} + +export class BearerAuthProvider implements core.AuthProvider { + private readonly token: core.Supplier | undefined; + + constructor(options: BearerAuthProvider.Options) { + this.token = options.token; + } + + public static canCreate(options: BearerAuthProvider.Options): boolean { + return options.token != null || process.env?.SQUARE_TOKEN != null; + } + + public async getAuthRequest(_arg?: { endpointMetadata?: core.EndpointMetadata }): Promise { + const token = (await core.Supplier.get(this.token)) ?? process.env?.SQUARE_TOKEN; + if (token == null) { + throw new errors.SquareError({ + message: + "Please specify a token by either passing it in to the constructor or initializing a SQUARE_TOKEN environment variable", + }); + } + + return { + headers: { Authorization: `Bearer ${token}` }, + }; + } +} diff --git a/src/auth/index.ts b/src/auth/index.ts new file mode 100644 index 000000000..bb4f660ad --- /dev/null +++ b/src/auth/index.ts @@ -0,0 +1 @@ +export { BearerAuthProvider } from "./BearerAuthProvider"; diff --git a/src/core/auth/AuthProvider.ts b/src/core/auth/AuthProvider.ts index ed076ec5d..ccb4263ea 100644 --- a/src/core/auth/AuthProvider.ts +++ b/src/core/auth/AuthProvider.ts @@ -1,5 +1,6 @@ +import type { EndpointMetadata } from "../fetcher/EndpointMetadata"; import type { AuthRequest } from "./AuthRequest"; export interface AuthProvider { - getAuthRequest(): Promise; + getAuthRequest(arg?: { endpointMetadata?: EndpointMetadata }): Promise; } diff --git a/src/core/auth/BearerToken.ts b/src/core/auth/BearerToken.ts index fe987fc9c..c44a06c38 100644 --- a/src/core/auth/BearerToken.ts +++ b/src/core/auth/BearerToken.ts @@ -2,13 +2,18 @@ export type BearerToken = string; const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i; -export const BearerToken = { - toAuthorizationHeader: (token: BearerToken | undefined): string | undefined => { - if (token == null) { - return undefined; - } - return `Bearer ${token}`; - }, +function toAuthorizationHeader(token: string | undefined): string | undefined { + if (token == null) { + return undefined; + } + return `Bearer ${token}`; +} + +export const BearerToken: { + toAuthorizationHeader: typeof toAuthorizationHeader; + fromAuthorizationHeader: (header: string) => BearerToken; +} = { + toAuthorizationHeader: toAuthorizationHeader, fromAuthorizationHeader: (header: string): BearerToken => { return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim() as BearerToken; }, diff --git a/src/version.ts b/src/version.ts index a6cd8df95..8db39c694 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const SDK_VERSION = "43.2.1"; +export const SDK_VERSION = "43.2.2"; diff --git a/yarn.lock b/yarn.lock index 580640dd6..7eb3ec29a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1287,9 +1287,9 @@ base64-js@^1.3.1: integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== baseline-browser-mapping@^2.8.25: - version "2.8.29" - resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.8.29.tgz#d8800b71399c783cb1bf2068c2bcc3b6cfd7892c" - integrity sha512-sXdt2elaVnhpDNRDz+1BDx1JQoJRuNk7oVlAlbGiFkLikHCAQiccexF/9e91zVi6RCgqspl04aP+6Cnl9zRLrA== + version "2.8.31" + resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.8.31.tgz#16c0f1814638257932e0486dbfdbb3348d0a5710" + integrity sha512-a28v2eWrrRWPpJSzxc+mKwm0ZtVx/G8SepdQZDArnXYU/XS+IF6mp8aB/4E+hH1tyGCoDo3KlUCdlSxGDsRkAw== brace-expansion@^1.1.7: version "1.1.12" @@ -1368,9 +1368,9 @@ camelcase@^6.2.0: integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-lite@^1.0.30001754: - version "1.0.30001756" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001756.tgz#fe80104631102f88e58cad8aa203a2c3e5ec9ebd" - integrity sha512-4HnCNKbMLkLdhJz3TToeVWHSnfJvPaq6vu/eRP0Ahub/07n484XHhBF5AJoSGHdVrS8tKFauUQz8Bp9P7LVx7A== + version "1.0.30001757" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001757.tgz#a46ff91449c69522a462996c6aac4ef95d7ccc5e" + integrity sha512-r0nnL/I28Zi/yjk1el6ilj27tKcdjLsNqAOZr0yVjWPrSQyHgKI2INaEWw21bAQSv2LXRt1XuCS/GomNpWOxsQ== chalk@^4.0.0, chalk@^4.1.0: version "4.1.2" @@ -1575,9 +1575,9 @@ dunder-proto@^1.0.1: gopd "^1.2.0" electron-to-chromium@^1.5.249: - version "1.5.258" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.258.tgz#094b0280928b1bf967b202e4be5b335aa4754b69" - integrity sha512-rHUggNV5jKQ0sSdWwlaRDkFc3/rRJIVnOSe9yR4zrR07m3ZxhP4N27Hlg8VeJGGYgFTxK5NqDmWI4DSH72vIJg== + version "1.5.260" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.260.tgz#73f555d3e9b9fd16ff48fc406bbad84efa9b86c7" + integrity sha512-ov8rBoOBhVawpzdre+Cmz4FB+y66Eqrk6Gwqd8NGxuhv99GQ8XqMAr351KEkOt7gukXWDg6gJWEMKgL2RLMPtA== emittery@^0.13.1: version "0.13.1" @@ -3234,17 +3234,17 @@ tiny-warning@^1.0.3: resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754" integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA== -tldts-core@^7.0.18: - version "7.0.18" - resolved "https://registry.yarnpkg.com/tldts-core/-/tldts-core-7.0.18.tgz#78edfd38e8c35e20fb4d2cde63c759139e169d31" - integrity sha512-jqJC13oP4FFAahv4JT/0WTDrCF9Okv7lpKtOZUGPLiAnNbACcSg8Y8T+Z9xthOmRBqi/Sob4yi0TE0miRCvF7Q== +tldts-core@^7.0.19: + version "7.0.19" + resolved "https://registry.yarnpkg.com/tldts-core/-/tldts-core-7.0.19.tgz#9dd8a457a09b4e65c8266c029f1847fa78dead20" + integrity sha512-lJX2dEWx0SGH4O6p+7FPwYmJ/bu1JbcGJ8RLaG9b7liIgZ85itUVEPbMtWRVrde/0fnDPEPHW10ZsKW3kVsE9A== tldts@^7.0.5: - version "7.0.18" - resolved "https://registry.yarnpkg.com/tldts/-/tldts-7.0.18.tgz#72cac7a2bdb6bba78f8a09fdf7ef84843b09aa94" - integrity sha512-lCcgTAgMxQ1JKOWrVGo6E69Ukbnx4Gc1wiYLRf6J5NN4HRYJtCby1rPF8rkQ4a6qqoFBK5dvjJ1zJ0F7VfDSvw== + version "7.0.19" + resolved "https://registry.yarnpkg.com/tldts/-/tldts-7.0.19.tgz#84cd7a7f04e68ec93b93b106fac038c527b99368" + integrity sha512-8PWx8tvC4jDB39BQw1m4x8y5MH1BcQ5xHeL2n7UVFulMPH/3Q0uiamahFJ3lXA0zO2SUyRXuVVbWSDmstlt9YA== dependencies: - tldts-core "^7.0.18" + tldts-core "^7.0.19" tmpl@1.0.5: version "1.0.5"