fix(core): update
This commit is contained in:
parent
1cf81f86ff
commit
9f70eba74a
1440
package-lock.json
generated
1440
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
27
package.json
27
package.json
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@mojoio/letterxpress",
|
||||
"name": "@apiclient.xyz/letterxpress",
|
||||
"version": "1.0.15",
|
||||
"private": false,
|
||||
"description": "an unofficial API package for the letterxpress API",
|
||||
@ -11,22 +11,23 @@
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"format": "(gitzone format)",
|
||||
"buildDocs": "tsdoc"
|
||||
"localPublish": "gitzone commit && pnpm run build && pnpm publish && pnpm publish --access public --registry=\"https://registry.npmjs.org\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
"@gitzone/tstest": "^1.0.71",
|
||||
"@pushrocks/qenv": "^4.0.10",
|
||||
"@pushrocks/tapbundle": "^5.0.3",
|
||||
"@types/node": "^18.0.0"
|
||||
"@git.zone/tsbuild": "^2.1.63",
|
||||
"@git.zone/tsrun": "^1.2.46",
|
||||
"@git.zone/tstest": "^1.0.71",
|
||||
"@push.rocks/qenv": "^6.0.5",
|
||||
"@push.rocks/tapbundle": "^5.0.3",
|
||||
"@types/node": "^20.11.19"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartbuffer": "^1.0.3",
|
||||
"@pushrocks/smarthash": "^3.0.1",
|
||||
"@pushrocks/smartletter": "^2.0.13",
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"@pushrocks/smartrequest": "^1.1.56",
|
||||
"@pushrocks/smartrx": "^2.0.25",
|
||||
"@design.estate/dees-document": "^1.0.99",
|
||||
"@push.rocks/smartbuffer": "^1.0.3",
|
||||
"@push.rocks/smarthash": "^3.0.1",
|
||||
"@push.rocks/smartpromise": "^4.0.3",
|
||||
"@push.rocks/smartrequest": "^2.0.21",
|
||||
"@push.rocks/smartrx": "^3.0.7",
|
||||
"@tsclass/tsclass": "^4.0.17"
|
||||
},
|
||||
"files": [
|
||||
|
6361
pnpm-lock.yaml
Normal file
6361
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,8 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as letterxpress from '../ts/index.js';
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
import { Qenv } from '@pushrocks/qenv';
|
||||
import { Qenv } from '@push.rocks/qenv';
|
||||
let testQenv = new Qenv('./', './.nogit/');
|
||||
|
||||
let testAccount: letterxpress.LetterXpressAccount;
|
||||
@ -10,8 +10,8 @@ let testLetter: tsclass.business.ILetter;
|
||||
|
||||
tap.test('should create a valid account', async () => {
|
||||
testAccount = await letterxpress.LetterXpressAccount.createAndInit({
|
||||
apiKey: testQenv.getEnvVarOnDemand('API_TOKEN'),
|
||||
username: testQenv.getEnvVarOnDemand('API_USERNAME'),
|
||||
apiKey: await testQenv.getEnvVarOnDemand('API_TOKEN'),
|
||||
username: await testQenv.getEnvVarOnDemand('API_USERNAME'),
|
||||
});
|
||||
expect(testAccount).toBeInstanceOf(letterxpress.LetterXpressAccount);
|
||||
});
|
||||
@ -75,31 +75,36 @@ tap.test('should send an actual letter', async () => {
|
||||
vatId: 'DE293580420',
|
||||
},
|
||||
subject: 'General Terms - Update',
|
||||
text: [
|
||||
`
|
||||
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
|
||||
|
||||
`,
|
||||
],
|
||||
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: [],
|
||||
timesheetData: null,
|
||||
type: 'notice',
|
||||
versionInfo: {
|
||||
type: 'final',
|
||||
version: '1.0.0',
|
||||
}
|
||||
};
|
||||
await testAccount.sendLetter(testLetter);
|
||||
const result = await testAccount.sendLetter(testLetter);
|
||||
});
|
||||
|
||||
tap.test('should be able to delete the sending job', async (toolsArg) => {
|
||||
await toolsArg.delayFor(3000);
|
||||
await toolsArg.delayFor(30000);
|
||||
await testAccount.cancelLetter(testLetter);
|
||||
});
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@mojoio/letterxpress',
|
||||
version: '1.0.15',
|
||||
name: '@apiclient.xyz/letterxpress',
|
||||
version: '1.0.16',
|
||||
description: 'an unofficial API package for the letterxpress API'
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
import { IObjectAction } from '@tsclass/tsclass/dist_ts/database/objectaction.js';
|
||||
|
||||
import * as plugins from './letterxpress.plugins.js';
|
||||
|
||||
export interface ILetterXpressConstructorOptions {
|
||||
@ -16,9 +14,9 @@ export class LetterXpressAccount {
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
public baseApiUrl = 'https://api.letterxpress.de/v1';
|
||||
public baseApiUrl = 'https://api.letterxpress.de/v2';
|
||||
public options: ILetterXpressConstructorOptions;
|
||||
public smartletterInstance: plugins.smartletter.Smartletter;
|
||||
public deesDocumentInstance: plugins.deesDocument.PdfService;
|
||||
|
||||
public letterSentObservable = new plugins.smartrx.rxjs.Subject<plugins.tsclass.business.ILetter>();
|
||||
|
||||
@ -28,7 +26,7 @@ export class LetterXpressAccount {
|
||||
}
|
||||
|
||||
public async init() {
|
||||
this.smartletterInstance = await plugins.smartletter.Smartletter.createAndInit();
|
||||
this.deesDocumentInstance = await plugins.deesDocument.PdfService.createAndStart({});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -36,18 +34,17 @@ export class LetterXpressAccount {
|
||||
* @param letterArg
|
||||
*/
|
||||
public async sendLetter(letterArg: plugins.tsclass.business.ILetter) {
|
||||
const letter = await this.smartletterInstance.createLetterFromData(letterArg);
|
||||
const pdfToSend = await letter.getCombinedPdf();
|
||||
const response = await this.request('/setJob', 'POST', {
|
||||
const pdfToSend = await this.deesDocumentInstance.createPdfFromLetterObject(letterArg);
|
||||
const response = await this.request('/printjobs', 'POST', {
|
||||
letter: {
|
||||
base64_file: plugins.smartbuffer.arrayBufferToBase64(pdfToSend.buffer),
|
||||
base64_checksum: await plugins.smarthash.md5FromString(
|
||||
base64_file_checksum: await plugins.smarthash.md5FromString(
|
||||
plugins.smartbuffer.arrayBufferToBase64(pdfToSend.buffer)
|
||||
),
|
||||
specification: {
|
||||
color: '4',
|
||||
mode: 'simplex',
|
||||
ship: letterArg.to.address.country === 'Germany' ? 'national' : 'international',
|
||||
shipping: letterArg.to.address.country === 'Germany' ? 'national' : 'international',
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -55,7 +52,7 @@ export class LetterXpressAccount {
|
||||
name: 'letterxpress-sent',
|
||||
message: 'requested letterxpress to send the letter',
|
||||
privateMessage: null,
|
||||
data: response.body.letter.job_id,
|
||||
data: response.body.data.id,
|
||||
timestamp: Date.now(),
|
||||
userId: null
|
||||
})
|
||||
@ -74,9 +71,7 @@ export class LetterXpressAccount {
|
||||
}
|
||||
|
||||
public async cancelLetterByProcessingId(processingId: string) {
|
||||
const response = await this.request(`/deleteJob/${processingId}`, 'DELETE', {
|
||||
letter: {}
|
||||
});
|
||||
const response = await this.request(`/printjobs/${processingId}`, 'DELETE', {});
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -88,11 +83,14 @@ export class LetterXpressAccount {
|
||||
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: {
|
||||
@ -105,6 +103,6 @@ export class LetterXpressAccount {
|
||||
}
|
||||
|
||||
public async stop() {
|
||||
await this.smartletterInstance.stop();
|
||||
await this.deesDocumentInstance.stop();
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,17 @@
|
||||
import * as smartbuffer from '@pushrocks/smartbuffer';
|
||||
import * as smarthash from '@pushrocks/smarthash';
|
||||
import * as smartletter from '@pushrocks/smartletter';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartrx from '@pushrocks/smartrx';
|
||||
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, smartletter, smartpromise, smartrequest, smartrx };
|
||||
export { smartbuffer, smarthash, smartpromise, smartrequest, smartrx };
|
||||
|
||||
// @design.estate scope
|
||||
import * as deesDocument from '@design.estate/dees-document/ts';
|
||||
|
||||
export {
|
||||
deesDocument
|
||||
}
|
||||
|
||||
// tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
@ -3,7 +3,12 @@
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext"
|
||||
}
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user