Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
6b73313bbc | |||
d58f21f5de | |||
4c13cae34d | |||
f800d61576 | |||
679d1cf9c4 | |||
ce060f0cf9 | |||
4d4d46ef7c | |||
696d56067c | |||
fa3f4b4ccf | |||
5b823b09ac | |||
ebd50b0bed | |||
9f70eba74a | |||
1cf81f86ff | |||
b28200e1fc | |||
afa0a769f6 | |||
f5842147be | |||
1a37a499f2 | |||
cfee9db0aa | |||
7caad0ed66 | |||
a79362b85a | |||
275c4351e4 | |||
8dd5f59286 | |||
6e5faaef35 | |||
5aa148ef7d | |||
9a08c869ed | |||
37850f92b6 | |||
cf02cd86e5 | |||
d50cb5449a | |||
c40d745f98 | |||
a619fbb239 | |||
|
fdb3c792f0 | ||
|
340287ea55 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -15,8 +15,6 @@ node_modules/
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
dist_*/
|
||||
|
||||
# custom
|
126
.gitlab-ci.yml
126
.gitlab-ci.yml
@@ -1,126 +0,0 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
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:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
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: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- 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
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@@ -2,28 +2,10 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"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"
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -11,7 +11,13 @@
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone"
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
113
changelog.md
Normal file
113
changelog.md
Normal file
@@ -0,0 +1,113 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-04-28 - 1.0.21 - fix(metadata)
|
||||
Update repository, package, and branding details to reflect new project ownership and naming
|
||||
|
||||
- Changed author in package.json from 'Lossless GmbH' to 'Task Venture Capital GmbH'
|
||||
- Updated repository URL, issues URL, and homepage in package.json
|
||||
- Revised npmextra.json with updated githost, gitscope, npmPackagename, and projectDomain
|
||||
- Updated readme.md to replace '@mojoio/letterxpress' with '@apiclient.xyz/letterxpress' and adjust corresponding links
|
||||
- Replaced old license file with new license.md reflecting updated copyright information
|
||||
|
||||
## 2025-03-15 - 1.0.20 - fix(letterxpress)
|
||||
Update dependencies, adjust PDF generation parameters, and remove obsolete CI configuration
|
||||
|
||||
- Updated @push.rocks/smartbuffer from ^2.0.1 to ^3.0.4
|
||||
- Updated @tsclass/tsclass from ^4.0.54 to ^5.0.0
|
||||
- Updated @types/node from ^20.12.7 to ^22.13.10
|
||||
- Changed dees-document import path to use the 'node' entry point
|
||||
- Modified sendLetter to pass an object with letterData and documentSettings to createPdfFromLetterObject
|
||||
- Removed obsolete .gitlab-ci.yml file
|
||||
|
||||
## 2024-04-17 - 1.0.18 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module updated.
|
||||
|
||||
## 2024-02-19 - 1.0.17 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module updated.
|
||||
|
||||
## 2024-02-17 - 1.0.16 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module updated.
|
||||
|
||||
## 2024-02-16 - 1.0.15 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module updated.
|
||||
|
||||
## 2022-06-29 - 1.0.14 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module update applied.
|
||||
|
||||
## 2022-06-16 - 1.0.13 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module update applied.
|
||||
|
||||
## 2022-06-16 - 1.0.12 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module update applied.
|
||||
|
||||
## 2022-06-16 - 1.0.11 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module update applied.
|
||||
|
||||
## 2019-11-22 - 1.0.10 - build
|
||||
fix(build): now including all necessary types
|
||||
|
||||
- Included all necessary type definitions in the build process.
|
||||
|
||||
## 2019-11-22 - 1.0.09 - security
|
||||
fix(security): update snyk
|
||||
|
||||
- Updated snyk for improved security.
|
||||
|
||||
## 2019-11-22 - 1.0.08 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module updated.
|
||||
|
||||
## 2019-11-21 - 1.0.07 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module updated.
|
||||
|
||||
## 2019-11-18 - 1.0.06 - readme
|
||||
fix(readme): show how to instantiate account
|
||||
|
||||
- Updated documentation to show how to instantiate an account.
|
||||
|
||||
## 2019-11-18 - 1.0.05 - readme
|
||||
fix(readme): add links to documentation
|
||||
|
||||
- Added links to documentation in the readme.
|
||||
|
||||
## 2019-11-18 - 1.0.04 - test
|
||||
fix(test): add first account test
|
||||
|
||||
- Added the first account test.
|
||||
|
||||
## 2019-11-18 - 1.0.03 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module updated.
|
||||
|
||||
## 2019-11-16 - 1.0.02 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module updated.
|
||||
|
||||
## 2019-11-13 - 1.0.01 - core
|
||||
fix(core): update
|
||||
|
||||
- Core module updated.
|
||||
|
||||
## Other versions (omitted)
|
||||
The following version(s) included only version bump commits without additional changes: 1.0.19.
|
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2019 Lossless GmbH (hello@lossless.com)
|
||||
Copyright (c) 2019 Task Venture Capital GmbH (hello@task.vc)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
@@ -1,13 +1,14 @@
|
||||
{
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "mojoio",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "apiclient.xyz",
|
||||
"gitrepo": "letterxpress",
|
||||
"shortDescription": "an unofficial API package for the letterxpress API",
|
||||
"npmPackagename": "@mojoio/letterxpress",
|
||||
"description": "an unofficial API package for the letterxpress API",
|
||||
"npmPackagename": "@apiclient.xyz/letterxpress",
|
||||
"license": "MIT",
|
||||
"projectDomain": "mojo.io"
|
||||
"projectDomain": "apiclient.xyz"
|
||||
}
|
||||
},
|
||||
"npmci": {
|
||||
|
1621
package-lock.json
generated
1621
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
59
package.json
59
package.json
@@ -1,37 +1,64 @@
|
||||
{
|
||||
"name": "@mojoio/letterxpress",
|
||||
"version": "1.0.5",
|
||||
"name": "@apiclient.xyz/letterxpress",
|
||||
"version": "1.0.21",
|
||||
"private": false,
|
||||
"description": "an unofficial API package for the letterxpress API",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"author": "Lossless GmbH",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"author": "Task Venture Capital GmbH",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://code.foss.global/apiclient.xyz/letterxpress.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://code.foss.global/apiclient.xyz/letterxpress/issues"
|
||||
},
|
||||
"homepage": "https://code.foss.global/apiclient.xyz/letterxpress#readme",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"format": "(gitzone format)"
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"format": "(gitzone format)",
|
||||
"localPublish": "gitzone commit && pnpm run build && pnpm publish && pnpm publish --access public --registry=\"https://registry.npmjs.org\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.11.7",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
"@git.zone/tsbuild": "^2.1.63",
|
||||
"@git.zone/tsrun": "^1.2.46",
|
||||
"@git.zone/tstest": "^1.0.88",
|
||||
"@push.rocks/qenv": "^6.0.5",
|
||||
"@push.rocks/tapbundle": "^5.0.23",
|
||||
"@types/node": "^22.13.10"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartrequest": "^1.1.42"
|
||||
"@design.estate/dees-document": "^1.0.99",
|
||||
"@push.rocks/smartbuffer": "^3.0.4",
|
||||
"@push.rocks/smarthash": "^3.0.1",
|
||||
"@push.rocks/smartpromise": "^4.0.3",
|
||||
"@push.rocks/smartrequest": "^2.0.22",
|
||||
"@push.rocks/smartrx": "^3.0.7",
|
||||
"@tsclass/tsclass": "^5.0.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_web/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
]
|
||||
],
|
||||
"type": "module",
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
],
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"esbuild",
|
||||
"mongodb-memory-server",
|
||||
"puppeteer"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
10054
pnpm-lock.yaml
generated
Normal file
10054
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
0
readme.hints.md
Normal file
0
readme.hints.md
Normal file
38
readme.md
38
readme.md
@@ -1,31 +1,29 @@
|
||||
# @mojoio/letterxpress
|
||||
# @apiclient.xyz/letterxpress
|
||||
an unofficial API package for the letterxpress API
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/letterxpress)
|
||||
* [gitlab.com (source)](https://gitlab.com/mojoio/letterxpress)
|
||||
* [github.com (source mirror)](https://github.com/mojoio/letterxpress)
|
||||
* [docs (typedoc)](https://mojoio.gitlab.io/letterxpress/)
|
||||
## Availability and Links
|
||||
* [npm package](https://www.npmjs.com/package/@apiclient.xyz/letterxpress)
|
||||
* [Source code (Code.Foss.Global)](https://code.foss.global/apiclient.xyz/letterxpress)
|
||||
* [Issue tracker](https://code.foss.global/apiclient.xyz/letterxpress/issues)
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/mojoio/letterxpress/commits/master)
|
||||
[](https://gitlab.com/mojoio/letterxpress/commits/master)
|
||||
[](https://www.npmjs.com/package/@mojoio/letterxpress)
|
||||
[](https://snyk.io/test/npm/@mojoio/letterxpress)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://prettier.io/)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class intellisense.
|
||||
|
||||
## Contribution
|
||||
letterxpress implements the LXP API documented here: [LXP API Documentation](https://www.letterxpress.de/briefe-uebertragen/api)
|
||||
|
||||
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). :)
|
||||
```typescript
|
||||
import * as letterxpress from '@apiclient.xyz/letterxpress';
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
const account = new letterxpress.LetterXpressAccount({
|
||||
email: 'myemail@example.com',
|
||||
apiToken: 'abcdefghijklmnop1234567890',
|
||||
});
|
||||
```
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
## Contributing
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
Contributions, bug reports, and feature requests are welcome! Please open an issue or submit a pull request at [Code.Foss.Global](https://code.foss.global/apiclient.xyz/letterxpress/issues).
|
||||
|
||||
> MIT licensed | © Task Venture Capital GmbH
|
||||
|
116
test/test.nonci.ts
Normal file
116
test/test.nonci.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as letterxpress from '../ts/index.js';
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
import { Qenv } from '@push.rocks/qenv';
|
||||
let testQenv = new Qenv('./', './.nogit/');
|
||||
|
||||
let testAccount: letterxpress.LetterXpressAccount;
|
||||
let testLetter: tsclass.business.ILetter;
|
||||
|
||||
tap.test('should create a valid account', async () => {
|
||||
testAccount = await letterxpress.LetterXpressAccount.createAndStart({
|
||||
apiKey: await testQenv.getEnvVarOnDemand('API_TOKEN'),
|
||||
username: await testQenv.getEnvVarOnDemand('API_USERNAME'),
|
||||
});
|
||||
expect(testAccount).toBeInstanceOf(letterxpress.LetterXpressAccount);
|
||||
});
|
||||
|
||||
tap.test('should send an actual letter', async () => {
|
||||
testLetter = {
|
||||
from: {
|
||||
name: 'Lossless GmbH',
|
||||
type: 'company',
|
||||
description: 'a company',
|
||||
sepaConnection: {
|
||||
iban: 'NL83 BUNQ 2035 5639 41',
|
||||
bic: 'BUNQNL2AXXX',
|
||||
},
|
||||
address: {
|
||||
name: 'default',
|
||||
city: 'Bremen',
|
||||
country: 'Germany',
|
||||
postalCode: '28359',
|
||||
houseNumber: '5',
|
||||
streetName: 'Karl-Ferdinand-Braun-Str.',
|
||||
},
|
||||
},
|
||||
to: {
|
||||
name: 'Lossless GmbH',
|
||||
type: 'company',
|
||||
description: 'a company',
|
||||
address: {
|
||||
city: 'Bremen',
|
||||
country: 'Germany',
|
||||
postalCode: '28359',
|
||||
streetName: 'Karl-Ferdinand-Braun-Str.',
|
||||
houseNumber: '5',
|
||||
},
|
||||
},
|
||||
incidenceId: 'abc123',
|
||||
legalContact: {
|
||||
type: 'company',
|
||||
salutation: null,
|
||||
surname: null,
|
||||
title: null,
|
||||
address: {
|
||||
city: 'Bremen',
|
||||
country: 'Germany',
|
||||
name: 'Lossless GmbH',
|
||||
postalCode: '28359',
|
||||
streetName: 'Karl-Ferdinand-Braun-Str.',
|
||||
houseNumber: '5',
|
||||
},
|
||||
sepaConnection: {
|
||||
iban: 'NL83 BUNQ 2035 5639 41',
|
||||
bic: 'BUNQNL2AXXX',
|
||||
},
|
||||
customerNumber: null,
|
||||
description: null,
|
||||
email: 'hello@lossless.com',
|
||||
fax: '+49 421 408951 46',
|
||||
phone: '+49 421 16767 548',
|
||||
legalEntity: 'Lossless GmbH',
|
||||
name: 'Lossless GmbH',
|
||||
vatId: 'DE293580420',
|
||||
},
|
||||
subject: 'General Terms - Update',
|
||||
content: {
|
||||
textData: [`
|
||||
To whome it may concern,
|
||||
|
||||
**this is a testmessage.** we write to inform you about a change in our General Terms.
|
||||
As of December 1st 2019 we will start storing IPs that connect to our app for a period of 3 month.
|
||||
|
||||
Regards
|
||||
Lossless GmbH - Legal Department
|
||||
|
||||
`],
|
||||
timesheetData: null,
|
||||
},
|
||||
date: Date.now(),
|
||||
language: 'DE',
|
||||
logoUrl: '',
|
||||
needsCoverSheet: true,
|
||||
objectActions: [],
|
||||
pdfAttachments: [],
|
||||
type: 'notice',
|
||||
versionInfo: {
|
||||
type: 'final',
|
||||
version: '1.0.0',
|
||||
}
|
||||
};
|
||||
const result = await testAccount.sendLetter(testLetter);
|
||||
});
|
||||
|
||||
tap.test('should be able to delete the sending job', async (toolsArg) => {
|
||||
await toolsArg.delayFor(5000);
|
||||
await testAccount.cancelLetter(testLetter);
|
||||
});
|
||||
|
||||
tap.test('should wrap things up', async () => {
|
||||
await testAccount.stop();
|
||||
console.log(testLetter);
|
||||
});
|
||||
|
||||
tap.start();
|
11
test/test.ts
11
test/test.ts
@@ -1,11 +0,0 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as letterxpress from '../ts/index';
|
||||
|
||||
let testAccount: letterxpress.LetterXpressAccount;
|
||||
|
||||
tap.test('should create a valid account', async () => {
|
||||
testAccount = new letterxpress.LetterXpressAccount();
|
||||
expect(testAccount).to.be.instanceOf(letterxpress.LetterXpressAccount);
|
||||
});
|
||||
|
||||
tap.start();
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@apiclient.xyz/letterxpress',
|
||||
version: '1.0.21',
|
||||
description: 'an unofficial API package for the letterxpress API'
|
||||
}
|
@@ -1 +1 @@
|
||||
export * from './letterxpress.classes.account';
|
||||
export * from './letterxpress.classes.account.js';
|
||||
|
@@ -1,5 +1,109 @@
|
||||
import * as plugins from './letterxpress.plugins';
|
||||
import * as plugins from './letterxpress.plugins.js';
|
||||
|
||||
export interface ILetterXpressConstructorOptions {
|
||||
username: string;
|
||||
apiKey: string;
|
||||
}
|
||||
|
||||
export class LetterXpressAccount {
|
||||
|
||||
}
|
||||
// STATIC
|
||||
public static async createAndStart(optionsArg: ConstructorParameters<typeof LetterXpressAccount>[0]) {
|
||||
const letterXpressInstance = new LetterXpressAccount(optionsArg);
|
||||
await letterXpressInstance.start();
|
||||
return letterXpressInstance;
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
public baseApiUrl = 'https://api.letterxpress.de/v2';
|
||||
public options: ILetterXpressConstructorOptions;
|
||||
public deesDocumentInstance: plugins.deesDocument.PdfService;
|
||||
|
||||
public letterSentObservable = new plugins.smartrx.rxjs.Subject<plugins.tsclass.business.ILetter>();
|
||||
|
||||
constructor(optionsArg: ILetterXpressConstructorOptions) {
|
||||
const done = plugins.smartpromise.defer();
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
public async start() {
|
||||
this.deesDocumentInstance = await plugins.deesDocument.PdfService.createAndStart({});
|
||||
}
|
||||
|
||||
/**
|
||||
* sends a letter
|
||||
* @param letterArg
|
||||
*/
|
||||
public async sendLetter(letterArg: plugins.tsclass.business.ILetter) {
|
||||
const pdfToSend = await this.deesDocumentInstance.createPdfFromLetterObject({letterData: letterArg, documentSettings: {}});
|
||||
const response = await this.request('/printjobs', 'POST', {
|
||||
letter: {
|
||||
base64_file: plugins.smartbuffer.uInt8ArrayToBase64(pdfToSend.buffer),
|
||||
base64_file_checksum: await plugins.smarthash.md5FromString(
|
||||
plugins.smartbuffer.uInt8ArrayToBase64(pdfToSend.buffer)
|
||||
),
|
||||
specification: {
|
||||
color: '4',
|
||||
mode: 'simplex',
|
||||
shipping: letterArg.to.address.country === 'Germany' ? 'national' : 'international',
|
||||
},
|
||||
},
|
||||
});
|
||||
letterArg.objectActions.push({
|
||||
name: 'letterxpress-sent',
|
||||
message: 'requested letterxpress to send the letter',
|
||||
privateMessage: null,
|
||||
data: response.body.data.id,
|
||||
timestamp: Date.now(),
|
||||
userId: null
|
||||
})
|
||||
return letterArg;
|
||||
}
|
||||
|
||||
public async cancelLetter(letterArg: plugins.tsclass.business.ILetter) {
|
||||
const processingId = letterArg.objectActions.reduce<string>((previousVal, currentVal) => {
|
||||
if (currentVal.name === 'letterxpress-sent') {
|
||||
return currentVal.data
|
||||
} else {
|
||||
return previousVal;
|
||||
}
|
||||
}, null);
|
||||
return await this.cancelLetterByProcessingId(processingId);
|
||||
}
|
||||
|
||||
public async cancelLetterByProcessingId(processingId: string) {
|
||||
const response = await this.request(`/printjobs/${processingId}`, 'DELETE', {});
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* fires the request
|
||||
*/
|
||||
private async request(routeArg: string, methodArg: 'GET' | 'POST' | 'DELETE', payload: any) {
|
||||
const requestUrl = `${this.baseApiUrl}${routeArg}`;
|
||||
console.log(requestUrl);
|
||||
const requestData = {
|
||||
auth: {
|
||||
mode: "live",
|
||||
username: this.options.username,
|
||||
apikey: this.options.apiKey,
|
||||
},
|
||||
...payload,
|
||||
};
|
||||
// console.log(methodArg);
|
||||
// console.log(requestData);
|
||||
const response = await plugins.smartrequest.request(requestUrl, {
|
||||
method: methodArg,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
requestBody: JSON.stringify(requestData),
|
||||
keepAlive: false,
|
||||
});
|
||||
console.log(response.body);
|
||||
return response;
|
||||
}
|
||||
|
||||
public async stop() {
|
||||
await this.deesDocumentInstance.stop();
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,21 @@
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartbuffer from '@push.rocks/smartbuffer';
|
||||
import * as smarthash from '@push.rocks/smarthash';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartrequest from '@push.rocks/smartrequest';
|
||||
import * as smartrx from '@push.rocks/smartrx';
|
||||
|
||||
export { smartbuffer, smarthash, smartpromise, smartrequest, smartrx };
|
||||
|
||||
// @design.estate scope
|
||||
import * as deesDocument from '@design.estate/dees-document/node';
|
||||
|
||||
export {
|
||||
smartrequest
|
||||
};
|
||||
deesDocument
|
||||
}
|
||||
|
||||
// tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
export {
|
||||
tsclass
|
||||
}
|
||||
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
17
tslint.json
17
tslint.json
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
Reference in New Issue
Block a user