UNPKG

@capawesome/cli

Version:

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

69 lines (68 loc) 2.53 kB
import httpClient from '../utils/http-client.js'; import authorizationService from '../services/authorization-service.js'; class AppDevicesServiceImpl { httpClient; constructor(httpClient) { this.httpClient = httpClient; } async delete(data) { await this.httpClient.delete(`/v1/apps/${data.appId}/devices/${data.deviceId}`, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); } async findOneById(data) { const response = await this.httpClient.get(`/v1/apps/${data.appId}/devices/${data.deviceId}`, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, params: { relations: 'appChannel', }, }); return response.data; } async probe(data) { const params = { appVersionCode: data.appVersionCode, appVersionName: data.appVersionName, osVersion: data.osVersion, platform: data.platform.toString(), pluginVersion: data.pluginVersion, }; if (data.channelName) { params.channelName = data.channelName; } if (data.customId) { params.customId = data.customId; } if (data.deviceId) { params.deviceId = data.deviceId; } const response = await this.httpClient.get(`/v1/apps/${data.appId}/bundles/latest`, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, params, }); return response.data; } async update(data) { await this.httpClient.patch(`/v1/apps/${data.appId}/devices/${data.deviceId}`, { forcedAppChannelId: data.forcedAppChannelId }, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); } async updateMany(data) { const ids = data.deviceIds.join(','); await this.httpClient.patch(`/v1/apps/${data.appId}/devices?ids=${ids}`, { forcedAppChannelId: data.forcedAppChannelId }, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); } } const appDevicesService = new AppDevicesServiceImpl(httpClient); export default appDevicesService;