Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/clients/EcomTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ export type ResourceLink = {
};
};

export type ImageResource = {
createdAt: string;
updatedAt: string;
extension: string;
size: number;
title: string;
thumb: string;
src: string;
};

export type PaymentData = {
method: string;
};
Expand Down Expand Up @@ -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;
};
11 changes: 10 additions & 1 deletion src/clients/LightspeedEcomApi.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -88,6 +88,15 @@ class LightspeedEcomApi {
const response = await this.axiosClient.get(`variants/${variantId}.json`);
return response.data.variant as ProductVariant;
}

getVariantsAllProducts(): EcomApiCursor<ProductVariant[]> {
return new EcomApiCursor<ProductVariant[]>('variants', this.axiosClient, 'variants');
}

getProducts(): EcomApiCursor<Product[]> {
return new EcomApiCursor<Product[]>('products', this.axiosClient, 'products');
}

}

export default LightspeedEcomApi;