1.26.0-pre.1 • Published 3 days ago

@sr-sdks/api-sdk-axios v1.26.0-pre.1

Weekly downloads
-
License
Unlicense
Repository
github
Last release
3 days ago

@sr-sdks/api-sdk-axios@1.26.0-pre.1

This is a TypeScript/JavaScript client that utilizes 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)

Consuming

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

npm install @sr-sdks/api-sdk-axios@1.26.0-pre.1 --save

APIs available

The following APIs are available:

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:
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.

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.

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.

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:

npm install
npm run build

Publishing

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

1.26.0-pre.1

3 days ago

1.26.0-pre.0

10 days ago

1.25.0-pre.2

15 days ago

1.25.0-pre.0

19 days ago

1.23.0-pre.0

1 month ago

1.23.0-pre.1

1 month ago

1.22.0-pre.3

2 months ago

1.22.0-pre.2

2 months ago

1.22.0-pre.0

2 months ago

1.22.0-pre.1

2 months ago

1.20.0

2 months ago

1.19.0

3 months ago

1.18.0

4 months ago

1.17.0-pre.1

4 months ago

1.17.0-pre.0

5 months ago

1.16.0

5 months ago

1.16.0-pre.0

5 months ago

1.16.0-pre.1

5 months ago

1.15.0

5 months ago

1.14.0

6 months ago

1.13.0

6 months ago

1.5.0-pre.1

10 months ago

1.12.0

7 months ago

1.5.0-pre.0

10 months ago

1.5.0-pre.2

10 months ago

1.9.0

8 months ago

1.8.0

9 months ago

1.6.0

10 months ago

1.5.0

10 months ago

1.7.0-pre.0

10 months ago

1.7.0-pre.1

9 months ago

1.6.0-pre.0

10 months ago

1.10.0-pre.2

8 months ago

1.11.0-pre.1

7 months ago

1.11.0-pre.2

7 months ago

1.10.0-pre.0

8 months ago

1.10.0-pre.1

8 months ago

1.13.0-pre.1

6 months ago

1.13.0-pre.0

7 months ago

1.15.0-pre.0

6 months ago

1.14.0-pre.0

6 months ago

1.15.0-pre.1

6 months ago

1.15.0-pre.2

6 months ago

1.4.0-pre.4

11 months ago

1.3.0

11 months ago

1.2.1-pre.4

11 months ago

1.2.1-pre.3

11 months ago

1.2.1-pre.2

11 months ago

1.2.0

11 months ago

1.1.3-pre.3

12 months ago

1.1.2-pre.1

1 year ago

1.1.2-pre.0

1 year ago

1.1.1-pre.0

1 year ago

1.1.1-pre.3

1 year ago