gbkannan89 commented on code in PR #7358:
URL: https://github.com/apache/trafficcontrol/pull/7358#discussion_r1125978332


##########
experimental/traffic-portal/src/app/api/statuses.service.ts:
##########
@@ -0,0 +1,68 @@
+import { HttpClient } from "@angular/common/http";
+import { Injectable } from "@angular/core";
+import { ResponseStatus } from "trafficops-types";
+
+import { APIService } from "./base-api.service";
+
+@Injectable()
+export class StatusesService extends APIService {
+
+       /**
+        * Injects the Angular HTTP client service into the parent constructor.
+        *
+        * @param http The Angular HTTP client service.
+        */
+       constructor(http: HttpClient) {
+               super(http);
+       }
+
+       public async getStatuses(idOrName: number | string): 
Promise<ResponseStatus>;
+       public async getStatuses(): Promise<Array<ResponseStatus>>;
+       /**
+        * @param id Specify either the integral, unique identifier (number.
+        * @returns The requested status(s).
+        */
+       public async getStatuses(id?: number | string): 
Promise<Array<ResponseStatus> | ResponseStatus> {
+               const path = "statuses";
+               if (id !== undefined) {
+                       let statuses;
+                       statuses = await this.get<[ResponseStatus]>(path, 
undefined, { id: String(id) }).toPromise();
+                       if (statuses.length < 1) {
+                               throw new Error(`no such statuses '${id}'`);
+                       }
+                       return statuses[0];
+               }
+               return this.get<Array<ResponseStatus>>(path).toPromise();
+       }
+
+       /**
+        * Creating new Status.
+        *
+        * @param data containes name and description for the status.
+        * @returns The 'response' property of the TO status response. See TO 
API docs.
+        */
+       public async createStatus(data: ResponseStatus) {
+               const path = "statuses";
+               return this.post<ResponseStatus>(path, data).toPromise();
+       }
+
+       /**
+        * Updates status.
+        *
+        * @param data containes name and description for the status., unique 
identifier thereof.
+        * @param id The Status ID
+        */
+       public async updateStatus(data: ResponseStatus, id: number): 
Promise<ResponseStatus | undefined> {
+               const path = `statuses/${id}`;
+               return this.put(path, data).toPromise();
+       }
+
+       /**
+        * Deletes an existing Status.
+        *
+        * @param id The Status ID
+        */
+       public async deleteStatus(id: number): Promise<void> {
+               return this.delete(`statuses/${id}`).toPromise();
+       }
+}

Review Comment:
   removed new statuses.service and created the update, delete and create 
status in server.service. @ocket8888 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to