Skip to content

Commit

Permalink
feat: add custom header param support (twilio#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
eshanholtz committed Jul 17, 2020
1 parent 33eabe1 commit 2de7aff
Show file tree
Hide file tree
Showing 6 changed files with 498 additions and 0 deletions.
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'];

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

0 comments on commit 2de7aff

Please sign in to comment.