fix(core): update
This commit is contained in:
parent
59999a05b3
commit
d379fce4a3
17
.gitignore
vendored
17
.gitignore
vendored
@ -1,5 +1,20 @@
|
||||
.nogit/
|
||||
node_modules/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
115
.gitlab-ci.yml
115
.gitlab-ci.yml
@ -1,49 +1,62 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .yarn/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- mirror
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: mirror
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testSTABLE:
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
@ -51,36 +64,74 @@ testSTABLE:
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: pages
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command yarn global add npmpage
|
||||
- npmci command npmpage
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${relativeFile}"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "test.ts",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"test/test.ts"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
}
|
||||
]
|
||||
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
module.name: smartmodule
|
||||
module.description: a smart description
|
||||
module.author: Lossless GmbH
|
||||
module.license: MIT
|
@ -1,7 +1,16 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmGlobalTools": [
|
||||
"npmts"
|
||||
]
|
||||
"npmGlobalTools": []
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "mojoio",
|
||||
"gitrepo": "paypal",
|
||||
"shortDescription": "an unofficial paypal API package",
|
||||
"npmPackagename": "@mojoio/paypal",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
11073
package-lock.json
generated
Normal file
11073
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
35
package.json
35
package.json
@ -1,18 +1,39 @@
|
||||
{
|
||||
"name": "ppal",
|
||||
"name": "@mojoio/paypal",
|
||||
"private": "false",
|
||||
"version": "1.0.1",
|
||||
"description": "mojoio PayPal API abstraction",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild --web)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tapbundle": "^1.0.13"
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tstest": "^1.0.44",
|
||||
"@pushrocks/qenv": "^4.0.10",
|
||||
"@pushrocks/tapbundle": "^3.2.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"typings-global": "^1.0.16"
|
||||
}
|
||||
"@pushrocks/smartrequest": "^1.1.47",
|
||||
"@pushrocks/smartstring": "^3.0.18"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
],
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
]
|
||||
}
|
40
readme.md
Normal file
40
readme.md
Normal file
@ -0,0 +1,40 @@
|
||||
# @mojoio/paypal
|
||||
an unofficial paypal API package
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/paypal)
|
||||
* [gitlab.com (source)](https://gitlab.com/mojoio/paypal)
|
||||
* [github.com (source mirror)](https://github.com/mojoio/paypal)
|
||||
* [docs (typedoc)](https://mojoio.gitlab.io/paypal/)
|
||||
|
||||
## Status for master
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [![pipeline status](https://gitlab.com/mojoio/paypal/badges/master/pipeline.svg)](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/mojoio/paypal/badges/master/coverage.svg)](https://lossless.cloud)
|
||||
npm | [![npm downloads per month](https://badgen.net/npm/dy/@mojoio/paypal)](https://lossless.cloud)
|
||||
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/mojoio/paypal)](https://lossless.cloud)
|
||||
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
|
||||
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@mojoio/paypal)](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@mojoio/paypal)](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@mojoio/paypal)](https://lossless.cloud)
|
||||
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class intellisense
|
||||
|
||||
|
||||
## Contribution
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
|
||||
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
|
25
test/test.ts
25
test/test.ts
@ -1,8 +1,21 @@
|
||||
import { expect, tap } from 'tapbundle'
|
||||
import * as ppal from '../ts/index'
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as paypal from '../ts/index';
|
||||
|
||||
tap.test('first test', async () => {
|
||||
console.log(ppal.standardExport)
|
||||
})
|
||||
import { Qenv } from '@pushrocks/qenv';
|
||||
const testQenv = new Qenv('./', './.nogit/');
|
||||
|
||||
tap.start()
|
||||
let testPayPalInstance: paypal.PayPal;
|
||||
|
||||
tap.test('should create a valid paypal instance', async () => {
|
||||
testPayPalInstance = new paypal.PayPal({
|
||||
clientId: testQenv.getEnvVarOnDemand('PAYPAL_CLIENT_ID'),
|
||||
clientSecret: testQenv.getEnvVarOnDemand('PAYPAL_CLIENT_SECRET'),
|
||||
});
|
||||
expect(testPayPalInstance).to.be.instanceOf(paypal.PayPal);
|
||||
});
|
||||
|
||||
tap.test('should get an access token', async () => {
|
||||
await testPayPalInstance.request();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -1,3 +1 @@
|
||||
import * as plugins from './ppal.plugins'
|
||||
|
||||
export let standardExport = 'Hi there! :) This is a exported string'
|
||||
export * from './paypal.classes.paypal';
|
||||
|
51
ts/paypal.classes.paypal.ts
Normal file
51
ts/paypal.classes.paypal.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import * as plugins from './paypal.plugins';
|
||||
|
||||
export interface IPayPalOptions {
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
}
|
||||
|
||||
export class PayPal {
|
||||
public apiBaseUrl: string = 'https://api.paypal.com'
|
||||
public options: IPayPalOptions;
|
||||
|
||||
private apiToken: string;
|
||||
private apiTokenExpirationTime: number;
|
||||
|
||||
constructor(optionsArg: IPayPalOptions) {
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
public async request() {
|
||||
if (!this.apiToken || this.apiTokenExpirationTime < Date.now()) {
|
||||
const authHeader = `Basic ${plugins.smartstring.base64.encode(
|
||||
`${this.options.clientId}:${this.options.clientSecret}`
|
||||
)}`;
|
||||
const response = await plugins.smartrequest.request(
|
||||
`${this.apiBaseUrl}/v1/oauth2/token?grant_type=client_credentials`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Accept-Language': 'en_US',
|
||||
Authorization: authHeader,
|
||||
},
|
||||
keepAlive: false,
|
||||
}
|
||||
);
|
||||
this.apiToken = response.body.access_token;
|
||||
this.apiTokenExpirationTime = Date.now() + response.body.expires_in * 1000 - 600000;
|
||||
}
|
||||
|
||||
// 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`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Accept-Language': 'en_US',
|
||||
Authorization: `Bearer ${this.apiToken}`,
|
||||
},
|
||||
});
|
||||
console.log(response.body);
|
||||
}
|
||||
}
|
1
ts/paypal.classes.transaction.ts
Normal file
1
ts/paypal.classes.transaction.ts
Normal file
@ -0,0 +1 @@
|
||||
import * as plugins from './paypal.plugins'
|
5
ts/paypal.plugins.ts
Normal file
5
ts/paypal.plugins.ts
Normal file
@ -0,0 +1,5 @@
|
||||
// pupshrocks scope
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
|
||||
export { smartrequest, smartstring };
|
@ -1 +0,0 @@
|
||||
import 'typings-global'
|
16
tslint.json
16
tslint.json
@ -1,3 +1,17 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user