Added definitions for the wishlist

This commit is contained in:
Luis Alvarez 2020-10-26 10:34:52 -05:00
parent 610d456f13
commit 23a36d0826
3 changed files with 158 additions and 21 deletions

View File

@ -1215,12 +1215,11 @@ export interface definitions {
/**
* Array of option and option values IDs that make up this variant. Will be empty if the variant is the product's base variant.
*/
option_values?: definitions['productVariantOptionValue_Full'][]
option_values?: definitions['productVariantOptionValue_Base'][]
/**
* The price of the variant as seen on the storefront. This price takes into account `sale_price` and any price adjustment rules that are applicable to this variant.
*/
calculated_price?: number
''?: string
}
/**
* The model for a POST to create variants on a product.
@ -1296,7 +1295,7 @@ export interface definitions {
/**
* Array of option and option values IDs that make up this variant. Will be empty if the variant is the product's base variant.
*/
option_values?: definitions['productVariantOptionValue_Full'][]
option_values?: { id?: number; option_id?: number }[]
}
variantCollection_Put: definitions['productVariant_Full'][]
/**
@ -1481,16 +1480,7 @@ export interface definitions {
/**
* Common Product Variant Option properties.
*/
productVariantOptionValue_Base: {
/**
* `option_value` ID.
*/
id?: number
/**
* `option` ID.
*/
option_id?: number
}
productVariantOptionValue_Base: { id?: number; option_id?: number }
/**
* The model for a POST to create option values on a variant.
*/
@ -1909,7 +1899,9 @@ export interface definitions {
*/
image_url?: string
}
product_Post: definitions['product_Base']
product_Post: definitions['product_Base'] & {
variants?: definitions['productVariant_Post_Product']
}
/**
* The model for a PUT to update a product.
*/
@ -2721,11 +2713,11 @@ export interface definitions {
/**
* The product name.
*/
name: string
name?: string
/**
* The product type. One of: `physical` - a physical stock unit, `digital` - a digital download.
*/
type: 'physical' | 'digital'
type?: 'physical' | 'digital'
/**
* User defined product code/stock keeping unit (SKU).
*/
@ -2737,7 +2729,7 @@ export interface definitions {
/**
* Weight of the product, which can be used when calculating shipping costs. This is based on the unit set on the store
*/
weight: number
weight?: number
/**
* Width of the product, which can be used when calculating shipping costs.
*/
@ -2753,7 +2745,7 @@ export interface definitions {
/**
* The price of the product. The price should include or exclude tax, based on the store settings.
*/
price: number
price?: number
/**
* The cost price of the product. Stored for reference only; it is not used or displayed anywhere on the store.
*/

View File

@ -0,0 +1,142 @@
/**
* This file was auto-generated by swagger-to-ts.
* Do not make direct changes to the file.
*/
export interface definitions {
wishlist_Post: {
/**
* The customer id.
*/
customer_id: number
/**
* Whether the wishlist is available to the public.
*/
is_public?: boolean
/**
* The title of the wishlist.
*/
name?: string
/**
* Array of Wishlist items.
*/
items?: {
/**
* The ID of the product.
*/
product_id?: number
/**
* The variant ID of the product.
*/
variant_id?: number
}[]
}
wishlist_Put: {
/**
* The customer id.
*/
customer_id: number
/**
* Whether the wishlist is available to the public.
*/
is_public?: boolean
/**
* The title of the wishlist.
*/
name?: string
/**
* Array of Wishlist items.
*/
items?: {
/**
* The ID of the item
*/
id?: number
/**
* The ID of the product.
*/
product_id?: number
/**
* The variant ID of the item.
*/
variant_id?: number
}[]
}
wishlist_Full: {
/**
* Wishlist ID, provided after creating a wishlist with a POST.
*/
id?: number
/**
* The ID the customer to which the wishlist belongs.
*/
customer_id?: number
/**
* The Wishlist's name.
*/
name?: string
/**
* Whether the Wishlist is available to the public.
*/
is_public?: boolean
/**
* The token of the Wishlist. This is created internally within BigCommerce. The Wishlist ID is to be used for external apps. Read-Only
*/
token?: string
/**
* Array of Wishlist items
*/
items?: definitions['wishlistItem_Full'][]
}
wishlistItem_Full: {
/**
* The ID of the item
*/
id?: number
/**
* The ID of the product.
*/
product_id?: number
/**
* The variant ID of the item.
*/
variant_id?: number
}
wishlistItem_Post: {
/**
* The ID of the product.
*/
product_id?: number
/**
* The variant ID of the product.
*/
variant_id?: number
}
/**
* Data about the response, including pagination and collection totals.
*/
pagination: {
/**
* Total number of items in the result set.
*/
total?: number
/**
* Total number of items in the collection response.
*/
count?: number
/**
* The amount of items returned in the collection per page, controlled by the limit parameter.
*/
per_page?: number
/**
* The page you are currently on within the collection.
*/
current_page?: number
/**
* The total number of pages in the collection.
*/
total_pages?: number
}
error: { status?: number; title?: string; type?: string }
metaCollection: { pagination?: definitions['pagination'] }
}

View File

@ -8,7 +8,7 @@ const fetch = require('node-fetch')
const swaggerToTS = require('@manifoldco/swagger-to-ts').default
async function getSchema(filename) {
const url = `https://next-api.stoplight.io/projects/8433/files/${filename}?ref=version%2F1.3`
const url = `https://next-api.stoplight.io/projects/8433/files/${filename}`
const res = await fetch(url)
if (!res.ok) {
@ -19,9 +19,12 @@ async function getSchema(filename) {
}
const schemas = Object.entries({
'../api/definitions/catalog.ts': 'BigCommerce_Catalog_API.oas2.yml',
'../api/definitions/catalog.ts':
'BigCommerce_Catalog_API.oas2.yml?ref=version%2F20.930',
'../api/definitions/store-content.ts':
'BigCommerce_Store_Content_API.oas2.yml',
'BigCommerce_Store_Content_API.oas2.yml?ref=version%2F20.930',
'../api/definitions/wishlist.ts':
'BigCommerce_Wishlist_API.oas2.yml?ref=version%2F20.930',
// swagger-to-ts is not working for the schema of the cart API
// '../api/definitions/cart.ts':
// 'BigCommerce_Server_to_Server_Cart_API.oas2.yml',