Skip to content

Commit

Permalink
update jsdocs and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
fedeatanasoff committed Jul 22, 2021
1 parent dc0e740 commit 72c23a8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -259,5 +259,5 @@ If you want to keep the functionality of v1.x must require and change `RequestSa
const Request = require('@janiscommerce/request');

// new way
const { Request } = require('@janiscommerce/request');
const { RequestSafe } = require('@janiscommerce/request');
```
28 changes: 1 addition & 27 deletions lib/request.js
Expand Up @@ -75,8 +75,6 @@ module.exports = class Request {
/**
* To get default request headers
*
* @readonly
* @static
*/
static get defaultHeaders() {
return defaultHeaders;
Expand All @@ -85,8 +83,6 @@ module.exports = class Request {
/**
* To get request http method
*
* @readonly
* @static
*/
static get httpMethod() {
return this.response.originRequest.method;
Expand All @@ -95,8 +91,6 @@ module.exports = class Request {
/**
* To get request endopoint
*
* @readonly
* @static
*/
static get endpoint() {
return this.response.originRequest.endpoint;
Expand All @@ -105,8 +99,6 @@ module.exports = class Request {
/**
* To get request headers
*
* @readonly
* @static
*/
static get headers() {
return this.response.originRequest.headers;
Expand All @@ -115,8 +107,6 @@ module.exports = class Request {
/**
* To get request body
*
* @readonly
* @static
*/
static get body() {
return this.response.originRequest.body;
Expand All @@ -125,8 +115,6 @@ module.exports = class Request {
/**
* To get response status code
*
* @readonly
* @static
*/
static get statusCode() {
return this.response.statusCode;
Expand All @@ -135,8 +123,6 @@ module.exports = class Request {
/**
* To get response headers
*
* @readonly
* @static
*/
static get responseHeaders() {
return this.response.headers;
Expand All @@ -145,8 +131,6 @@ module.exports = class Request {
/**
* To get response body
*
* @readonly
* @static
*/
static get responseBody() {
return this.response.body;
Expand All @@ -155,8 +139,6 @@ module.exports = class Request {
/**
* Get the safe mode value
*
* @readonly
* @static
*/
static get safeMode() {
return false;
Expand All @@ -165,7 +147,6 @@ module.exports = class Request {
/**
* To make a GET request
*
* @static
* @param {string} endpoint
* @param {RequestOptions} [options={}]
* @returns {Promise<RequestResponse>}
Expand All @@ -177,7 +158,6 @@ module.exports = class Request {
/**
* To make a POST request
*
* @static
* @param {string} endpoint
* @param {*} body
* @param {RequestOptions} [options={}]
Expand All @@ -190,7 +170,6 @@ module.exports = class Request {
/**
* To make a PUT request
*
* @static
* @param {string} endpoint
* @param {*} body
* @param {RequestOptions} [options={}]
Expand All @@ -203,7 +182,6 @@ module.exports = class Request {
/**
* To make a PATCH request
*
* @static
* @param {string} endpoint
* @param {*} body
* @param {RequestOptions} [options={}]
Expand All @@ -216,7 +194,6 @@ module.exports = class Request {
/**
* To make a DELETE request
*
* @static
* @param {string} endpoint
* @param {RequestOptions} [options={}]
* @returns {Promise<RequestResponse>}
Expand All @@ -228,7 +205,6 @@ module.exports = class Request {
/**
* To make a custom request
*
* @static
* @param {object} params CallOptions params
* @param {*} body
* @param {boolean} strictMode
Expand Down Expand Up @@ -256,13 +232,12 @@ module.exports = class Request {
/**
* To make a custom request
*
* @static
* @param {CallOptions} options
* @returns {Promise<RequestResponse>}
*/
static async call({ body, strictMode, ...params }) {

const response = await Request.makeRequest(params, body, strictMode);
const response = await this.makeRequest(params, body, strictMode);

if(!this.safeMode && this.statusCode >= 400)
throw new RequestError(`Request failed: ${this.responseBody}`, RequestError.codes.REQUEST_ERROR);
Expand All @@ -273,7 +248,6 @@ module.exports = class Request {
/**
* The request callback function
*
* @static
* @param {object} res Response from node request
* @param {function} resolve Master promise resolve function
* @param {function} reject Master promise reject function
Expand Down

0 comments on commit 72c23a8

Please sign in to comment.