From a89dc7e1a460734000628ba7aafbfbbac7352392 Mon Sep 17 00:00:00 2001 From: Stephane Segning Lambou Date: Tue, 17 Dec 2024 06:51:32 +0100 Subject: [PATCH] initial --- packages/.gitignore | 4 +- packages/vymalo-keycloak/package.json | 2 +- packages/vymalo-mail/package.json | 2 +- packages/vymalo-meilisearch/package.json | 2 +- packages/vymalo-minio/package.json | 2 +- packages/vymalo-printful/package.json | 2 +- .../core/generated/printful/core/ApiError.ts | 25 - .../printful/core/ApiRequestOptions.ts | 21 - .../core/generated/printful/core/ApiResult.ts | 7 - .../printful/core/CancelablePromise.ts | 126 - .../core/generated/printful/core/OpenAPI.ts | 57 - .../core/generated/printful/core/request.ts | 387 -- .../src/core/generated/printful/index.ts | 6 - .../core/generated/printful/services.gen.ts | 1844 --------- .../src/core/generated/printful/types.gen.ts | 3668 ----------------- packages/vymalo-ui-preset/package.json | 2 +- 16 files changed, 9 insertions(+), 6148 deletions(-) delete mode 100644 packages/vymalo-printful/src/core/generated/printful/core/ApiError.ts delete mode 100644 packages/vymalo-printful/src/core/generated/printful/core/ApiRequestOptions.ts delete mode 100644 packages/vymalo-printful/src/core/generated/printful/core/ApiResult.ts delete mode 100644 packages/vymalo-printful/src/core/generated/printful/core/CancelablePromise.ts delete mode 100644 packages/vymalo-printful/src/core/generated/printful/core/OpenAPI.ts delete mode 100644 packages/vymalo-printful/src/core/generated/printful/core/request.ts delete mode 100644 packages/vymalo-printful/src/core/generated/printful/index.ts delete mode 100644 packages/vymalo-printful/src/core/generated/printful/services.gen.ts delete mode 100644 packages/vymalo-printful/src/core/generated/printful/types.gen.ts diff --git a/packages/.gitignore b/packages/.gitignore index cc23de4..dddce65 100644 --- a/packages/.gitignore +++ b/packages/.gitignore @@ -1,4 +1,6 @@ **/dist tsconfig.tsbuildinfo -**/tsconfig.tsbuildinfo \ No newline at end of file +**/tsconfig.tsbuildinfo + +generated \ No newline at end of file diff --git a/packages/vymalo-keycloak/package.json b/packages/vymalo-keycloak/package.json index 3c58fdd..5b6fd27 100644 --- a/packages/vymalo-keycloak/package.json +++ b/packages/vymalo-keycloak/package.json @@ -8,7 +8,7 @@ }, "main": "dist/index.js", "scripts": { - "build": "rm -rf {dist,tsconfig.tsbuildinfo} && tsc --build" + "build": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && tsc --build" }, "keywords": [], "author": "", diff --git a/packages/vymalo-mail/package.json b/packages/vymalo-mail/package.json index ae466e8..31ab1f8 100644 --- a/packages/vymalo-mail/package.json +++ b/packages/vymalo-mail/package.json @@ -8,7 +8,7 @@ }, "main": "dist/index.js", "scripts": { - "build": "rm -rf {dist,tsconfig.tsbuildinfo} && tsc --build" + "build": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && tsc --build" }, "keywords": [], "author": "", diff --git a/packages/vymalo-meilisearch/package.json b/packages/vymalo-meilisearch/package.json index d4e7133..d7832b1 100644 --- a/packages/vymalo-meilisearch/package.json +++ b/packages/vymalo-meilisearch/package.json @@ -15,7 +15,7 @@ "./jobs/*": "./dist/jobs/*.js" }, "scripts": { - "build": "rm -rf {dist,tsconfig.tsbuildinfo} && tsc --build" + "build": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && tsc --build" }, "keywords": [], "author": "", diff --git a/packages/vymalo-minio/package.json b/packages/vymalo-minio/package.json index 61184d1..4680ba9 100644 --- a/packages/vymalo-minio/package.json +++ b/packages/vymalo-minio/package.json @@ -8,7 +8,7 @@ }, "main": "dist/index.js", "scripts": { - "build": "rm -rf {dist,tsconfig.tsbuildinfo} && tsc --build" + "build": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && tsc --build" }, "keywords": [], "author": "", diff --git a/packages/vymalo-printful/package.json b/packages/vymalo-printful/package.json index 2fae5c6..c0d1827 100644 --- a/packages/vymalo-printful/package.json +++ b/packages/vymalo-printful/package.json @@ -17,7 +17,7 @@ "./*": "./dist/modules/*/index.js" }, "scripts": { - "prod:build": "rm -rf {dist,tsconfig.tsbuildinfo} && tsc --build", + "prod:build": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && tsc --build", "gen:printful": "cross-env rimraf src/core/generated/printful && openapi-ts", "build": "yarn gen:printful && yarn prod:build" }, diff --git a/packages/vymalo-printful/src/core/generated/printful/core/ApiError.ts b/packages/vymalo-printful/src/core/generated/printful/core/ApiError.ts deleted file mode 100644 index 7491017..0000000 --- a/packages/vymalo-printful/src/core/generated/printful/core/ApiError.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; - -export class ApiError extends Error { - public readonly url: string; - public readonly status: number; - public readonly statusText: string; - public readonly body: unknown; - public readonly request: ApiRequestOptions; - - constructor( - request: ApiRequestOptions, - response: ApiResult, - message: string - ) { - super(message); - - this.name = 'ApiError'; - this.url = response.url; - this.status = response.status; - this.statusText = response.statusText; - this.body = response.body; - this.request = request; - } -} diff --git a/packages/vymalo-printful/src/core/generated/printful/core/ApiRequestOptions.ts b/packages/vymalo-printful/src/core/generated/printful/core/ApiRequestOptions.ts deleted file mode 100644 index 65a21f7..0000000 --- a/packages/vymalo-printful/src/core/generated/printful/core/ApiRequestOptions.ts +++ /dev/null @@ -1,21 +0,0 @@ -export type ApiRequestOptions = { - readonly body?: any; - readonly cookies?: Record; - readonly errors?: Record; - readonly formData?: Record | any[] | Blob | File; - readonly headers?: Record; - readonly mediaType?: string; - readonly method: - | 'DELETE' - | 'GET' - | 'HEAD' - | 'OPTIONS' - | 'PATCH' - | 'POST' - | 'PUT'; - readonly path?: Record; - readonly query?: Record; - readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => Promise; - readonly url: string; -}; diff --git a/packages/vymalo-printful/src/core/generated/printful/core/ApiResult.ts b/packages/vymalo-printful/src/core/generated/printful/core/ApiResult.ts deleted file mode 100644 index 84b9f9d..0000000 --- a/packages/vymalo-printful/src/core/generated/printful/core/ApiResult.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type ApiResult = { - readonly body: TData; - readonly ok: boolean; - readonly status: number; - readonly statusText: string; - readonly url: string; -}; diff --git a/packages/vymalo-printful/src/core/generated/printful/core/CancelablePromise.ts b/packages/vymalo-printful/src/core/generated/printful/core/CancelablePromise.ts deleted file mode 100644 index 08af4a1..0000000 --- a/packages/vymalo-printful/src/core/generated/printful/core/CancelablePromise.ts +++ /dev/null @@ -1,126 +0,0 @@ -export class CancelError extends Error { - constructor(message: string) { - super(message); - this.name = 'CancelError'; - } - - public get isCancelled(): boolean { - return true; - } -} - -export interface OnCancel { - readonly isResolved: boolean; - readonly isRejected: boolean; - readonly isCancelled: boolean; - - (cancelHandler: () => void): void; -} - -export class CancelablePromise implements Promise { - private _isResolved: boolean; - private _isRejected: boolean; - private _isCancelled: boolean; - readonly cancelHandlers: (() => void)[]; - readonly promise: Promise; - private _resolve?: (value: T | PromiseLike) => void; - private _reject?: (reason?: unknown) => void; - - constructor( - executor: ( - resolve: (value: T | PromiseLike) => void, - reject: (reason?: unknown) => void, - onCancel: OnCancel - ) => void - ) { - this._isResolved = false; - this._isRejected = false; - this._isCancelled = false; - this.cancelHandlers = []; - this.promise = new Promise((resolve, reject) => { - this._resolve = resolve; - this._reject = reject; - - const onResolve = (value: T | PromiseLike): void => { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._isResolved = true; - if (this._resolve) this._resolve(value); - }; - - const onReject = (reason?: unknown): void => { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._isRejected = true; - if (this._reject) this._reject(reason); - }; - - const onCancel = (cancelHandler: () => void): void => { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this.cancelHandlers.push(cancelHandler); - }; - - Object.defineProperty(onCancel, 'isResolved', { - get: (): boolean => this._isResolved, - }); - - Object.defineProperty(onCancel, 'isRejected', { - get: (): boolean => this._isRejected, - }); - - Object.defineProperty(onCancel, 'isCancelled', { - get: (): boolean => this._isCancelled, - }); - - return executor(onResolve, onReject, onCancel as OnCancel); - }); - } - - get [Symbol.toStringTag]() { - return 'Cancellable Promise'; - } - - public then( - onFulfilled?: ((value: T) => TResult1 | PromiseLike) | null, - onRejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): Promise { - return this.promise.then(onFulfilled, onRejected); - } - - public catch( - onRejected?: ((reason: unknown) => TResult | PromiseLike) | null - ): Promise { - return this.promise.catch(onRejected); - } - - public finally(onFinally?: (() => void) | null): Promise { - return this.promise.finally(onFinally); - } - - public cancel(): void { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._isCancelled = true; - if (this.cancelHandlers.length) { - try { - for (const cancelHandler of this.cancelHandlers) { - cancelHandler(); - } - } catch (error) { - console.warn('Cancellation threw an error', error); - return; - } - } - this.cancelHandlers.length = 0; - if (this._reject) this._reject(new CancelError('Request aborted')); - } - - public get isCancelled(): boolean { - return this._isCancelled; - } -} diff --git a/packages/vymalo-printful/src/core/generated/printful/core/OpenAPI.ts b/packages/vymalo-printful/src/core/generated/printful/core/OpenAPI.ts deleted file mode 100644 index ab0c4e8..0000000 --- a/packages/vymalo-printful/src/core/generated/printful/core/OpenAPI.ts +++ /dev/null @@ -1,57 +0,0 @@ -import type { AxiosRequestConfig, AxiosResponse } from 'axios'; -import type { ApiRequestOptions } from './ApiRequestOptions'; - -type Headers = Record; -type Middleware = (value: T) => T | Promise; -type Resolver = (options: ApiRequestOptions) => Promise; - -export class Interceptors { - _fns: Middleware[]; - - constructor() { - this._fns = []; - } - - eject(fn: Middleware): void { - const index = this._fns.indexOf(fn); - if (index !== -1) { - this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; - } - } - - use(fn: Middleware): void { - this._fns = [...this._fns, fn]; - } -} - -export type OpenAPIConfig = { - BASE: string; - CREDENTIALS: 'include' | 'omit' | 'same-origin'; - ENCODE_PATH?: ((path: string) => string) | undefined; - HEADERS?: Headers | Resolver | undefined; - PASSWORD?: string | Resolver | undefined; - TOKEN?: string | Resolver | undefined; - USERNAME?: string | Resolver | undefined; - VERSION: string; - WITH_CREDENTIALS: boolean; - interceptors: { - request: Interceptors; - response: Interceptors; - }; -}; - -export const OpenAPI: OpenAPIConfig = { - BASE: 'https://api.printful.com', - CREDENTIALS: 'include', - ENCODE_PATH: undefined, - HEADERS: undefined, - PASSWORD: undefined, - TOKEN: undefined, - USERNAME: undefined, - VERSION: '1.0', - WITH_CREDENTIALS: false, - interceptors: { - request: new Interceptors(), - response: new Interceptors(), - }, -}; diff --git a/packages/vymalo-printful/src/core/generated/printful/core/request.ts b/packages/vymalo-printful/src/core/generated/printful/core/request.ts deleted file mode 100644 index bc98c68..0000000 --- a/packages/vymalo-printful/src/core/generated/printful/core/request.ts +++ /dev/null @@ -1,387 +0,0 @@ -import axios from 'axios'; -import type { - AxiosError, - AxiosRequestConfig, - AxiosResponse, - AxiosInstance, -} from 'axios'; - -import { ApiError } from './ApiError'; -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; -import { CancelablePromise } from './CancelablePromise'; -import type { OnCancel } from './CancelablePromise'; -import type { OpenAPIConfig } from './OpenAPI'; - -export const isString = (value: unknown): value is string => { - return typeof value === 'string'; -}; - -export const isStringWithValue = (value: unknown): value is string => { - return isString(value) && value !== ''; -}; - -export const isBlob = (value: any): value is Blob => { - return value instanceof Blob; -}; - -export const isFormData = (value: unknown): value is FormData => { - return value instanceof FormData; -}; - -export const isSuccess = (status: number): boolean => { - return status >= 200 && status < 300; -}; - -export const base64 = (str: string): string => { - try { - return btoa(str); - } catch (err) { - // @ts-ignore - return Buffer.from(str).toString('base64'); - } -}; - -export const getQueryString = (params: Record): string => { - const qs: string[] = []; - - const append = (key: string, value: unknown) => { - qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); - }; - - const encodePair = (key: string, value: unknown) => { - if (value === undefined || value === null) { - return; - } - - if (value instanceof Date) { - append(key, value.toISOString()); - } else if (Array.isArray(value)) { - value.forEach((v) => encodePair(key, v)); - } else if (typeof value === 'object') { - Object.entries(value).forEach(([k, v]) => encodePair(`${key}[${k}]`, v)); - } else { - append(key, value); - } - }; - - Object.entries(params).forEach(([key, value]) => encodePair(key, value)); - - return qs.length ? `?${qs.join('&')}` : ''; -}; - -const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => { - const encoder = config.ENCODE_PATH || encodeURI; - - const path = options.url - .replace('{api-version}', config.VERSION) - .replace(/{(.*?)}/g, (substring: string, group: string) => { - if (options.path?.hasOwnProperty(group)) { - return encoder(String(options.path[group])); - } - return substring; - }); - - const url = config.BASE + path; - return options.query ? url + getQueryString(options.query) : url; -}; - -export const getFormData = ( - options: ApiRequestOptions -): FormData | undefined => { - if (options.formData) { - const formData = new FormData(); - - const process = (key: string, value: unknown) => { - if (isString(value) || isBlob(value)) { - formData.append(key, value); - } else { - formData.append(key, JSON.stringify(value)); - } - }; - - Object.entries(options.formData) - .filter(([, value]) => value !== undefined && value !== null) - .forEach(([key, value]) => { - if (Array.isArray(value)) { - value.forEach((v) => process(key, v)); - } else { - process(key, value); - } - }); - - return formData; - } - return undefined; -}; - -type Resolver = (options: ApiRequestOptions) => Promise; - -export const resolve = async ( - options: ApiRequestOptions, - resolver?: T | Resolver -): Promise => { - if (typeof resolver === 'function') { - return (resolver as Resolver)(options); - } - return resolver; -}; - -export const getHeaders = async ( - config: OpenAPIConfig, - options: ApiRequestOptions -): Promise> => { - const [token, username, password, additionalHeaders] = await Promise.all([ - // @ts-ignore - resolve(options, config.TOKEN), - // @ts-ignore - resolve(options, config.USERNAME), - // @ts-ignore - resolve(options, config.PASSWORD), - // @ts-ignore - resolve(options, config.HEADERS), - ]); - - const headers = Object.entries({ - Accept: 'application/json', - ...additionalHeaders, - ...options.headers, - }) - .filter(([, value]) => value !== undefined && value !== null) - .reduce( - (headers, [key, value]) => ({ - ...headers, - [key]: String(value), - }), - {} as Record - ); - - if (isStringWithValue(token)) { - headers['Authorization'] = `Bearer ${token}`; - } - - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = base64(`${username}:${password}`); - headers['Authorization'] = `Basic ${credentials}`; - } - - if (options.body !== undefined) { - if (options.mediaType) { - headers['Content-Type'] = options.mediaType; - } else if (isBlob(options.body)) { - headers['Content-Type'] = options.body.type || 'application/octet-stream'; - } else if (isString(options.body)) { - headers['Content-Type'] = 'text/plain'; - } else if (!isFormData(options.body)) { - headers['Content-Type'] = 'application/json'; - } - } else if (options.formData !== undefined) { - if (options.mediaType) { - headers['Content-Type'] = options.mediaType; - } - } - - return headers; -}; - -export const getRequestBody = (options: ApiRequestOptions): unknown => { - if (options.body) { - return options.body; - } - return undefined; -}; - -export const sendRequest = async ( - config: OpenAPIConfig, - options: ApiRequestOptions, - url: string, - body: unknown, - formData: FormData | undefined, - headers: Record, - onCancel: OnCancel, - axiosClient: AxiosInstance -): Promise> => { - const controller = new AbortController(); - - let requestConfig: AxiosRequestConfig = { - data: body ?? formData, - headers, - method: options.method, - signal: controller.signal, - url, - withCredentials: config.WITH_CREDENTIALS, - }; - - onCancel(() => controller.abort()); - - for (const fn of config.interceptors.request._fns) { - requestConfig = await fn(requestConfig); - } - - try { - return await axiosClient.request(requestConfig); - } catch (error) { - const axiosError = error as AxiosError; - if (axiosError.response) { - return axiosError.response; - } - throw error; - } -}; - -export const getResponseHeader = ( - response: AxiosResponse, - responseHeader?: string -): string | undefined => { - if (responseHeader) { - const content = response.headers[responseHeader]; - if (isString(content)) { - return content; - } - } - return undefined; -}; - -export const getResponseBody = (response: AxiosResponse): unknown => { - if (response.status !== 204) { - return response.data; - } - return undefined; -}; - -export const catchErrorCodes = ( - options: ApiRequestOptions, - result: ApiResult -): void => { - const errors: Record = { - 400: 'Bad Request', - 401: 'Unauthorized', - 402: 'Payment Required', - 403: 'Forbidden', - 404: 'Not Found', - 405: 'Method Not Allowed', - 406: 'Not Acceptable', - 407: 'Proxy Authentication Required', - 408: 'Request Timeout', - 409: 'Conflict', - 410: 'Gone', - 411: 'Length Required', - 412: 'Precondition Failed', - 413: 'Payload Too Large', - 414: 'URI Too Long', - 415: 'Unsupported Media Type', - 416: 'Range Not Satisfiable', - 417: 'Expectation Failed', - 418: 'Im a teapot', - 421: 'Misdirected Request', - 422: 'Unprocessable Content', - 423: 'Locked', - 424: 'Failed Dependency', - 425: 'Too Early', - 426: 'Upgrade Required', - 428: 'Precondition Required', - 429: 'Too Many Requests', - 431: 'Request Header Fields Too Large', - 451: 'Unavailable For Legal Reasons', - 500: 'Internal Server Error', - 501: 'Not Implemented', - 502: 'Bad Gateway', - 503: 'Service Unavailable', - 504: 'Gateway Timeout', - 505: 'HTTP Version Not Supported', - 506: 'Variant Also Negotiates', - 507: 'Insufficient Storage', - 508: 'Loop Detected', - 510: 'Not Extended', - 511: 'Network Authentication Required', - ...options.errors, - }; - - const error = errors[result.status]; - if (error) { - throw new ApiError(options, result, error); - } - - if (!result.ok) { - const errorStatus = result.status ?? 'unknown'; - const errorStatusText = result.statusText ?? 'unknown'; - const errorBody = (() => { - try { - return JSON.stringify(result.body, null, 2); - } catch (e) { - return undefined; - } - })(); - - throw new ApiError( - options, - result, - `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}` - ); - } -}; - -/** - * Request method - * @param config The OpenAPI configuration object - * @param options The request options from the service - * @param axiosClient The axios client instance to use - * @returns CancelablePromise - * @throws ApiError - */ -export const request = ( - config: OpenAPIConfig, - options: ApiRequestOptions, - axiosClient: AxiosInstance = axios -): CancelablePromise => { - return new CancelablePromise(async (resolve, reject, onCancel) => { - try { - const url = getUrl(config, options); - const formData = getFormData(options); - const body = getRequestBody(options); - const headers = await getHeaders(config, options); - - if (!onCancel.isCancelled) { - let response = await sendRequest( - config, - options, - url, - body, - formData, - headers, - onCancel, - axiosClient - ); - - for (const fn of config.interceptors.response._fns) { - response = await fn(response); - } - - const responseBody = getResponseBody(response); - const responseHeader = getResponseHeader( - response, - options.responseHeader - ); - - let transformedBody = responseBody; - if (options.responseTransformer && isSuccess(response.status)) { - transformedBody = await options.responseTransformer(responseBody); - } - - const result: ApiResult = { - url, - ok: isSuccess(response.status), - status: response.status, - statusText: response.statusText, - body: responseHeader ?? transformedBody, - }; - - catchErrorCodes(options, result); - - resolve(result.body); - } - } catch (error) { - reject(error); - } - }); -}; diff --git a/packages/vymalo-printful/src/core/generated/printful/index.ts b/packages/vymalo-printful/src/core/generated/printful/index.ts deleted file mode 100644 index 8675c0c..0000000 --- a/packages/vymalo-printful/src/core/generated/printful/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts -export { ApiError } from './core/ApiError'; -export { CancelablePromise, CancelError } from './core/CancelablePromise'; -export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI'; -export * from './services.gen'; -export * from './types.gen'; diff --git a/packages/vymalo-printful/src/core/generated/printful/services.gen.ts b/packages/vymalo-printful/src/core/generated/printful/services.gen.ts deleted file mode 100644 index 8ac140c..0000000 --- a/packages/vymalo-printful/src/core/generated/printful/services.gen.ts +++ /dev/null @@ -1,1844 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { CancelablePromise } from './core/CancelablePromise'; -import { OpenAPI } from './core/OpenAPI'; -import { request as __request } from './core/request'; -import type { - GetApprovalSheetsData, - GetApprovalSheetsResponse, - ApproveDesignData, - ApproveDesignResponse, - SubmitApprovalSheetChangesData, - SubmitApprovalSheetChangesResponse, - GetProductsData, - GetProductsResponse, - GetVariantByIdData, - GetVariantByIdResponse, - GetProductByIdData, - GetProductByIdResponse, - GetProductSizeGuideByIdData, - GetProductSizeGuideByIdResponse, - GetCategoriesResponse, - GetCategoryByIdData, - GetCategoryByIdResponse, - GetCountriesResponse, - GetStoreSyncProductsData, - GetStoreSyncProductsResponse, - GetStoreSyncProductByIdData, - GetStoreSyncProductByIdResponse, - DeleteStoreSyncProductData, - DeleteStoreSyncProductResponse, - GetStoreSyncVariantByIdData, - GetStoreSyncVariantByIdResponse, - UpdateStoreSyncVariantData, - UpdateStoreSyncVariantResponse, - DeleteStoreSyncVariantData, - DeleteStoreSyncVariantResponse, - AddFileData, - AddFileResponse, - GetFileData, - GetFileResponse, - ThreadColorsData, - ThreadColorsResponse, - CreateGeneratorTaskData, - CreateGeneratorTaskResponse, - GetPrintfilesData, - GetPrintfilesResponse, - GetTaskData, - GetTaskResponse, - GetTemplatesData, - GetTemplatesResponse, - GetScopesResponse, - GetOrdersData, - GetOrdersResponse, - CreateOrderData, - CreateOrderResponse, - GetOrderByIdData, - GetOrderByIdResponse, - CancelOrderByIdData, - CancelOrderByIdResponse, - UpdateOrderByIdData, - UpdateOrderByIdResponse, - ConfirmOrderByIdData, - ConfirmOrderByIdResponse, - EstimateOrderCostsData, - EstimateOrderCostsResponse, - GetSyncProductsData, - GetSyncProductsResponse, - CreateSyncProductData, - CreateSyncProductResponse, - GetSyncProductByIdData, - GetSyncProductByIdResponse, - DeleteSyncProductData, - DeleteSyncProductResponse, - UpdateSyncProductData, - UpdateSyncProductResponse, - GetSyncVariantByIdData, - GetSyncVariantByIdResponse, - DeleteSyncVariantData, - DeleteSyncVariantResponse, - UpdateSyncVariantData, - UpdateSyncVariantResponse, - CreateSyncVariantData, - CreateSyncVariantResponse, - GetProductTemplatesData, - GetProductTemplatesResponse, - GetProductTemplateByIdData, - GetProductTemplateByIdResponse, - DeleteProductTemplateData, - DeleteProductTemplateResponse, - GetStatisticsData, - GetStatisticsResponse, - CalculateShippingRatesData, - CalculateShippingRatesResponse, - ChangePackingSlipData, - ChangePackingSlipResponse, - GetStoresResponse, - GetStoreData, - GetStoreResponse, - GetTaxCountriesResponse, - CalculateTaxRatesData, - CalculateTaxRatesResponse, - GetWarehouseProductsData, - GetWarehouseProductsResponse, - GetWarehouseProductData, - GetWarehouseProductResponse, - GetWebhooksData, - GetWebhooksResponse, - CreateWebhookData, - CreateWebhookResponse, - DisableWebhookData, - DisableWebhookResponse, -} from './types.gen'; - -export class ApprovalSheetsApiService { - /** - * Retrieve a list of approval sheets - * Retrieve a list of approval sheets confirming suggested changes to files of on hold orders. - * @param data The data for the request. - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getApprovalSheets( - data: GetApprovalSheetsData = {} - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/approval-sheets', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - }, - }); - } - - /** - * Approve a design - * Uses the confirm hash of an approval sheet to approve a design and remove the hold on an order - * @param data The data for the request. - * @param data.confirmHash The confirm hash for the approval sheet you would like to approve. - * @param data.requestBody POST request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static approveDesign( - data: ApproveDesignData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/approval-sheets', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - query: { - confirm_hash: data.confirmHash, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Submit changes to an approval sheet - * Use this to submit alternative changes to a design that has an approval sheet - * @param data The data for the request. - * @param data.confirmHash The confirm hash for the approval sheet you would like to approve. - * @param data.requestBody POST request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static submitApprovalSheetChanges( - data: SubmitApprovalSheetChangesData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/approval-sheets/changes', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - query: { - confirm_hash: data.confirmHash, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - }, - }); - } -} - -export class CatalogApiService { - /** - * Get Products - * Returns list of Products available in the Printful - * @param data The data for the request. - * @param data.categoryId A comma-separated list of Category IDs of the Products that are to be returned - * @returns unknown OK - * @throws ApiError - */ - public static getProducts( - data: GetProductsData = {} - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/products', - query: { - category_id: data.categoryId, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } - - /** - * Get Variant - * Returns information about a specific Variant and its Product - * @param data The data for the request. - * @param data.id Variant id - * @returns unknown OK - * @throws ApiError - */ - public static getVariantById( - data: GetVariantByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/products/variant/{id}', - path: { - id: data.id, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } - - /** - * Get Product - * Returns information about a specific product and a list of variants for this product. - * @param data The data for the request. - * @param data.id Product ID. - * @returns unknown OK - * @throws ApiError - */ - public static getProductById( - data: GetProductByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/products/{id}', - path: { - id: data.id, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } - - /** - * Get Product Size Guide - * Returns information about the size guide for a specific product. - * @param data The data for the request. - * @param data.id Product ID. - * @param data.unit A comma-separated list of measurement unit in which size tables are to be returned (`inches` or `cm`). - * The default value is determined based on the locale country. The inches are used for United States, Liberia - * and Myanmar, for other countries the unit defaults to centimeters. - * - * @returns unknown OK - * @throws ApiError - */ - public static getProductSizeGuideById( - data: GetProductSizeGuideByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/products/{id}/sizes', - path: { - id: data.id, - }, - query: { - unit: data.unit, - }, - errors: { - 404: 'Not found', - }, - }); - } - - /** - * Get Categories - * Returns list of Catalog Categories available in the Printful - * @returns unknown OK - * @throws ApiError - */ - public static getCategories(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/categories', - errors: { - 401: 'Unauthorized', - }, - }); - } - - /** - * Get Category - * Returns information about a specific category. - * @param data The data for the request. - * @param data.id Category ID - * @returns unknown OK - * @throws ApiError - */ - public static getCategoryById( - data: GetCategoryByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/categories/{id}', - path: { - id: data.id, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } -} - -export class CountryStateCodeApiService { - /** - * Retrieve country list - * Returns list of countries and states that are accepted by the Printful. - * @returns unknown OK - * @throws ApiError - */ - public static getCountries(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/countries', - errors: { - 401: 'Unauthorized', - }, - }); - } -} - -export class EcommercePlatformSyncApiService { - /** - * Get list of Sync Products - * Returns list of Sync Product objects from your store. - * @param data The data for the request. - * @param data.search Product search needle - * @param data.offset Result set offset - * @param data.limit Number of items per page (max 100) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @param data.status Parameter used to filter results by status/group of Sync Products - * @returns unknown OK - * @throws ApiError - */ - public static getStoreSyncProducts( - data: GetStoreSyncProductsData = {} - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/sync/products', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - query: { - search: data.search, - offset: data.offset, - limit: data.limit, - status: data.status, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } - - /** - * Get a Sync Product - * Get information about a single Sync Product and its Sync Variants - * @param data The data for the request. - * @param data.id Sync Product ID (integer) or External ID (if prefixed with @) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getStoreSyncProductById( - data: GetStoreSyncProductByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/sync/products/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Delete a Sync Product - * Deletes a Sync Product with all of its Sync Variants - * @param data The data for the request. - * @param data.id Sync Product ID (integer) or External ID (if prefixed with @) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static deleteStoreSyncProduct( - data: DeleteStoreSyncProductData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/sync/products/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Get a Sync Variant - * Get information about a single Sync Variant - * @param data The data for the request. - * @param data.id Sync Variant ID (integer) or External ID (if prefixed with @) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getStoreSyncVariantById( - data: GetStoreSyncVariantByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/sync/variant/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Modify a Sync Variant - * Modifies an existing Sync Variant. - * - * Please note that in the request body you only need to specify the fields that need to be changed. See examples for more insights. - * - * [See examples](#section/Ecommerce-Platform-Sync-API-examples/Modify-a-Sync-Variant) - * - * @param data The data for the request. - * @param data.id Sync Variant ID (integer) or External ID (if prefixed with @) - * @param data.requestBody PUT request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static updateStoreSyncVariant( - data: UpdateStoreSyncVariantData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/sync/variant/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Delete a Sync Variant - * Deletes configuraton information (`variant_id`, print files and options) and disables automatic order importing for this Sync Variant. - * @param data The data for the request. - * @param data.id Sync Variant ID (integer) or External ID (if prefixed with @) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static deleteStoreSyncVariant( - data: DeleteStoreSyncVariantData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/sync/variant/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } -} - -export class FileLibraryApiService { - /** - * Add a new file - * Adds a new File to the library by providing URL of the file. - * - * If a file with identical URL already exists, then the original file is returned. If a file does not exist, a new file is created. - * - * [See examples](#section/File-Library-API-examples/Add-a-new-file) - * - * @param data The data for the request. - * @param data.requestBody POST request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static addFile(data: AddFileData): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/files', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - }, - }); - } - - /** - * Get file - * Returns information about the given file. - * @param data The data for the request. - * @param data.id File ID. - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getFile(data: GetFileData): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/files/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Return available thread colors from provided image URL - * Returns colors in hexadecimal format. - * - * Returned thread colors are matched as closely as possible to provided image colors. - * - * [See examples](#section/File-Library-API-examples/Suggest-thread-colors) - * - * @param data The data for the request. - * @param data.requestBody POST request body - * @returns unknown OK - * @throws ApiError - */ - public static threadColors( - data: ThreadColorsData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/files/thread-colors', - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - }, - }); - } -} - -export class MockupGeneratorApiService { - /** - * Create a mockup generation task - * Creates an asynchronous mockup generation task. - * Generation result can be retrieved using mockup generation task retrieval endpoint.
- * **Rate limiting**: Up to 10 requests per 60 seconds for established stores; - * 2 requests per 60 seconds for new stores. Currently available rate is returned in response headers. - * A 60 seconds lockout is applied if request count is exceeded. We also limit the number of files that may - * be generated to 20,000 files per account in a 24-hour period. - * - * @param data The data for the request. - * @param data.id Product ID. - * @param data.requestBody POST request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static createGeneratorTask( - data: CreateGeneratorTaskData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/mockup-generator/create-task/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Retrieve product variant printfiles - * List of printfiles available for products variants. Printfile indicates what file resolution should be used to create a mockup or submit an order. - * - *
- * This endpoint uses DTG as a default printing technique for products - * with more than one technique available. For products with DTG and more - * techniques available please specify the correct technique in query by using - * the `technique` parameter. For more information read the examples. - *
- * - * @param data The data for the request. - * @param data.id Product ID. - * @param data.orientation - * @param data.technique - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getPrintfiles( - data: GetPrintfilesData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/mockup-generator/printfiles/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - query: { - orientation: data.orientation, - technique: data.technique, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Mockup generation task result - * Returns asynchronous mockup generation task result. If generation task is completed, it will contain a list of generated mockups. - * @param data The data for the request. - * @param data.taskKey Task key retrieved when creating the generation task. - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getTask(data: GetTaskData): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/mockup-generator/task', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - query: { - task_key: data.taskKey, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Layout templates - * Retrieve list of templates that can be used for client-side positioning. - * - *
- * This endpoint uses DTG as a default printing technique for product layouts - * with more than one technique available. For products with DTG and more - * techniques available please specify the correct technique in query by using - * the `technique` parameter. For more information read the examples. - *
- * - * @param data The data for the request. - * @param data.id Product ID. - * @param data.orientation - * @param data.technique - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getTemplates( - data: GetTemplatesData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/mockup-generator/templates/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - query: { - orientation: data.orientation, - technique: data.technique, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } -} - -export class OauthApiService { - /** - * Get scopes for token - * Returns a list of scopes associated with the token - * @returns unknown OK - * @throws ApiError - */ - public static getScopes(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/oauth/scopes', - errors: { - 401: 'Unauthorized', - 403: 'Forbidden', - }, - }); - } -} - -export class OrdersApiService { - /** - * Get list of orders - * Returns list of order objects from your store - * @param data The data for the request. - * @param data.status Filter by order status - * @param data.offset Result set offset - * @param data.limit Number of items per page (max 100) - * @returns unknown OK - * @throws ApiError - */ - public static getOrders( - data: GetOrdersData = {} - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/orders', - query: { - status: data.status, - offset: data.offset, - limit: data.limit, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } - - /** - * Create a new order - * Creates a new order and optionally submits it for fulfillment ([See examples](#section/Orders-API-examples)) - * @param data The data for the request. - * @param data.requestBody POST request body - * @param data.confirm Automatically submit the newly created order for fulfillment (skip the Draft phase) - * @param data.updateExisting Try to update existing order if an order with the specified external_id already exists - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static createOrder( - data: CreateOrderData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/orders', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - query: { - confirm: data.confirm, - update_existing: data.updateExisting, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - }, - }); - } - - /** - * Get order data - * Returns order data by ID or External ID. - * @param data The data for the request. - * @param data.id Order ID (integer) or External ID (if prefixed with @) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getOrderById( - data: GetOrderByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/orders/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Cancel an order - * Cancels pending order or draft. Charged amount is returned to the store owner's credit card. - * @param data The data for the request. - * @param data.id Order ID (integer) or External ID (if prefixed with @) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static cancelOrderById( - data: CancelOrderByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/orders/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Update order data - * Updates unsubmitted order and optionally submits it for the fulfillment. - * - * Note that you need to post only the fields that need to be changed, not all required fields. - * - * If items array is given in the update data, the items will be: - * - * a) updated, if the update data contains the item id or external_id parameter that alreay exists - * - * b) deleted, if the request doesn't contain the item with previously existing id - * - * c) created as new if the id is not given or does not already exist - * @param data The data for the request. - * @param data.id Order ID (integer) or External ID (if prefixed with @) - * @param data.requestBody POST request body - * @param data.confirm Automatically submit the newly created order for fulfillment (skip the Draft phase) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static updateOrderById( - data: UpdateOrderByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/orders/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - query: { - confirm: data.confirm, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Confirm draft for fulfillment - * Approves for fulfillment an order that was saved as a draft. Store owner's credit card is charged when the order is submitted for fulfillment. - * @param data The data for the request. - * @param data.id Order ID (integer) or External ID (if prefixed with @) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static confirmOrderById( - data: ConfirmOrderByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/orders/{id}/confirm', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Estimate order costs - * Calculates the estimated order costs including item costs, print costs (back prints, inside labels etc.), shipping and taxes - * @param data The data for the request. - * @param data.requestBody POST request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static estimateOrderCosts( - data: EstimateOrderCostsData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/orders/estimate-costs', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - }, - }); - } -} - -export class ProductsApiService { - /** - * Get Sync Products - * Returns a list of Sync Product objects from your custom Printful store. - * @param data The data for the request. - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @param data.status Parameter used to filter results by status/group of Sync Products - * @param data.categoryId A comma-separated list of Category IDs of the Products that are to be returned - * @returns unknown OK - * @throws ApiError - */ - public static getSyncProducts( - data: GetSyncProductsData = {} - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/store/products', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - query: { - status: data.status, - category_id: data.categoryId, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } - - /** - * Create a new Sync Product - * Creates a new Sync Product together with its Sync Variants ([See examples](#section/Products-API-examples/Create-a-new-Sync-Product)). - * @param data The data for the request. - * @param data.requestBody POST request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static createSyncProduct( - data: CreateSyncProductData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/store/products', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - }, - }); - } - - /** - * Get a Sync Product - * Get information about a single Sync Product and its Sync Variants. - * @param data The data for the request. - * @param data.id Sync Product ID (integer) or External ID (if prefixed with @) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getSyncProductById( - data: GetSyncProductByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/store/products/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Delete a Sync Product - * Deletes a Sync Product with all of its Sync Variants - * @param data The data for the request. - * @param data.id Sync Product ID (integer) or External ID (if prefixed with @) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static deleteSyncProduct( - data: DeleteSyncProductData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/store/products/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Modify a Sync Product - * Modifies an existing Sync Product with its Sync Variants. - * - * Please note that in the request body you only need to specify the fields that need to be changed. Furthermore, if you want to update existing sync variants, - * then in the sync variants array you must specify the IDs of all existing sync variants. All omitted existing sync variants will be deleted. All new sync - * variants without an ID will be created. See examples for more insights. - * - * **Rate limiting:** Up to 10 requests per 60 seconds. A 60 seconds lockout is applied if request count is exceeded. - * - * [See examples](#section/Products-API-examples/Modify-a-Sync-Product) - * - * @param data The data for the request. - * @param data.id Sync Product ID (integer) or External ID (if prefixed with @) - * @param data.requestBody PUT request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static updateSyncProduct( - data: UpdateSyncProductData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/store/products/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Get a Sync Variant - * Get information about a single Sync Variant. - * @param data The data for the request. - * @param data.id Sync Variant ID (integer) or External ID (if prefixed with @) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getSyncVariantById( - data: GetSyncVariantByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/store/variants/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Delete a Sync Variant - * Deletes a single Sync Variant. - * @param data The data for the request. - * @param data.id Sync Variant ID (integer) or External ID (if prefixed with @) - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static deleteSyncVariant( - data: DeleteSyncVariantData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/store/variants/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Modify a Sync Variant - * Modifies an existing Sync Variant. - * - * Please note that in the request body you only need to specify the fields that need to be changed. See examples for more insights. - * - * [See examples](#section/Products-API-examples/Modify-a-Sync-Variant) - * - * @param data The data for the request. - * @param data.id Sync Variant ID (integer) or External ID (if prefixed with @) - * @param data.requestBody POST request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static updateSyncVariant( - data: UpdateSyncVariantData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/store/variants/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * Create a new Sync Variant - * Creates a new Sync Variant for an existing Sync Product ([See examples](#section/Products-API-examples/Create-a-new-Sync-Variant)). - * @param data The data for the request. - * @param data.id Sync Product ID (integer) or External ID (if prefixed with @) - * @param data.requestBody POST request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static createSyncVariant( - data: CreateSyncVariantData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/store/products/{id}/variants', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } -} - -export class ProductTemplatesApiService { - /** - * Get product template list - * Returns a list of templates. - * @param data The data for the request. - * @param data.offset Result set offset - * @param data.limit Number of items per page (max 100) - * @returns unknown OK - * @throws ApiError - */ - public static getProductTemplates( - data: GetProductTemplatesData = {} - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/product-templates', - query: { - offset: data.offset, - limit: data.limit, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } - - /** - * Get product template - * Get information about a single product template - * @param data The data for the request. - * @param data.id Template ID (integer) or External Product ID (if prefixed with @) - * @returns unknown OK - * @throws ApiError - */ - public static getProductTemplateById( - data: GetProductTemplateByIdData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/product-templates/{id}', - path: { - id: data.id, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } - - /** - * Delete product template - * Delete product template by ID or External Product ID - * @param data The data for the request. - * @param data.id Template ID (integer) or External Product ID (if prefixed with @) - * @returns unknown OK - * @throws ApiError - */ - public static deleteProductTemplate( - data: DeleteProductTemplateData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/product-templates/{id}', - path: { - id: data.id, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } -} - -export class ReportsApiService { - /** - * Get statistics - * Returns statistics for specified report types. - * - * You need to specify the report types you want to retrieve in the `report_types` query parameter as a comma-separated list, - * e.g. `report_types=sales_and_costs,profit`. - * - * **Note**: You cannot get statistics for a period longer than 6 months. - * - * #### Example - * - * To get statistics in the default currency of a store for `sales_and_costs` and `profit` reports for August 2022, you can use the - * following - * URL: https://api.printful.com/reports/statistics?report_types=sales_and_costs,profit&date_from=2022-08-01&date_to=2022-08-31. - * - * ### Report types - * - * Currently, the following report types are available: - * - * | Report type | Description | - * |----------------------------|----------------------------------------------------------| - * | `sales_and_costs` | Detailed information on sales and costs grouped by date. | - * | `sales_and_costs_summary` | Short information on sales and costs grouped by date. | - * | `printful_costs` | Amount paid to Printful for fulfillment and shipping. | - * | `profit` | Profit in the specified period. | - * | `total_paid_orders` | The number of paid orders in the specified period. | - * | `costs_by_amount` | Information on costs by amount grouped by date. | - * | `costs_by_product` | Information on costs grouped by product. | - * | `costs_by_variant` | Information on costs grouped by variant. | - * | `average_fulfillment_time` | Average time it took Printful to fulfill your orders. | - * - * The response structure for the specific reports is documented in the response schema (`result.store_statistics.[reportName]`). - * - * @param data The data for the request. - * @param data.dateFrom The beginning of the period to get the statistics from (date in `Y-m-d` format). - * @param data.dateTo The end of the period to get the statistics from (date in `Y-m-d` format). - * @param data.reportTypes A comma-separated list of report types to be retrieved. - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @param data.currency The currency (3-letter code) to return the statistics in. You can also specify `display_currency` as the value to get the statistics in the account's display currency. The store currency will be used by default. - * @returns unknown OK - * @throws ApiError - */ - public static getStatistics( - data: GetStatisticsData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/reports/statistics', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - query: { - date_from: data.dateFrom, - date_to: data.dateTo, - currency: data.currency, - report_types: data.reportTypes, - }, - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } -} - -export class ShippingRateApiService { - /** - * Calculate shipping rates - * Returns available shipping options and rates for the given list of products. - * @param data The data for the request. - * @param data.requestBody POST request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static calculateShippingRates( - data: CalculateShippingRatesData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/shipping/rates', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } -} - -export class StoreInformationApiService { - /** - * Change packing slip - * Modifies packing slip information of the currently authorized Printful store. - * @param data The data for the request. - * @param data.requestBody POST request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static changePackingSlip( - data: ChangePackingSlipData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/store/packing-slip', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - }, - }); - } - - /** - * Get basic information about stores - * Get basic information about stores depending on the token access level - * @returns unknown OK - * @throws ApiError - */ - public static getStores(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/stores', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Forbidden', - }, - }); - } - - /** - * Get basic information about a store - * Get basic information about a store based on provided ID - * @param data The data for the request. - * @param data.id Store ID - * @returns unknown OK - * @throws ApiError - */ - public static getStore( - data: GetStoreData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/stores/{id}', - path: { - id: data.id, - }, - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Forbidden', - }, - }); - } -} - -export class TaxRateApiService { - /** - * Get a list of countries for tax calculation - * Retrieve state list that requires sales tax calculation - * @returns unknown OK - * @throws ApiError - */ - public static getTaxCountries(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/tax/countries', - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } - - /** - * @deprecated - * Calculate tax rate - * Calculates sales tax rate for given address if required - * @param data The data for the request. - * @param data.requestBody POST request body - * @returns unknown OK - * @throws ApiError - */ - public static calculateTaxRates( - data: CalculateTaxRatesData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/tax/rates', - body: data.requestBody, - mediaType: 'application/json', - errors: { - 404: 'Not found', - }, - }); - } -} - -export class WarehouseProductsApiService { - /** - * Get a list of your warehouse products - * Returns a list of warehouse products from your store - * - *
- * The response for this endpoint was documented as paginated, although it was not paginated. The behavior will be - * fixed and the paginated result will be set as the default. Currently to get paginated results please send - * trueor 1 in X-PF-Force-Pagination header. - *
- * - * @param data The data for the request. - * @param data.query Filter by partial or full product name - * @param data.xPfForcePagination Whether the pagination behavior should be forced. The response will be paginated if the value is `true` or `1`. - * @param data.limit Number of items per page (max 100) - * @param data.offset Result set offset - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getWarehouseProducts( - data: GetWarehouseProductsData = {} - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/warehouse/products', - headers: { - 'X-PF-Force-Pagination': data.xPfForcePagination, - 'X-PF-Store-Id': data.xPfStoreId, - }, - query: { - query: data.query, - limit: data.limit, - offset: data.offset, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } - - /** - * Get warehouse product data - * Returns warehouse product data by ID - * @param data The data for the request. - * @param data.id Product ID - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getWarehouseProduct( - data: GetWarehouseProductData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/warehouse/products/{id}', - path: { - id: data.id, - }, - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - 404: 'Not found', - }, - }); - } -} - -export class WebhookApiService { - /** - * Get webhook configuration - * Returns configured webhook URL and list of webhook event types enabled for the store - * @param data The data for the request. - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static getWebhooks( - data: GetWebhooksData = {} - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/webhooks', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } - - /** - * Set up webhook configuration - * Use this endpoint to enable a webhook URL for a store and select webhook event types that will be sent to this URL. - * - * Note that only one webhook URL can be active for a store, so calling this method disables all existing webhook configuration. - * - * Setting up the [Stock updated](#operation/stockUpdated) webhook requires passing IDs for products that need to be monitored for changes. Stock update webhook will only include information for specified products. These product IDs need to be set up using the params property. - * @param data The data for the request. - * @param data.requestBody POST request body - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static createWebhook( - data: CreateWebhookData - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/webhooks', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 400: 'Bad Request', - 401: 'Unauthorized', - }, - }); - } - - /** - * Disable webhook support - * Removes the webhook URL and all event types from the store. - * @param data The data for the request. - * @param data.xPfStoreId Use this to specify which store you want to use (required only for account level token). - * - * The store IDs can be retrieved with the [Get basic information about stores](/docs/#operation/getStores) endpoint. - * - * @returns unknown OK - * @throws ApiError - */ - public static disableWebhook( - data: DisableWebhookData = {} - ): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/webhooks', - headers: { - 'X-PF-Store-Id': data.xPfStoreId, - }, - errors: { - 401: 'Unauthorized', - }, - }); - } -} diff --git a/packages/vymalo-printful/src/core/generated/printful/types.gen.ts b/packages/vymalo-printful/src/core/generated/printful/types.gen.ts deleted file mode 100644 index 3637121..0000000 --- a/packages/vymalo-printful/src/core/generated/printful/types.gen.ts +++ /dev/null @@ -1,3668 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -/** - * Information about the address - */ -export type Address = { - /** - * Full name - */ - name?: string; - /** - * Company name - */ - company?: string; - /** - * Address line 1 - */ - address1?: string; - /** - * Address line 2 - */ - address2?: string; - /** - * City - */ - city?: string; - /** - * State code - */ - state_code?: string; - /** - * State name - */ - state_name?: string; - /** - * Country code - */ - country_code?: string; - /** - * Country name - */ - country_name?: string; - /** - * ZIP/Postal code - */ - zip?: string; - /** - * Phone number - */ - phone?: string; - /** - * Email address - */ - email?: string; - /** - * TAX number (`optional`, but in case of Brazil country this field becomes `required` and will be used as CPF/CNPJ number)
CPF format is 000.000.000-00 (14 characters);
CNPJ format is 00.000.000/0000-00 (18 characters). - */ - tax_number?: string; -}; - -/** - * Recipient location information - */ -export type AddressInfo = { - /** - * Address line 1 - */ - address1: string; - /** - * City - */ - city: string; - /** - * Country code - */ - country_code: string; - /** - * State code (optional, required for United States, Australia and Canada) - */ - state_code?: string; - /** - * ZIP or postal code (optional, required for some countries to calculate expedited shipping rates) - */ - zip?: string; - /** - * Phone number (optional) - */ - phone?: string; -}; - -/** - * Approval sheet - */ -export type ApprovalSheet = { - id?: number; - status?: 'waiting_for_action' | 'approved'; - confirm_hash?: string; - submitted_design?: string; - recommended_design?: string; - approval_sheet?: string; -}; - -export enum status { - WAITING_FOR_ACTION = 'waiting_for_action', - APPROVED = 'approved', -} - -export type ApprovalSheetWebhookFile = { - confirm_hash?: string; - submitted_design?: string; - recommended_design?: string; - approval_sheet?: string; -}; - -export type AvailabilityStatus = { - /** - * Region code - */ - region?: string; - /** - * Stock status. Possible values include: 'in_stock' - available for fulfillment, 'stocked_on_demand' - available for fulfillment, 'discontinued' - permanently unavailable, 'out_of_stock' - temporarily unavailable - */ - status?: string; -}; - -export type AvailableTechnique = { - /** - * The technique key to be used in the API - */ - key?: string; - /** - * The human-readable technique name - */ - display_name?: string; - /** - * Whether the technique is the default one - */ - is_default?: boolean; -}; - -/** - * Average fulfillment time report - */ -export type AverageFulfillmentTime = { - /** - * Average time it took Printful to fulfill your orders. - */ - value?: number; - /** - * Relative difference from the value from the previous period. -1 means 100% decrease, 1 means 100% increase. 0 is returned if there is no change or the previous value was 0. - */ - relative_difference?: number; -}; - -export type CatalogFileOption = { - /** - * File option identifier. Use this to specify which option you are adding to your file in a request. - */ - id?: string; - /** - * The type of the value property when using this option in a request. - */ - type?: string; - title?: string; - /** - * Additional cost this will add to the item. - */ - additional_price?: number; -}; - -/** - * Information about the Category - */ -export type Category = { - /** - * Category ID - */ - id?: number; - /** - * ID of the parent Category. If there is no parent Category, 0 is returned. - */ - parent_id?: number; - /** - * The URL of the Category image - */ - image_url?: string; - /** - * The size of the category image - */ - size?: 'small' | 'medium' | 'large'; - /** - * Category title - */ - title?: string; -}; - -/** - * The size of the category image - */ -export enum size { - SMALL = 'small', - MEDIUM = 'medium', - LARGE = 'large', -} - -/** - * Order costs (Printful prices) - */ -export type Costs = { - /** - * 3 letter currency code - */ - currency?: string; - /** - * Total cost of all items - */ - subtotal?: string; - /** - * Discount sum - */ - discount?: string; - /** - * Shipping costs - */ - shipping?: string; - /** - * Digitization costs - */ - digitization?: string; - /** - * Additional fee for custom product - */ - additional_fee?: string; - /** - * Custom product fulfillment fee - */ - fulfillment_fee?: string; - /** - * Retail delivery fee - */ - retail_delivery_fee?: string; - /** - * Sum of taxes (not included in the item price) - */ - tax?: string; - /** - * Sum of vat (not included in the item price) - */ - vat?: string; - /** - * Grand Total (subtotal-discount+tax+vat+shipping) - */ - total?: string; -}; - -/** - * Costs by amount report - */ -export type CostsByAmount = Array<{ - /** - * The date of the value: day in `Y-m-d` format, month in `Y-m` format or "Total" for the first element of the list which shows the total values for the whole requested period - */ - date?: string; - /** - * Product & fulfillment costs - */ - product_amount?: number; - /** - * Embroidery digitization costs - */ - digitization?: number; - /** - * Pack-in costs - */ - branding?: number; - /** - * Tax amounts. If not applicable, it will be 0. - */ - vat?: number; - /** - * Tax amounts. If not applicable, it will be 0. - */ - sales_tax?: number; - /** - * Shipping costs that were charged by Printful - */ - shipping?: number; - /** - * Any fulfillment discounts (such as the monthly discount) set up on Printful's side - */ - discount?: number; - /** - * Summary of all costs - */ - total?: number; -}>; - -/** - * Costs by product report - */ -export type CostsByProduct = Array<{ - /** - * Product ID. See [Catalog API](#tag/Catalog-API). - */ - product_id?: number; - /** - * Product name. - */ - product_name?: string; - /** - * All fulfillment costs that are charged by Printful, excluding shipping. - */ - fulfillment?: number; - /** - * Order retail price data. Available only if retail price fields are properly set up on the integration's side. - */ - sales?: number; - /** - * Total quantity of items ordered from this product in the selected period. - */ - quantity?: number; -}>; - -/** - * Costs by variant report - */ -export type CostsByVariant = Array<{ - /** - * Variant ID. See [Catalog API](#tag/Catalog-API). - */ - variant_id?: number; - /** - * Variant name. - */ - variant_name?: string; - /** - * Product ID. See [Catalog API](#tag/Catalog-API). - */ - product_id?: number; - /** - * All fulfillment costs that are charged by Printful, excluding shipping. - */ - fulfillment?: number; - /** - * Order retail price data. Available only if retail price fields are properly set up on the integration's side. - */ - sales?: number; - /** - * Total quantity of items ordered from this product in the selected period. - */ - quantity?: number; -}>; - -export type Country = { - /** - * Country code - */ - code?: string; - /** - * Country name - */ - name?: string; - states?: Array | null; - region?: string; -}; - -/** - * Information about the File - */ -export type File = { - /** - * Role of the file - */ - type?: string; - /** - * File ID - */ - readonly id?: number; - /** - * Source URL where the file is downloaded from. The use of .ai .psd and .tiff files have been depreciated, if your application uses these file types or accepts these types from users you will need to add validation. - */ - url: string; - /** - * Array of additional options for this file [See examples](#section/Options) - */ - options?: Array; - /** - * MD5 checksum of the file - */ - readonly hash?: string; - /** - * File name - */ - filename?: string; - /** - * MIME type of the file - */ - readonly mime_type?: string; - /** - * Size in bytes - */ - readonly size?: number; - /** - * Width in pixels - */ - readonly width?: number; - /** - * Height in pixels - */ - readonly height?: number; - /** - * Resolution DPI.
**Note:** for vector files this may be indicated as only 72dpi, but it doesn't affect print quality since the vector files are resolution independent. - */ - readonly dpi?: number; - /** - * File processing status:
**ok** - file was processed successfuly
**waiting** - file is being processed
**failed** - file failed to be processed - */ - readonly status?: string; - /** - * File creation timestamp - */ - readonly created?: number; - /** - * Small thumbnail URL - */ - readonly thumbnail_url?: string; - /** - * Medium preview image URL - */ - readonly preview_url?: string; - /** - * Show file in the Printfile Library (default true) - */ - visible?: boolean; - /** - * Whether it is a temporary printfile. - */ - readonly is_temporary?: boolean; -}; - -/** - * File option - */ -export type FileOption = { - /** - * Option id - */ - id: string; - /** - * Option value - */ - value: string; -}; - -export type FileType = { - /** - * Deprecated file type identifier. Please use type field instead! - * @deprecated - */ - id?: string; - /** - * File type identifier - use this to specify a file's purpose when creating an order [See examples](#section/Placements) - */ - type?: string; - /** - * Display name - */ - title?: string; - /** - * Additional price when this print file type is used - */ - additional_price?: string; - /** - * Additional options available to product files - */ - options?: Array; -}; - -/** - * GenerationTask - */ -export type GenerationTask = { - /** - * Task identifier you will use to retrieve generated mockups. - */ - task_key?: string; - /** - * Status of the generation task. - */ - status?: 'pending' | 'completed' | 'failed'; - /** - * If task has failed, reason will be provided here. - */ - error?: string; - /** - * If task is completed, list of mockups will be provided here. - */ - mockups?: Array; - /** - * If task is completed, list of printfiles will be provided here. - */ - printfiles?: Array; -}; - -/** - * Status of the generation task. - */ -export enum status2 { - PENDING = 'pending', - COMPLETED = 'completed', - FAILED = 'failed', -} - -/** - * Generation task extra mockup - */ -export type GenerationTaskExtraMockup = { - /** - * Display name of the extra mockup. - */ - title?: string; - /** - * Temporary URL of the mockup. - */ - url?: string; - /** - * Style option name - */ - option?: string; - /** - * Style option group name - */ - option_group?: string; -}; - -/** - * Placement and file mapping to be generated. - */ -export type GenerationTaskFile = { - /** - * Placement identifier (front, back, etc.). - */ - placement?: string; - /** - * Public URL where your file is stored. - */ - image_url?: string; - position?: GenerationTaskFilePosition; - /** - * Array of additional options for this file [See examples](#section/Options) - */ - options?: Array; -}; - -/** - * Position - */ -export type GenerationTaskFilePosition = { - /** - * Positioning area width on print area in pixels - */ - area_width?: number | null; - /** - * Positioning area height on print area in pixels - */ - area_height?: number | null; - /** - * Width of the image in given area in pixels - */ - width?: number; - /** - * Height of the image in given area in pixels - */ - height?: number; - /** - * Image top offset in given area in pixels - */ - top?: number; - /** - * Image left offset in given area in pixels - */ - left?: number; -}; - -/** - * Generation task mockup. - */ -export type GenerationTaskMockup = { - /** - * Placement identifier. - */ - placement?: string; - /** - * This is a name that can be displayed to end customers. - */ - display_name?: string; - /** - * List of variant ids this mockup is used for. One mockup can be used for multiple variants. - */ - variant_ids?: Array; - /** - * Optional extra mockups. - */ - extra?: Array; -}; - -/** - * Generated File placements and URLs. - */ -export type GenerationTaskTemplateFile = { - /** - * List of variant IDs associated with printfiles. - */ - variant_ids?: Array; - /** - * Placement identifier (front, back, etc.). - */ - placement?: string; - /** - * Public URL where your file is stored. - */ - url?: string; -}; - -/** - * Optional gift message for the packing slip - */ -export type Gift = { - /** - * Gift message title - */ - subject?: string; - /** - * Gift message text - */ - message?: string; -}; - -/** - * Information about an incomplete item in the order - */ -export type IncompleteItem = { - /** - * Incomplete item name - */ - name?: string; - /** - * Incompleted item quantity - */ - quantity?: number; - /** - * Sync variant ID of the incompleted item. - */ - sync_variant_id?: number; - /** - * External variant ID of the incompleted item. - */ - external_variant_id?: string; - /** - * External order line item id. - */ - external_line_item_id?: string; -}; - -/** - * Information about an item in the order - */ -export type Item = { - /** - * Line item ID - */ - id?: number; - /** - * Line item ID from the external system - */ - external_id?: string; - /** - * Variant ID of the item ordered. See [Catalog API](#tag/Catalog-API) - */ - variant_id?: number; - /** - * Sync variant ID of the item ordered. [Example](#section/Orders-API-examples/Using-a-sync-variant). - */ - sync_variant_id?: number; - /** - * External variant ID of the item ordered. [Example](#section/Orders-API-examples/Using-sync-variant-with-external-ID). - */ - external_variant_id?: string; - /** - * Warehousing product variant ID of the item ordered. See Warehouse Products API - */ - warehouse_product_variant_id?: number; - /** - * The ID of a Product Template to generate the printfiles from. The `variant_id` field must be passed as well. - * Can't be combined with following fields: `sync_variant_id`, `external_variant_id`, `warehouse_product_variant_id`, - * `files`, `options`, `external_product_id`. [Examples](#section/Orders-API-examples/Using-a-product-template). - * - */ - product_template_id?: number; - /** - * The External Product ID associated with a Product Template to generate the printfiles from. - * The `variant_id` field must be passed as well. Can't be combined with following fields: `sync_variant_id`, - * `external_variant_id`, `warehouse_product_variant_id`, `files`, `options`, `product_template_id`. [Examples](#section/Orders-API-examples/Using-a-product-template). - * - */ - external_product_id?: string; - /** - * Number of items ordered (Limited to 1000 for one item) - */ - quantity?: number; - /** - * Printful price of the item - */ - price?: string; - /** - * Original retail price of the item to be displayed on the packing slip - */ - retail_price?: string; - /** - * Display name of the item. If not given, a name from the Printful system will be displayed on the packing slip - */ - name?: string; - product?: ProductVariant; - /** - * Array of attached printfiles / preview images - */ - files?: Array< - File & { - position?: GenerationTaskFilePosition & { - /** - * Should limit printfile to print area - */ - limit_to_print_area?: boolean; - }; - } - >; - /** - * Array of additional options for this product [See examples](#section/Options) - */ - options?: Array