1.4.2 • Published 9 months ago

@jeanpiaget/api v1.4.2

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

Jean Piaget API Javascript SDK

This is a SDK of our API made for js. It's built with Node.js and TypeScript.

Build & Test Publish Package

Features

  • Built with TypeScript
  • Jean Piaget's API access
  • Automatic NPM release
  • Complete API coverage
  • GVCollege API coverage
  • 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.

  1. Clone the repository:
git clone https://github.com/Jean-Piaget/api-js.git
cd api-js
  1. Install the dependencies:
npm install

Using the SDK

Jean Piaget API

  1. Add the SDK:
npm i @jean-piaget/api-js@latest
  1. 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;
  1. 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);
  1. Access all the data you want
const exams = await client.exams.read({
  where: { subjectId: 41 },
  page: 4,
  pageSize: 15,
});

GVCollege API

  1. Add the SDK:
npm i @jean-piaget/api-js@latest
  1. 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;
  1. 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.

Useful Links

1.4.2

9 months ago

1.4.1

9 months ago

1.4.0

9 months ago

1.3.1

9 months ago

1.3.0

9 months ago

1.2.0

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.0

9 months ago