UNPKG

@capawesome/cli

Version:

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

67 lines (66 loc) 2.36 kB
import authorizationService from '../services/authorization-service.js'; import httpClient from '../utils/http-client.js'; class AppDestinationsServiceImpl { httpClient; constructor(httpClient) { this.httpClient = httpClient; } async create(dto) { const response = await this.httpClient.post(`/v1/apps/${dto.appId}/destinations`, dto, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); return response.data; } async delete(dto) { await this.httpClient.delete(`/v1/apps/${dto.appId}/destinations/${dto.destinationId}`, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); } async findAll(dto) { const params = {}; if (dto.limit !== undefined) { params.limit = dto.limit.toString(); } if (dto.offset !== undefined) { params.offset = dto.offset.toString(); } if (dto.name) { params.name = dto.name; } if (dto.platform) { params.platform = dto.platform; } if (dto.query) { params.query = dto.query; } const response = await this.httpClient.get(`/v1/apps/${dto.appId}/destinations`, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, params, }); return response.data; } async findOneById(dto) { const response = await this.httpClient.get(`/v1/apps/${dto.appId}/destinations/${dto.destinationId}`, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); return response.data; } async update(dto) { const response = await this.httpClient.patch(`/v1/apps/${dto.appId}/destinations/${dto.destinationId}`, dto, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); return response.data; } } const appDestinationsService = new AppDestinationsServiceImpl(httpClient); export default appDestinationsService;