UNPKG

@mikle7/litty-api-client

Version:

TypeScript client for Litty API with clean, semantic type definitions

259 lines (258 loc) 13 kB
/* tslint:disable */ /* eslint-disable */ /** * Litty API * Complete API documentation for the Litty platform. ## Authentication Most endpoints require authentication via Supabase JWT tokens. Include the token in the Authorization header: `Bearer <token>` ## API Structure - **Contests**: Create and manage contests, entries, and settlements - **Markets**: Manage prediction markets within contests - **Transactions**: Handle financial transactions for contest entries and rewards - **Wallet**: Manage user wallet balances (cashable, points, tickets) - **Users**: User management and profiles - **Leaderboards**: Competition rankings and scoring - **Uploads**: File upload management - **Shows**: TV show and episode management (admin only) ## Response Formats All endpoints return JSON responses with consistent error handling. Error responses include `statusCode`, `message`, and `error` fields. * * The version of the OpenAPI document: 1.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import { CreateWallet201ResponseFromJSON, CreditWallet200ResponseFromJSON, CreditWalletRequestToJSON, DebitWallet200ResponseFromJSON, DebitWalletRequestToJSON, DebugWallet200ResponseFromJSON, FixWalletDiscrepancy200ResponseFromJSON, FixWalletEventStreams200ResponseFromJSON, GetUserWallet200ResponseFromJSON, } from '../models/index'; /** * */ export class WalletApi extends runtime.BaseAPI { /** * Create a new wallet for a specific user with default currency balances. * Create a wallet for a user */ async createWalletRaw(requestParameters, initOverrides) { if (requestParameters['userId'] == null) { throw new runtime.RequiredError('userId', 'Required parameter "userId" was null or undefined when calling createWallet().'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("JWT-auth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/wallet/users/{userId}`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters['userId']))), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateWallet201ResponseFromJSON(jsonValue)); } /** * Create a new wallet for a specific user with default currency balances. * Create a wallet for a user */ async createWallet(requestParameters, initOverrides) { const response = await this.createWalletRaw(requestParameters, initOverrides); return await response.value(); } /** * Add funds to a user wallet in the specified currency. * Credit wallet */ async creditWalletRaw(requestParameters, initOverrides) { if (requestParameters['userId'] == null) { throw new runtime.RequiredError('userId', 'Required parameter "userId" was null or undefined when calling creditWallet().'); } if (requestParameters['creditWalletRequest'] == null) { throw new runtime.RequiredError('creditWalletRequest', 'Required parameter "creditWalletRequest" was null or undefined when calling creditWallet().'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("JWT-auth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/wallet/users/{userId}/credit`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters['userId']))), method: 'POST', headers: headerParameters, query: queryParameters, body: CreditWalletRequestToJSON(requestParameters['creditWalletRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreditWallet200ResponseFromJSON(jsonValue)); } /** * Add funds to a user wallet in the specified currency. * Credit wallet */ async creditWallet(requestParameters, initOverrides) { const response = await this.creditWalletRaw(requestParameters, initOverrides); return await response.value(); } /** * Remove funds from a user wallet in the specified currency. * Debit wallet */ async debitWalletRaw(requestParameters, initOverrides) { if (requestParameters['userId'] == null) { throw new runtime.RequiredError('userId', 'Required parameter "userId" was null or undefined when calling debitWallet().'); } if (requestParameters['debitWalletRequest'] == null) { throw new runtime.RequiredError('debitWalletRequest', 'Required parameter "debitWalletRequest" was null or undefined when calling debitWallet().'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("JWT-auth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/wallet/users/{userId}/debit`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters['userId']))), method: 'POST', headers: headerParameters, query: queryParameters, body: DebitWalletRequestToJSON(requestParameters['debitWalletRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => DebitWallet200ResponseFromJSON(jsonValue)); } /** * Remove funds from a user wallet in the specified currency. * Debit wallet */ async debitWallet(requestParameters, initOverrides) { const response = await this.debitWalletRaw(requestParameters, initOverrides); return await response.value(); } /** * Debug endpoint to check wallet state and event stream consistency. * Debug wallet state (Admin) */ async debugWalletRaw(requestParameters, initOverrides) { if (requestParameters['walletId'] == null) { throw new runtime.RequiredError('walletId', 'Required parameter "walletId" was null or undefined when calling debugWallet().'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("JWT-auth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/wallet/debug/{walletId}`.replace(`{${"walletId"}}`, encodeURIComponent(String(requestParameters['walletId']))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => DebugWallet200ResponseFromJSON(jsonValue)); } /** * Debug endpoint to check wallet state and event stream consistency. * Debug wallet state (Admin) */ async debugWallet(requestParameters, initOverrides) { const response = await this.debugWalletRaw(requestParameters, initOverrides); return await response.value(); } /** * Debug endpoint to fix wallet discrepancy by adding missing credit events. * Fix wallet discrepancy (Admin) */ async fixWalletDiscrepancyRaw(requestParameters, initOverrides) { if (requestParameters['walletId'] == null) { throw new runtime.RequiredError('walletId', 'Required parameter "walletId" was null or undefined when calling fixWalletDiscrepancy().'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("JWT-auth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/wallet/debug/{walletId}/fix-discrepancy`.replace(`{${"walletId"}}`, encodeURIComponent(String(requestParameters['walletId']))), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FixWalletDiscrepancy200ResponseFromJSON(jsonValue)); } /** * Debug endpoint to fix wallet discrepancy by adding missing credit events. * Fix wallet discrepancy (Admin) */ async fixWalletDiscrepancy(requestParameters, initOverrides) { const response = await this.fixWalletDiscrepancyRaw(requestParameters, initOverrides); return await response.value(); } /** * TEMPORARY ENDPOINT: Fix missing wallet event streams by creating WalletCreated events for existing wallets. This endpoint should be removed after all wallets are fixed. * Fix missing wallet event streams (Admin) */ async fixWalletEventStreamsRaw(initOverrides) { const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("JWT-auth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/wallet/admin/fix-wallet-streams`, method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FixWalletEventStreams200ResponseFromJSON(jsonValue)); } /** * TEMPORARY ENDPOINT: Fix missing wallet event streams by creating WalletCreated events for existing wallets. This endpoint should be removed after all wallets are fixed. * Fix missing wallet event streams (Admin) */ async fixWalletEventStreams(initOverrides) { const response = await this.fixWalletEventStreamsRaw(initOverrides); return await response.value(); } /** * Retrieve wallet information for a specific user including all currency balances. * Get user wallet */ async getUserWalletRaw(requestParameters, initOverrides) { if (requestParameters['userId'] == null) { throw new runtime.RequiredError('userId', 'Required parameter "userId" was null or undefined when calling getUserWallet().'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("JWT-auth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/wallet/users/{userId}`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters['userId']))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => GetUserWallet200ResponseFromJSON(jsonValue)); } /** * Retrieve wallet information for a specific user including all currency balances. * Get user wallet */ async getUserWallet(requestParameters, initOverrides) { const response = await this.getUserWalletRaw(requestParameters, initOverrides); return await response.value(); } }