# PokerogueAdminApi | pokemon-rogue-battle
Documentation for pokemon-rogue-battle

# Class PokerogueAdminApi

#### Hierarchy (View Summary)

- ApiBase
  - PokerogueAdminApi

- Defined in src/plugins/api/pokerogue-admin-api.ts:11

##### Index

### Constructors

constructor

### Properties

base
ERR_GENERIC
ERR_USERNAME_NOT_FOUND

### Methods

doFetch
doGet
doPost
linkAccountToDiscord
linkAccountToGoogleId
searchAccount
toUrlSearchParams
unlinkAccountFromDiscord
unlinkAccountFromGoogleId

## Constructors

### constructor

- new PokerogueAdminApi(base: string): PokerogueAdminApi

  #### Parameters

  - base: string

  #### Returns PokerogueAdminApi

  Inherited from ApiBase.constructor

  - Defined in src/plugins/api/api-base.ts:15

## Properties

### `Protected` `Readonly` base

base: string

Inherited from ApiBase.base

- Defined in src/plugins/api/api-base.ts:11

### `Readonly` ERR_GENERIC

ERR_GENERIC: string = "There was an error"

Inherited from ApiBase.ERR_GENERIC

- Defined in src/plugins/api/api-base.ts:9

### `Readonly` ERR_USERNAME_NOT_FOUND

ERR_USERNAME_NOT_FOUND: string = "Username not found!"

- Defined in src/plugins/api/pokerogue-admin-api.ts:12

## Methods

### `Protected` doFetch

- doFetch(path: string, config: RequestInit): Promise<Response>

  A generic request helper.

  #### Parameters

  - path: string

    The path to send the request to.

  - config: RequestInit

    The request RequestInit | Configuration.

  #### Returns Promise<Response>

  Inherited from ApiBase.doFetch

  - Defined in src/plugins/api/api-base.ts:65

### `Protected` doGet

- doGet(path: string): Promise<Response>

  Send a GET request.

  #### Parameters

  - path: string

    The path to send the request to.

  #### Returns Promise<Response>

  Inherited from ApiBase.doGet

  - Defined in src/plugins/api/api-base.ts:25

### `Protected` doPost

- doPost< D = undefined>(
  path: string,
  bodyData?: D ,
  dataType?: DataType,
  ): Promise<Response>

  Send a POST request.

  #### Type Parameters

  - D = undefined

  #### Parameters

  - path: string

    THe path to send the request to.

  - `Optional` bodyData: D

    The body-data to send.

  - dataType: DataType = "json"

    The data-type of the bodyData.

  #### Returns Promise<Response>

  Inherited from ApiBase.doPost

  - Defined in src/plugins/api/api-base.ts:35

### linkAccountToDiscord

- linkAccountToDiscord(
  params: LinkAccountToDiscordIdRequest ,
  ): Promise<null | string>

  Links an account to a discord id.

  #### Parameters

  - params: LinkAccountToDiscordIdRequest

    The `LinkAccountToDiscordIdRequest` to send

  #### Returns Promise<null | string>

  `null` if successful, error message if not

  - Defined in src/plugins/api/pokerogue-admin-api.ts:19

### linkAccountToGoogleId

- linkAccountToGoogleId(
  params: LinkAccountToGoogledIdRequest ,
  ): Promise<null | string>

  Links an account to a google id.

  #### Parameters

  - params: LinkAccountToGoogledIdRequest

    The `LinkAccountToGoogledIdRequest` to send

  #### Returns Promise<null | string>

  `null` if successful, error message if not

  - Defined in src/plugins/api/pokerogue-admin-api.ts:67

### searchAccount

- searchAccount(
  params: SearchAccountRequest ,
  ): Promise<[data?: SearchAccountResponse , error?: string]>

  Search an account.

  #### Parameters

  - params: SearchAccountRequest

    The `SearchAccountRequest` to send

  #### Returns Promise<[data?: SearchAccountResponse , error?: string]>

  an array of `SearchAccountResponse` and error. Both can be `undefined`

  - Defined in src/plugins/api/pokerogue-admin-api.ts:115

### `Protected` toUrlSearchParams

- toUrlSearchParams< D extends Record<string, any>>(data: D ): URLSearchParams

  Helper to transform data to URLSearchParams Any key with a value of `undefined` will be ignored. Any key with a value of `null` will be included.

  #### Type Parameters

  - D extends Record<string, any>

  #### Parameters

  - data: D

    the data to transform to URLSearchParams

  #### Returns URLSearchParams

  a URLSearchParams representaton of data

  Inherited from ApiBase.toUrlSearchParams

  - Defined in src/plugins/api/api-base.ts:86

### unlinkAccountFromDiscord

- unlinkAccountFromDiscord(
  params: UnlinkAccountFromDiscordIdRequest ,
  ): Promise<null | string>

  Unlinks an account from a discord id.

  #### Parameters

  - params: UnlinkAccountFromDiscordIdRequest

    The `UnlinkAccountFromDiscordIdRequest` to send

  #### Returns Promise<null | string>

  `null` if successful, error message if not

  - Defined in src/plugins/api/pokerogue-admin-api.ts:43

### unlinkAccountFromGoogleId

- unlinkAccountFromGoogleId(
  params: UnlinkAccountFromGoogledIdRequest ,
  ): Promise<null | string>

  Unlinks an account from a google id.

  #### Parameters

  - params: UnlinkAccountFromGoogledIdRequest

    The `UnlinkAccountFromGoogledIdRequest` to send

  #### Returns Promise<null | string>

  `null` if successful, error message if not

  - Defined in src/plugins/api/pokerogue-admin-api.ts:91