npm package: @sr-sdks/api-sdk-axios
Description: OpenAPI client for @sr-sdks/api-sdk-axios
Author: OpenAPI-Generator Contributors
Latest version: 2.18.0-pre.1

## @sr-sdks/api-sdk-axios@2.18.0-pre.1

This is a TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios).

It is generated from OpenAPI (Swagger) specs produced by the backend project.

It includes API classes and model interfaces compatible with the backend. The benefit of this is that the client side doesn't need to maintain matching interfaces or hand coded APIs.

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))


### Consuming

Navigate to the folder of your consuming project and run the following command to install from the published package:

```bash
npm install @sr-sdks/api-sdk-axios@2.18.0-pre.1 --save
```

### APIs available

The following APIs are available:

* Permissions microservice

  * [InvitationsApi](./apis/invitations-api.ts)
  * [UsersApi](./apis/users-api.ts)
  * [PermissionsApi](./apis/permissions-api.ts)
  * [RolesApi](./apis/roles-api.ts)
  * [UserRolesApi](./apis/user-roles-api.ts)

* Workspaces microservice

  * [WorkspacesApi](./apis/workspaces-api.ts)
  * [ClientsApi](./apis/clients-api.ts)
  * [LookupsApi](./apis/lookups-api.ts)

* Payments microservice

  * [AirwallexApi](./apis/airwallex-api.ts)
  * [BankDetailsApi](./apis/bank-details-api.ts)
  * [InvoicesApi](./apis/invoices-api.ts)
  * [PayoutsApi](./apis/payouts-api.ts)
  * [TransactionsApi](./apis/transactions-api.ts)

* Titles microservice

  * [TitlesApi](./apis/titles-api.ts)

* Documents microservice

  * [DocumentsApi](./apis/documents-api.ts)
  * [DownloadsApi](./apis/downloads-api.ts)

* Shared microservice

  * [ActivitiesApi](./apis/activities-api.ts)
  * [NotificationsApi](./apis/notifications-api.ts)


### Example usage

You can use the SDK to make API calls to the server. For example, to get a list of users, you can use the following code:

#### Pre-requisites

* An axios instance. This could simply be created with `axios.create()` or something more complex with interceptors for adding request Authorization headers, caching, response handling, etc. depending on application requirements.
* Define a function which will prepare an instance of the API class to be used:

```typescript
import { Configuration, UsersApi } from '@sr-sdks/api-sdk-axios';
import axiosInstance from './utils/axiosInstance';

// function for creating an instance of the UsersApi class
const GetUsersApi = () => {
  return new UsersApi(
    new Configuration(),
    process.env.REACT_APP_PERMISSIONS_API_BASE,
    axiosInstance,
  );
};
```

#### Example 1: Get a list of users for a workspace

Use the UsersApi class to make a call to the find all users endpoint.

```typescript
import { User, UsersApi } from '@sr-sdks/api-sdk-axios';

// get the workspace id from somewhere, e.g.:
const workspaceId = 'workspace-id-from-path-params';
let users: User[];

try {
  const result = await GetUsersApi().usersControllerFindAllV2(workspaceId);

  users = result.data.items;
} catch (error) {
  // handle error
}
```

#### Example 2: Get the current user

Use the UsersApi class to make a call to the find user me endpoint.

```typescript
import { User, UsersApi } from '@sr-sdks/api-sdk-axios';

let userMe: User;

try {
  const result = await GetUsersApi().usersControllerFindMe();

  userMe = result.data;
} catch (error) {
  // handle error
}
```

#### Example 3: Create an invitation

Use the InvitationApi class to make a call to the create invitation endpoint.

```typescript
import { Configuration, CreateInvitationDto, Invitation, InvitationsApi } from '@sr-sdks/api-sdk-axios';

// function for creating an instance of the InvitationsApi class
const GetInvitationsApi = () => {
  return new InvitationsApi(
    new Configuration(),
    process.env.REACT_APP_PERMISSIONS_API_BASE,
    axiosInstance,
  );
};

let invitation: Invitation;
const createInvitationDto: CreateInvitationDto = {
  // properties of the invitation assembled from user-entered form data or CSV, etc.
};

try {
  const result = await GetInvitationsApi().invitationControllerCreate(createInvitationDto);

  invitation = result.data;
} catch (error) {
  // handle error
}
```


### Generating

Use the scripts defined in the backend project.


### Building

To build and compile the typescript sources to javascript use:
```bash
npm install
npm run build
```

### Publishing

Commit and push the code. Bitbucket Pipelines will automatically publish the package.