From 96499b24680531491aeee09e126c2ca16a4d217a Mon Sep 17 00:00:00 2001 From: MagicStino Date: Tue, 7 Feb 2023 01:52:44 +0100 Subject: [PATCH 1/4] getAllProductVariants, getProduct, ImageResource --- package-lock.json | 28 ++++++++++----------- src/clients/EcomTypes.ts | 43 ++++++++++++++++++++++++++++++++ src/clients/LightspeedEcomApi.ts | 11 +++++++- 3 files changed, 67 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3c717b9..c3a62e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lightspeed-sdk", - "version": "0.1.0-beta.10", + "version": "0.1.0-beta.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "lightspeed-sdk", - "version": "0.1.0-beta.10", + "version": "0.1.0-beta.11", "license": "MIT", "dependencies": { "axios": "^0.21.0", @@ -1744,9 +1744,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.14.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz", - "integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "funding": [ { "type": "individual", @@ -2697,9 +2697,9 @@ "dev": true }, "node_modules/json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true, "bin": { "json5": "lib/cli.js" @@ -5033,9 +5033,9 @@ } }, "follow-redirects": { - "version": "1.14.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz", - "integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==" + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" }, "form-data": { "version": "3.0.0", @@ -5742,9 +5742,9 @@ "dev": true }, "json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true }, "kleur": { diff --git a/src/clients/EcomTypes.ts b/src/clients/EcomTypes.ts index a2bb1f4..1c2aee6 100644 --- a/src/clients/EcomTypes.ts +++ b/src/clients/EcomTypes.ts @@ -33,6 +33,16 @@ export type ResourceLink = { }; }; +export type ImageResource = { + createdAt: string, + updatedAt: string, + extension: string, + size: number, + title: string, + thumb: string, //url + src: string //url +}; + export type PaymentData = { method: string; }; @@ -239,3 +249,36 @@ export type ProductVariant = { weightUnit: string; weightValue: string; }; + + +export type Product = { + id: number, + createdAt: string, + updatedAt: string, + isVisible: boolean, + visibility: string, + hasMatrix: boolean, + data01: string, + data02: string, + data03: string, + url: string, + title: string, + fulltitle: string, + description: string, + content: string, + set: boolean, + brand: ResourceLink, + categories: ResourceLink, + deliverydate: boolean, + image: ImageResource, + images: ResourceLink, + relations: ResourceLink, + metafields: ResourceLink, + reviews: ResourceLink, + type: boolean, + attributes: ResourceLink, + supplier: ResourceLink, + tags: ResourceLink, + variants: ResourceLink, + movements: ResourceLink +} \ No newline at end of file diff --git a/src/clients/LightspeedEcomApi.ts b/src/clients/LightspeedEcomApi.ts index b3c334c..105687c 100644 --- a/src/clients/LightspeedEcomApi.ts +++ b/src/clients/LightspeedEcomApi.ts @@ -1,6 +1,6 @@ import axios, { AxiosInstance } from 'axios'; import EcomApiCursor from '../utils/EcomApiCursor'; -import { Account, Order, OrderProduct, ProductVariant } from './EcomTypes'; +import { Account, Order, OrderProduct, ProductVariant, Product } from './EcomTypes'; type ClusterId = 'eu1' | 'EU1' | 'us1' | 'US1'; @@ -88,6 +88,15 @@ class LightspeedEcomApi { const response = await this.axiosClient.get(`variants/${variantId}.json`); return response.data.variant as ProductVariant; } + + getVariantsAllProducts(): EcomApiCursor { + return new EcomApiCursor('variants', this.axiosClient, 'variants'); + } + + getProducts(): EcomApiCursor { + return new EcomApiCursor('products', this.axiosClient, 'products'); + } + } export default LightspeedEcomApi; From ada268500a08605120fa802811175dc0bea55e8d Mon Sep 17 00:00:00 2001 From: MagicStino Date: Tue, 7 Feb 2023 02:43:35 +0100 Subject: [PATCH 2/4] reverted package-lock.json, added ending semicolons to type --- package-lock.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index c3a62e9..3c717b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lightspeed-sdk", - "version": "0.1.0-beta.11", + "version": "0.1.0-beta.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "lightspeed-sdk", - "version": "0.1.0-beta.11", + "version": "0.1.0-beta.10", "license": "MIT", "dependencies": { "axios": "^0.21.0", @@ -1744,9 +1744,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "version": "1.14.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz", + "integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==", "funding": [ { "type": "individual", @@ -2697,9 +2697,9 @@ "dev": true }, "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", + "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", "dev": true, "bin": { "json5": "lib/cli.js" @@ -5033,9 +5033,9 @@ } }, "follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" + "version": "1.14.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz", + "integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==" }, "form-data": { "version": "3.0.0", @@ -5742,9 +5742,9 @@ "dev": true }, "json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", + "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", "dev": true }, "kleur": { From 4c554256a3b07a02274ca6e438f49d9623a9e36c Mon Sep 17 00:00:00 2001 From: MagicStino Date: Tue, 7 Feb 2023 02:49:46 +0100 Subject: [PATCH 3/4] Added semicol at end of Product type declaration --- src/clients/EcomTypes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clients/EcomTypes.ts b/src/clients/EcomTypes.ts index 1c2aee6..a2eb898 100644 --- a/src/clients/EcomTypes.ts +++ b/src/clients/EcomTypes.ts @@ -281,4 +281,4 @@ export type Product = { tags: ResourceLink, variants: ResourceLink, movements: ResourceLink -} \ No newline at end of file +}; \ No newline at end of file From 537a3e699dd616a1ab0ff7725ebfac764417b2ab Mon Sep 17 00:00:00 2001 From: MagicStino Date: Tue, 7 Feb 2023 21:53:25 +0100 Subject: [PATCH 4/4] replaced commas with semicolons in EcomTypes for ImageResource and Product types declarations --- src/clients/EcomTypes.ts | 72 ++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/clients/EcomTypes.ts b/src/clients/EcomTypes.ts index a2eb898..32837a0 100644 --- a/src/clients/EcomTypes.ts +++ b/src/clients/EcomTypes.ts @@ -34,13 +34,13 @@ export type ResourceLink = { }; export type ImageResource = { - createdAt: string, - updatedAt: string, - extension: string, - size: number, - title: string, - thumb: string, //url - src: string //url + createdAt: string; + updatedAt: string; + extension: string; + size: number; + title: string; + thumb: string; + src: string; }; export type PaymentData = { @@ -252,33 +252,33 @@ export type ProductVariant = { export type Product = { - id: number, - createdAt: string, - updatedAt: string, - isVisible: boolean, - visibility: string, - hasMatrix: boolean, - data01: string, - data02: string, - data03: string, - url: string, - title: string, - fulltitle: string, - description: string, - content: string, - set: boolean, - brand: ResourceLink, - categories: ResourceLink, - deliverydate: boolean, - image: ImageResource, - images: ResourceLink, - relations: ResourceLink, - metafields: ResourceLink, - reviews: ResourceLink, - type: boolean, - attributes: ResourceLink, - supplier: ResourceLink, - tags: ResourceLink, - variants: ResourceLink, - movements: ResourceLink + id: number; + createdAt: string; + updatedAt: string; + isVisible: boolean; + visibility: string; + hasMatrix: boolean; + data01: string; + data02: string; + data03: string; + url: string; + title: string; + fulltitle: string; + description: string; + content: string; + set: boolean; + brand: ResourceLink; + categories: ResourceLink; + deliverydate: boolean; + image: ImageResource; + images: ResourceLink; + relations: ResourceLink; + metafields: ResourceLink; + reviews: ResourceLink; + type: boolean; + attributes: ResourceLink; + supplier: ResourceLink; + tags: ResourceLink; + variants: ResourceLink; + movements: ResourceLink; }; \ No newline at end of file