Skip to content

unparallel-innovation/smartclide-backend-connector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This module is a wrapper for swagger-client that simplifies the process of making calls to the SmartCLIDE DB API, given its swagger description and a Keycloak Bearer Authorization Token.

The current version provides:

  • call method that takes an object with the request configuration and returns the response from the API. The configuration object has the following properties:
Property Description Required for
operationID ID of the operation according to the swagger description All requests
parameters Object containing the parameters required by the request (e.g., { userId: "<userId>" } to send the userId to the /{userId} endpoint) When demanded by the request
requestBody Object containing the data to be sent to the API, in the request body (e.g., { id: "<id>", email: "<email>", team_id: "<team_id>" } to send the details of the user to be created/updated) POST and PUT requests
token Keycloak Bearer Authorization Token All requests that require authentication
  • exists method that returns a boolean indicating whether there is a document of the given entity with the provided ID. The parameters are:
Parameter Description
entity Entity in which to search for the given ID
id ID of the document to be searched for
token Keycloak Bearer Authorization Token

How to use?

Add as a dependency to the package.json

{
  "dependencies": {
    "@unparallel/smartclide-backend-connector": "latest"
  }
}

Install dependencies

npm install

Usage Example

// Import the module
import SmartCLIDEBackendConnector from "@unparallel/smartclide-backend-connector";

// Instantiate the connector providing the URL of the swagger description of the API
let connector = await new SmartCLIDEBackendConnector("<swaggerURL>");

// Create a configuration object with the required properties
let configuration = {
    operationID: "<operationID>",
    parameters: { userId: "<userID>" },
    requestBody: {
        id: "<id>",
        email: "<email>",
        team_id: "<team_id>"
    },
    token: "<Keycloak Token>"
};

// Make the request
let result = await connector.call(configuration);

// Log the response
console.log(result);

License

MIT

About

A connector for the endpoints available on SmartCLIDE Backend

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published