UNPKG

@capawesome/cli

Version:

The Capawesome Cloud Command Line Interface (CLI) to manage Live Updates and more.

68 lines (67 loc) 2.36 kB
import authorizationService from '../services/authorization-service.js'; import httpClient from '../utils/http-client.js'; class AppDeploymentsServiceImpl { httpClient; constructor(httpClient) { this.httpClient = httpClient; } async create(dto) { const response = await this.httpClient.post(`/v1/apps/${dto.appId}/deployments`, dto, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); return response.data; } async findAll(dto) { const params = {}; if (dto.appBuildId) { params.appBuildId = dto.appBuildId; } if (dto.appChannelId) { params.appChannelId = dto.appChannelId; } if (dto.appDestinationId) { params.appDestinationId = dto.appDestinationId; } if (dto.limit !== undefined) { params.limit = dto.limit.toString(); } if (dto.offset !== undefined) { params.offset = dto.offset.toString(); } if (dto.relations) { params.relations = dto.relations; } const response = await this.httpClient.get(`/v1/apps/${dto.appId}/deployments`, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, params, }); return response.data; } async findOne(dto) { const params = {}; if (dto.relations) { params.relations = dto.relations; } const response = await this.httpClient.get(`/v1/apps/${dto.appId}/deployments/${dto.appDeploymentId}`, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, params, }); return response.data; } async update(dto) { const response = await this.httpClient.patch(`/v1/apps/${dto.appId}/deployments/${dto.appDeploymentId}`, dto, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); return response.data; } } const appDeploymentsService = new AppDeploymentsServiceImpl(httpClient); export default appDeploymentsService;