Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add custom header param support #98

Merged
merged 4 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/services/cli-http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const { NETWORK_ERROR } = require('../services/messaging/help-messages');

const NETWORK_ERROR_CODES = new Set(['ETIMEDOUT', 'ESOCKETTIMEDOUT', 'ECONNABORTED']);

const STANDARD_HEADERS = ['user-agent', 'accept-charset', 'connection', 'authorization', 'accept', 'content-type'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use a set for efficiency (probably)


class CliRequestClient {
constructor(commandName, logger, http) {
this.commandName = commandName;
Expand Down Expand Up @@ -125,6 +127,14 @@ class CliRequestClient {
this.logger.debug(options.params);
}

const customHeaders = Object.keys(options.headers).filter(header => {
return !STANDARD_HEADERS.includes(header.toLowerCase());
});
if (customHeaders) {
this.logger.debug('Custom HTTP Headers:');
customHeaders.forEach(header => this.logger.debug(header + ': ' + options.headers[header]));
}

this.logger.debug('User-Agent: ' + options.headers['User-Agent']);
this.logger.debug('-- END Twilio API Request --');
}
Expand Down
132 changes: 132 additions & 0 deletions src/services/twilio-api/twilio_chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -5392,6 +5392,18 @@
"pattern": "^IS[0-9a-fA-F]{32}$",
"type": "string"
}
},
{
"description": "The X-Twilio-Webhook-Enabled HTTP request header",
"in": "header",
"name": "X-Twilio-Webhook-Enabled",
"schema": {
"enum": [
"true",
"false"
],
"type": "string"
}
}
],
"requestBody": {
Expand Down Expand Up @@ -5915,6 +5927,18 @@
"schema": {
"type": "string"
}
},
{
"description": "The X-Twilio-Webhook-Enabled HTTP request header",
"in": "header",
"name": "X-Twilio-Webhook-Enabled",
"schema": {
"enum": [
"true",
"false"
],
"type": "string"
}
}
],
"requestBody": {
Expand Down Expand Up @@ -6032,6 +6056,18 @@
"schema": {
"type": "string"
}
},
{
"description": "The X-Twilio-Webhook-Enabled HTTP request header",
"in": "header",
"name": "X-Twilio-Webhook-Enabled",
"schema": {
"enum": [
"true",
"false"
],
"type": "string"
}
}
],
"responses": {
Expand Down Expand Up @@ -6136,6 +6172,18 @@
"schema": {
"type": "string"
}
},
{
"description": "The X-Twilio-Webhook-Enabled HTTP request header",
"in": "header",
"name": "X-Twilio-Webhook-Enabled",
"schema": {
"enum": [
"true",
"false"
],
"type": "string"
}
}
],
"requestBody": {
Expand Down Expand Up @@ -6344,6 +6392,18 @@
"schema": {
"type": "string"
}
},
{
"description": "The X-Twilio-Webhook-Enabled HTTP request header",
"in": "header",
"name": "X-Twilio-Webhook-Enabled",
"schema": {
"enum": [
"true",
"false"
],
"type": "string"
}
}
],
"requestBody": {
Expand Down Expand Up @@ -6460,6 +6520,18 @@
"pattern": "^IM[0-9a-fA-F]{32}$",
"type": "string"
}
},
{
"description": "The X-Twilio-Webhook-Enabled HTTP request header",
"in": "header",
"name": "X-Twilio-Webhook-Enabled",
"schema": {
"enum": [
"true",
"false"
],
"type": "string"
}
}
],
"responses": {
Expand Down Expand Up @@ -6570,6 +6642,18 @@
"pattern": "^IM[0-9a-fA-F]{32}$",
"type": "string"
}
},
{
"description": "The X-Twilio-Webhook-Enabled HTTP request header",
"in": "header",
"name": "X-Twilio-Webhook-Enabled",
"schema": {
"enum": [
"true",
"false"
],
"type": "string"
}
}
],
"requestBody": {
Expand Down Expand Up @@ -7108,6 +7192,18 @@
"schema": {
"type": "string"
}
},
{
"description": "The X-Twilio-Webhook-Enabled HTTP request header",
"in": "header",
"name": "X-Twilio-Webhook-Enabled",
"schema": {
"enum": [
"true",
"false"
],
"type": "string"
}
}
],
"responses": {
Expand Down Expand Up @@ -7194,6 +7290,18 @@
"schema": {
"type": "string"
}
},
{
"description": "The X-Twilio-Webhook-Enabled HTTP request header",
"in": "header",
"name": "X-Twilio-Webhook-Enabled",
"schema": {
"enum": [
"true",
"false"
],
"type": "string"
}
}
],
"requestBody": {
Expand Down Expand Up @@ -7713,6 +7821,18 @@
"pattern": "^IS[0-9a-fA-F]{32}$",
"type": "string"
}
},
{
"description": "The X-Twilio-Webhook-Enabled HTTP request header",
"in": "header",
"name": "X-Twilio-Webhook-Enabled",
"schema": {
"enum": [
"true",
"false"
],
"type": "string"
}
}
],
"requestBody": {
Expand Down Expand Up @@ -7892,6 +8012,18 @@
"schema": {
"type": "string"
}
},
{
"description": "The X-Twilio-Webhook-Enabled HTTP request header",
"in": "header",
"name": "X-Twilio-Webhook-Enabled",
"schema": {
"enum": [
"true",
"false"
],
"type": "string"
}
}
],
"requestBody": {
Expand Down
Loading