UNPKG

@capawesome/cli

Version:

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

49 lines (48 loc) 1.71 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 { appId, appBuildId, appDestinationName } = dto; const bodyData = { appBuildId, }; if (appDestinationName) { bodyData.appDestinationName = appDestinationName; } const response = await this.httpClient.post(`/v1/apps/${appId}/deployments`, bodyData, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); return response.data; } async findAll(dto) { const { appId } = dto; const response = await this.httpClient.get(`/v1/apps/${appId}/deployments`, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); return response.data; } async findOne(dto) { const { appId, appDeploymentId, relations } = dto; const params = {}; if (relations) { params.relations = relations; } const response = await this.httpClient.get(`/v1/apps/${appId}/deployments/${appDeploymentId}`, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, params, }); return response.data; } } const appDeploymentsService = new AppDeploymentsServiceImpl(httpClient); export default appDeploymentsService;