chore: add GetCatalogOptions type

!BREAKING_CHANGE
This commit is contained in:
Adhiraj Singh
2022-12-08 13:32:10 +05:30
parent c96a7652d9
commit bed4f7f524
2 changed files with 13 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import { CatalogCursor, ProductCreate, ProductUpdate, SocketConfig } from '../Types'
import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types'
import { parseCatalogNode, parseCollectionsNode, parseOrderDetailsNode, parseProductNode, toProductNode, uploadingNecessaryImagesOfProduct } from '../Utils/business'
import { BinaryNode, jidNormalizedUser, S_WHATSAPP_NET } from '../WABinary'
import { getBinaryNodeChild } from '../WABinary/generic-utils'
@@ -12,11 +12,7 @@ export const makeBusinessSocket = (config: SocketConfig) => {
waUploadToServer
} = sock
const getCatalog = async(
jid?: string,
limit = 10,
cursor?: CatalogCursor
) => {
const getCatalog = async({ jid, limit, cursor }: GetCatalogOptions) => {
jid = jid || authState.creds.me?.id
jid = jidNormalizedUser(jid!)
@@ -24,7 +20,7 @@ export const makeBusinessSocket = (config: SocketConfig) => {
{
tag: 'limit',
attrs: { },
content: Buffer.from(limit.toString())
content: Buffer.from((limit || 10).toString())
},
{
tag: 'width',

View File

@@ -72,4 +72,13 @@ export type OrderDetails = {
products: OrderProduct[]
}
export type CatalogCursor = string
export type CatalogCursor = string
export type GetCatalogOptions = {
/** cursor to start from */
cursor?: CatalogCursor
/** number of products to fetch */
limit?: number
jid?: string
}