fix(core): update
This commit is contained in:
parent
93a7a4b236
commit
49c3d5df5c
30
package-lock.json
generated
30
package-lock.json
generated
@ -1378,7 +1378,6 @@
|
||||
"version": "4.0.17",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-4.0.17.tgz",
|
||||
"integrity": "sha512-K5dX3k3i7iVxFMJ+IYwJRljewukJCc2zgj6+88R18/8SajVAq7ITOl3/FTbmEPFCJv5rl/LQ9FtcMynWlwSlzQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartdelay": "^2.0.10",
|
||||
"@pushrocks/smartmatch": "^1.0.7",
|
||||
@ -1484,7 +1483,6 @@
|
||||
"version": "2.0.10",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.10.tgz",
|
||||
"integrity": "sha512-JOFpEfYiKnqcQYoUrL/jDyBDZUmlgJNm5U30MQQ3f+yci+rlFnMY5VvBBEYn5WgoX0ilwU+E15mtpDWhXcmhzg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartpromise": "^3.0.6"
|
||||
}
|
||||
@ -1848,7 +1846,6 @@
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartmatch/-/smartmatch-1.0.7.tgz",
|
||||
"integrity": "sha512-D+lK5HIKO4Kj1Jm/ycKvy1VzDJ3V6ucHqmf5DMBFdm18BrMj2Zb6M7wN8HUKtkfHvOI7ig85JMuANSEyO7kAPg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"matcher": "^3.0.0"
|
||||
}
|
||||
@ -2008,7 +2005,6 @@
|
||||
"version": "2.0.18",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrx/-/smartrx-2.0.18.tgz",
|
||||
"integrity": "sha512-DqUmtS7mONO6bvWEZmSLy4M9hlxNWysMYc7XOZLr50BMaa0HUNYWI1myUFCMNcbUUOxuQNig01XqR1smfIN69g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/lik": "^4.0.14",
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
@ -2045,7 +2041,6 @@
|
||||
"version": "3.0.24",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.24.tgz",
|
||||
"integrity": "sha512-c/n0Y3CUnVNa3TnuXZ5aRc0bWj4RX7+XSjPes1J4HidU1yBOd9UOt6l08W8aPH5jMjT9Ei2jH0GsheaTGoVEYA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/lik": "^4.0.13",
|
||||
"@pushrocks/smartdelay": "^2.0.10",
|
||||
@ -2363,8 +2358,7 @@
|
||||
"@types/minimatch": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fminimatch/-/minimatch-3.0.3.tgz",
|
||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "14.6.0",
|
||||
@ -3930,8 +3924,7 @@
|
||||
"croner": {
|
||||
"version": "1.1.23",
|
||||
"resolved": "https://verdaccio.lossless.one/croner/-/croner-1.1.23.tgz",
|
||||
"integrity": "sha512-VsSyKBVtshU8qd2yPEWsBv5xxTLbRUuq6DX5bgUb4TTn/H6hmFGtfJtr0NKswu1UEsZZ6uhYc0kSOAvPlicQUA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-VsSyKBVtshU8qd2yPEWsBv5xxTLbRUuq6DX5bgUb4TTn/H6hmFGtfJtr0NKswu1UEsZZ6uhYc0kSOAvPlicQUA=="
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "6.0.5",
|
||||
@ -4291,8 +4284,7 @@
|
||||
"dayjs": {
|
||||
"version": "1.8.34",
|
||||
"resolved": "https://verdaccio.lossless.one/dayjs/-/dayjs-1.8.34.tgz",
|
||||
"integrity": "sha512-Olb+E6EoMvdPmAMq2QoucuyZycKHjTlBXmRx8Ada+wGtq4SIXuDCdtoaX4KkK0yjf1fJLnwXQURr8gQKWKaybw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-Olb+E6EoMvdPmAMq2QoucuyZycKHjTlBXmRx8Ada+wGtq4SIXuDCdtoaX4KkK0yjf1fJLnwXQURr8gQKWKaybw=="
|
||||
},
|
||||
"deasync": {
|
||||
"version": "0.1.20",
|
||||
@ -4396,7 +4388,6 @@
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://verdaccio.lossless.one/define-properties/-/define-properties-1.1.3.tgz",
|
||||
"integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"object-keys": "^1.0.12"
|
||||
}
|
||||
@ -4810,8 +4801,7 @@
|
||||
"escape-string-regexp": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
|
||||
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="
|
||||
},
|
||||
"escodegen": {
|
||||
"version": "1.9.1",
|
||||
@ -6816,7 +6806,6 @@
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://verdaccio.lossless.one/is-nan/-/is-nan-1.3.0.tgz",
|
||||
"integrity": "sha512-z7bbREymOqt2CCaZVly8aC4ML3Xhfi0ekuOnjO2L8vKdl+CttdVoGZQhd4adMFAsxQ5VeRVwORs4tU8RH+HFtQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "^1.1.3"
|
||||
}
|
||||
@ -7390,7 +7379,6 @@
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/matcher/-/matcher-3.0.0.tgz",
|
||||
"integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"escape-string-regexp": "^4.0.0"
|
||||
}
|
||||
@ -7860,8 +7848,7 @@
|
||||
"object-keys": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://verdaccio.lossless.one/object-keys/-/object-keys-1.1.1.tgz",
|
||||
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA=="
|
||||
},
|
||||
"object-visit": {
|
||||
"version": "1.0.1",
|
||||
@ -9532,7 +9519,6 @@
|
||||
"version": "6.6.2",
|
||||
"resolved": "https://verdaccio.lossless.one/rxjs/-/rxjs-6.6.2.tgz",
|
||||
"integrity": "sha512-BHdBMVoWC2sL26w//BCu3YzKT4s2jip/WhwsGEDmeKYBhKDZeYezVUnHatYB7L85v5xs0BAQmg6BEYJEKxBabg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
@ -10339,8 +10325,7 @@
|
||||
"symbol-tree": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://verdaccio.lossless.one/symbol-tree/-/symbol-tree-3.2.4.tgz",
|
||||
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw=="
|
||||
},
|
||||
"systeminformation": {
|
||||
"version": "4.26.11",
|
||||
@ -10505,8 +10490,7 @@
|
||||
"tslib": {
|
||||
"version": "1.13.0",
|
||||
"resolved": "https://verdaccio.lossless.one/tslib/-/tslib-1.13.0.tgz",
|
||||
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
|
||||
"dev": true
|
||||
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q=="
|
||||
},
|
||||
"tty-browserify": {
|
||||
"version": "0.0.0",
|
||||
|
@ -19,7 +19,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartrequest": "^1.1.47",
|
||||
"@pushrocks/smartstring": "^3.0.18"
|
||||
"@pushrocks/smartstring": "^3.0.18",
|
||||
"@pushrocks/smarttime": "^3.0.24"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
|
@ -3,6 +3,7 @@ import * as paypal from '../ts/index';
|
||||
|
||||
import { Qenv } from '@pushrocks/qenv';
|
||||
const testQenv = new Qenv('./', './.nogit/');
|
||||
import * as smarttime from '@pushrocks/smarttime';
|
||||
|
||||
let testPayPalInstance: paypal.PayPal;
|
||||
|
||||
@ -15,7 +16,8 @@ tap.test('should create a valid paypal instance', async () => {
|
||||
});
|
||||
|
||||
tap.test('should get an access token', async () => {
|
||||
await testPayPalInstance.request();
|
||||
const transactions = await paypal.PayPalTransaction.getTransactionFor30days(testPayPalInstance, smarttime.ExtendedDate.fromHyphedDate('2020-05-01').getTime());
|
||||
console.log(transactions);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -1 +1,2 @@
|
||||
export * from './paypal.classes.paypal';
|
||||
export * from './paypal.classes.transaction';
|
||||
|
@ -16,7 +16,7 @@ export class PayPal {
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
public async request() {
|
||||
public async request(methodArg: 'GET' | 'POST', routeArg: string, payloadArg: any) {
|
||||
if (!this.apiToken || this.apiTokenExpirationTime < Date.now()) {
|
||||
const authHeader = `Basic ${plugins.smartstring.base64.encode(
|
||||
`${this.options.clientId}:${this.options.clientSecret}`
|
||||
@ -38,7 +38,7 @@ export class PayPal {
|
||||
}
|
||||
|
||||
// we have a token
|
||||
const response = await plugins.smartrequest.request(`${this.apiBaseUrl}/v1/reporting/transactions?start_date=2020-05-01T00:00:00Z&end_date=2020-05-30T00:00:00Z`, {
|
||||
const response = await plugins.smartrequest.request(`${this.apiBaseUrl}${routeArg}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@ -46,6 +46,6 @@ export class PayPal {
|
||||
Authorization: `Bearer ${this.apiToken}`,
|
||||
},
|
||||
});
|
||||
console.log(response.body);
|
||||
return response.body;
|
||||
}
|
||||
}
|
||||
|
@ -1 +1,64 @@
|
||||
import * as plugins from './paypal.plugins'
|
||||
import * as plugins from './paypal.plugins';
|
||||
import { PayPal } from './paypal.classes.paypal';
|
||||
|
||||
export interface IPayPalOriginTransactionApiObject {
|
||||
paypal_account_id: string;
|
||||
transaction_id: string;
|
||||
transaction_event_code: string;
|
||||
transaction_initiation_date: string;
|
||||
transaction_updated_date: string;
|
||||
transaction_amount: { currency_code: string; value: string };
|
||||
transaction_status: string;
|
||||
transaction_subject: string;
|
||||
ending_balance: { currency_code: string; value: string };
|
||||
available_balance: { currency_code: string; value: string };
|
||||
invoice_id: string;
|
||||
protection_eligibility: string;
|
||||
}
|
||||
|
||||
export interface IPayPalTransactionOptions {
|
||||
id: string;
|
||||
originApiObject: IPayPalOriginTransactionApiObject
|
||||
amount: number;
|
||||
currency: 'USD' | 'EUR';
|
||||
timestampIso: string;
|
||||
}
|
||||
|
||||
export class PayPalTransaction {
|
||||
public static async getTransactionFor30days(
|
||||
paypalInstanceArg: PayPal,
|
||||
startPointMillis: number = Date.now() - plugins.smarttime.units.days(30)
|
||||
) {
|
||||
const startDate = startPointMillis;
|
||||
const endDate = startDate + plugins.smarttime.units.days(30);
|
||||
const startDateIso = plugins.smarttime.ExtendedDate.fromMillis(startDate).toISOString();
|
||||
const endDateIso = plugins.smarttime.ExtendedDate.fromMillis(endDate).toISOString();
|
||||
console.log(endDateIso);
|
||||
console.log(startDateIso);
|
||||
const response = await paypalInstanceArg.request(
|
||||
'GET',
|
||||
`/v1/reporting/transactions?start_date=${startDateIso}&end_date=${endDateIso}`,
|
||||
{}
|
||||
);
|
||||
|
||||
const returnTransactions: PayPalTransaction[] = []
|
||||
for (const transactionDetail of response.transaction_details) {
|
||||
const apiObject: IPayPalOriginTransactionApiObject = transactionDetail.transaction_info;
|
||||
const paypalTransaction = new PayPalTransaction({
|
||||
originApiObject: apiObject,
|
||||
id: apiObject.transaction_id,
|
||||
amount: parseFloat(apiObject.transaction_amount.value),
|
||||
currency: apiObject.transaction_amount.currency_code as 'EUR' | 'USD',
|
||||
timestampIso: apiObject.transaction_initiation_date
|
||||
});
|
||||
returnTransactions.push(paypalTransaction);
|
||||
}
|
||||
return returnTransactions;
|
||||
}
|
||||
|
||||
public data: IPayPalTransactionOptions;
|
||||
|
||||
constructor(dataArg: IPayPalTransactionOptions) {
|
||||
this.data = dataArg;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
// pupshrocks scope
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
import * as smarttime from '@pushrocks/smarttime';
|
||||
|
||||
export { smartrequest, smartstring };
|
||||
export { smartrequest, smartstring, smarttime };
|
||||
|
Loading…
Reference in New Issue
Block a user