UNPKG

@updatedev/js

Version:

Update JavaScript SDK

39 lines 1.3 kB
import { API_KEY_HEADER, ENVIRONMENT_HEADER } from "./types/internal"; import { UpdateBillingClient } from "./UpdateBilling"; import { UpdateEntitlements } from "./UpdateEntitlements"; import { RequestClient } from "./utils/request"; class UpdateClient { constructor(apiKey, options) { this.apiKey = apiKey; var _a; const billingEnvironment = this.getEnvironment(options); const requestClient = new RequestClient({ baseUrl: (_a = options == null ? void 0 : options.apiUrl) != null ? _a : "https://api.update.dev/v1", headers: { [ENVIRONMENT_HEADER]: billingEnvironment, [API_KEY_HEADER]: this.apiKey }, getAuthorizationToken: options.getSessionToken }); this.billing = new UpdateBillingClient({ requestClient, hasSessionToken: options.getSessionToken !== void 0 }); this.entitlements = new UpdateEntitlements({ requestClient, hasSessionToken: options.getSessionToken !== void 0 }); } getEnvironment(options) { if (options.environment) { if (options.environment === "live") return "live"; if (options.environment === "test") return "test"; throw new Error("Invalid environment"); } return "test"; } } export { UpdateClient }; //# sourceMappingURL=Update.js.map