diff --git a/src/index.ts b/src/index.ts index dc7565a..84c4333 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import { events, Product, Response, Stock, Order, OrderItem, OrderPart, OPERATOR, User } from './types' import api, { client, getConfig, init, initialise, resetConfig, updateToken, updateInstanceUrl } from './api' import { getTelecomCountryCode, hasError, isError } from './util' -import { askQuery, getAvailableTimeZones, getGitBookPage, getNotificationEnumIds, getNotificationUserPrefTypeIds, getUserFacilities, fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent, fetchProductsStock, fetchProductsStockAtFacility, getEComStoresByFacility, getOrderDetails, getProductIdentificationPref, getProfile, logout, removeClientRegistrationToken, searchQuery, setProductIdentificationPref, storeClientRegistrationToken, subscribeTopic, unsubscribeTopic, updateOrderStatus, getUserPreference, setUserPreference, setUserLocale, setUserTimeZone} from './modules' +import { askQuery, getAvailableTimeZones, getGitBookPage, getNotificationEnumIds, getNotificationUserPrefTypeIds, getUserFacilities, fetchGoodIdentificationTypes, fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent, fetchProductsStock, fetchProductsStockAtFacility, getEComStoresByFacility, getOrderDetails, getProductIdentificationPref, getProfile, logout, removeClientRegistrationToken, searchQuery, setProductIdentificationPref, storeClientRegistrationToken, subscribeTopic, unsubscribeTopic, updateOrderStatus, getUserPreference, setUserPreference, setUserLocale, setUserTimeZone} from './modules' export { api, @@ -9,6 +9,7 @@ export { client, getOrderDetails, updateOrderStatus, + fetchGoodIdentificationTypes, fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent, diff --git a/src/modules/index.ts b/src/modules/index.ts index da56ed0..f1e9997 100644 --- a/src/modules/index.ts +++ b/src/modules/index.ts @@ -1,5 +1,5 @@ import { getOrderDetails, updateOrderStatus } from '../modules/order' -import { fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent } from '../modules/product' +import { fetchGoodIdentificationTypes, fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent } from '../modules/product' import { getEComStoresByFacility, getAvailableTimeZones, getProductIdentificationPref, getProfile, getUserFacilities, getUserPreference, logout, setProductIdentificationPref, setUserPreference, setUserLocale, setUserTimeZone} from '../modules/user' import { getNotificationEnumIds, getNotificationUserPrefTypeIds, removeClientRegistrationToken, storeClientRegistrationToken, subscribeTopic, unsubscribeTopic } from '../modules/notification' import { fetchProductsStock, fetchProductsStockAtFacility } from '../modules/stock' @@ -7,6 +7,7 @@ import { askQuery, getGitBookPage, searchQuery } from '../modules/gitbook' export { askQuery, + fetchGoodIdentificationTypes, fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent, diff --git a/src/modules/product/index.ts b/src/modules/product/index.ts index 36280a0..5900462 100644 --- a/src/modules/product/index.ts +++ b/src/modules/product/index.ts @@ -165,4 +165,35 @@ async function fetchProductsGroupedByParent(params: any): Promise { + const payload = { + "inputFields": { + "parentTypeId": parentTypeId, + }, + "fieldList": ["goodIdentificationTypeId", "description"], + "viewSize": 50, + "entityName": "GoodIdentificationType", + "noConditionFind": "Y" + } + try { + const resp = await api({ + url: "performFind", + method: "get", + params: payload + }) as any + + if (!hasError(resp)) { + return Promise.resolve(resp.data.docs) + } else { + throw resp.data; + } + } catch (err) { + return Promise.reject({ + code: 'error', + message: 'Something went wrong', + serverResponse: err + }) + } +} + +export { fetchGoodIdentificationTypes, fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent }