OSDN Git Service

865b3bca4c6724ef3686d3c6d77e8356a1154dd9
[eos/zephyr.git] / front-end / app / scripts / services / APIEndPoint.ts
1 namespace app.services {
2     export class APIEndPoint {
3
4         private $resource: ng.resource.IResourceService;
5
6         constructor($resource: ng.resource.IResourceService) {
7             this.$resource = $resource;
8         }
9
10         private resource(endPoint: string) {
11             /**
12              * setting custom action
13              */
14             var customAction: ng.resource.IActionDescriptor = {
15                 method: 'GET',
16                 isArray: false
17             };
18
19             return <declares.IResponseResource> this.$resource(endPoint, {}, { customAction: customAction});
20         }
21
22         public getOptionControlFile(command: string): ng.resource.IResource<declares.IResponse> {
23             var endPoint = '/api/optionControlFile/' + command;
24             return <declares.IResponseOption>this.resource(endPoint).get();
25         }
26
27         public getFiles(fileId: string): ng.resource.IResource<declares.IResponse> {
28             var endPoint = '/api/v1/workspace'; 
29
30             if(fileId) {
31                 endPoint += '/' + fileId;
32             }
33             return <declares.IResponseFileInfo>this.resource(endPoint).get();
34         }
35     }
36 }