Skip to content

Commit

Permalink
chore: Added some catalog products functions
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Nov 15, 2021
1 parent 675d199 commit b810b2a
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/whatsapp/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ export * from './getOrGenerate';
export * from './groupParticipants';
export * from './isAuthenticated';
export * from './msgFindQuery';
export * from './products';
export * from './randomId';
export * from './sendClear';
export * from './sendCreateGroup';
export * from './sendDelete';
export * from './sendQueryExists';
export * from './sendTextMsgToChat';
export * from './uploadProductImage';
60 changes: 60 additions & 0 deletions src/whatsapp/functions/products.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*!
* 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 { ProductModel } from '..';
import { exportModule } from '../exportModule';

/** @whatsapp 2.2144.10:35339 */
export declare function createBusinessCatalog(): Promise<any>;

/**
* @whatsapp 2.2144.10:68793
*/
export declare function addProduct(
product: ProductModel,
imageWidth?: number,
imageHeight?: number
): Promise<any>;

/**
* @whatsapp 2.2144.10:68793
*/
export declare function editProduct(
product: ProductModel,
imageWidth?: number,
imageHeight?: number
): Promise<any>;

/**
* @whatsapp 2.2144.10:68793
*/
export declare function deleteProducts(productIds: string[]): Promise<any>;

/**
* @whatsapp 2.2144.10:68793
*/
export declare function sendProductToChat(...args: any[]): Promise<any>;

exportModule(
exports,
{
addProduct: 'addProduct',
editProduct: 'editProduct',
deleteProducts: 'deleteProducts',
sendProductToChat: 'sendProductToChat',
},
(m) => m.sendProductToChat
);
32 changes: 32 additions & 0 deletions src/whatsapp/functions/uploadProductImage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*!
* 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 { OpaqueData } from '..';
import { exportModule } from '../exportModule';

/** @whatsapp 2.2144.10:57990 */
export declare function uploadProductImage(
mediaBlob: OpaqueData,
filehash: string
): Promise<string>;

exportModule(
exports,
{
uploadProductImage: 'uploadProductImage',
},
(m) => m.MediaPrep
);
3 changes: 2 additions & 1 deletion src/whatsapp/models/CatalogModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { CatalogCollection } from '../collections';
import { exportProxyModel } from '../exportModule';
import { Wid } from '../misc';
import { ProductModel } from '.';
import {
Model,
ModelOptions,
Expand Down Expand Up @@ -52,7 +53,7 @@ export declare class CatalogModel extends Model<CatalogCollection> {
triggerMsgUpdate(): any;
markProductCollectionOld(): any;
addProduct(e?: any): any;
editProduct(e?: any): any;
editProduct(e: ProductModel): any;
pullProduct(e?: any): any;
updateProduct(e?: any): any;
getCollection(): CatalogCollection;
Expand Down

0 comments on commit b810b2a

Please sign in to comment.