fix(core): update

This commit is contained in:
Philipp Kunz 2020-08-24 01:55:50 +00:00
parent 12b6a771a2
commit d6a0a9d438
6 changed files with 65 additions and 6 deletions

44
package-lock.json generated
View File

@ -10492,6 +10492,50 @@
"resolved": "https://verdaccio.lossless.one/tslib/-/tslib-1.13.0.tgz", "resolved": "https://verdaccio.lossless.one/tslib/-/tslib-1.13.0.tgz",
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q=="
}, },
"tslint": {
"version": "6.1.3",
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-6.1.3.tgz",
"integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
"builtin-modules": "^1.1.1",
"chalk": "^2.3.0",
"commander": "^2.12.1",
"diff": "^4.0.1",
"glob": "^7.1.1",
"js-yaml": "^3.13.1",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.3",
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.13.0",
"tsutils": "^2.29.0"
},
"dependencies": {
"builtin-modules": {
"version": "1.1.1",
"resolved": "https://verdaccio.lossless.one/builtin-modules/-/builtin-modules-1.1.1.tgz",
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
"dev": true
}
}
},
"tslint-config-prettier": {
"version": "1.18.0",
"resolved": "https://verdaccio.lossless.one/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz",
"integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==",
"dev": true
},
"tsutils": {
"version": "2.29.0",
"resolved": "https://verdaccio.lossless.one/tsutils/-/tsutils-2.29.0.tgz",
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
},
"tty-browserify": { "tty-browserify": {
"version": "0.0.0", "version": "0.0.0",
"resolved": "https://verdaccio.lossless.one/tty-browserify/-/tty-browserify-0.0.0.tgz", "resolved": "https://verdaccio.lossless.one/tty-browserify/-/tty-browserify-0.0.0.tgz",

View File

@ -15,7 +15,9 @@
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.44", "@gitzone/tstest": "^1.0.44",
"@pushrocks/qenv": "^4.0.10", "@pushrocks/qenv": "^4.0.10",
"@pushrocks/tapbundle": "^3.2.9" "@pushrocks/tapbundle": "^3.2.9",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartrequest": "^1.1.47", "@pushrocks/smartrequest": "^1.1.47",

View File

@ -16,7 +16,10 @@ tap.test('should create a valid paypal instance', async () => {
}); });
tap.test('should get an access token', async () => { tap.test('should get an access token', async () => {
const transactions = await paypal.PayPalTransaction.getTransactionFor30days(testPayPalInstance, smarttime.ExtendedDate.fromHyphedDate('2020-05-01').getTime()); const transactions = await testPayPalInstance.getTransactionsFromTo(
smarttime.ExtendedDate.fromHyphedDate('2020-01-01').getTime(),
smarttime.ExtendedDate.fromHyphedDate('2020-08-01').getTime(),
);
console.log(transactions); console.log(transactions);
}); });

View File

@ -1,2 +1,2 @@
export * from './paypal.classes.paypal'; export * from './paypal.classes.account';
export * from './paypal.classes.transaction'; export * from './paypal.classes.transaction';

View File

@ -1,4 +1,5 @@
import * as plugins from './paypal.plugins'; import * as plugins from './paypal.plugins';
import { PayPalTransaction } from './paypal.classes.transaction';
export interface IPayPalOptions { export interface IPayPalOptions {
clientId: string; clientId: string;
@ -16,6 +17,16 @@ export class PayPalAccount {
this.options = optionsArg; this.options = optionsArg;
} }
public async getTransactionsFromTo (fromTimeMillisArg: number, toTimeMillisArg: number) {
let returnTransactions: PayPalTransaction[] = [];
do {
const transactions = await PayPalTransaction.getTransactionFor30days(this, fromTimeMillisArg);
returnTransactions = returnTransactions.concat(transactions);
fromTimeMillisArg = fromTimeMillisArg + plugins.smarttime.getMilliSecondsFromUnits({days: 30});
} while (fromTimeMillisArg < toTimeMillisArg);
return returnTransactions;
}
public async request(methodArg: 'GET' | 'POST', routeArg: string, payloadArg: any) { public async request(methodArg: 'GET' | 'POST', routeArg: string, payloadArg: any) {
if (!this.apiToken || this.apiTokenExpirationTime < Date.now()) { if (!this.apiToken || this.apiTokenExpirationTime < Date.now()) {
const authHeader = `Basic ${plugins.smartstring.base64.encode( const authHeader = `Basic ${plugins.smartstring.base64.encode(

View File

@ -1,5 +1,5 @@
import * as plugins from './paypal.plugins'; import * as plugins from './paypal.plugins';
import { PayPalAccount } from './paypal.classes.paypal'; import { PayPalAccount } from './paypal.classes.account';
export interface IPayPalOriginTransactionApiObject { export interface IPayPalOriginTransactionApiObject {
paypal_account_id: string; paypal_account_id: string;
@ -33,8 +33,7 @@ export class PayPalTransaction {
const endDate = startDate + plugins.smarttime.units.days(30); const endDate = startDate + plugins.smarttime.units.days(30);
const startDateIso = plugins.smarttime.ExtendedDate.fromMillis(startDate).toISOString(); const startDateIso = plugins.smarttime.ExtendedDate.fromMillis(startDate).toISOString();
const endDateIso = plugins.smarttime.ExtendedDate.fromMillis(endDate).toISOString(); const endDateIso = plugins.smarttime.ExtendedDate.fromMillis(endDate).toISOString();
console.log(endDateIso); console.log(`getting PayPal transactions from ${startDateIso} + ${endDateIso}`);
console.log(startDateIso);
const response = await paypalInstanceArg.request( const response = await paypalInstanceArg.request(
'GET', 'GET',
`/v1/reporting/transactions?start_date=${startDateIso}&end_date=${endDateIso}`, `/v1/reporting/transactions?start_date=${startDateIso}&end_date=${endDateIso}`,