var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import SDK, { typedDataResponse, typedVoidResponse, blobResponse } from '@komi-app/sdk';
import { CreateLocalizationError, CreatePresaveError, CreateProfileError, DeleteLinkRedirectError, DeleteLocalizationError, DeleteMetaPixelError, DeleteProfileLinkError, EnableLinkRedirectError, EnableLocalizationError, LinkRedirectError, ModulesError, PublishProfileError, SetLinkRedirectError, SetPresaveMarketingPermissionError, UpdateCurrencyError, ProfilePageError, UpdateHeaderError, UpdateLocalizationError, SetMetaPixelError, UpdateModulesError, UpdateNameError, UpdateProfileLinksError, UpdatePrivacyPolicyError, UpdateProfileStatusError, UpdateThemeError, UpdateHandleError, ValidateMetaPixelError, ValidatePodcastLinksError, GetLatestPodcastsError, GetYoutubeCollectionsError, GetPreReleaseCountError, GetListPreReleaseError, ExportPreReleaseCSVError, GetFormDataCountError, ExportDataCaptureCSVError, GetDataCaptureFormError, GetListProfilesError, GetHandleError, ResolveTikTokURLError, CreateVideoDirectUploadError, GetVideoError, ClaimPreviewProfileError, ConnectTikTokOAuthError, ConnectInstagramOAuthError } from './shared.js';
export class Profiles extends SDK {
    create(data) {
        return __awaiter(this, void 0, void 0, function* () {
            const { profile } = yield this.post('/v1', { body: data }).then(typedDataResponse(CreateProfileError));
            return profile;
        });
    }
    createLocalization(data) {
        return __awaiter(this, void 0, void 0, function* () {
            const { localizationId } = yield this.post('/v1/localization', {
                body: data
            }).then(typedDataResponse(CreateLocalizationError));
            return localizationId;
        });
    }
    createPresave(localizationId, data) {
        return __awaiter(this, void 0, void 0, function* () {
            const { userCapture } = yield this.post(`/v1/end-user/music-presave/${localizationId}`, { body: data }).then(typedDataResponse(CreatePresaveError));
            return userCapture;
        });
    }
    deleteLink(localizationId, type) {
        return this.delete(`/v1/links/${localizationId}/${type}`).then(typedVoidResponse(DeleteProfileLinkError));
    }
    deleteLinkRedirect() {
        return this.delete('/v1/link-redirect').then(typedVoidResponse(DeleteLinkRedirectError));
    }
    deleteLocalization(localizationId) {
        return this.delete(`/v1/localization/${localizationId}`).then(typedVoidResponse(DeleteLocalizationError));
    }
    deleteMetaPixel(localizationId) {
        return this.delete(`/v1/meta-pixel/${localizationId}`).then(typedVoidResponse(DeleteMetaPixelError));
    }
    enableLinkRedirect(enabled) {
        return this.patch('/v1/link-redirect', {
            body: {
                isEnabled: enabled
            }
        }).then(typedVoidResponse(EnableLinkRedirectError));
    }
    enableLocalization(enabled) {
        return this.patch('/v1/localization', {
            body: {
                isLocalizationEnabled: enabled
            }
        }).then(typedVoidResponse(EnableLocalizationError));
    }
    getProfile() {
        return this.get('/v1').then(typedDataResponse(ProfilePageError));
    }
    getLinkRedirect() {
        return __awaiter(this, void 0, void 0, function* () {
            const { linkRedirect } = yield this.get('/v1/link-redirect').then(typedDataResponse(LinkRedirectError));
            return linkRedirect;
        });
    }
    getModules(localizationId) {
        return __awaiter(this, void 0, void 0, function* () {
            const path = localizationId
                ? `/v1/modules/${localizationId}`
                : '/v1/modules';
            const { modules } = yield this.get(path).then(typedDataResponse(ModulesError));
            return modules;
        });
    }
    publish(data) {
        return this.post('/v1/publish', { body: data }).then(typedVoidResponse(PublishProfileError));
    }
    setLinkRedirect(data) {
        return __awaiter(this, void 0, void 0, function* () {
            const { linkRedirect } = yield this.put('/v1/link-redirect', {
                body: data
            }).then(typedDataResponse(SetLinkRedirectError));
            return linkRedirect;
        });
    }
    setPresaveMarketingPermission(localizationId, data) {
        return this.put(`/v1/end-user/music-presave/${localizationId}/marketing-permission`, { body: data }).then(typedVoidResponse(SetPresaveMarketingPermissionError));
    }
    updateCurrency(data) {
        return this.put('/v1/currency', { body: data }).then(typedVoidResponse(UpdateCurrencyError));
    }
    updateHeader(localizationId, data) {
        return this.put(`/v1/header/${localizationId}`, { body: data }).then(typedVoidResponse(UpdateHeaderError));
    }
    updateLinks(localizationId, data) {
        return __awaiter(this, void 0, void 0, function* () {
            const { links } = yield this.put(`/v1/links/${localizationId}`, {
                body: data
            }).then(typedDataResponse(UpdateProfileLinksError));
            return links;
        });
    }
    updateLocalization(localizationId, data) {
        return this.put(`/v1/localization/${localizationId}`, { body: data }).then(typedVoidResponse(UpdateLocalizationError));
    }
    setMetaPixel(localizationId, data) {
        return this.put(`/v1/meta-pixel/${localizationId}`, { body: data }).then(typedVoidResponse(SetMetaPixelError));
    }
    updateModules(localizationId, data) {
        return __awaiter(this, void 0, void 0, function* () {
            const { modules } = yield this.put(`/v1/modules/${localizationId}`, {
                body: data
            }).then(typedDataResponse(UpdateModulesError));
            return modules;
        });
    }
    getHandle(handle) {
        return this.get(`/v1/handle/${handle}`).then(typedDataResponse(GetHandleError));
    }
    updateHandle(data) {
        return this.put('/v1/handle', { body: data }).then(typedVoidResponse(UpdateHandleError));
    }
    updateName(data) {
        return this.put('/v1/name', { body: data }).then(typedVoidResponse(UpdateNameError));
    }
    updatePrivacyPolicy(localizationId, data) {
        return this.put(`/v1/privacy-policy/${localizationId}`, {
            body: data
        }).then(typedVoidResponse(UpdatePrivacyPolicyError));
    }
    updateStatus(data) {
        return this.put('/v1/status', { body: data }).then(typedVoidResponse(UpdateProfileStatusError));
    }
    updateTheme(localizationId, data) {
        return __awaiter(this, void 0, void 0, function* () {
            const { theme } = yield this.put(`/v1/theme/${localizationId}`, {
                body: data
            }).then(typedDataResponse(UpdateThemeError));
            return theme;
        });
    }
    validateMetaPixel(localizationId, data) {
        return this.post(`/v1/meta-pixel/${localizationId}/validate`, {
            body: data
        }).then(typedVoidResponse(ValidateMetaPixelError));
    }
    validatePodcastLinks(data) {
        return this.post('/v1/podcasts/validate-url', { body: data }).then(typedVoidResponse(ValidatePodcastLinksError));
    }
    getLatestPodcasts(query) {
        return this.get('/v1/podcasts', { queryParams: query }).then(typedDataResponse(GetLatestPodcastsError));
    }
    getYoutubeCollection(query) {
        return __awaiter(this, void 0, void 0, function* () {
            const { collection } = yield this.get('/v1/youtube', {
                queryParams: query
            }).then(typedDataResponse(GetYoutubeCollectionsError));
            return collection;
        });
    }
    getPreReleaseCount(data) {
        return __awaiter(this, void 0, void 0, function* () {
            const { count } = yield this.get('/v1/music-presaves/count', {
                queryParams: data
            }).then(typedDataResponse(GetPreReleaseCountError));
            return count;
        });
    }
    getListPreRelease() {
        return __awaiter(this, void 0, void 0, function* () {
            const { presaves } = yield this.get('/v1/music-presaves').then(typedDataResponse(GetListPreReleaseError));
            return presaves;
        });
    }
    exportPreReleaseCSV(data) {
        return this.get('/v1/music-presaves/export', { queryParams: data }).then(blobResponse(ExportPreReleaseCSVError));
    }
    getDataFormCount(data) {
        return __awaiter(this, void 0, void 0, function* () {
            const { count } = yield this.get('/v1/forms/answers/count', {
                queryParams: data
            }).then(typedDataResponse(GetFormDataCountError));
            return count;
        });
    }
    exportDataCaptureCSV(data) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.get('/v1/forms/answers', { queryParams: data }).then(blobResponse(ExportDataCaptureCSVError));
        });
    }
    getDataCaptureForms() {
        return __awaiter(this, void 0, void 0, function* () {
            const { forms } = yield this.get('/v1/forms').then(typedDataResponse(GetDataCaptureFormError));
            return forms;
        });
    }
    getListProfiles(data) {
        return this.get('/v1/list', { queryParams: data }).then(typedDataResponse(GetListProfilesError));
    }
    resolveTikTokURL(url) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.get(`/v1/tiktok/resolve?url=${url}`).then(typedDataResponse(ResolveTikTokURLError));
        });
    }
    createVideoDirectUpload() {
        return this.post('/v1/video/direct-upload-url').then(typedDataResponse(CreateVideoDirectUploadError));
    }
    getVideo(id) {
        return this.get(`/v1/video/${id}`).then(typedDataResponse(GetVideoError));
    }
    claimPreviewProfile(data) {
        return this.post('/v1/previews/claim', { body: data }).then(typedVoidResponse(ClaimPreviewProfileError));
    }
    connectTikTokOAuth() {
        return this.get('/v1/tiktok/auth/redirect').then(typedVoidResponse(ConnectTikTokOAuthError));
    }
    connectInstagramOAuth() {
        return this.get('/v1/instagram/auth/redirect').then(typedVoidResponse(ConnectInstagramOAuthError));
    }
}
export default Profiles;
