# Users

## Create user

`client.users.create(UserCreateParamsbody?, RequestOptionsoptions?): User`

**post** `/user`

This can only be done by the logged in user.

### Parameters

- `body: UserCreateParams`

  - `id?: number`

  - `email?: string`

  - `firstName?: string`

  - `lastName?: string`

  - `password?: string`

  - `phone?: string`

  - `username?: string`

  - `userStatus?: number`

    User Status

### Returns

- `User`

  - `id?: number`

  - `email?: string`

  - `firstName?: string`

  - `lastName?: string`

  - `password?: string`

  - `phone?: string`

  - `username?: string`

  - `userStatus?: number`

    User Status

### Example

```typescript
import RpTestDocs1 from 'rp-test-docs-1';

const client = new RpTestDocs1({
  apiKey: process.env['PETSTORE_API_KEY'], // This is the default and can be omitted
});

const user = await client.users.create();

console.log(user.id);
```

#### Response

```json
{
  "id": 10,
  "email": "john@email.com",
  "firstName": "John",
  "lastName": "James",
  "password": "12345",
  "phone": "12345",
  "username": "theUser",
  "userStatus": 1
}
```

## Creates list of users with given input array

`client.users.createWithList(UserCreateWithListParamsparams?, RequestOptionsoptions?): User`

**post** `/user/createWithList`

Creates list of users with given input array

### Parameters

- `params: UserCreateWithListParams`

  - `items?: Array<User>`

    - `id?: number`

    - `email?: string`

    - `firstName?: string`

    - `lastName?: string`

    - `password?: string`

    - `phone?: string`

    - `username?: string`

    - `userStatus?: number`

      User Status

### Returns

- `User`

  - `id?: number`

  - `email?: string`

  - `firstName?: string`

  - `lastName?: string`

  - `password?: string`

  - `phone?: string`

  - `username?: string`

  - `userStatus?: number`

    User Status

### Example

```typescript
import RpTestDocs1 from 'rp-test-docs-1';

const client = new RpTestDocs1({
  apiKey: process.env['PETSTORE_API_KEY'], // This is the default and can be omitted
});

const user = await client.users.createWithList();

console.log(user.id);
```

#### Response

```json
{
  "id": 10,
  "email": "john@email.com",
  "firstName": "John",
  "lastName": "James",
  "password": "12345",
  "phone": "12345",
  "username": "theUser",
  "userStatus": 1
}
```

## Logs user into the system

`client.users.login(UserLoginParamsquery?, RequestOptionsoptions?): UserLoginResponse`

**get** `/user/login`

Logs user into the system

### Parameters

- `query: UserLoginParams`

  - `password?: string`

    The password for login in clear text

  - `username?: string`

    The user name for login

### Returns

- `UserLoginResponse = string`

### Example

```typescript
import RpTestDocs1 from 'rp-test-docs-1';

const client = new RpTestDocs1({
  apiKey: process.env['PETSTORE_API_KEY'], // This is the default and can be omitted
});

const response = await client.users.login();

console.log(response);
```

#### Response

```json
"string"
```

## Logs out current logged in user session

`client.users.logout(RequestOptionsoptions?): void`

**get** `/user/logout`

Logs out current logged in user session

### Example

```typescript
import RpTestDocs1 from 'rp-test-docs-1';

const client = new RpTestDocs1({
  apiKey: process.env['PETSTORE_API_KEY'], // This is the default and can be omitted
});

await client.users.logout();
```

## Get user by user name

`client.users.retrieve(stringusername, RequestOptionsoptions?): User`

**get** `/user/{username}`

Get user by user name

### Parameters

- `username: string`

### Returns

- `User`

  - `id?: number`

  - `email?: string`

  - `firstName?: string`

  - `lastName?: string`

  - `password?: string`

  - `phone?: string`

  - `username?: string`

  - `userStatus?: number`

    User Status

### Example

```typescript
import RpTestDocs1 from 'rp-test-docs-1';

const client = new RpTestDocs1({
  apiKey: process.env['PETSTORE_API_KEY'], // This is the default and can be omitted
});

const user = await client.users.retrieve('username');

console.log(user.id);
```

#### Response

```json
{
  "id": 10,
  "email": "john@email.com",
  "firstName": "John",
  "lastName": "James",
  "password": "12345",
  "phone": "12345",
  "username": "theUser",
  "userStatus": 1
}
```

## Update user

`client.users.update(stringexistingUsername, UserUpdateParamsbody?, RequestOptionsoptions?): void`

**put** `/user/{username}`

This can only be done by the logged in user.

### Parameters

- `existingUsername: string`

- `body: UserUpdateParams`

  - `id?: number`

  - `email?: string`

  - `firstName?: string`

  - `lastName?: string`

  - `password?: string`

  - `phone?: string`

  - `username?: string`

  - `userStatus?: number`

    User Status

### Example

```typescript
import RpTestDocs1 from 'rp-test-docs-1';

const client = new RpTestDocs1({
  apiKey: process.env['PETSTORE_API_KEY'], // This is the default and can be omitted
});

await client.users.update('username');
```

## Delete user

`client.users.delete(stringusername, RequestOptionsoptions?): void`

**delete** `/user/{username}`

This can only be done by the logged in user.

### Parameters

- `username: string`

### Example

```typescript
import RpTestDocs1 from 'rp-test-docs-1';

const client = new RpTestDocs1({
  apiKey: process.env['PETSTORE_API_KEY'], // This is the default and can be omitted
});

await client.users.delete('username');
```

## Domain Types

### User

- `User`

  - `id?: number`

  - `email?: string`

  - `firstName?: string`

  - `lastName?: string`

  - `password?: string`

  - `phone?: string`

  - `username?: string`

  - `userStatus?: number`

    User Status

### User Login Response

- `UserLoginResponse = string`
