fix(core): update

This commit is contained in:
2019-11-21 14:01:41 +00:00
parent c40d745f98
commit d50cb5449a
4 changed files with 63 additions and 49 deletions

View File

@ -6,11 +6,42 @@ export interface ILetterXpressConstructorOptions {
}
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;
}
public request() {}
/**
* 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)
});
}
}

View File

@ -1,3 +1,5 @@
import * as smartletter from '@pushrocks/smartletter';
import * as smartrequest from '@pushrocks/smartrequest';
import * as smartrx from '@pushrocks/smartrx';
export { smartrequest };
export { smartletter, smartrequest, smartrx };