Skip to content

Commit

Permalink
feat(inventory): add getAttributes method
Browse files Browse the repository at this point in the history
  • Loading branch information
jerlyrosa committed Sep 19, 2023
1 parent 105fc3e commit 8f0e2e7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/modules/inventory/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ClientType } from './../../index';
import {
GET_ATTRIBUTES,
GET_PRODUCTS,
GET_PRODUCT_TYPES,
GET_REGIONS,
Expand Down Expand Up @@ -31,6 +32,7 @@ import {
UpdatedVariantWarehouse,
AllCreatedProducts,
CreatedWarehouses,
CreatedAttributes,
} from '../../types';

export class Inventory {
Expand Down Expand Up @@ -149,4 +151,14 @@ export class Inventory {
});
return response.data;
}

public async getAttributes(
whereCondition?: WhereCondition
): Promise<CreatedAttributes> {
const response = await this.client.query({
query: GET_ATTRIBUTES,
variables: { whereCondition },
});
return response.data;
}
}
15 changes: 15 additions & 0 deletions src/queries/inventory.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
`;
6 changes: 6 additions & 0 deletions src/types/inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ export interface CreatedWarehouses {
};
}

export interface CreatedAttributes {
attributes: {
data: AttributesInterface[];
};
}

export interface DeleteProduct {
deleteProduct: boolean;
}

0 comments on commit 8f0e2e7

Please sign in to comment.