From 9ca977c44fd64ff0c2b946cd27390f916a7aa9a4 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Wed, 30 Sep 2020 12:32:46 -0500 Subject: [PATCH] Fix --- lib/bigcommerce/api/index.ts | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/bigcommerce/api/index.ts b/lib/bigcommerce/api/index.ts index 01e607320..457451326 100644 --- a/lib/bigcommerce/api/index.ts +++ b/lib/bigcommerce/api/index.ts @@ -17,8 +17,8 @@ export interface GetAllProductsResult { } export default class BigcommerceAPI implements CommerceAPI { - protected commerceUrl: string; - protected apiToken: string; + commerceUrl: string; + apiToken: string; constructor({ commerceUrl, apiToken }: CommerceAPIOptions) { this.commerceUrl = commerceUrl; @@ -52,24 +52,20 @@ export default class BigcommerceAPI implements CommerceAPI { async getAllProducts(opts: { query: string; }): Promise>; - async getAllProducts({ - query, - }: { query?: string } = {}): Promise< - GetAllProductsResult - // T extends GetAllProductsQuery - // ? GetAllProductsResult - // : Partial> - > { - if (!query) { - const data = await this.fetch(getAllProductsQuery); - return { - products: data.site.products.edges, - }; - } + async getAllProducts(opts?: { + query?: string; + }): Promise>; + + async getAllProducts({ + query = getAllProductsQuery, + }: { query?: string } = {}): Promise< + GetAllProductsResult> + > { + const data = await this.fetch>(query); return { - products: undefined, + products: data?.site?.products?.edges, }; } }