export type OrdersAppModelsOrderItemOrderItemStatusChoices = 'open' | 'shipped' | 'cancelled' | 'returned'; export type OrderItemSchema = {return_tracking_key: string | null, shipment_tracking_key: string | null, sku: string, status: OrdersAppModelsOrderItemOrderItemStatusChoices, id?: (number | null) | undefined, vat?: number | undefined, price_without_tax: number, price_with_tax: number}; export type OrdersAppModelsOrderOrderStatusChoices = 'open' | 'shipped' | 'cancelled' | 'returned' | 'mixed'; export type GetOrderSchema = {order_items: Array, order_number: string, carrier_key: string, cost_without_tax: number, cost_with_tax: number, delivery_document_url: string, status: OrdersAppModelsOrderOrderStatusChoices, customer_key: string, shop: number, created_at: string, updated_at: string, fulfillment_type?: string | undefined, payment_method?: (string | null) | undefined, billing_street: string, billing_zip_code: string, billing_city: string, billing_country_code: string, billing_recipient_gender?: (string | null) | undefined, billing_recipient_first_name: string, billing_recipient_last_name: string, billing_additional?: (string | null) | undefined, shipping_street?: (string | null) | undefined, shipping_zip_code?: (string | null) | undefined, shipping_city?: (string | null) | undefined, shipping_country_code?: (string | null) | undefined, shipping_additional?: (string | null) | undefined, shipping_collection_point_key?: (string | null) | undefined, shipping_collection_point_type?: (string | null) | undefined, shipping_collection_point_description?: (string | null) | undefined, customer_phone?: (string | null) | undefined, customer_email?: (string | null) | undefined, shipping_recipient_gender?: (string | null) | undefined, shipping_recipient_first_name: string, shipping_recipient_last_name: string, currency_code: string}; export type OrderCreatedWebhookSchema = {id: number, event: 'order.created', timestamp?: string | undefined, message: GetOrderSchema, subscription_id?: (number | null) | undefined}; export type CreateApiApiV1WebhooksOrderCreatedArgs = {body: OrderCreatedWebhookSchema}; export type CreateApiApiV1WebhooksOrderCreatedOptions = {baseUrl: string, APIKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Order Created Webhook * * POST /api/v1/webhooks/order-created */ export const createApiApiV1WebhooksOrderCreated = async (args: CreateApiApiV1WebhooksOrderCreatedArgs, options: CreateApiApiV1WebhooksOrderCreatedOptions) => { const {baseUrl, fetch: fetchFn = fetch, APIKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (APIKeyAuth !== undefined) headers.set("X-API-Key", APIKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/webhooks/order-created${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 };