UNPKG

@capawesome/cli

Version:

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

43 lines (42 loc) 1.47 kB
import httpClient from '../utils/http-client.js'; import authorizationService from '../services/authorization-service.js'; class OrganizationsServiceImpl { httpClient; constructor(httpClient) { this.httpClient = httpClient; } async create(dto) { const response = await this.httpClient.post('/v1/organizations', dto, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); return response.data; } async findAll(dto) { const params = {}; if (dto?.limit !== undefined) { params.limit = dto.limit.toString(); } if (dto?.offset !== undefined) { params.offset = dto.offset.toString(); } const response = await this.httpClient.get(`/v1/organizations`, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, params, }); return response.data; } async findOne(dto) { const response = await this.httpClient.get(`/v1/organizations/${dto.organizationId}`, { headers: { Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`, }, }); return response.data; } } const organizationsService = new OrganizationsServiceImpl(httpClient); export default organizationsService;