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

# Class PokerogueSessionSavedataApi

A wrapper for PokéRogue session savedata API requests.

#### Hierarchy (View Summary)

- ApiBase
  - PokerogueSessionSavedataApi

- Defined in src/plugins/api/pokerogue-session-savedata-api.ts:15

##### Index

### Constructors

constructor

### Properties

base
ERR_GENERIC

### Methods

clear
delete
doFetch
doGet
doPost
get
newclear
toUrlSearchParams
update

## Constructors

### constructor

- new PokerogueSessionSavedataApi(base: string): PokerogueSessionSavedataApi

  #### Parameters

  - base: string

  #### Returns PokerogueSessionSavedataApi

  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

## Methods

### clear

- clear(
  params: ClearSessionSavedataRequest ,
  sessionData: SessionSaveData ,
  ): Promise< ClearSessionSavedataResponse >

  Clears the session savedata of the given slot.
  This is NOT the same as `newclear()`.

  #### Parameters

  - params: ClearSessionSavedataRequest

    The `ClearSessionSavedataRequest` to send

  - sessionData: SessionSaveData

    The `SessionSaveData` object

  #### Returns Promise< ClearSessionSavedataResponse >

  - Defined in src/plugins/api/pokerogue-session-savedata-api.ts:99

### delete

- delete(params: DeleteSessionSavedataRequest ): Promise<null | string>

  Delete a session savedata slot.

  #### Parameters

  - params: DeleteSessionSavedataRequest

    The `DeleteSessionSavedataRequest` to send

  #### Returns Promise<null | string>

  An error message if something went wrong

  - Defined in src/plugins/api/pokerogue-session-savedata-api.ts:78

### `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

### get

- get(params: GetSessionSavedataRequest ): Promise<null | string>

  Get a session savedata.

  #### Parameters

  - params: GetSessionSavedataRequest

    The `GetSessionSavedataRequest` to send

  #### Returns Promise<null | string>

  The session as `string`

  - Defined in src/plugins/api/pokerogue-session-savedata-api.ts:42

### newclear

- newclear(params: NewClearSessionSavedataRequest ): Promise<boolean>

  Mark a session as cleared aka "newclear".
  This is NOT the same as `clear()`.

  #### Parameters

  - params: NewClearSessionSavedataRequest

    The `NewClearSessionSavedataRequest` to send

  #### Returns Promise<boolean>

  The raw savedata as `string`.

  - Defined in src/plugins/api/pokerogue-session-savedata-api.ts:24

### `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

### update

- update(
  params: UpdateSessionSavedataRequest ,
  rawSavedata: string,
  ): Promise<string>

  Update a session savedata.

  #### Parameters

  - params: UpdateSessionSavedataRequest

    The `UpdateSessionSavedataRequest` to send

  - rawSavedata: string

    The raw savedata (as `string`)

  #### Returns Promise<string>

  An error message if something went wrong

  - Defined in src/plugins/api/pokerogue-session-savedata-api.ts:60