npm package: @opexa/portal-sdk
Description: A library that provides a set of functions to interact with Opexa Portal API.
Latest version: 0.59.1

## Opexa Portal SDK

A library that provides a set of functions to interact with Opexa Portal API.

## Installation

```bash
npm install @opexa/portal-sdk
```

## Usage

- Create sdk instance

```ts
// lib/sdk.js
import Sdk from '@opexa/portal-sdk';

export const sdk = new Sdk({
  platform: 'Z892',
  environment: 'development',
});
```

- Use sdk instance

```jsx
import { sdk } from '$lib/sdk';
import * as React from 'react';

function Page() {
  const [account, setAccount] = React.useState();

  React.useEffect(function () {
    sdk.account().then(setAccount);
  }, []);

  return (
    <pre>
      <code>{JSON.stringify(account, null, 2)}</code>
    </pre>
  );
}
```

## API

### `Sdk`

`Sdk` accepts the following options:

- `*site` - The site ID to be used
- `*sitePlatform` - The site platform ID to be used
- `*platform` - The platform code to be used
- `*environment` - Whether to use production/development api

, and returns the following methods:

- `signIn` - Start user session

  ```ts
  signIn(input: SignInInput): Promise<SignInReturn>
  ```

  ```ts
  type SignInInput =
    | {
        type: 'NAME_AND_PASSWORD';
        name: string;
        password: string;
      }
    | {
        type: 'MOBILE_NUMBER';
        mobileNumber: string;
        verificationCode: string;
      };

  type SignInReturn =
    | {
        ok: true;
      }
    | {
        ok: false;
        error:
          | HttpError
          | {
              name: 'AccountNotFound';
              message: string;
            };
      };
  ```

- `signOut` - End current user session

  ```ts
  signOut(): Promise<void>
  ```

