UNPKG

@letsparky/api-v2-client

Version:

TypeScript client for the LetsParky API V2

83 lines (82 loc) 2.62 kB
import { ApiClient } from './client'; import { ApiResponse, UserRegisterParams, UserLoginParams, LoginResponse, User, UserPasswordUpdateParams, OtpRequestParams, OtpVerifyParams, ApiKeyCreateParams } from './types'; export declare class Auth { private client; constructor(client: ApiClient); /** * Register a new user * @param params User registration parameters * @returns Promise with the registered user */ register(params: UserRegisterParams): Promise<ApiResponse<User>>; /** * Login a user * @param params Login credentials * @returns Promise with login result containing token and user data */ login(params: UserLoginParams): Promise<ApiResponse<LoginResponse>>; /** * Request an OTP for authentication * @param params Phone number for OTP request * @returns Promise with the request result */ requestOtp(params: OtpRequestParams): Promise<ApiResponse<{ message: string; phone_number: string; success?: boolean; }>>; /** * Verify OTP code and login * @param params Phone number and OTP code * @returns Promise with login result containing token and user data */ verifyOtp(params: OtpVerifyParams): Promise<ApiResponse<LoginResponse>>; /** * Logout the current user * @returns Promise with logout result */ logout(): Promise<ApiResponse<{ success: boolean; }>>; /** * Get current user profile * @returns Promise with user profile data */ getProfile(): Promise<ApiResponse<User>>; /** * Update user password * @param params Password update parameters * @returns Promise with update result */ updatePassword(params: UserPasswordUpdateParams): Promise<ApiResponse<{ success: boolean; }>>; /** * Create a new API key * @param params Optional API key creation parameters * @returns Promise with the created API key */ createApiKey(params?: ApiKeyCreateParams): Promise<ApiResponse<{ api_key: string; }>>; /** * Set a new API key for the client * @param apiKey The API key to set */ setApiKey(apiKey: string): void; /** * Validate the current API key * @returns Promise with validation result */ validateKey(): Promise<ApiResponse<{ valid: boolean; }>>; /** * Get information about the current API key * @returns Promise with API key information */ getKeyInfo(): Promise<ApiResponse<{ scopes: string[]; createdAt: string; }>>; }