Skip to content

Commit

Permalink
feat: Added WPP.catalog.getProducts function
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Aug 13, 2022
1 parent 5153e81 commit f4d1716
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/catalog/functions/getProducts.ts
@@ -0,0 +1,41 @@
/*!
* Copyright 2021 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { createWid } from '../../util';
import { queryCatalog } from '../../whatsapp/functions';

/**
* Retrieves product by contact id
*
* @example
* Get products of catalogs
* ```javascript
* await WPP.catalog.getProducts('5521985625689@c.us', 10);
* ```
* @return A array with products
* @category Catalog
*/

export async function getProducts(chatId: string, qnt: number): Promise<any[]> {
const { data } = await queryCatalog(
createWid(chatId),
undefined,
qnt || 10,
100,
100
);
return data;
}
13 changes: 13 additions & 0 deletions src/catalog/functions/index.ts
Expand Up @@ -14,4 +14,17 @@
* limitations under the License.
*/

export { createProduct } from './createProduct';
export { changeProductImage } from './changeProductImage';
export { createCollection } from './createCollection';
export { deleteCollection } from './deleteCollection';
export { delProducts } from './deleteProduct';
export { editCollection } from './editCollection';
export { editProduct } from './editProduct';
export { getMyCatalog } from './getMyCatalog';
export { getCollections } from './getCollections';
export { getProductById } from './getProductById';
export { getProducts } from './getProducts';
export { removeProductImage } from './removeProductImage';
export { setProductVisibility } from './setProductVisibility';
export { addProductImage } from './addProductImage';

0 comments on commit f4d1716

Please sign in to comment.