- `site` - Retrieve site details

  ```ts
  site(): Promise<SiteReturn>
  ```

  ```ts
  interface Site {
    id: string;
    name: string;
    logo?: string;
  }
  ```

  ```ts
  type SiteReturn =
    | {
        ok: true;
        data: Site;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `platform` - Retrieve current platform details

  ```ts
  platform(): Promise<PlatformReturn>
  ```

  ```ts
  interface Platform {
    paymentSettings: {
      minimumFirstDepositAmount?: number;
      restrictWithdrawalsToVerifiedMembers: boolean;
      depositGateway: {
        bank: GatewaySettings;
        gcash: GatewaySettings;
        maya: GatewaySettings;
        mayaApp: GatewaySettings;
      };
      withdrawalGateway: {
        bank: GatewaySettings;
        gcash: GatewaySettings;
        maya: GatewaySettings;
        mayaApp: GatewaySettings;
      };
    };
    pointsClubSettings: {
      multiplier: number;
    };
  }

  type PlatformReturn =
    | {
        ok: true;
        data: Platform;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `account` - Retrieve current user's details

  ```ts
  account(): Promise<AccountReturn>
  ```

  ```ts
  interface Account {
    id: string;
    name: string;
    status: MemberAccountStatus;
    realName?: string;
    nickName?: string;
    dateOfBirth?: Date;
    validId?: string;
    emailAddress?: string;
    mobileNumber?: string;
    verified: boolean;
    verificationStatus: MemberAccountVerificationStatus;
    mobileNumberVerified: boolean;
    mobileNumberVerificationRequired: boolean;
    transactionPassword: boolean;
    dateTimeLastActive?: Date;
    dateTimeCreated: Date;
    dateTimeLastUpdated: Date;
  }

  type AccountReturn =
    | {
        ok: true;
        data: Account;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `createAccount` - Create new user account

  ```ts
  createAccount(input: CreateAccountInput): Promise<CreateAccountReturn>
  ```

  ```ts
  interface CreateAccountInput {
    id?: string;
    name: string;
    password: string;
    mobileNumber: string;
    dateOfBirth: string;
    btag?: string;
    domain?: string;
    referralCode?: string;
    verificationCode?: string;
    reCAPTCHAResponse?: string;
  }

  type CreateAccountReturn =
    | {
        ok: true;
        error?: never;
        data: {
          id: string;
        };
      }
    | {
        ok: false;
        data?: never;
        error:
          | HttpError
          | {
              name:
                | 'AccountNameNotAvailableError'
                | 'InvalidPlatformError'
                | 'InvalidReCAPTCHAResponseError'
                | 'InvalidSMSVerificationCodeError'
                | 'MinimumAgeRequirementError'
                | 'MobileNumberNotAvailableError';
              message: string;
            };
      };
  ```

- `updateAccount` - Update current user's details

  ```ts
  updateAccount(input: UpdateAccountInput): Promise<UpdateAccountReturn>
  ```

  ```ts
  type UpdateAccountReturn =
    | {
        ok: true;
        data?: never;
        error?: never;
      }
    | {
        ok: false;
        data?: never;
        error: {
          name:
            | 'AccountNameNotAvailableError'
            | 'EmailAddressNotAvailableError'
            | 'InvalidTransactionPasswordError'
            | 'MobileNumberNotAvailableError'
            | 'NickNameNotAvailableError'
            | 'RealNameAlreadySetError'
            | 'ValidIdAlreadySetError';
          message: string;
        };
      };
  ```

- `deleteAccount` - Delete current user's account

  ```ts
  deleteAccount(id: string): Promise<DeleteAccountReturn>
  ```

  ```ts
  type DeleteAccountReturn =
    | {
        ok: true;
      }
    | {
        ok: false;
        error: UnknownError | HttpError;
      };
  ```

- `resetPassword` - Reset user's password

  ```ts
  resetPassword(input: ResetPasswordInput): Promise<ResetPasswordReturn>
  ```

  ```ts
  interface ResetPasswordInput {
    mobileNumber: string;
    newPassword: string;
    verificationCode: string;
  }

  type ResetPasswordReturn =
    | {
        ok: true;
      }
    | {
        ok: false;
        error:
          | HttpError
          | {
              name: 'AccountNotFoundError' | 'InvalidVerificationCodeError';
              message: string;
            };
      };
  ```

- `verificationDetails` - Retrieve user's verification details

  ```ts
  verificationDetails(): Promise<VerificationDetailsReturn>
  ```

  ```ts
  interface VerificationDetails {
    id: string;
    status: MemberVerificationStatus;
    address: string;
    sourceOfIncome: string;
    natureOfWork: string;
    nationality: string;
    placeOfBirth: string;
    idFrontImage: File;
    selfieImage: File;
  }

  type VerificationDetailsReturn =
    | {
        ok: true;
        data: VerificationDetails;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `submitVerificationDetails` - Submit current user's verification details

  ```ts
  submitVerificationDetails(input: SubmitVerificationDetailsInput): Promise<SubmitVerificationDetailsReturn>
  ```

  ```ts
  interface SubmitVerificationDetailsInput {
    id?: string;
    idFrontImage: string;
    selfieImage: string;
    address: string;
    sourceOfIncome: string;
    natureOfWork: string;
    nationality: string;
    placeOfBirth: string;
  }

  type SubmitVerificationDetailsReturn =
    | {
        ok: true;
        data: {
          id: string;
        };
      }
    | {
        ok: false;
        error:
          | HttpError
          | {
              name:
                | 'FileDoesNotExistError'
                | 'FileNotReadyError'
                | 'MemberVerificationAlreadyExistsError';
              message: string;
            };
      };
  ```

- `updateVerificationDetails` - Update current user's verification details

  ```ts
  updateVerificationDetails(input: UpdateVerificationDetailsInput): Promise<UpdateVerificationDetailsReturn>
  ```

  ```ts
  interface UpdateVerificationDetailsInput {
    idFrontImage: string;
    selfieImage: string;
    address: string;
    permanentAddress: string;
    sourceOfIncome: string;
    natureOfWork: string;
    nationality: string;
    placeOfBirth: string;
  }

  type UpdateVerificationDetailsReturn =
    | {
        ok: true;
      }
    | {
        ok: false;
        error:
          | HttpError
          | {
              name:
                | 'FileDoesNotExistError'
                | 'FileNotReadyError'
                | 'MemberVerificationAlreadyApprovedError'
                | 'MemberVerificationDoesNotExistError';
              message: string;
            };
      };
  ```

- `verifyMobileNumber` - Verify current user's mobile number

  ```ts
  verifyMobileNumber(verificationCode: string): Promise<VerifyMobileNumberReturn>
  ```

  ```ts
  type VerifyMobileNumberReturn =
    | {
        ok: true;
      }
    | {
        ok: false;
        error:
          | HttpError
          | {
              name: 'InvalidSMSVerificationCodeError' | 'MobileNumberAlreadyVerifiedError';
              message: string;
            };
      };
  ```

- `profileCompletion` - Retrieve current user's profile completion status

  ```ts
  profileCompletion(): Promise<ProfileCompletionReturn>
  ```

  ```ts
  interface ProfileCompletion {
    completionPercentage: number;
    personalInformation: boolean;
    accountVerification: boolean;
    mobileNumberVerification: boolean;
    transactionPassword: boolean;
    accountPassword: boolean;
  }

  type ProfileCompletionReturn =
    | {
        ok: true;
        data: ProfileCompletion;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `sendVerificationCode` - Send verification code to mobile number or email address

  ```ts
  sendVerificationCode(mobileNumber: string): Promise<SendVerificationCodeReturn>
  ```

  ```ts
  type SendVerificationCodeReturn =
    | {
        ok: true;
      }
    | {
        ok: false;
        error:
          | HttpError
          | {
              name: 'InvalidPlatformError' | 'NotReadyToSendVerficationCodeError';
              message: string;
            };
      };
  ```

- `wallet` - Retrieve current user's wallet details

  ```ts
  wallet(): Promise<WalletReturn>
  ```

  ```ts
  interface Wallet {
    id: string;
    balance: number;
    currency: Currency;
    dateTimeCreated: Date;
    dateTimeLastUpdated: Date;
  }

  type WalletReturn =
    | {
        ok: true;
        data: Wallet | null;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `announcements` - Retrieve announcements for current platform

  ```ts
  announcements(input?: AnnouncementsInput): Promise<AnnouncementsReturn>
  ```

  ```ts
  interface AnnouncementsInput {
    first?: number;
    after?: string;
  }

  interface Announcement {
    id: string;
    type: 'RELEASE' | 'SCHEDULED_MAINTENANCE';
    title: string;
    status: 'ACTIVE' | 'INACTIVE';
    message: string;
    activationStartDateTime: Date;
    activationEndDateTime: Date;
    dateTimeCreated: Date;
    dateTimeLastUpdated: Date;
  }

  type AnnouncementsReturn =
    | {
        ok: true;
        data: {
          announcements: (Announcement & { cursor: string })[];
          totalCount: number;
          hasNextPage: boolean;
          endCursor?: string;
        };
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `createWithdrawal` - Create new withdrawal request

  ```ts
  createWithdrawal(input: CreateWithdrawalInput): Promise<CreateWithdrawalReturn>
  ```

  ```ts
  interface CreateBankWithdrawalInput {
    id?: string;
    type: 'BANK';
    amount: number;
    transactionPassword: string;
  }

  interface CreateGCashWithdrawalInput {
    id?: string;
    type: 'GCASH';
    amount: number;
    transactionPassword: string;
    recipientMobileNumber: string;
  }

  interface CreateGCashStandardCashInWithdrawalInput {
    id?: string;
    type: 'GCASH_STANDARD_CASHIN';
    amount: number;
    transactionPassword: string;
    recipientMobileNumber: string;
  }

  interface CreateMayaWithdrawalInput {
    id?: string;
    type: 'MAYA';
    amount: number;
    transactionPassword: string;
    recipientMobileNumber: string;
  }

  interface CreateMayaAppWithdrawalInput {
    id?: string;
    type: 'MAYA_APP';
    amount: number;
    transactionPassword: string;
  }

  type CreateWithdrawalInput =
    | CreateBankWithdrawalInput
    | CreateGCashWithdrawalInput
    | CreateGCashStandardCashInWithdrawalInput
    | CreateMayaWithdrawalInput
    | CreateMayaAppWithdrawalInput;

  type CreateWithdrawalReturn =
    | {
        ok: true;
        data: {
          id: string;
        };
      }
    | {
        ok: false;
        error:
          | HttpError
          | {
              name:
                | 'MobileNumberNotVerifiedError'
                | 'AccountNotVerifiedError'
                | 'InvalidWithdrawalAmountError'
                | 'WithdrawalDailyLimitExceededError'
                | 'InvalidTransactionPasswordError'
                | 'NotEnoughBalanceError';
              message: string;
            };
      };
  ```

- `withdrawalRecords` - Retrieve current user's withdrawal records

  ```ts
  withdrawalRecords(input?: WithdrawalRecordsInput): Promise<WithdrawalRecordsReturn>
  ```

  ```ts
  type WithdrawalRecordType = 'MANUAL' | 'BANK' | 'GCASH' | 'MAYA';
  type WithdrawalRecordStatus = 'PENDING' | 'APPROVED' | 'REJECTED' | 'CONFIRMED' | 'CANCELLED';

  interface WithdrawalRecordsInput {
    first?: number;
    after?: string;
    filter?: {
      type?: {
        equal?: WithdrawalRecordType;
        notEqual?: WithdrawalRecordType;
        in?: WithdrawalRecordType[];
        notIn?: WithdrawalRecordType[];
      };
      status?: {
        equal?: WithdrawalRecordStatus;
        notEqual?: WithdrawalRecordStatus;
        in?: WithdrawalRecordStatus[];
        notIn?: WithdrawalRecordStatus[];
      };
      reference?: {
        equal?: string;
        notEqual?: string;
        in?: string[];
        notIn?: string[];
        contains?: string;
        startsWith?: string;
      };
      withdrawalNumber?: {
        equal?: string;
        notEqual?: string;
        in?: string[];
        notIn?: string[];
        contains?: string;
        startsWith?: string;
      };
      dateTimeCreated?: {
        equal?: Date | string;
        notEqual?: Date | string;
        in?: Date | string[];
        notIn?: Date | string[];
        lesserThan?: Date | string;
        lesserThanOrEqual?: Date | string;
        greaterThan?: Date | string;
        greaterThanOrEqual?: Date | string;
      };
      dateTimeLastUpdated?: {
        equal?: Date | string;
        notEqual?: Date | string;
        in?: Date | string[];
        notIn?: Date | string[];
        lesserThan?: Date | string;
        lesserThanOrEqual?: Date | string;
        greaterThan?: Date | string;
        greaterThanOrEqual?: Date | string;
      };
    };
  }

  interface WithdrawalRecord {
    id: string;
    type: WithdrawalRecordType;
    bank?: 'AUBKPHMM' | 'MBTCPHMM' | 'BNORPHMM' | 'MKRUPHM1';
    fee: number;
    amount: number;
    netAmount: number;
    status: WithdrawalRecordStatus;
    reference?: string;
    withdrawalNumber: string;
    recipientMobileNumber?: string;
    dateTimeConfirmed?: Date;
    dateTimeCreated: Date;
    dateTimeLastUpdated: Date;
  }

  type WithdrawalRecordsReturn =
    | {
        ok: true;
        data: {
          withdrawalRecords: (WithdrawalRecord & { cursor: string })[];
          totalCount: number;
          hasNextPage: boolean;
          endCursor?: string;
        };
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `remainingDailyWithdrawalsCount` - Retrieve current user's remaining daily withdrawals count

  ```ts
  remainingDailyWithdrawalsCount(): Promise<RemainingDailyWithdrawalsCountReturn>
  ```

  ```ts
  type RemainingDailyWithdrawalsCountReturn =
    | {
        ok: true;
        data: number;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `createDeposit` - Create new deposit request

  ```ts
  createDeposit(input: CreateDepositInput): Promise<CreateDepositReturn>
  ```

  ```ts
  interface CreateMayaDepositInput {
    id?: string;
    type: 'MAYA';
    amount: number;
    promo?: string;
  }

  interface CreateGCashDepositInput {
    id?: string;
    type: 'GCASH';
    amount: number;
    promo?: string;
  }

  interface CreateMayaAppDepositInput {
    id?: string;
    type: 'MAYA_APP';
    amount: number;
    promo?: string;
  }

  type CreateDepositInput =
    | CreateMayaDepositInput
    | CreateGCashDepositInput
    | CreateMayaAppDepositInput;

  type CreateDepositReturn =
    | {
        ok: true;
        data: {
          id: string;
        };
      }
    | {
        ok: false;
        error:
          | HttpError
          | {
              name:
                | 'DepositPromoMaximumAmountExceededError'
                | 'DepositPromoMinimumAmountNotMetError'
                | 'MaximumDepositAmountExceededError'
                | 'MinimumDepositAmountNotMetError'
                | 'MinimumFirstDepositAmountNotMetError'
                | 'PromoNotEnabledError'
                | 'WalletDoesNotExistError';
              message: string;
            };
      };
  ```

- `deposit` - Retrieve deposit details

  ```ts
  deposit(id: string): Promise<DepositReturn>
  ```

  ```ts
  interface Deposit {
    id: string;
    type: 'BANK' | 'GCASH' | 'MANUAL' | 'MAYA' | 'MAYA_APP';
    status: 'PENDING' | 'ACCEPTED' | 'APPROVED' | 'REJECTED' | 'CONFIRMED' | 'CANCELLED';
    amount: number;
    netAmount: number;
    fee: number;
    reference?: string;
    checkoutUrl?: string;
    dateTimeCreated: Date;
    dateTimeLastUpdated: Date;
  }

  type DepositReturn =
    | {
        ok: true;
        data: Deposit | null;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `depositRecords` - Retrieve current user's deposit records

  ```ts
  depositRecords(input?: DepositRecordsInput): Promise<DepositRecordsReturn>
  ```

  ```ts
  type DepositRecordType = 'BANK' | 'GCASH' | 'MANUAL' | 'MAYA' | 'MAYA_APP';
  type DepositRecordStatus =
    | 'PENDING'
    | 'ACCEPTED'
    | 'APPROVED'
    | 'REJECTED'
    | 'CONFIRMED'
    | 'CANCELLED';

  interface DepositRecordsInput {
    first?: number;
    after?: string;
    filter?: {
      type?: {
        equal?: DepositRecordType;
        notEqual?: DepositRecordType;
        in?: DepositRecordType[];
        notIn?: DepositRecordType[];
      };
      status?: {
        equal?: DepositRecordStatus;
        notEqual?: DepositRecordStatus;
        in?: DepositRecordStatus[];
        notIn?: DepositRecordStatus[];
      };
      reference?: {
        equal?: string;
        notEqual?: string;
        in?: string[];
        notIn?: string[];
        contains?: string;
        startsWith?: string;
      };
      depositNumber?: {
        equal?: string;
        notEqual?: string;
        in?: string[];
        notIn?: string[];
        contains?: string;
        startsWith?: string;
      };
      dateTimeCreated?: {
        equal?: Date | string;
        notEqual?: Date | string;
        in?: Date | string[];
        notIn?: Date | string[];
        lesserThan?: Date | string;
        lesserThanOrEqual?: Date | string;
        greaterThan?: Date | string;
        greaterThanOrEqual?: Date | string;
      };
      dateTimeLastUpdated?: {
        equal?: Date | string;
        notEqual?: Date | string;
        in?: Date | string[];
        notIn?: Date | string[];
        lesserThan?: Date | string;
        lesserThanOrEqual?: Date | string;
        greaterThan?: Date | string;
        greaterThanOrEqual?: Date | string;
      };
    };
  }

  interface DepositRecord {
    id: string;
    type: DepositRecordType;
    status: DepositRecordStatus;
    amount: number;
    netAmount: number;
    fee: number;
    reference?: string;
    depositNumber: string;
    dateTimeCreated: Date;
    dateTimeLastUpdated: Date;
  }

  type DepositRecordsReturn =
    | {
        ok: true;
        data: {
          depositRecords: (DepositRecord & { cursor: string })[];
          totalCount: number;
          hasNextPage: boolean;
          endCursor?: string;
        };
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `depositsCount` - Retrieve current user's deposits count

  ```ts
  depositsCount(): Promise<DepositsCountReturn>
  ```

  ```ts
  type DepositsCountReturn =
    | {
        ok: true;
        data: number;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `betRecords` - Retrieve current user's bet records

  ```ts
  betRecords(input?: BetRecordsInput): Promise<BetRecordsReturn>
  ```

  ```ts
  type BetRecordStatus = 'STARTED' | 'SETTLED' | 'CANCELLED';

  interface BetRecordsInput {
    first?: number;
    after?: string;
    sort?: SortOrder;
    filter?: {
      serialCode?: {
        equal?: string;
        notEqual?: string;
        in?: string[];
        notIn?: string[];
        contains?: string;
        startsWith?: string;
      };
      game?: {
        equal?: string;
        notEqual?: string;
        in?: string[];
        notIn?: string[];
      };
      game__externalId?: {
        equal?: string;
        notEqual?: string;
        in?: string[];
        notIn?: string[];
        contains?: string;
        startsWith?: string;
      };
      game__type?: {
        equal?: GameType;
        notEqual?: GameType;
        in?: GameType[];
        notIn?: GameType[];
      };
      game__provider?: {
        equal?: GameProvider;
        notEqual?: GameProvider;
        in?: GameProvider[];
        notIn?: GameProvider[];
      };
      dateTimeCreated?: {
        equal?: Date | string;
        notEqual?: Date | string;
        in?: Date | string[];
        notIn?: Date | string[];
        lesserThan?: Date | string;
        lesserThanOrEqual?: Date | string;
        greaterThan?: Date | string;
        greaterThanOrEqual?: Date | string;
      };
      vendorRoundId?: {
        equal?: string;
        notEqual?: string;
        in?: string[];
        notIn?: string[];
        contains?: string;
        startsWith?: string;
      };
      status?: {
        equal?: BetRecordStatus;
        notEqual?: BetRecordStatus;
        in?: BetRecordStatus[];
        notIn?: BetRecordStatus[];
      };
    };
    startDateTime?: {
      equal?: Date | string;
      notEqual?: Date | string;
      in?: Date | string[];
      notIn?: Date | string[];
      lesserThan?: Date | string;
      lesserThanOrEqual?: Date | string;
      greaterThan?: Date | string;
      greaterThanOrEqual?: Date | string;
    };
    endDateTime?: {
      equal?: Date | string;
      notEqual?: Date | string;
      in?: Date | string[];
      notIn?: Date | string[];
      lesserThan?: Date | string;
      lesserThanOrEqual?: Date | string;
      greaterThan?: Date | string;
      greaterThanOrEqual?: Date | string;
    };
  }

  interface BetRecord {
    id: string;
    game: Game;
    status: BetRecordStatus;
    serialCode: string;
    vendorRoundId?: string;
    bet: number;
    payout: number;
    validBet: number;
    jackpotContribution: number;
    jackpotPayout: number;
    winloss?: number;
    betContent?: string;
    contestName?: string;
    externalCategory?: string;
    dateTimeSettled?: Date;
    dateTimeCreated: Date;
    dateTimeLastUpdated: Date;
    metadata: {
      odds?: string;
      validBet?: number;
    };
  }

  type BetRecordsReturn =
    | {
        ok: true;
        data: {
          betRecords: (BetRecord & { cursor: string })[];
          totalCount: number;
          hasNextPage: boolean;
          endCursor?: string;
        };
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `transactionRecords` - Retrieve current user's transaction records

  ```ts
  transactionRecords(input?: TransactionRecordsInput): Promise<TransactionRecordsReturn>
  ```

  ```ts
  type TransactionRecordType =
    | 'DEPOSIT'
    | 'PAYOUT'
    | 'WITHDRAWAL_REFUND'
    | 'TRANSFER_IN'
    | 'WITHDRAWAL'
    | 'BET'
    | 'TRANSFER_OUT'
    | 'ROLLBACK'
    | 'BET_REFUND'
    | 'PAYOUT_REFUND'
    | 'CASHBACK_BONUS'
    | 'BONUS'
    | 'RESERVE'
    | 'REJECT_WITHDRAWAL'
    | 'MANUAL_DEPOSIT'
    | 'GCASH_DEPOSIT'
    | 'MANUAL_WITHDRAWAL'
    | 'BANK_WITHDRAWAL'
    | 'GCASH_WITHDRAWAL'
    | 'COMMIT_RESERVE'
    | 'ROLLBACK_PAYOUT'
    | 'ROLLBACK_RESERVE';

  interface TransactionRecordsInput {
    first?: number;
    after?: string;
    filter?: {
      type?: {
        equal?: TransactionRecordType;
        notEqual?: TransactionRecordType;
        in?: TransactionRecordType[];
        notIn?: TransactionRecordType[];
      };
      referenceNumber?: {
        equal?: string;
        notEqual?: string;
        in?: string[];
        notIn?: string[];
        contains?: string;
        startsWith?: string;
      };
      dateTimeCreated?: {
        equal?: Date | string;
        notEqual?: Date | string;
        in?: Date | string[];
        notIn?: Date | string[];
        lesserThan?: Date | string;
        lesserThanOrEqual?: Date | string;
        greaterThan?: Date | string;
        greaterThanOrEqual?: Date | string;
      };
    };
  }

  interface TransactionRecord {
    id: string;
    type: TransactionRecordType;
    amount: number;
    content?: string;
    currentBalance: number;
    referenceNumber: string;
    dateTimeCreated: Date;
    dateTimeLastUpdated: Date;
  }

  type TransactionRecordsReturn =
    | {
        ok: true;
        data: {
          transactionRecords: (TransactionRecord & { cursor: string })[];
          totalCount: number;
          hasNextPage: boolean;
          endCursor?: string;
        };
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `promos` - Retrieve promos for current platform

  ```ts
  promos(): Promise<PromosReturn>
  ```

  ```ts
  interface Promo {
    id: string;
    type: 'DEPOSIT';
    name: string;
    banner: {
      id: string;
      url: string;
      status: 'READY';
      dateTimeCreated: Date;
    };
    status: 'ACTIVE' | 'INACTIVE' | 'DISABLED' | 'EXPIRED';
    description: string;
    minimumBonusAmount?: number;
    maximumBonusAmount?: number;
    minimumDepositAmount?: number;
    turnoverRequirementContributionPercentagePerGameProvider?: JSON;
    maximumDepositAmount?: number;
    activationStartDateTime: Date;
    activationEndDateTime: Date;
    dateTimeCreated: Date;
    dateTimeLastUpdated: Date;
  }

  type PromosReturn =
    | {
        ok: true;
        data: Promo[];
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `availablePromos` - Retrieve available promos for current user

  ```ts
  availablePromos(): Promise<PromosReturn>
  ```

- `bonus` - Retrieve current user's bonus details

  ```ts
  bonus(): Promise<BonusReturn>
  ```

  ```ts
  interface Bonus {
    id: string;
    promo: Promo;
    deposit?: {
      type: DepositRecordType;
      status: DepositRecordStatus;
      amount: number;
      netAmount: number;
      fee: number;
      reference?: string;
      dateTimeCreated: Date;
      dateTimeLastUpdated: Date;
    };
    amount: number;
    balance: number;
    turnoverRequirement: number;
    currentTurnoverRequirementContribution: number;
    currentTurnoverRequirementContributionPercentage: number;
    expiration: Date;
    dateTimeCreated: Date;
    dateTimeLastUpdated: Date;
  }

  type BonusReturn =
    | {
        ok: true;
        data: Bonus | null;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `cashbacks` - Retrieve cashbacks for current platform

  ```ts
  cashbacks(): Promise<CashbackReturn>
  ```

  ```ts
  interface Cashback {
    id: string;
    name: string;
    banner: {
      id: string;
      url: string;
      status: 'READY';
      dateTimeCreated: Date;
    };
    status: CashbackStatus;
    description: string;
    activationStartDateTime: Date;
    activationEndDateTime: Date;
    dateTimeCreated: Date;
    dateTimeLastUpdated: Date;
  }

  type CashbackReturn =
    | {
        ok: true;
        data: Cashback[];
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `cashbackBonuses` - Retrieve current user's cashback bonuses

  ```ts
  cashbackBonuses(): Promise<CashbackBonusesReturn>
  ```

  ```ts
  interface CashbackBonus {
    id: string;
    balance: number;
    cashback: Cashback;
    dateTimeCreated: Date;
    dateTimeLastUpdated: Date;
  }

  type CashbackBonusesReturn =
    | {
        ok: true;
        data: CashbackBonus[];
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `claimCashbackBonus` - Claim cashback bonus

  ```ts
  claimCashbackBonus(id: string): Promise<ClaimCashbackBonusReturn>
  ```

  ```ts
  type ClaimCashbackBonusReturn =
    | {
        ok: true;
      }
    | {
        ok: false;
        error:
          | HttpError
          | {
              name: 'CashbackBonusDoesNotExistError';
              message: string;
            };
      };
  ```

- `games` - Retrieve games

  ```ts
  games(input?: GamesInput): Promise<GamesReturn>
  ```

  ```ts
  type GameType = 'SLOTS' | 'SPORTS' | 'BINGO' | 'FISHING' | 'LIVE' | 'GAMES';
  type GameProvider =
    | 'JILI'
    | 'PGSOFT'
    | 'FACHAI'
    | 'PLAYTECH'
    | 'CQ9'
    | 'JDB'
    | 'BOOONGO'
    | 'HABANERO'
    | 'DIGITAIN'
    | 'RELAXGAMING'
    | 'DG'
    | 'E2E'
    | 'BTI'
    | 'DARWIN'
    | 'MEGABALL'
    | 'DRBINGO'
    | 'RTG';

  interface GamesInput {
    after?: string;
    first?: number;
    filter?: {
      id?: {
        equal?: string;
        notEqual?: string;
        in?: string[];
        notIn?: string[];
      };
      name?: {
        equal?: string;
        notEqual?: string;
        in?: string[];
        notIn?: string[];
        contains?: string;
        startsWith?: string;
      };
      type?: {
        equal?: GameType;
        notEqual?: GameType;
        in?: GameType[];
        notIn?: GameType[];
      };
      provider?: {
        equal?: GameProvider;
        notEqual?: GameProvider;
        in?: GameProvider[];
        notIn?: GameProvider[];
      };
    };
  }

  interface Game {
    id: string;
    type: GameType;
    name: string;
    image: string;
    provider: GameProvider;
  }

  type GamesReturn =
    | {
        ok: true;
        data: {
          games: (Game & { cursor: string })[];
          totalCount: number;
          hasNextPage: boolean;
          endCursor?: string;
        };
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `gameSession` - Retrieve game session details

  ```ts
  gameSession(id: string): Promise<GameSessionReturn>
  ```

  ```ts
  type GameSession =
    | {
        id: string;
        game: Game;
        status: 'READY';
        launchUrl: string;
        dateTimeCreated: Date;
        dateTimeLastUpdated: Date;
      }
    | {
        id: string;
        game: Game;
        status: 'PENDING' | 'STARTING' | 'ENDED' | 'CANCELLED';
        dateTimeCreated: Date;
        dateTimeLastUpdated: Date;
      };

  type GameSessionReturn =
    | {
        ok: true;
        data: GameSession | null;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `createGameSession` - Create new game session

  ```ts
  createGameSession(input:CreateGameSessionInput): Promise<CreateGameSessionReturn>
  ```

  ```ts
  interface CreateGameSessionInput {
    id?: string;
    game: string;
  }

  type CreateGameSessionReturn =
    | {
        ok: true;
        data: {
          id: string;
        };
      }
    | {
        ok: false;
        error:
          | HttpError
          | {
              name: 'GameDoesNotExistError';
              message: string;
            };
      };
  ```

- `endGameSession` - End game session

  ```ts
  endGameSession(id: string): Promise<EndGameSessionReturn>
  ```

  ```ts
  type EndGameSessionReturn =
    | {
        ok: true;
      }
    | {
        ok: false;
        error: HttpError | UnknownError;
      };
  ```

- `file` - Retrieve file details

  ```ts
  file(id: string): Promise<FileReturn>
  ```

  ```ts
  type File =
    | {
        id: string;
        url?: never;
        status: 'UPLOADING' | 'FAILED';
        dateTimeCreated: Date;
      }
    | {
        id: string;
        url: string;
        status: 'READY';
        dateTimeCreated: Date;
      }
    | {
        id: string;
        url?: string;
        status: 'DELETED';
        dateTimeCreated: Date;
      };

  type FileReturn =
    | {
        ok: true;
        data: File | null;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `uploadImageFile` - Upload image file

  ```ts
  uploadImageFile(input: globalThis.File): Promise<UploadImageFileReturn>
  ```

  ```ts
  type UploadImageFileReturn =
    | {
        ok: true;
        data: {
          id: string;
        };
      }
    | {
        ok: false;
        error:
          | HttpError
          | {
              name: 'FileFormatNotSupportedError' | 'FileNameTooLongError' | 'FileSizeTooBigError';
              message: string;
            };
      };
  ```

- `pointsWallet` - Retrieve current user's points wallet details

  ```ts
  pointsWallet(): Promise<PointsWalletReturn>
  ```

  ```ts
  interface PointsWallet {
    id: string;
    points: number;
    account: string;
    dateTimeCreated: Date;
  }

  type PointsWalletReturn =
    | {
        ok: true;
        data: PointsWallet | null;
      }
    | {
        ok: false;
        error: HttpError;
      };
  ```

- `pointsToCashConversion` - Convert points to cash

  ```ts
  pointsToCashConversion(amount: number): Promise<PointsToCashConversionReturn>
  ```

  ```ts
  type PointsToCashConversionReturn =
    | {
        ok: true;
      }
    | {
        ok: false;
        error:
          | HttpError
          | {
              name: 'InsufficientPointsError';
              message: string;
            };
      };
  ```