UNPKG

ordercloud-javascript-sdk

Version:

The offical Javascript SDK for the Ordercloud ecommerce API

311 lines (310 loc) 21.3 kB
import { ListPageWithFacets } from '../models/ListPageWithFacets'; import { Searchable } from '../models/Searchable'; import { Sortable } from '../models/Sortable'; import { Filters } from '../models/Filters'; import { Product } from '../models/Product'; import { SearchType } from '../models/SearchType'; import { ListPage } from '../models/ListPage'; import { Spec } from '../models/Spec'; import { ProductSupplier } from '../models/ProductSupplier'; import { Variant } from '../models/Variant'; import { VariantOverrides } from '../models/VariantOverrides'; import { ProductAssignment } from '../models/ProductAssignment'; import { PartialDeep } from '../models/PartialDeep'; import { RequiredDeep } from '../models/RequiredDeep'; import { RequestOptions } from '../models/RequestOptions'; declare class Products { private impersonating; /** * @ignore * not part of public api, don't include in generated docs */ constructor(); /** * List products * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/list|api docs} for more info * * @param listOptions.catalogID ID of the catalog. * @param listOptions.categoryID ID of the category. * @param listOptions.supplierID ID of the supplier. * @param listOptions.search Word or phrase to search for. * @param listOptions.searchOn Comma-delimited list of fields to search on. * @param listOptions.searchType Type of search to perform. * @param listOptions.sortBy Comma-delimited list of fields to sort by. * @param listOptions.page Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation. * @param listOptions.pageSize Number of results to return per page. * @param listOptions.filters An object or dictionary representing key/value pairs to apply as filters. Valid keys are top-level properties of the returned model or 'xp.???' * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ List<TProduct extends Product>(listOptions?: { catalogID?: string; categoryID?: string; supplierID?: string; search?: string; searchOn?: Searchable<'Products.List'>; searchType?: SearchType; sortBy?: Sortable<'Products.List'>; page?: number; pageSize?: number; filters?: Filters; }, requestOptions?: RequestOptions): Promise<RequiredDeep<ListPageWithFacets<TProduct>>>; /** * Create a product * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/create|api docs} for more info * * @param product Required fields: Name * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ Create<TProduct extends Product>(product: Product, requestOptions?: RequestOptions): Promise<RequiredDeep<TProduct>>; /** * Retrieve a product * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/get|api docs} for more info * * @param productID ID of the product. * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ Get<TProduct extends Product>(productID: string, requestOptions?: RequestOptions): Promise<RequiredDeep<TProduct>>; /** * Create or update a product If an object with the same ID already exists, it will be overwritten. * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/save|api docs} for more info * * @param productID ID of the product. * @param product Required fields: Name * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ Save<TProduct extends Product>(productID: string, product: Product, requestOptions?: RequestOptions): Promise<RequiredDeep<TProduct>>; /** * Delete a product * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/delete|api docs} for more info * * @param productID ID of the product. * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ Delete(productID: string, requestOptions?: RequestOptions): Promise<void>; /** * Partially update a product * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/patch|api docs} for more info * * @param productID ID of the product. * @param product * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ Patch<TProduct extends Product>(productID: string, product: PartialDeep<Product>, requestOptions?: RequestOptions): Promise<RequiredDeep<TProduct>>; /** * Delete a product assignment * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/delete-assignment|api docs} for more info * * @param productID ID of the product. * @param buyerID ID of the buyer. * @param listOptions.userID ID of the user. * @param listOptions.userGroupID ID of the user group. * @param listOptions.sellerID ID of the seller. * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ DeleteAssignment(productID: string, buyerID: string, listOptions?: { userID?: string; userGroupID?: string; sellerID?: string; }, requestOptions?: RequestOptions): Promise<void>; /** * List product specs * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/list-specs|api docs} for more info * * @param productID ID of the product. * @param listOptions.search Word or phrase to search for. * @param listOptions.searchOn Comma-delimited list of fields to search on. * @param listOptions.sortBy Comma-delimited list of fields to sort by. * @param listOptions.page Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation. * @param listOptions.pageSize Number of results to return per page. * @param listOptions.filters An object or dictionary representing key/value pairs to apply as filters. Valid keys are top-level properties of the returned model or 'xp.???' * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ ListSpecs<TSpec extends Spec>(productID: string, listOptions?: { search?: string; searchOn?: Searchable<'Products.ListSpecs'>; sortBy?: Sortable<'Products.ListSpecs'>; page?: number; pageSize?: number; filters?: Filters; }, requestOptions?: RequestOptions): Promise<RequiredDeep<ListPage<TSpec>>>; /** * List product suppliers * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/list-suppliers|api docs} for more info * * @param productID ID of the product. * @param listOptions.search Word or phrase to search for. * @param listOptions.searchOn Comma-delimited list of fields to search on. * @param listOptions.sortBy Comma-delimited list of fields to sort by. * @param listOptions.page Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation. * @param listOptions.pageSize Number of results to return per page. * @param listOptions.filters An object or dictionary representing key/value pairs to apply as filters. Valid keys are top-level properties of the returned model or 'xp.???' * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ ListSuppliers<TProductSupplier extends ProductSupplier>(productID: string, listOptions?: { search?: string; searchOn?: Searchable<'Products.ListSuppliers'>; sortBy?: Sortable<'Products.ListSuppliers'>; page?: number; pageSize?: number; filters?: Filters; }, requestOptions?: RequestOptions): Promise<RequiredDeep<ListPage<TProductSupplier>>>; /** * Create or update a product supplier * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/save-supplier|api docs} for more info * * @param productID ID of the product. * @param supplierID ID of the supplier. * @param listOptions.defaultPriceScheduleID ID of the default price schedule. * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ SaveSupplier(productID: string, supplierID: string, listOptions?: { defaultPriceScheduleID?: string; }, requestOptions?: RequestOptions): Promise<void>; /** * Remove a product supplier * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/remove-supplier|api docs} for more info * * @param productID ID of the product. * @param supplierID ID of the supplier. * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ RemoveSupplier(productID: string, supplierID: string, requestOptions?: RequestOptions): Promise<void>; /** * List product variants * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/list-variants|api docs} for more info * * @param productID ID of the product. * @param listOptions.search Word or phrase to search for. * @param listOptions.searchOn Comma-delimited list of fields to search on. * @param listOptions.sortBy Comma-delimited list of fields to sort by. * @param listOptions.page Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation. * @param listOptions.pageSize Number of results to return per page. * @param listOptions.filters An object or dictionary representing key/value pairs to apply as filters. Valid keys are top-level properties of the returned model or 'xp.???' * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ ListVariants<TVariant extends Variant>(productID: string, listOptions?: { search?: string; searchOn?: Searchable<'Products.ListVariants'>; sortBy?: Sortable<'Products.ListVariants'>; page?: number; pageSize?: number; filters?: Filters; }, requestOptions?: RequestOptions): Promise<RequiredDeep<ListPage<TVariant>>>; /** * Retrieve a product variant * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/get-variant|api docs} for more info * * @param productID ID of the product. * @param variantID ID of the variant. * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ GetVariant<TVariant extends Variant>(productID: string, variantID: string, requestOptions?: RequestOptions): Promise<RequiredDeep<TVariant>>; /** * Update a product variant Update a product variant. * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/save-variant|api docs} for more info * * @param productID ID of the product. * @param variantID ID of the variant. * @param variant * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ SaveVariant<TVariant extends Variant>(productID: string, variantID: string, variant: Variant, requestOptions?: RequestOptions): Promise<RequiredDeep<TVariant>>; /** * Partially update a product variant * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/patch-variant|api docs} for more info * * @param productID ID of the product. * @param variantID ID of the variant. * @param variant * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ PatchVariant<TVariant extends Variant>(productID: string, variantID: string, variant: PartialDeep<Variant>, requestOptions?: RequestOptions): Promise<RequiredDeep<TVariant>>; /** * Generate variants * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/generate-variants|api docs} for more info * * @param productID ID of the product. * @param listOptions.overwriteExisting Overwrite existing of the product. * @param variantOverrides * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ GenerateVariants<TProduct extends Product>(productID: string, variantOverrides: VariantOverrides, listOptions?: { overwriteExisting?: boolean; }, requestOptions?: RequestOptions): Promise<RequiredDeep<TProduct>>; /** * List product assignments * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/list-assignments|api docs} for more info * * @param listOptions.productID ID of the product. * @param listOptions.priceScheduleID ID of the price schedule. * @param listOptions.buyerID ID of the buyer. * @param listOptions.userGroupID ID of the user group. * @param listOptions.level Level of the product assignment. Possible values: Group, Company. * @param listOptions.page Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation. * @param listOptions.pageSize Number of results to return per page. * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ ListAssignments<TProductAssignment extends ProductAssignment>(listOptions?: { productID?: string; priceScheduleID?: string; buyerID?: string; userGroupID?: string; level?: 'Group' | 'Company'; page?: number; pageSize?: number; }, requestOptions?: RequestOptions): Promise<RequiredDeep<ListPage<TProductAssignment>>>; /** * Create or update a product assignment * Check out the {@link https://ordercloud.io/api-reference/product-catalogs/products/save-assignment|api docs} for more info * * @param productAssignment Required fields: ProductID, BuyerID * @param requestOptions.accessToken Provide an alternative token to the one stored in the sdk instance (useful for impersonation). * @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request. * @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs. */ SaveAssignment(productAssignment: ProductAssignment, requestOptions?: RequestOptions): Promise<void>; /** * @description * enables impersonation by calling the subsequent method with the stored impersonation token * * @example * Products.As().List() // lists Products using the impersonated users' token */ As(): this; } declare const _default: Products; export default _default;