From 5a139ceb4d7de4082d011bc037ca1801f36046eb Mon Sep 17 00:00:00 2001 From: Elise Shanholtz Date: Tue, 17 Mar 2020 17:19:49 -0700 Subject: [PATCH] cleanup --- packages/client/src/classes/client.js | 9 ++++----- packages/client/src/request.d.ts | 6 +++--- packages/helpers/classes/index.js | 2 -- packages/helpers/classes/request.js | 15 --------------- packages/helpers/classes/response-error.js | 2 +- packages/mail/src/classes/mail-service.js | 2 +- 6 files changed, 9 insertions(+), 27 deletions(-) delete mode 100644 packages/helpers/classes/request.js diff --git a/packages/client/src/classes/client.js b/packages/client/src/classes/client.js index 2c7c0cc8a..1657e0c89 100644 --- a/packages/client/src/classes/client.js +++ b/packages/client/src/classes/client.js @@ -10,8 +10,8 @@ const { mergeData, }, classes: { - ResponseError, Response, + ResponseError, }, } = require('@sendgrid/helpers'); @@ -36,7 +36,6 @@ class Client { //Empty default request this.defaultRequest = { - data: {}, baseURL: 'https://api.sendgrid.com/', url: '', method: 'GET', @@ -97,9 +96,9 @@ class Client { url: opts.uri || opts.url, baseURL: opts.baseUrl, method: opts.method, - data: opts.body || {}, - params: opts.qs || {}, - headers: opts.headers || {}, + data: opts.body, + params: opts.qs, + headers: opts.headers, }; //Merge data with empty request diff --git a/packages/client/src/request.d.ts b/packages/client/src/request.d.ts index 3ca2ab05f..1bd039c44 100644 --- a/packages/client/src/request.d.ts +++ b/packages/client/src/request.d.ts @@ -1,4 +1,4 @@ -import { Request, RequestOptions } from "@sendgrid/helpers/classes/request"; +import {Request, RequestOptions} from "@sendgrid/helpers/classes/request"; -export { Request as ClientRequest }; -export { RequestOptions }; +export {Request as ClientRequest}; +export {RequestOptions}; diff --git a/packages/helpers/classes/index.js b/packages/helpers/classes/index.js index e446e53c1..8224b4804 100644 --- a/packages/helpers/classes/index.js +++ b/packages/helpers/classes/index.js @@ -7,7 +7,6 @@ const Attachment = require('./attachment'); const EmailAddress = require('./email-address'); const Mail = require('./mail'); const Personalization = require('./personalization'); -const Request = require('./request'); const Response = require('./response'); const ResponseError = require('./response-error'); const Statistics = require('./statistics'); @@ -20,7 +19,6 @@ module.exports = { EmailAddress, Mail, Personalization, - Request, Response, ResponseError, Statistics, diff --git a/packages/helpers/classes/request.js b/packages/helpers/classes/request.js deleted file mode 100644 index e5b3e4f45..000000000 --- a/packages/helpers/classes/request.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -class Request { - constructor(opts) { - opts = opts || {}; - this.method = opts.method; - this.url = opts.url; - this.auth = opts.auth; - this.params = opts.params; - this.data = opts.data; - this.headers = opts.headers; - } -} - -module.exports = Request; diff --git a/packages/helpers/classes/response-error.js b/packages/helpers/classes/response-error.js index 38f8d2f33..6e8c86422 100644 --- a/packages/helpers/classes/response-error.js +++ b/packages/helpers/classes/response-error.js @@ -24,7 +24,7 @@ class ResponseError extends Error { //Set data this.code = status; this.message = statusText; - this.response = {headers, data}; + this.response = {headers, body: data}; //Capture stack trace if (!this.stack) { diff --git a/packages/mail/src/classes/mail-service.js b/packages/mail/src/classes/mail-service.js index cce2ede14..ec4e455e0 100644 --- a/packages/mail/src/classes/mail-service.js +++ b/packages/mail/src/classes/mail-service.js @@ -192,7 +192,7 @@ class MailService { const request = { method: 'POST', url: '/v3/mail/send', - data: body, + body, }; //Send