typedrequest/ts/index.ts

27 lines
701 B
TypeScript
Raw Normal View History

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;
};
/**
* 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
}
});
return response.body.response;
}
}