import { createAmioApi } from './amioApiFactory' import { handleAmioError, AmioChannel } from './amioService' export async function getChannels() { const amioApi = createAmioApi() try { const channels = await amioApi.channels.list() return channels.items } catch (err) { handleAmioError(err) } } export async function createChannel(request: AmioChannel, botId: string) { const amioApi = createAmioApi() request.name = botId try { return await amioApi.channels.create(request) } catch (err) { handleAmioError(err) } } export async function updateChannel(channelId: string, request: AmioChannel) { const amioApi = createAmioApi() try { return await amioApi.channels.update(channelId, request) } catch (err) { handleAmioError(err) } } export async function deleteChannel(channelId: string) { const amioApi = createAmioApi() try { return await amioApi.channels.delete(channelId) } catch (err) { handleAmioError(err) } }