import {z} from 'zod' export type GetApiApiPlatformConfigurationOptions = {baseUrl?: string | undefined, FrontBearerToken?: string | undefined, fetch?: typeof fetch | undefined}; export const pC01Response200FeaturesCatalog = z.object({allow_shop_contribution_to_all_channels: z.boolean(), exclude_invalid_products: z.boolean(), list_of_multiple_values_separator: z.string(), product_acceptance_by_channel: z.boolean(), product_data_validation_by_channel: z.boolean(), product_import_only_on_leaf: z.boolean()}); export const pC01Response200FeaturesDirectPaymentCustomerStore = z.object({activated: z.boolean(), refund_cancel_authorized: z.boolean()}); export const pC01Response200FeaturesDropship = z.object({retail_pricing_edition_enabled: z.string().optional(), retail_pricing_enabled: z.boolean().optional()}); export const pC01Response200FeaturesOrderConditions = z.object({lead_time_to_ship: z.boolean(), maximum_order_quantity: z.boolean(), minimum_order_quantity: z.boolean(), package_order_quantity: z.boolean()}); export const pC01Response200FeaturesOrderWorkflows = z.object({no_customer_payment_confirmation: z.boolean(), order_acceptance: z.string(), pause_debit_workflow: z.boolean(), pay_on_due_date: z.boolean(), pay_on_shipment: z.boolean(), sellers_edit_shipping_origin: z.boolean(), shipping_and_billing_details_before_acceptance: z.boolean()}); export const pC01Response200FeaturesPricing = z.object({channel_pricing: z.string(), discount_period_required: z.boolean(), discount_price_creation_in_the_past_blocked: z.boolean(), scheduled_pricing: z.boolean(), volume_discount: z.boolean(), volume_pricing: z.boolean()}); export const pC01Response200FeaturesPromotion = z.object({cart_promotion_campaign: z.boolean(), discount_campaign: z.boolean(), seller_promotion: z.boolean()}); export const pC01Response200FeaturesReturns = z.object({drop_ship: z.boolean().optional(), marketplace: z.boolean().optional(), one_creditor: z.boolean().optional()}); export const pC01Response200FeaturesShipment = z.object({multi_part_item_shipment: z.boolean(), multi_shipment: z.boolean()}); export const pC01Response200FeaturesShopTaxOptionsLocalTaxNumber = z.object({mandatory: z.boolean(), validation_regex: z.string().optional()}); export const pC01Response200FeaturesShopTaxOptionsTaxIdentificationNumber = z.object({mandatory: z.boolean(), validation_regex: z.string().optional()}); export const pC01Response200FeaturesShopTaxOptions = z.object({local_tax_number: pC01Response200FeaturesShopTaxOptionsLocalTaxNumber.optional(), tax_identification_number: pC01Response200FeaturesShopTaxOptionsTaxIdentificationNumber}); export const pC01Response200FeaturesTaxCollection = z.object({activated: z.string(), product_tax_code_mandatory: z.boolean(), tax_collection_by_operator: z.boolean()}); export const pC01Response200FeaturesTaxIdNumber = z.object({mandatory: z.boolean(), validation_regex: z.string().optional()}); export const pC01Response200FeaturesWarehouses = z.object({geolocation: z.boolean(), restricted_countries: z.array(z.string())}); export const pC01Response200Features = z.object({catalog: pC01Response200FeaturesCatalog, circular_economy_data_collection: z.boolean(), competitive_pricing_tool: z.boolean(), direct_payment_customer_store: pC01Response200FeaturesDirectPaymentCustomerStore, disable_seller_alternative_carrier: z.boolean(), dropship: pC01Response200FeaturesDropship, kyc_status_per_seller: z.boolean(), lead_time_to_ship_by_sellers_enabled: z.string(), multi_currency: z.boolean(), multi_payout_psp_per_seller: z.boolean(), no_reply_needed: z.boolean(), offer_prices_decimals: z.string(), operator_csv_delimiter: z.string(), order_conditions: pC01Response200FeaturesOrderConditions, order_tax_mode: z.string(), order_workflows: pC01Response200FeaturesOrderWorkflows, payment_confirmation: z.boolean(), pricing: pC01Response200FeaturesPricing, product_data_validation_by_channel: z.boolean(), promotion: pC01Response200FeaturesPromotion, returns: pC01Response200FeaturesReturns, shipment: pC01Response200FeaturesShipment, shop_tax_options: pC01Response200FeaturesShopTaxOptions, tax_collection: pC01Response200FeaturesTaxCollection, tax_id_number: pC01Response200FeaturesTaxIdNumber, warehouses: pC01Response200FeaturesWarehouses}); export const pC01Response200ModulesTaxManagerTaxProvider = z.object({avalara: z.boolean(), vertex: z.boolean()}); export const pC01Response200ModulesTaxManager = z.object({activated: z.boolean(), tax_provider: pC01Response200ModulesTaxManagerTaxProvider}); export const pC01Response200Modules = z.object({mirakl_catalog_integrator: z.boolean(), mirakl_catalog_manager: z.boolean(), mirakl_catalog_transformer: z.boolean(), mirakl_platform_services: z.boolean(), offer_management: z.boolean(), offer_management_mode: z.string().optional(), order_management: z.boolean(), order_management_mode: z.string().optional(), promotions: z.boolean(), quotes: z.boolean(), tax_manager: pC01Response200ModulesTaxManager}); export const pC01Response200PlatformConfigurationCustomerModel = z.object({b2b: z.boolean(), b2c: z.boolean()}); export const pC01Response200PlatformConfigurationEnhancedSellerInvoicing = z.object({enabled: z.boolean()}); export const pC01Response200PlatformConfigurationPlatformModel = z.object({drop_ship: z.boolean(), marketplace: z.boolean(), one_creditor: z.boolean()}); export const pC01Response200PlatformConfiguration = z.object({customer_model: pC01Response200PlatformConfigurationCustomerModel, enhanced_seller_invoicing: pC01Response200PlatformConfigurationEnhancedSellerInvoicing, platform_model: pC01Response200PlatformConfigurationPlatformModel}); export const pC01Response200 = z.object({features: pC01Response200Features, modules: pC01Response200Modules, platform_configuration: pC01Response200PlatformConfiguration, platform_name: z.string(), tenant_name: z.string(), timezone: z.string()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * PC01 - List platform configurations * * GET /api/platform/configuration * * Also accepts auth: OAuth-2 */ export const getApiApiPlatformConfiguration = async (options?: GetApiApiPlatformConfigurationOptions) => { const {baseUrl = "https://your-instance.mirakl.net", fetch: fetchFn = fetch, FrontBearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (FrontBearerToken !== undefined) headers.set('authorization', `Bearer ${FrontBearerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/platform/configuration${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(pC01Response200, await res.json()) };