Skip to content

Commit

Permalink
chore: changes for json ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
tiwarishubham635 committed Nov 16, 2023
1 parent 1f6d8eb commit 15c6fe2
Show file tree
Hide file tree
Showing 20 changed files with 574 additions and 1,209 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
node: [ 14, 16, 18, lts/* ]
node: [ 14, 16, 18 ]
steps:
- name: Checkout twilio-node
uses: actions/checkout@v3
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
npm run test

- name: SonarCloud Scan
if: ${{ (github.event_name == 'pull_request' || github.ref_type == 'branch') && matrix.node == 'lts/*' && !github.event.pull_request.head.repo.fork }}
if: ${{ (github.event_name == 'pull_request' || github.ref_type == 'branch') && matrix.node == '18' && !github.event.pull_request.head.repo.fork }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
Expand All @@ -69,7 +69,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: lts/*
node-version: 18

- run: npm install

Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
twilio-node changelog
=====================

[2023-11-07] Version 5.0.0-rc.0
---------------------------
- Release Candidate preparation

[2023-11-06] Version 4.19.1
---------------------------
**Flex**
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ it can be.

If you have questions about how to use `twilio-node`, please see our
[docs](./README.md), and if you don't find the answer there, please contact
[help@twilio.com](mailto:help@twilio.com) with any issues you have.
[Twilio Support](https://www.twilio.com/help/contact) with any issues you have.

## <a name="issue"></a> Found an Issue?

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (C) 2023, Twilio, Inc. <help@twilio.com>
Copyright (C) 2023, Twilio, Inc. <https://www.twilio.com/help/contact>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
10 changes: 10 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

_All `MAJOR` version bumps will have upgrade notes posted here._

## [2023-10-17] 4.x.x to 5.x.x-rc.x

---
### Overview

#### Twilio Node Helper Library’s major version 5.0.0-rc.x is now available. We ensured that you can upgrade to Node helper Library 5.0.0-rc.x version without any breaking changes

Support for JSON payloads has been added in the request body


## [2023-01-25] 3.x.x to 4.x.x

---
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "twilio",
"description": "A Twilio helper library",
"version": "4.19.1",
"version": "5.0.0-rc.0",
"author": "API Team <api@twilio.com>",
"contributors": [
{
Expand All @@ -20,7 +20,7 @@
"url": "https://github.com/twilio/twilio-node.git"
},
"dependencies": {
"axios": "^0.26.1",
"axios": "^1.6.0",
"dayjs": "^1.11.9",
"https-proxy-agent": "^5.0.0",
"jsonwebtoken": "^9.0.0",
Expand Down
12 changes: 9 additions & 3 deletions src/base/RequestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function getExponentialBackoffResponseHandler(
);
const delay = Math.floor(baseDelay * Math.random()); // Full jitter backoff

return new Promise((resolve) => {
return new Promise((resolve: (value: Promise<AxiosResponse>) => void) => {
setTimeout(() => resolve(axios(config)), delay);
});
}
Expand Down Expand Up @@ -190,8 +190,14 @@ class RequestClient {
validateStatus: (status) => status >= 100 && status < 600,
};

if (opts.data) {
options.data = qs.stringify(opts.data, { arrayFormat: "repeat" });
if (opts.data && options.headers) {
if (
options.headers["Content-Type"] === "application/x-www-form-urlencoded"
) {
options.data = qs.stringify(opts.data, { arrayFormat: "repeat" });
} else if (options.headers["Content-Type"] === "application/json") {
options.data = opts.data;
}
}

if (opts.params) {
Expand Down
52 changes: 0 additions & 52 deletions src/rest/Oauth.ts

This file was deleted.

13 changes: 13 additions & 0 deletions src/rest/PreviewMessaging.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import PreviewMessagingBase from "./PreviewMessagingBase";
import { MessageListInstance } from "./previewMessaging/v1/message";

class PreviewMessaging extends PreviewMessagingBase {
/**
* @deprecated - Use v1.messages; instead
*/
get messages(): MessageListInstance {
console.warn("messages is deprecated. Use v1.messages; instead.");
return this.v1.messages;
}
}
export = PreviewMessaging;
10 changes: 5 additions & 5 deletions src/rest/OauthBase.ts → src/rest/PreviewMessagingBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
*/

import Domain from "../base/Domain";
import V1 from "./oauth/V1";
import V1 from "./previewMessaging/V1";

class OauthBase extends Domain {
class PreviewMessagingBase extends Domain {
_v1?: V1;

/**
* Initialize oauth domain
* Initialize accounts domain
*
* @param twilio - The twilio client
*/
constructor(twilio: any) {
super(twilio, "https://oauth.twilio.com");
super(twilio, "https://preview.messaging.twilio.com");
}

get v1(): V1 {
Expand All @@ -30,4 +30,4 @@ class OauthBase extends Domain {
}
}

export = OauthBase;
export = PreviewMessagingBase;
8 changes: 0 additions & 8 deletions src/rest/Twilio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import Microvisor from "./Microvisor";
import Monitor from "./Monitor";
import Notify from "./Notify";
import Numbers from "./Numbers";
import Oauth from "./Oauth";
import Preview from "./Preview";
import Pricing from "./Pricing";
import Proxy from "./Proxy";
Expand Down Expand Up @@ -118,8 +117,6 @@ class Twilio extends Client {
_notify?: Notify;
/** (Twilio.Numbers) - numbers domain */
_numbers?: Numbers;
/** (Twilio.Oauth) - oauth domain */
_oauth?: Oauth;
/** (Twilio.Preview) - preview domain */
_preview?: Preview;
/** (Twilio.Pricing) - pricing domain */
Expand Down Expand Up @@ -188,7 +185,6 @@ class Twilio extends Client {
this.monitor;
this.notify;
this.numbers;
this.oauth;
this.preview;
this.pricing;
this.proxy;
Expand Down Expand Up @@ -314,10 +310,6 @@ class Twilio extends Client {
get numbers(): Numbers {
return this._numbers ?? (this._numbers = new (require("./Numbers"))(this));
}
/** Getter for (Twilio.Oauth) domain */
get oauth(): Oauth {
return this._oauth ?? (this._oauth = new (require("./Oauth"))(this));
}
/** Getter for (Twilio.Preview) domain */
get preview(): Preview {
return this._preview ?? (this._preview = new (require("./Preview"))(this));
Expand Down
74 changes: 0 additions & 74 deletions src/rest/oauth/V1.ts

This file was deleted.

Loading

0 comments on commit 15c6fe2

Please sign in to comment.