@jeanpiaget/api
v4.1.0
Published
Jean Piaget API SDK
Downloads
596
Readme
Jean Piaget API Javascript SDK
This is a SDK of our API made for js. It's built with Node.js and TypeScript.
Features
- [x] Built with TypeScript
- [x] Jean Piaget's API access
- [x] Automatic NPM release
- [x] Complete API coverage
- [x] GVCollege API coverage
- [x] Unit test coverage
Table of Contents
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Prerequisites
Installation
Note that the installation is meant for development of the SDK. If you plan on using it in a project see the Using the SDK section.
- Clone the repository:
git clone https://github.com/Jean-Piaget/api-js.git
cd api-js
- Install the dependencies:
npm install
Using the SDK
Jean Piaget API
- Add the SDK:
npm i @jean-piaget/api-js@latest
- Create a file for export the client
//( src/lib/client.ts )
const client = new ApiClient({
url: 'some.url.com',
version: 'v1',
GVCollegeApiUrl: 'gvcollege.url.com/api',
GVCollegeApiToken: '4superT0ken',
});
export default client;
- Login using your or the user credentials/jwt token
// Using Credentials
client.login('userName', 'p@ssw0rd');
// Using JWT Token
const jwt = 'MySuperSecretjwt';
client.login(jwt);
- Access all the data you want
const exams = await client.exams.read({
where: { subjectId: 41 },
page: 4,
pageSize: 15,
});
GVCollege API
- Add the SDK:
npm i @jean-piaget/api-js@latest
- Create a file for export the client and login with your GVCollege token
//( src/lib/client.ts )
const client = new ApiClient({
url: 'some.url.com',
version: 'v1',
GVCollegeApiUrl: 'gvcollege.url.com/api',
GVCollegeApiToken: '4superT0ken',
});
export default client;
- Access all the data you want
const classes = await client.classes.read({ year: 2024 });
Running tests
To run the tests, use the following command:
npm test
Project Structure
This project follows a modular structure, organized around the functionality of the application. Here's a brief overview of the main directories and files:
.github/workflows/
: Contains the GitHub Actions workflow files.resources/
: Contains static files and resources.test/
: Contains every test of every content of the SDK.lib/
: Contains the custom libraries of the project.utils.ts
: File where the utility functions are exported.
src/
: Contains the main source of the API SDK.index.ts
: File where the SDK is configured.
note that the tests files MUST be compiled to js before running.