chore: SDK cleanup (#14763)
This commit is contained in:
@@ -2,9 +2,9 @@ import axios from "axios";
|
||||
import axiosRetry from "axios-retry";
|
||||
|
||||
import { Bookings } from "./endpoints/bookings";
|
||||
import { ManagedUsers } from "./endpoints/ee/users";
|
||||
import { Events } from "./endpoints/events";
|
||||
import { EventTypes } from "./endpoints/events/event-types";
|
||||
import { ManagedUsers } from "./endpoints/managed-users";
|
||||
import { OAuthFlow } from "./endpoints/oauth-flow";
|
||||
import { Schedules } from "./endpoints/schedules";
|
||||
import { Slots } from "./endpoints/slots";
|
||||
@@ -24,7 +24,7 @@ export class CalSdk {
|
||||
schedules: Schedules;
|
||||
users: ManagedUsers;
|
||||
|
||||
private _secrets: SdkSecrets;
|
||||
private readonly _secrets: SdkSecrets;
|
||||
|
||||
constructor(
|
||||
public readonly clientId: string,
|
||||
|
||||
@@ -6,7 +6,7 @@ import { assert } from "ts-essentials";
|
||||
import type { CalSdk } from "../cal";
|
||||
|
||||
export abstract class EndpointHandler {
|
||||
constructor(private readonly key: string, private readonly calSdk: CalSdk) {}
|
||||
protected constructor(private readonly key: string, private readonly calSdk: CalSdk) {}
|
||||
|
||||
withForAtomParam(forAtom: boolean, config?: AxiosRequestConfig<unknown>) {
|
||||
if (!forAtom) return config;
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
import type { CalSdk } from "../../../cal";
|
||||
import { Endpoints } from "../../../lib/endpoints";
|
||||
import type { BasicPlatformResponse, PaginationOptions } from "../../../types";
|
||||
import { EndpointHandler } from "../../endpoint-handler";
|
||||
import type { CalSdk } from "../../cal";
|
||||
import { Endpoints } from "../../lib/endpoints";
|
||||
import type { BasicPlatformResponse, PaginationOptions } from "../../types";
|
||||
import { EndpointHandler } from "../endpoint-handler";
|
||||
import type { CreateUserArgs, CreateUserResponse, User } from "./types";
|
||||
|
||||
export class ManagedUsers extends EndpointHandler {
|
||||
@@ -35,7 +35,9 @@ export class HttpCaller {
|
||||
private readonly axiosClient: AxiosInstance,
|
||||
private readonly options?: HttpCallerOptions
|
||||
) {
|
||||
this.setupInterceptors();
|
||||
if (options?.shouldHandleRefresh) {
|
||||
this.setupInterceptors();
|
||||
}
|
||||
}
|
||||
|
||||
private async retryQueuedRequests() {
|
||||
@@ -161,8 +163,4 @@ export class HttpCaller {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
isAwaitingRefresh() {
|
||||
return this.awaitingRefresh;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,10 +58,7 @@ export class SdkSecrets {
|
||||
return !!this.accessToken;
|
||||
}
|
||||
|
||||
public _debug() {
|
||||
return {
|
||||
refreshedAt: this.refreshedAt,
|
||||
accessToken: this.accessToken,
|
||||
};
|
||||
public getRefreshedAt(): Date | null {
|
||||
return this.refreshedAt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export enum ApiVersion {
|
||||
}
|
||||
|
||||
export type SdkAuthOptions = {
|
||||
clientSecret: string;
|
||||
clientSecret?: string;
|
||||
accessToken?: string;
|
||||
refreshToken?: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user