UNPKG

@pfantato/printful-ts

Version:

Typescript SDK to integrate with Printful

1,246 lines (1,245 loc) 43.6 kB
import type { Options } from 'ky'; import { CreateOrderBody, CreateOrderEstimationTaskBody, CreateOrderItemBody, GetOrderItemPathParams as OrderItemPathParams, GetOrderItemsSearchParams, ListOrdersSearchParams, type StoreId, type ExternalIdParam } from '@printful-ts/schemas'; import { PrintfulApiService } from './printful-api.service'; import { ListOrderShipmentsSearchParams } from '@printful-ts/schemas/endpoints/orders/list-order-shipments.schema'; export declare class OrdersService extends PrintfulApiService { listOrders(params?: ListOrdersSearchParams, options?: Options): Promise<{ _links?: { self?: { href?: string; }; first?: { href?: string; }; last?: { href?: string; }; next?: { href?: string; }; previous?: { href?: string; }; }; data?: { status?: "partial" | "failed" | "pending" | "draft" | "canceled" | "onhold" | "inprocess" | "fulfilled"; store_id?: number; id?: number; _links?: { self?: { href?: string; }; order_items?: { href?: string; }; shipments?: { href?: string; }; }; shipping?: string; costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; digitization?: string; additional_fee?: string; fulfillment_fee?: string; retail_delivery_fee?: string; vat?: string; tax?: string; }; retail_costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; vat?: string; tax?: string; }; external_id?: string; created_at?: string; updated_at?: string; recipient?: { email?: string; name?: string; company?: string; address1?: string; address2?: string; city?: string; state_code?: string; state_name?: string; country_code?: string; country_name?: string; zip?: string; phone?: string; tax_number?: string; }; order_items?: ({ name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "warehouse"; external_id?: string; quantity?: number; retail_price?: string; warehouse_product_variant_id?: number; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; placements?: { status?: "failed" | "ok"; placement_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; layers?: { type?: string; layer_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; }[]; placement?: string; technique?: "dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm"; status_explanation?: string; }[]; source?: "catalog"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_options?: { value?: boolean; name?: "inside_pocket" | "stitch_color" | "notes" | "lifelike" | "custom_border_color" | "base_color" | "trim_color" | "color_reduction_mode"; }[]; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "product_template"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_template_id?: string | number; })[]; }[]; paging?: { total?: number; offset?: number; limit?: number; }; }>; getOrder(order_id: ExternalIdParam, store_id?: StoreId, options?: Options): Promise<{ data?: { status?: "partial" | "failed" | "pending" | "draft" | "canceled" | "onhold" | "inprocess" | "fulfilled"; store_id?: number; id?: number; _links?: { self?: { href?: string; }; order_items?: { href?: string; }; order_confirmation?: { href?: string; }; order_invoices?: { href?: string; }; shipments?: { href?: string; }; }; shipping?: string; costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; digitization?: string; additional_fee?: string; fulfillment_fee?: string; retail_delivery_fee?: string; vat?: string; tax?: string; }; retail_costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; vat?: string; tax?: string; }; external_id?: string; created_at?: string; updated_at?: string; recipient?: { email?: string; name?: string; company?: string; address1?: string; address2?: string; city?: string; state_code?: string; state_name?: string; country_code?: string; country_name?: string; zip?: string; phone?: string; tax_number?: string; }; order_items?: ({ name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "warehouse"; external_id?: string; quantity?: number; retail_price?: string; warehouse_product_variant_id?: number; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; placements?: { status?: "failed" | "ok"; placement_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; layers?: { type?: string; layer_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; }[]; placement?: string; technique?: "dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm"; status_explanation?: string; }[]; source?: "catalog"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_options?: { value?: boolean; name?: "inside_pocket" | "stitch_color" | "notes" | "lifelike" | "custom_border_color" | "base_color" | "trim_color" | "color_reduction_mode"; }[]; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "product_template"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_template_id?: string | number; })[]; customization?: { gift?: { message?: string; subject?: string; }; packing_slip?: { email?: string; message?: string; phone?: string; logo_url?: string; store_name?: string; custom_order_id?: string; }; }; }; }>; createOrder(body: CreateOrderBody, options?: Options): Promise<{ data?: { status?: "partial" | "failed" | "pending" | "draft" | "canceled" | "onhold" | "inprocess" | "fulfilled"; store_id?: number; id?: number; _links?: { self?: { href?: string; }; order_items?: { href?: string; }; order_confirmation?: { href?: string; }; order_invoices?: { href?: string; }; shipments?: { href?: string; }; }; shipping?: string; costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; digitization?: string; additional_fee?: string; fulfillment_fee?: string; retail_delivery_fee?: string; vat?: string; tax?: string; }; retail_costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; vat?: string; tax?: string; }; external_id?: string; created_at?: string; updated_at?: string; recipient?: { email?: string; name?: string; company?: string; address1?: string; address2?: string; city?: string; state_code?: string; state_name?: string; country_code?: string; country_name?: string; zip?: string; phone?: string; tax_number?: string; }; order_items?: ({ name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "warehouse"; external_id?: string; quantity?: number; retail_price?: string; warehouse_product_variant_id?: number; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; placements?: { status?: "failed" | "ok"; placement_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; layers?: { type?: string; layer_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; }[]; placement?: string; technique?: "dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm"; status_explanation?: string; }[]; source?: "catalog"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_options?: { value?: boolean; name?: "inside_pocket" | "stitch_color" | "notes" | "lifelike" | "custom_border_color" | "base_color" | "trim_color" | "color_reduction_mode"; }[]; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "product_template"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_template_id?: string | number; })[]; customization?: { gift?: { message?: string; subject?: string; }; packing_slip?: { email?: string; message?: string; phone?: string; logo_url?: string; store_name?: string; custom_order_id?: string; }; }; }; }>; updateOrder(order_id: ExternalIdParam, body: CreateOrderBody, options?: Options): Promise<{ data?: { status?: "partial" | "failed" | "pending" | "draft" | "canceled" | "onhold" | "inprocess" | "fulfilled"; store_id?: number; id?: number; _links?: { self?: { href?: string; }; order_items?: { href?: string; }; order_confirmation?: { href?: string; }; order_invoices?: { href?: string; }; shipments?: { href?: string; }; }; shipping?: string; costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; digitization?: string; additional_fee?: string; fulfillment_fee?: string; retail_delivery_fee?: string; vat?: string; tax?: string; }; retail_costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; vat?: string; tax?: string; }; external_id?: string; created_at?: string; updated_at?: string; recipient?: { email?: string; name?: string; company?: string; address1?: string; address2?: string; city?: string; state_code?: string; state_name?: string; country_code?: string; country_name?: string; zip?: string; phone?: string; tax_number?: string; }; order_items?: ({ name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "warehouse"; external_id?: string; quantity?: number; retail_price?: string; warehouse_product_variant_id?: number; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; placements?: { status?: "failed" | "ok"; placement_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; layers?: { type?: string; layer_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; }[]; placement?: string; technique?: "dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm"; status_explanation?: string; }[]; source?: "catalog"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_options?: { value?: boolean; name?: "inside_pocket" | "stitch_color" | "notes" | "lifelike" | "custom_border_color" | "base_color" | "trim_color" | "color_reduction_mode"; }[]; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "product_template"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_template_id?: string | number; })[]; customization?: { gift?: { message?: string; subject?: string; }; packing_slip?: { email?: string; message?: string; phone?: string; logo_url?: string; store_name?: string; custom_order_id?: string; }; }; }; }>; confirmOrder(order_id: ExternalIdParam, store_id?: StoreId, options?: Options): Promise<{ _links?: { order?: { href?: string; }; order_items?: { href?: string; }; shipments?: { href?: string; }; _self?: { href?: string; }; }; data?: { status?: "partial" | "failed" | "pending" | "draft" | "canceled" | "onhold" | "inprocess" | "fulfilled"; store_id?: number; id?: number; _links?: { self?: { href?: string; }; order_items?: { href?: string; }; order_confirmation?: { href?: string; }; order_invoices?: { href?: string; }; shipments?: { href?: string; }; }; shipping?: string; costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; digitization?: string; additional_fee?: string; fulfillment_fee?: string; retail_delivery_fee?: string; vat?: string; tax?: string; }; retail_costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; vat?: string; tax?: string; }; external_id?: string; created_at?: string; updated_at?: string; recipient?: { email?: string; name?: string; company?: string; address1?: string; address2?: string; city?: string; state_code?: string; state_name?: string; country_code?: string; country_name?: string; zip?: string; phone?: string; tax_number?: string; }; order_items?: ({ name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "warehouse"; external_id?: string; quantity?: number; retail_price?: string; warehouse_product_variant_id?: number; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; placements?: { status?: "failed" | "ok"; placement_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; layers?: { type?: string; layer_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; }[]; placement?: string; technique?: "dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm"; status_explanation?: string; }[]; source?: "catalog"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_options?: { value?: boolean; name?: "inside_pocket" | "stitch_color" | "notes" | "lifelike" | "custom_border_color" | "base_color" | "trim_color" | "color_reduction_mode"; }[]; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "product_template"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_template_id?: string | number; })[]; customization?: { gift?: { message?: string; subject?: string; }; packing_slip?: { email?: string; message?: string; phone?: string; logo_url?: string; store_name?: string; custom_order_id?: string; }; }; }; }>; deleteOrder(order_id: ExternalIdParam, store_id?: StoreId, options?: Options): Promise<unknown>; listOrderItems(order_id: ExternalIdParam, params: GetOrderItemsSearchParams, options?: Options): Promise<{ _links?: { self?: { href?: string; }; first?: { href?: string; }; last?: { href?: string; }; next?: { href?: string; }; previous?: { href?: string; }; order?: { href?: string; }; }; data?: ({ name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "warehouse"; external_id?: string; quantity?: number; retail_price?: string; warehouse_product_variant_id?: number; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; placements?: { status?: "failed" | "ok"; placement_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; layers?: { type?: string; layer_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; }[]; placement?: string; technique?: "dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm"; status_explanation?: string; }[]; source?: "catalog"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_options?: { value?: boolean; name?: "inside_pocket" | "stitch_color" | "notes" | "lifelike" | "custom_border_color" | "base_color" | "trim_color" | "color_reduction_mode"; }[]; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "product_template"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_template_id?: string | number; })[]; }>; getOrderItem(path_params: OrderItemPathParams, store_id: number, options?: Options): Promise<{ _links?: { self?: { href?: string; }; order?: { href?: string; }; shipments?: { href?: string; }; all_items?: { href?: string; }; }; data?: { name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "warehouse"; external_id?: string; quantity?: number; retail_price?: string; warehouse_product_variant_id?: number; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; placements?: { status?: "failed" | "ok"; placement_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; layers?: { type?: string; layer_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; }[]; placement?: string; technique?: "dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm"; status_explanation?: string; }[]; source?: "catalog"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_options?: { value?: boolean; name?: "inside_pocket" | "stitch_color" | "notes" | "lifelike" | "custom_border_color" | "base_color" | "trim_color" | "color_reduction_mode"; }[]; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "product_template"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_template_id?: string | number; }; }>; createOrderItem(order_id: ExternalIdParam, body: CreateOrderItemBody, options?: Options): Promise<{ _links?: { self?: { href?: string; }; first?: { href?: string; }; last?: { href?: string; }; next?: { href?: string; }; previous?: { href?: string; }; order?: { href?: string; }; }; data?: ({ name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "warehouse"; external_id?: string; quantity?: number; retail_price?: string; warehouse_product_variant_id?: number; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; placements?: { status?: "failed" | "ok"; placement_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; layers?: { type?: string; layer_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; }[]; placement?: string; technique?: "dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm"; status_explanation?: string; }[]; source?: "catalog"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_options?: { value?: boolean; name?: "inside_pocket" | "stitch_color" | "notes" | "lifelike" | "custom_border_color" | "base_color" | "trim_color" | "color_reduction_mode"; }[]; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "product_template"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_template_id?: string | number; })[]; }>; updateOrderItem(path_params: OrderItemPathParams, body: CreateOrderItemBody, options?: Options): Promise<{ _links?: { self?: { href?: string; }; first?: { href?: string; }; last?: { href?: string; }; next?: { href?: string; }; previous?: { href?: string; }; order?: { href?: string; }; }; data?: ({ name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "warehouse"; external_id?: string; quantity?: number; retail_price?: string; warehouse_product_variant_id?: number; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; placements?: { status?: "failed" | "ok"; placement_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; layers?: { type?: string; layer_options?: { values?: unknown[]; type?: string; name?: string; techniques?: ("dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm")[]; }[]; }[]; placement?: string; technique?: "dtg" | "digital" | "cut-sew" | "uv" | "embroidery" | "sublimation" | "dtfilm"; status_explanation?: string; }[]; source?: "catalog"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_options?: { value?: boolean; name?: "inside_pocket" | "stitch_color" | "notes" | "lifelike" | "custom_border_color" | "base_color" | "trim_color" | "color_reduction_mode"; }[]; } | { name?: string; id?: number; _links?: { self?: { href?: string; }; }; source?: "product_template"; external_id?: string; quantity?: number; retail_price?: string; catalog_variant_id?: number; product_template_id?: string | number; })[]; }>; deleteOrderItem(path_params: OrderItemPathParams, store_id: number, options?: Options): Promise<unknown>; listShipments(order_id: ExternalIdParam, params: ListOrderShipmentsSearchParams, options?: Options): Promise<{ _links?: { self?: { href?: string; }; first?: { href?: string; }; last?: { href?: string; }; next?: { href?: string; }; previous?: { href?: string; }; }; data?: { id?: number; _links?: { self?: { href?: string; }; order?: { href?: string; }; }; order_id?: number; carrier?: string; shipment_status?: "pending" | "canceled" | "onhold" | "packaged" | "shipped" | "returned" | "outstock"; shipped_at?: string; delivery_status?: "unknown" | "canceled" | "delivered" | "pre_transit" | "in_transit" | "out_for_delivery" | "available_for_pickup" | "return_to_sender" | "failure"; delivery_at?: string; departure_addess?: { state_code?: string; country_code?: string; country_name?: string; }; is_reshipment?: boolean; tracking_url?: string; tracking_events?: { description?: string; triggered_at?: string; }[]; shipment_items?: { id?: number; _links?: { order_item?: { href?: string; }; }; quantity?: number; order_item_id?: number; order_item_external_id?: string; order_item_name?: string; }[]; }[]; paging?: { total?: number; offset?: number; limit?: number; }; }>; getInvoice(order_id: ExternalIdParam, store_id?: StoreId, options?: Options): Promise<{ data?: { _links?: { self?: { href?: string; }; order?: { href?: string; }; }; media_type?: string; content?: string; }; }>; getOrderEstimationTask(task_id: string, store_id?: StoreId, options?: Options): Promise<{ data?: { status?: "failed" | "pending" | "completed"; id?: number; costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; digitization?: string; additional_fee?: string; fulfillment_fee?: string; retail_delivery_fee?: string; vat?: string; tax?: string; }; retail_costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; vat?: string; tax?: string; }; failure_reasons?: string[]; }; }>; createOrderEstimationTask(body: CreateOrderEstimationTaskBody, options?: Options): Promise<{ data?: { status?: "failed" | "pending" | "completed"; id?: number; costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; digitization?: string; additional_fee?: string; fulfillment_fee?: string; retail_delivery_fee?: string; vat?: string; tax?: string; }; retail_costs?: { total?: string; currency?: string; calculation_status?: "done" | "calculating" | "failed"; subtotal?: string; discount?: string; shipping?: string; vat?: string; tax?: string; }; failure_reasons?: string[]; }; }>; }