fix(core): update
This commit is contained in:
@ -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)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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 };
|
||||
|
Reference in New Issue
Block a user