2019-08-21 12:36:16 +00:00
|
|
|
import * as plugins from './typedrequest.plugins';
|
|
|
|
|
2019-08-22 14:44:44 +00:00
|
|
|
export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest> {
|
|
|
|
public urlEndPoint: string;
|
|
|
|
public method: string;
|
|
|
|
|
|
|
|
// STATIC
|
|
|
|
constructor(urlEndPointArg: string, methodArg: T['method']) {
|
|
|
|
this.urlEndPoint = urlEndPointArg;
|
|
|
|
this.method = methodArg;
|
2019-08-23 12:35:50 +00:00
|
|
|
}
|
2019-08-22 14:44:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* firest the request
|
|
|
|
*/
|
|
|
|
public async fire(fireArg: T['request']): Promise<T['response']> {
|
|
|
|
const response = await plugins.smartrequest.request(this.urlEndPoint, {
|
|
|
|
method: 'POST',
|
|
|
|
requestBody: {
|
|
|
|
method: this.method,
|
|
|
|
request: fireArg,
|
|
|
|
response: null
|
2019-08-23 12:35:50 +00:00
|
|
|
}
|
2019-08-22 14:44:44 +00:00
|
|
|
});
|
|
|
|
return response.body.response;
|
|
|
|
}
|
2019-08-23 12:35:50 +00:00
|
|
|
}
|