ora/ts/ora.classes.ora.ts

34 lines
848 B
TypeScript
Raw Permalink Normal View History

2020-06-21 16:06:11 +00:00
import * as plugins from './ora.plugins';
import { OraOrganization } from './ora.classes.organization';
export class Ora {
public apiBase: string = 'https://api.ora.pm';
private apiToken: string;
constructor(apiTokenArg: string) {
this.apiToken = apiTokenArg;
}
2020-06-21 18:41:04 +00:00
public async getOrganizations() {
2020-06-21 16:06:11 +00:00
return await OraOrganization.getAllOrganizations(this);
}
/**
* make a request
2020-06-21 18:41:04 +00:00
* @param routeArg
* @param methodArg
* @param payloadArg
2020-06-21 16:06:11 +00:00
*/
2020-06-21 18:41:04 +00:00
public async request(routeArg: string, methodArg: string, payloadArg?: string) {
2020-06-21 16:06:11 +00:00
const response = await plugins.smartrequest.request(this.apiBase + routeArg, {
method: methodArg,
requestBody: payloadArg,
headers: {
2020-06-21 18:41:04 +00:00
accept: 'application/json',
2020-06-21 16:06:11 +00:00
authorization: `Bearer ${this.apiToken}`
}
});
return response.body;
}
2020-06-21 18:41:04 +00:00
}