import { Base } from "./Base"; import type { Business, SubscriptionCustomField, UsedSeat, UserBusinessRole } from "./BusinessService"; import { BillingPageToken, License } from "./types/types"; import { BillingError } from "./types/billing"; export type UserAttribute = { id: string; userId: string; value: string; name: string; }; /** * * @remarks * This interface should be generated using OpenAPI generator in the future. * * @alpha */ export interface User { id?: string; username?: string; fullname?: string; firstName?: string; lastName?: string; companyEmailDomain?: string; userAttributes?: Array; } export type UserWithEmail = User & { email: string; }; export interface UserAttributes { fullname?: string; company?: string; tshirt?: string; } export interface UserCommunications { marketing?: boolean; onboarding?: boolean; } export type SubscriptionState = "active" | "canceled" | "expired" | "failed" | "future" | "paused"; export type UserBusinessWithSSOInfo = { role: UserBusinessRole; } & Pick & { sso: { id: string; identityProviderID: string; } | null; }; export type OfflineActivationCode = { activationCode: string; }; export type SubscriptionInfo = { id?: string | null; planName?: string | null; planCode?: string | null; /** * Current payment period start date string */ currentPeriodStartedAt?: string | null; /** * Current payment period end date string */ currentPeriodEndsAt?: string | null; /** * Trial start date string */ trialStartedAt?: string | null; /** * Trial end date string */ trialEndsAt?: string | null; /** * Total number of seats in this subscription. (Recurly subscription["quantity"]) */ seats: number; /** * The subscription that have been assigned to a user (`user_subscriptions` relation) */ usedSeats: UsedSeat[]; /** * Custom fields stored for the subscription */ customFields?: SubscriptionCustomField[]; /** * Name of the company of the Recurly account */ companyName?: string | null; /** * Account code of the subscription's Recurly account */ accountCode?: string | null; autoRenew: boolean; collectionMethod: "manual" | "automatic"; /** * Subscription seat used for offline */ offline: boolean; /** * True if the subscription belongs to a business Recurly account */ isBusinessAccount: boolean; /** * State of the subscription */ state: SubscriptionState; /** * Price of subscription */ unitAmount?: number | null; /** * Date on which the subscription expires. */ expiresAt?: string | null; /** * Date on which the subscription was cancelled. */ cancelledAt?: string | null; }; export type SubscriptionSeat = { id?: string | null; planName?: string | null; planCode?: string | null; /** * Current payment period start date string */ currentPeriodStartedAt?: string | null; /** * Current payment period end date string */ currentPeriodEndsAt?: string | null; /** * Trial start date string */ trialStartedAt?: string | null; /** * Trial end date string */ trialEndsAt?: string | null; /** * Total number of seats in this subscription. (Recurly subscription["quantity"]) */ seats: number; /** * The subscription that have been assigned to a user (`user_subscriptions` relation) */ usedSeats: UsedSeat[]; /** * Name of the company of the Recurly account */ companyName?: string | null; /** * Account code of the subscription's Recurly account */ accountCode?: string | null; /** * True if the subscription belongs to a business Recurly account */ isBusinessAccount: boolean; /** * Id of the business owning the subscription; null if subscription is individual */ businessId: string | null; /** * Id of the user that received the subscription */ userId: string; /** * State of the Recurly subscription */ recurlySubscriptionState: SubscriptionState; /** * Subscription activation date string */ activatedAt: string; /** * Subscription deactivation date string */ deactivatedAt: string | null; /** * Subscription creation date string */ createdAt: string; /** * Subscription update date string */ updatedAt: string; /** * Subscription expiration date string */ expiredAt: string | null; /** * Recurly subscription UUID format ID */ subscriptionId: string; /** * Recurly subscription short format ID */ shortSubscriptionId: string; /** * Is the seat active */ active: boolean; /** * Subscription used offline */ offline: boolean; }; export type Address = { /** * Phone number */ phone: string | null; /** * Street address 1 */ street1: string | null; /** * Street address 2 */ street2: string | null; /** * City */ city: string | null; /** * State or province. */ region: string | null; /** * Zip or postal code. */ postalCode: string | null; /** * Country, 2-letter ISO 3166-1 alpha-2 code. */ country: string | null; }; export type BillingInfo = { lastName: string | null; firstName: string | null; company: string | null; address: Address | null; type: string | null; vatNumber: string | null; email: string | null; paymentMethod?: { cardType: string | null; firstSix: string | null; lastTwo: string | null; lastFour: string | null; expMonth: Number | null; expYear: Number | null; }; }; export type BillingInfoUpdateWithoutToken = BillingInfo & { token?: null; threeDSecureActionResultTokenId?: null; }; export type BillingInfoUpdateWithToken = BillingInfo & { type: "credit_card"; token: string; threeDSecureActionResultTokenId?: string | null; paymentMethod: NonNullable; }; export interface ActivationCodeData { accessToken: string; idToken: string; refreshToken: string; } export type UploadAvatarResponse = { uri: string; }; export interface Invoice { date: Date | null; number: string | null; planCode: string | null; total: number | null; subtotal: number | null; state: string | null; currency: string | null; billingInfo: BillingInfo | null; /** * string if the invoice is from a child account of a LBID */ fromChildBusinessId?: Business["id"]; } export interface LinkedUserAccount { identityProviderAlias: string | undefined; identityProviderDisplayName: string | undefined; username: string | undefined; } export interface UserOTPPreferences { enabled: boolean; } export interface UserAuthMethod { /** * The method of authentication the user is using, `null` if the user doesn't have an account */ method: "sso" | "password" | "google" | "github" | null; emailAddress: string; identityProviderID?: string; /** * Generated unique username for registration */ username: null | string; } export type UserInvitationBusiness = { id: string; name: string; department?: string; license?: string; }; export interface UserInvitation { id: string; state: string; role: string; business: UserInvitationBusiness; } export type UserJoinRequestBusiness = { id: string; name: string; department?: string; license?: string; }; export interface UserJoinRequest { id: string; state: string; role: string; business: UserJoinRequestBusiness; } export interface UserOrganizationManagedMembershipInfo { managed: boolean; unlicensedAccessBlocked: boolean; } export interface UserOrganization { id: string; name: string; department?: string; license?: string; role: string; managedMembership?: boolean; managedMembershipInfo: UserOrganizationManagedMembershipInfo; } export interface PatchUserJoinRequestRequest { state: string; } export interface PatchUserJoinRequestResponse { state: string; } export interface PatchUserInvitationRequest { state: string; } export interface PatchUserInvitationResponse { state: string; } /** * * The class for consuming all `user` resources. * * currently we have: * - `.getOne` maps to `GET /users/{username}` * - `.getBillingPageToken` maps to `GET /users/{username}/billing-page-token` * * @remarks * This class should be generated using OpenAPI in the future. * * @alpha */ declare class UserService extends Base { getUsername(): Promise; getOne({ username }: { username: string; }, queryString?: string): Promise; getMany(queryString?: string): Promise; /** * Update user */ updateOne(username: string, user: User & { attributes?: UserAttributes; } & { password?: string; } & { email?: string; }): Promise; /** * Reset user password */ resetPassword(username: string, password: string): Promise; getSelf(): Promise; deleteOne(username: string): Promise; getUserSubscriptions(username: string): Promise; getUserSubscriptionsSeats(username: string): Promise; activateSubscription({ username, license, }: { username: string; license: License; }): Promise; activateSubscriptionSeat({ username, license, }: { username: string; license: License; }): Promise; getSubscriptionSeatOfflineActivationCode({ username, subscriptionSeatId, activationCodeData, }: { username: string; subscriptionSeatId: string; activationCodeData: ActivationCodeData; }): Promise; deactivateSubscriptionSeat({ username, license, }: { username: string; license: Pick; }): Promise; getBillingPageToken(username: string): Promise; getBillingPageTokenBySubscriptionId(username: string, subscriptionId: string): Promise; getUserBillingInformation(username: string): Promise; getUserBillingErrors(username: string): Promise; getUserInvoices(username: string): Promise; /** * Get all emails (primary+secondary) of the user */ getEmails(): Promise>; /** * Get user linked accounts */ getUserLinkedAccounts(): Promise; /** * Get user one time password preferences */ getUserOTPPreferences(): Promise; /** * Update user one time password preferences */ updateUserOTPPreferences(preferences: UserOTPPreferences): Promise; /** * Get user businesses */ getUserBusinesses(): Promise; /** * Get user communication preferences */ getUserCommunicationsPreferences(): Promise; /** * Update user communication preferences */ updateUserCommunicationsPreferences(communicationPreferences: UserCommunications): Promise; /** * Delete user linked account */ deleteUserLinkedAccount(identityProviderAlias: string): Promise; /** * Add new secondary email(s) to user's account, newly added email will be unverified * and can be promoted to primary later verification. */ createEmails(emails: string[]): Promise; /** * Fetch the avatar image as base64-encoded string * @param username */ getAvatar(username: string): Promise; /** * Upload user avatar * @param avatar: HTML form file input value */ uploadAvatar(avatar: File): Promise; /** * Delete secondary email(s) from user account */ deleteEmails(emails: string[]): Promise; /** * Send a verification email to a user's unverified secondary email address */ sendVerificationEmail(email: string): Promise; /** * Verify a user's secondary email using the token */ verifySecondaryEmail(token: string): Promise; /** * Set a verified email as user's primary email */ setPrimaryEmail(email: string): Promise; confirmPersonalLicenseEligibility(username: string): Promise; getUserFullName(user: User): string; getAuthMethod(email: string, invitationId?: string): Promise; getOrganizations(): Promise; getInvitations(): Promise; getJoinRequests(): Promise; leaveOrganization(businessId: string): Promise; patchJoinRequest({ joinRequestId, joinRequest, }: { joinRequestId: string; joinRequest: PatchUserJoinRequestRequest; }): Promise; patchInvitation({ invitationId, invitation, }: { invitationId: string; invitation: PatchUserInvitationRequest; }): Promise; deleteInvitation(invitationId: string): Promise; } export { UserService };