import { removeChannelV2, updateChannelV2, createChannelV2, } from "../discussions/api/channels/channels";
import { transformChannelToEntity } from "./_internal/transformChannelToEntity";
import { transformEntityToChannelData } from "./_internal/transformEntityToChannelData";
/**
 * Creates a new Channel from the given IHubChannel object
 * @param entity An IHubChannel object
 * @param context ArcGIS context
 * @returns a promise that resolves an IHubChannel representing the newly created channel
 */
export async function createHubChannel(entity, context) {
    const channelData = transformEntityToChannelData(entity);
    const createdChannel = await createChannelV2(Object.assign({ data: channelData }, context.hubRequestOptions));
    return transformChannelToEntity(createdChannel, context.currentUser);
}
/**
 * Updates an existing Channel from the given IHubChannel object
 * @param entity An IHubChannel object
 * @param context ArcGIS context
 * @returns a promise that resolves an IHubChannel representing the updated channel
 */
export async function updateHubChannel(entity, context) {
    const updatedChannelData = transformEntityToChannelData(entity);
    const updatedChannel = await updateChannelV2(Object.assign({ channelId: entity.id, data: updatedChannelData }, context.hubRequestOptions));
    return transformChannelToEntity(updatedChannel, context.currentUser);
}
/**
 * Updates an existing Channel from the given IHubChannel object
 * @param channelId The ID of the channel to delete
 * @param context ArcGIS context
 * @returns a promise
 */
export async function deleteHubChannel(channelId, context) {
    await removeChannelV2(Object.assign({ channelId }, context.hubRequestOptions));
}
//# sourceMappingURL=edit.js.map