Skip to content

Commit

Permalink
feat: Added WPP.group.reject function (close #1058)
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Apr 29, 2023
1 parent 0661f02 commit 687627d
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/group/functions/reject.ts
@@ -0,0 +1,55 @@
/*!
* Copyright 2023 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 { assertWid } from '../../assert';
import { WPPError } from '../../util';
import { Wid } from '../../whatsapp';
import { membershipApprovalRequestAction } from '../../whatsapp/functions';

/**
* Reject a membership request to group
*
* @example
* ```javascript
* await WPP.group.reject(12345645@g.us, 5554999999999@c.us);
* ```
*
* @category Group
*/
export async function reject(
groupId: string | Wid,
membershipIds: (string | Wid) | (string | Wid)[]
): Promise<
{
error: any;
wid: Wid;
}[]
> {
groupId = assertWid(groupId);
if (!Array.isArray(membershipIds)) {
membershipIds = [membershipIds];
}
const wids = membershipIds.map(assertWid);

try {
return await membershipApprovalRequestAction(groupId, wids, 'Reject');
} catch (error) {
throw new WPPError(
'error_on_reject_membership_request',
`Error on reject member on group ${groupId.toString()}`
);
}
}

0 comments on commit 687627d

Please sign in to comment.