@capawesome/cli
Version:
The Capawesome Cloud Command Line Interface (CLI) to manage Live Updates and more.
45 lines (44 loc) • 1.66 kB
JavaScript
import authorizationService from '../services/authorization-service.js';
import httpClient from '../utils/http-client.js';
class AppsServiceImpl {
httpClient;
constructor(httpClient) {
this.httpClient = httpClient;
}
async create(dto) {
const params = new URLSearchParams({ organizationId: dto.organizationId });
const { organizationId, ...bodyData } = dto;
const response = await this.httpClient.post(`/v1/apps?${params.toString()}`, bodyData, {
headers: {
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
},
});
return response.data;
}
async delete(dto) {
await this.httpClient.delete(`/v1/apps/${dto.id}`, {
headers: {
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
},
});
}
async findAll(dto) {
const params = new URLSearchParams({ organizationId: dto.organizationId });
const response = await this.httpClient.get(`/v1/apps?${params.toString()}`, {
headers: {
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
},
});
return response.data;
}
async findOne(dto) {
const response = await this.httpClient.get(`/v1/apps/${dto.appId}`, {
headers: {
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
},
});
return response.data;
}
}
const appsService = new AppsServiceImpl(httpClient);
export default appsService;