export type BeezUPCommonChannelId = unknown; export type ReportFilterPeriodType = 'Custom' | 'Yesterday' | 'Last7Days' | 'LastWeek' | 'ThisMonth' | 'Last30Days' | 'LastMonth' | 'Last60Days' | 'Last90Days' | 'Last3Months'; export type BeezUPCommonCatalogCategoryFilter = {categoryPath?: Array | undefined}; export type PerformanceIndicatorType = 'ClickCount' | 'Cost' | 'OrderCount' | 'ProductCount' | 'SoldProductCount' | 'DisabledProductCount' | 'EnabledProductCount' | 'TotalSales' | 'Margin' | 'ROI' | 'PerformanceIndicator'; export type PerformanceIndicatorFilterOperatorName = string; export type PerformanceIndicatorFilter = {performanceIndicator: PerformanceIndicatorType, operatorName: PerformanceIndicatorFilterOperatorName, value: number}; export type MarginType = 'Tracker' | 'Global'; export type LinkClickToOrderType = 'OnPurchaseDate' | 'OnClickDate'; export type PerformanceIndicatorFormulaParameterType = 'Cost' | 'TotalSales' | 'Margin' | 'TotalSalesMinusCost' | 'MarginMinusCost' | 'OrderCount' | 'ClickCount' | 'SoldProductCount' | 'One'; export type PerformanceIndicatorFormulaOperatorName = 'Multiply' | 'Divide'; export type PerformanceIndicatorFormula = {firstParameter?: PerformanceIndicatorFormulaParameterType | undefined, operatorName?: PerformanceIndicatorFormulaOperatorName | undefined, secondParameter?: PerformanceIndicatorFormulaParameterType | undefined, thirdParameter?: number | undefined}; export type ReportAdvancedFilters = {marginType: MarginType, globalMarginPercent?: number | undefined, linkClickToOrderType: LinkClickToOrderType, linkClickToOrderMaxDay?: number | undefined, onlyPaymentValidatedOrders: boolean, onlyDirectSales: boolean, performanceIndicatorFormula: PerformanceIndicatorFormula}; export type OrderByDirection = 'Ascending' | 'Descending'; export type ReportType = 'ByChannel' | 'ByCategory' | 'ByProduct' | 'ByDay'; export type BeezUPCommonCatalogColumnId = unknown; export type ProductColumnsToDisplay = Array; export type ProductStateFilter = 'All' | 'Enabled' | 'Disabled'; export type AnalyticsProductColumnFilterOperatorName = string; export type AnalyticsProductColumnFilter = {operatorName: AnalyticsProductColumnFilterOperatorName, values?: Array | undefined}; export type AdditionalAnalyticsProductColumnFilters = {[key: string]: AnalyticsProductColumnFilter}; export type AnalyticsProductColumnFilters = {sku?: string | undefined, title?: string | undefined, additionalAnalyticsProductColumnFilters?: AdditionalAnalyticsProductColumnFilters | undefined}; export type BeezUPCommonPageSize = number; export type BeezUPCommonPageNumber = number; export type OptimiseRequest = {channelId?: BeezUPCommonChannelId | undefined, periodType: ReportFilterPeriodType, beginPeriodUtcDate: string, endPeriodUtcDate: string, categoryFilter?: BeezUPCommonCatalogCategoryFilter | undefined, performanceIndicatorFilters?: Array | undefined, advancedFilters: ReportAdvancedFilters, orderBy?: PerformanceIndicatorType | undefined, orderByDirection?: OrderByDirection | undefined, reportType: ReportType, productColumnsToDisplay?: ProductColumnsToDisplay | undefined, productState?: ProductStateFilter | undefined, analyticsProductColumnFilters?: AnalyticsProductColumnFilters | undefined, pageSize?: BeezUPCommonPageSize | undefined, pageNumber?: BeezUPCommonPageNumber | undefined}; export type CreateApiV2UserAnalyticsStoreIdOptimisationsActionNameArgs = {storeId: unknown, actionName: 'reenable' | 'disable', body: OptimiseRequest}; export type CreateApiV2UserAnalyticsStoreIdOptimisationsActionNameOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Optimise products by page * * POST /v2/user/analytics/{storeId}/optimisations/{actionName} */ export const createApiV2UserAnalyticsStoreIdOptimisationsActionName = async (args: CreateApiV2UserAnalyticsStoreIdOptimisationsActionNameArgs, options?: CreateApiV2UserAnalyticsStoreIdOptimisationsActionNameOptions) => { const {baseUrl = "https://api.beezup.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v2/user/analytics/${encodeURIComponent(String(args.storeId))}/optimisations/${encodeURIComponent(String(args.actionName))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };