Skip to content

Commit

Permalink
adding jsdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Dec 14, 2023
1 parent a07f573 commit 2d6a615
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 104 deletions.
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export class AvantiApi {
}
let requestUrl = this.#apiConfiguration.base_api_url + apiEndpoint;
if (apiOptions.method === 'get') {
requestUrl +=
'?' +
objectToUrlSearchParameters(apiOptions.getParameters ?? {}).toString();
requestUrl += `?${objectToUrlSearchParameters(apiOptions.getParameters ?? {}).toString()}`;
}
const fetchOptions = {
method: apiOptions.method,
Expand All @@ -53,7 +51,8 @@ export class AvantiApi {
try {
const json = (await response.json()) ?? {};
if (typeof json === 'object' &&
(Object.hasOwn(json, 'status') || Object.hasOwn(json, 'instance'))) {
(Object.hasOwn(json, 'status') ||
Object.hasOwn(json, 'instance'))) {
return {
success: false,
error: json
Expand Down
55 changes: 28 additions & 27 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export class AvantiApi {

/**
* Requests an API endpoint excluded from the included functions.
* @param apiEndpoint ex. '/v1/Employees'
* @param apiOptions
* @returns
* @param {string} apiEndpoint - ex. '/v1/Employees'
* @param {AvantiApiOptions} apiOptions - API Options
* @returns {Promise<AvantiApiResponse<unknown>>} API Response
*/
async callApi(
apiEndpoint: `/v1/${string}`,
Expand All @@ -80,9 +80,9 @@ export class AvantiApi {
let requestUrl = this.#apiConfiguration.base_api_url + apiEndpoint

if (apiOptions.method === 'get') {
requestUrl +=
'?' +
objectToUrlSearchParameters(apiOptions.getParameters ?? {}).toString()
requestUrl += `?${objectToUrlSearchParameters(
apiOptions.getParameters ?? {}
).toString()}`
}

const fetchOptions: RequestInit = {
Expand All @@ -106,7 +106,8 @@ export class AvantiApi {

if (
typeof json === 'object' &&
(Object.hasOwn(json, 'status') || Object.hasOwn(json, 'instance'))
(Object.hasOwn(json as object, 'status') ||
Object.hasOwn(json as object, 'instance'))
) {
return {
success: false,
Expand Down Expand Up @@ -135,9 +136,9 @@ export class AvantiApi {
}

/**
* Endpoint: /v1/Employees
* @param parameters
* @returns
* List Employees: /v1/Employees
* @param {GetEmployeesRequest} parameters - Request parameters
* @returns {Promise<AvantiApiResponse<GetEmployeesResponse>>} See https://avanti.stoplight.io/docs/avanti-api/62932b8f232fb-list-employees
*/
async getEmployees(
parameters: GetEmployeesRequest
Expand All @@ -149,9 +150,9 @@ export class AvantiApi {
}

/**
* Endpoint: /v1/EmployeeJobData
* @param employeeNumber
* @returns
* Get Employee Job Data: /v1/EmployeeJobData
* @param {string} employeeNumber - Employee number
* @returns {Promise<AvantiApiResponse<GetEmployeeJobDataResponse>>} See https://avanti.stoplight.io/docs/avanti-api/a44b4af6f1abd-get-employee-job-data
*/
async getEmployeeJobData(
employeeNumber: string
Expand All @@ -165,9 +166,9 @@ export class AvantiApi {
}

/**
* Endpoint: /v1/PersonalInfo
* @param employeeNumber
* @returns
* Get Employee Personal Info: /v1/PersonalInfo
* @param {string} employeeNumber - Employee number
* @returns {Promise<AvantiApiResponse<GetEmployeePersonalInfoResponse>>} See https://avanti.stoplight.io/docs/avanti-api/f851b988b5cf6-get-employee-personal-info
*/
async getEmployeePersonalInfo(
employeeNumber: string
Expand All @@ -181,11 +182,11 @@ export class AvantiApi {
}

/**
* Endpoint: /v1/TimeManagement/{viewId}/{templateId}
* @param viewId
* @param templateId
* @param parameters
* @returns
* List Time Entries: /v1/TimeManagement/{viewId}/{templateId}
* @param {string} viewId - View Id
* @param {string} templateId - Template Id
* @param {GetTimeEntriesRequest} parameters - Request parameters
* @returns {Promise<AvantiApiResponse<GetTimeEntriesTimeEntry[]>>} See https://avanti.stoplight.io/docs/avanti-api/4952dd2917595-list-time-entries
*/
async getTimeEntries(
viewId: string,
Expand All @@ -199,9 +200,9 @@ export class AvantiApi {
}

/**
* Endpoint: /v1/TimeManagement/Templates
* @param parameters
* @returns
* List Time Entry Templates: /v1/TimeManagement/Templates
* @param {GetTimeEntryTemplatesRequest} parameters - Request parameters
* @returns {Promise<AvantiApiResponse<GetTimeEntryTemplatesTimeEntryTemplate[]>>} See https://avanti.stoplight.io/docs/avanti-api/faa0ddb0eb18d-list-time-entry-templates
*/
async getTimeEntryTemplates(
parameters: GetTimeEntryTemplatesRequest
Expand All @@ -213,9 +214,9 @@ export class AvantiApi {
}

/**
* Endpoint: /v1/Reporter/{reportId}
* @param reportId The ID of the report you would like to get the data for.
* @returns
* Get Report Data: /v1/Reporter/{reportId}
* @param {string} reportId - The ID of the report you would like to get the data for.
* @returns {Promise<AvantiApiResponse<object[]>>} See https://avanti.stoplight.io/docs/avanti-api/ed0485a9c98bb-get-report-data
*/
async getReport(reportId: string): Promise<AvantiApiResponse<object[]>> {
return (await this.callApi(`/v1/Reporter/${reportId}`, {
Expand Down
Loading

0 comments on commit 2d6a615

Please sign in to comment.