From 8f0e2e76bd6523ba5a13646148601053a98c0a2a Mon Sep 17 00:00:00 2001 From: jerlyrosa Date: Mon, 18 Sep 2023 21:09:08 -0400 Subject: [PATCH] feat(inventory): add getAttributes method --- src/modules/inventory/index.ts | 12 ++++++++++++ src/queries/inventory.query.ts | 15 +++++++++++++++ src/types/inventory.ts | 6 ++++++ 3 files changed, 33 insertions(+) diff --git a/src/modules/inventory/index.ts b/src/modules/inventory/index.ts index ebe5815f..79bb0f5a 100644 --- a/src/modules/inventory/index.ts +++ b/src/modules/inventory/index.ts @@ -1,5 +1,6 @@ import { ClientType } from './../../index'; import { + GET_ATTRIBUTES, GET_PRODUCTS, GET_PRODUCT_TYPES, GET_REGIONS, @@ -31,6 +32,7 @@ import { UpdatedVariantWarehouse, AllCreatedProducts, CreatedWarehouses, + CreatedAttributes, } from '../../types'; export class Inventory { @@ -149,4 +151,14 @@ export class Inventory { }); return response.data; } + + public async getAttributes( + whereCondition?: WhereCondition + ): Promise { + const response = await this.client.query({ + query: GET_ATTRIBUTES, + variables: { whereCondition }, + }); + return response.data; + } } diff --git a/src/queries/inventory.query.ts b/src/queries/inventory.query.ts index 7f5822e7..c6d3d46d 100644 --- a/src/queries/inventory.query.ts +++ b/src/queries/inventory.query.ts @@ -180,3 +180,18 @@ export const GET_WAREHOUSES = gql` } } `; + +export const GET_ATTRIBUTES = gql` + query getAttributes($whereCondition: QueryAttributesWhereWhereConditions) { + attributes(where: $whereCondition) { + data { + id + name + values { + id + value + } + } + } + } +`; diff --git a/src/types/inventory.ts b/src/types/inventory.ts index c4415b5c..2460919a 100644 --- a/src/types/inventory.ts +++ b/src/types/inventory.ts @@ -283,6 +283,12 @@ export interface CreatedWarehouses { }; } +export interface CreatedAttributes { + attributes: { + data: AttributesInterface[]; + }; +} + export interface DeleteProduct { deleteProduct: boolean; }