Skip to content

Commit

Permalink
Merge pull request #92 from hotwax/#91_fetch_good_identification_types
Browse files Browse the repository at this point in the history
Implemented: Added api to fetch good identification types (#91).
  • Loading branch information
ravilodhi authored Oct 24, 2024
2 parents 226e71f + e6bed48 commit ed269be
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
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,
askQuery,
client,
getOrderDetails,
updateOrderStatus,
fetchGoodIdentificationTypes,
fetchProducts,
fetchProductsGroupedBy,
fetchProductsGroupedByParent,
Expand Down
3 changes: 2 additions & 1 deletion src/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
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'
import { askQuery, getGitBookPage, searchQuery } from '../modules/gitbook'

export {
askQuery,
fetchGoodIdentificationTypes,
fetchProducts,
fetchProductsGroupedBy,
fetchProductsGroupedByParent,
Expand Down
33 changes: 32 additions & 1 deletion src/modules/product/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,35 @@ async function fetchProductsGroupedByParent(params: any): Promise<Product[] | Re
return await fetchProductsGroupedBy(payload);
}

export { fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent }
async function fetchGoodIdentificationTypes(parentTypeId: string = "HC_GOOD_ID_TYPE"): Promise<any> {
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 }

0 comments on commit ed269be

Please sign in to comment.