Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
cf02cd86e5 | |||
d50cb5449a | |||
c40d745f98 | |||
a619fbb239 | |||
|
fdb3c792f0 | ||
|
340287ea55 | ||
|
a602155d0b | ||
|
e2e20bab94 | ||
|
097039c34c | ||
|
d7b713fdad | ||
c6cdfdf137 | |||
71d14fa32f |
2088
package-lock.json
generated
2088
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mojoio/letterxpress",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.8",
|
||||
"private": false,
|
||||
"description": "an unofficial API package for the letterxpress API",
|
||||
"main": "dist/index.js",
|
||||
@@ -15,12 +15,17 @@
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.11.7",
|
||||
"@pushrocks/qenv": "^4.0.6",
|
||||
"@pushrocks/tapbundle": "^3.2.0",
|
||||
"@types/node": "^12.12.11",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartletter": "^1.0.15",
|
||||
"@pushrocks/smartrequest": "^1.1.42",
|
||||
"@pushrocks/smartrx": "^2.0.5"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
|
12
readme.md
12
readme.md
@@ -18,6 +18,18 @@ an unofficial API package for the letterxpress API
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class intellisense.
|
||||
|
||||
letterxpress implements the LXP API documented here: [LXP API Documentation](https://www.letterxpress.de/briefe-uebertragen/api)
|
||||
|
||||
```typescript
|
||||
import * as letterxpress from '@mojoio/letterxpress'
|
||||
|
||||
const account = new letterxpress.LetterXpressAccount({
|
||||
email: 'myemail@example.com',
|
||||
apiToken: 'abcdefghijklmnop1234567890'
|
||||
})
|
||||
```
|
||||
|
||||
## Contribution
|
||||
|
||||
|
13
test/test.ts
13
test/test.ts
@@ -1,8 +1,17 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as letterxpress from '../ts/index';
|
||||
|
||||
tap.test('first test', async () => {
|
||||
console.log(letterxpress.standardExport);
|
||||
import { Qenv } from '@pushrocks/qenv';
|
||||
let testQenv = new Qenv('./', './.nogit/');
|
||||
|
||||
let testAccount: letterxpress.LetterXpressAccount;
|
||||
|
||||
tap.test('should create a valid account', async () => {
|
||||
testAccount = new letterxpress.LetterXpressAccount({
|
||||
apiKey: testQenv.getEnvVarOnDemand('API_TOKEN'),
|
||||
email: testQenv.getEnvVarOnDemand('API_EMAIL')
|
||||
});
|
||||
expect(testAccount).to.be.instanceOf(letterxpress.LetterXpressAccount);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@@ -1,3 +1 @@
|
||||
import * as plugins from './letterxpress.plugins';
|
||||
|
||||
export let standardExport = 'Hi there! :) This is an exported string';
|
||||
export * from './letterxpress.classes.account';
|
||||
|
47
ts/letterxpress.classes.account.ts
Normal file
47
ts/letterxpress.classes.account.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import * as plugins from './letterxpress.plugins';
|
||||
|
||||
export interface ILetterXpressConstructorOptions {
|
||||
email: string;
|
||||
apiKey: string;
|
||||
}
|
||||
|
||||
export class LetterXpressAccount {
|
||||
public baseApiUrl = 'https://api.letterxpress.de/v1/';
|
||||
public options: ILetterXpressConstructorOptions;
|
||||
|
||||
public letterSentObservable = new plugins.smartrx.rxjs.Subject<plugins.smartletter.Letter>();
|
||||
|
||||
constructor(optionsArg: ILetterXpressConstructorOptions) {
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* sends a letter
|
||||
* @param letterArg
|
||||
*/
|
||||
public async sendLetter(letterArg: plugins.smartletter.Letter) {
|
||||
const letterPdfResult = await letterArg.getPdfResult();
|
||||
const response = await this.request('/setJob', 'POST', {});
|
||||
}
|
||||
|
||||
/**
|
||||
* fires the request
|
||||
*/
|
||||
private async request(routeArg: string, methodArg: 'GET' | 'POST', payload?: any) {
|
||||
const requestUrl = `${this.baseApiUrl}`;
|
||||
const requestData = {
|
||||
auth: {
|
||||
username: this.options.email,
|
||||
apikey: this.options.apiKey
|
||||
},
|
||||
...payload
|
||||
};
|
||||
const response = await plugins.smartrequest.request(routeArg, {
|
||||
method: methodArg,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
requestBody: JSON.stringify(requestData)
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,2 +1,5 @@
|
||||
const removeme = {};
|
||||
export { removeme };
|
||||
import * as smartletter from '@pushrocks/smartletter';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartrx from '@pushrocks/smartrx';
|
||||
|
||||
export { smartletter, smartrequest, smartrx };
|
||||
|
Reference in New Issue
Block a user