import { DocumentTypeService } from '../../../../core/backend-api/index.js';
import { tryExecute } from '../../../../core/resources/index.js';
/**
 * A data source for the Document Type Template that fetches data from the server
 * @class UmbDocumentTypeTemplateServerDataSource
 */
export class UmbDocumentTypeTemplateServerDataSource {
    #host;
    /**
     * Creates an instance of UmbDocumentTypeTemplateServerDataSource.
     * @param {UmbControllerHost} host - The controller host for this controller to be appended to
     * @memberof UmbDocumentTypeTemplateServerDataSource
     */
    constructor(host) {
        this.#host = host;
    }
    /**
     * Creates a template for a document type on the server
     * @param {string} unique
     * @param model
     * @returns {*}
     * @memberof UmbDocumentTypeTemplateServerDataSource
     */
    async createTemplate(unique, model) {
        const { data, error } = await tryExecute(this.#host, DocumentTypeService.postDocumentTypeByIdTemplate({
            path: { id: unique },
            body: {
                name: model.name,
                alias: model.alias,
                isDefault: model.isDefault,
            },
        }));
        if (data) {
            return { data: data };
        }
        return { error };
    }
}
