Qrvey Gateway
By Qrvey
qrvey-gateway
The qrvey-gateway package is a library that simplifies HTTP requests through a client interface for various methods like GET, POST, PUT, PATCH, and DELETE.
Installation
You can install the gateway-client package via npm. Run the following command in your terminal:
npm install gateway-client
API Documentation
Available Methods
get(endpoint: string, options: IHttpActionOptions): Promise<any>
: Performs an HTTP GET request.post(endpoint: string, body: unknown, options: IHttpActionOptions): Promise<any>
: Performs an HTTP POST request.put(endpoint: string, body: unknown, options: IHttpActionOptions): Promise<any>
: Performs an HTTP PUT request.patch(endpoint: string, body: unknown, options: IHttpActionOptions): Promise<any>
: Performs an HTTP PATCH request.delete(endpoint: string, body: unknown, options: IHttpActionOptions): Promise<any>
: Performs an HTTP DELETE request.
Sequence Diagram
sequenceDiagram
participant Application
participant GatewayClientPkg
participant Server
Application ->> GatewayClientPkg: Call GatewayClient method
Note over GatewayClientPkg: Process: Build HttpRequest
GatewayClientPkg ->> Server: Send HTTP Request
Server -->> GatewayClientPkg: HTTP Response
Note over GatewayClientPkg: Process: Handle response
GatewayClientPkg -->> Application: Return Response
Example Usage
const { AbstractGatewayClientService } = require('@qrvey/gateway-client');
class DataViewGatewayClient extends AbstractGatewayClientService {
static groups({ userId, appId, qrveyId }, { body, queryParameters, headers }) {
const endpoint = `/devapi/v5/user/${userId}/app/${appId}/qrvey/${qrveyId}/analytics/results/groups`;
return this.post(endpoint, body, { headers, queryParameters });
}
static rows({ userId, appId, qrveyId }, { body, queryParameters, headers }) {
const endpoint = `/devapi/v5/user/${userId}/app/${appId}/qrvey/${qrveyId}/analytics/results/rows`;
return this.post(endpoint, body, { headers, queryParameters });
}
static model({ userId, appId, qrveyId }, { queryParameters, headers }) {
const endpoint = `/devapi/v4/user/${userId}/app/${appId}/qrvey/${qrveyId}/analytiq/model`;
return this.get(endpoint, { headers, queryParameters });
}
}
module.exports = DataViewGatewayClient;