paddle-sdk
Advanced tools
Comparing version 4.0.1 to 4.1.0
@@ -253,4 +253,3 @@ import { CreateSubscriptionModifierResponse, GeneratePaylinkBody, GeneratePaylinkResponse, GetProductCouponsResponse, GetProductsResponse, GetSubscriptionPaymentsResponse, GetSubscriptionPlansResponse, GetSubscriptionUsersBody, GetSubscriptionUsersResponse, GetTransactionsResponse, GetWebhookHistoryResponse, UpdateSubscriptionUserResponse } from './types'; | ||
* @param {object} [options.headers] - header parameters | ||
* @param {boolean} [options.form] - form parameter (ref: got package) | ||
* @param {boolean} [options.json] - json parameter (ref: got package) | ||
* @param {boolean} [options.form] - serialize the data object to urlencoded format | ||
*/ | ||
@@ -257,0 +256,0 @@ private _request; |
@@ -8,3 +8,3 @@ "use strict"; | ||
const crypto_1 = __importDefault(require("crypto")); | ||
const got_1 = __importDefault(require("got")); | ||
const axios_1 = __importDefault(require("axios")); | ||
const serialize_1 = __importDefault(require("./serialize")); | ||
@@ -360,13 +360,12 @@ const version_1 = require("./version"); | ||
* @param {object} [options.headers] - header parameters | ||
* @param {boolean} [options.form] - form parameter (ref: got package) | ||
* @param {boolean} [options.json] - json parameter (ref: got package) | ||
* @param {boolean} [options.form] - serialize the data object to urlencoded format | ||
*/ | ||
async _request(path, { body, headers, form = true, json = false, checkoutAPI = false, } = {}) { | ||
async _request(path, { body: requestBody, headers, form = true, checkoutAPI = false, } = {}) { | ||
const url = this.serverURL(checkoutAPI) + path; | ||
// Requests to Checkout API are using only GET, | ||
const method = checkoutAPI ? 'GET' : 'POST'; | ||
const fullBody = { | ||
const fullRequestBody = { | ||
vendor_id: this.vendorID, | ||
vendor_auth_code: this.apiKey, | ||
...body, | ||
...requestBody, | ||
}; | ||
@@ -376,2 +375,3 @@ const options = { | ||
'User-Agent': `paddle-sdk/${version_1.VERSION} (https://github.com/avaly/paddle-sdk)`, | ||
...(form && { 'Content-Type': 'application/x-www-form-urlencoded' }), | ||
...(headers || {}), | ||
@@ -382,10 +382,5 @@ }, | ||
if (method !== 'GET') { | ||
if (form) { | ||
options.form = fullBody; | ||
} | ||
if (json) { | ||
options.json = fullBody; | ||
} | ||
options.data = fullRequestBody; | ||
} | ||
const data = await (0, got_1.default)(url, options).json(); | ||
const { data } = await (0, axios_1.default)(url, options); | ||
if ('success' in data && typeof data.success === 'boolean') { | ||
@@ -392,0 +387,0 @@ if (data.success) { |
@@ -160,2 +160,3 @@ export interface Product { | ||
customer_country?: string; | ||
customer_email?: string; | ||
customer_postcode?: string; | ||
@@ -162,0 +163,0 @@ discountable?: number; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "4.0.1"; | ||
export declare const VERSION = "4.1.0"; |
@@ -5,2 +5,2 @@ "use strict"; | ||
// Generated by yarn build | ||
exports.VERSION = '4.0.1'; | ||
exports.VERSION = '4.1.0'; |
@@ -253,4 +253,3 @@ import { CreateSubscriptionModifierResponse, GeneratePaylinkBody, GeneratePaylinkResponse, GetProductCouponsResponse, GetProductsResponse, GetSubscriptionPaymentsResponse, GetSubscriptionPlansResponse, GetSubscriptionUsersBody, GetSubscriptionUsersResponse, GetTransactionsResponse, GetWebhookHistoryResponse, UpdateSubscriptionUserResponse } from './types'; | ||
* @param {object} [options.headers] - header parameters | ||
* @param {boolean} [options.form] - form parameter (ref: got package) | ||
* @param {boolean} [options.json] - json parameter (ref: got package) | ||
* @param {boolean} [options.form] - serialize the data object to urlencoded format | ||
*/ | ||
@@ -257,0 +256,0 @@ private _request; |
import crypto from 'crypto'; | ||
import got from 'got'; | ||
import axios from 'axios'; | ||
import serialize from './serialize.js'; | ||
@@ -360,13 +360,12 @@ import { VERSION } from './version.js'; | ||
* @param {object} [options.headers] - header parameters | ||
* @param {boolean} [options.form] - form parameter (ref: got package) | ||
* @param {boolean} [options.json] - json parameter (ref: got package) | ||
* @param {boolean} [options.form] - serialize the data object to urlencoded format | ||
*/ | ||
async _request(path, { body, headers, form = true, json = false, checkoutAPI = false, } = {}) { | ||
async _request(path, { body: requestBody, headers, form = true, checkoutAPI = false, } = {}) { | ||
const url = this.serverURL(checkoutAPI) + path; | ||
// Requests to Checkout API are using only GET, | ||
const method = checkoutAPI ? 'GET' : 'POST'; | ||
const fullBody = { | ||
const fullRequestBody = { | ||
vendor_id: this.vendorID, | ||
vendor_auth_code: this.apiKey, | ||
...body, | ||
...requestBody, | ||
}; | ||
@@ -376,2 +375,3 @@ const options = { | ||
'User-Agent': `paddle-sdk/${VERSION} (https://github.com/avaly/paddle-sdk)`, | ||
...(form && { 'Content-Type': 'application/x-www-form-urlencoded' }), | ||
...(headers || {}), | ||
@@ -382,10 +382,5 @@ }, | ||
if (method !== 'GET') { | ||
if (form) { | ||
options.form = fullBody; | ||
} | ||
if (json) { | ||
options.json = fullBody; | ||
} | ||
options.data = fullRequestBody; | ||
} | ||
const data = await got(url, options).json(); | ||
const { data } = await axios(url, options); | ||
if ('success' in data && typeof data.success === 'boolean') { | ||
@@ -392,0 +387,0 @@ if (data.success) { |
@@ -160,2 +160,3 @@ export interface Product { | ||
customer_country?: string; | ||
customer_email?: string; | ||
customer_postcode?: string; | ||
@@ -162,0 +163,0 @@ discountable?: number; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "4.0.1"; | ||
export declare const VERSION = "4.1.0"; |
// Generated by yarn build | ||
export const VERSION = '4.0.1'; | ||
export const VERSION = '4.1.0'; |
{ | ||
"name": "paddle-sdk", | ||
"description": "The Paddle.com Node.js SDK", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"type": "module", | ||
@@ -26,3 +26,3 @@ "main": "./cjs/index.js", | ||
"engines": { | ||
"node": ">=14.0.0" | ||
"node": ">=14.17.0" | ||
}, | ||
@@ -38,2 +38,3 @@ "files": [ | ||
"prepack": "yarn build", | ||
"prepare": "husky install", | ||
"pretty": "prettier --write --list-different \"**/*.ts\"", | ||
@@ -50,3 +51,3 @@ "release": "standard-version -a", | ||
"dependencies": { | ||
"got": "^10.2.0" | ||
"axios": "1.3.5" | ||
}, | ||
@@ -59,8 +60,8 @@ "devDependencies": { | ||
"eslint": "8.36.0", | ||
"husky": "3.1.0", | ||
"husky": "8.0.3", | ||
"jest": "29.5.0", | ||
"lint-staged": "9.5.0", | ||
"lint-staged": "13.2.0", | ||
"nock": "11.7.0", | ||
"prettier": "2.8.7", | ||
"standard-version": "8.0.0", | ||
"standard-version": "9.5.0", | ||
"ts-jest": "29.0.5", | ||
@@ -72,8 +73,2 @@ "ts-node": "10.9.1", | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "validate-commit-msg", | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"standard-version": { | ||
@@ -80,0 +75,0 @@ "scripts": { |
75974
2027
+ Addedaxios@1.3.5
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@1.3.5(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedfollow-redirects@1.15.6(transitive)
+ Addedform-data@4.0.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
- Removedgot@^10.2.0
- Removed@sindresorhus/is@2.1.1(transitive)
- Removed@szmarczak/http-timer@4.0.6(transitive)
- Removed@types/cacheable-request@6.0.3(transitive)
- Removed@types/http-cache-semantics@4.0.4(transitive)
- Removed@types/keyv@3.1.4(transitive)
- Removed@types/node@20.12.11(transitive)
- Removed@types/responselike@1.0.3(transitive)
- Removedcacheable-lookup@2.0.1(transitive)
- Removedcacheable-request@7.0.4(transitive)
- Removedclone-response@1.0.3(transitive)
- Removeddecompress-response@5.0.0(transitive)
- Removeddefer-to-connect@2.0.1(transitive)
- Removedduplexer3@0.1.5(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedget-stream@5.2.0(transitive)
- Removedgot@10.7.0(transitive)
- Removedhttp-cache-semantics@4.1.1(transitive)
- Removedjson-buffer@3.0.1(transitive)
- Removedkeyv@4.5.4(transitive)
- Removedlowercase-keys@2.0.0(transitive)
- Removedmimic-response@1.0.12.1.0(transitive)
- Removednormalize-url@6.1.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedp-cancelable@2.1.1(transitive)
- Removedp-event@4.2.0(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedp-timeout@3.2.0(transitive)
- Removedpump@3.0.0(transitive)
- Removedresponselike@2.0.1(transitive)
- Removedto-readable-stream@2.1.0(transitive)
- Removedtype-fest@0.10.0(transitive)
- Removedundici-types@5.26.5(transitive)
- Removedwrappy@1.0.2(transitive)