Skip to content

Commit

Permalink
chore: add GetCatalogOptions type
Browse files Browse the repository at this point in the history
!BREAKING_CHANGE
  • Loading branch information
adiwajshing committed Dec 8, 2022
1 parent c96a765 commit bed4f7f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/Socket/business.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -12,19 +12,15 @@ 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!)

const queryParamNodes: BinaryNode[] = [
{
tag: 'limit',
attrs: { },
content: Buffer.from(limit.toString())
content: Buffer.from((limit || 10).toString())
},
{
tag: 'width',
Expand Down
11 changes: 10 additions & 1 deletion src/Types/Product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit bed4f7f

Please sign in to comment.