Skip to content

Commit

Permalink
feat: Added WPP.contact.get function (close #1012) (#1516)
Browse files Browse the repository at this point in the history
* feat: Added WPP.contact.get function

* fix: Typos fix
  • Loading branch information
icleitoncosta committed Nov 30, 2023
1 parent 77298e1 commit 0c31d37
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
37 changes: 37 additions & 0 deletions src/contact/functions/get.ts
@@ -0,0 +1,37 @@
/*!
* 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 { ContactModel, ContactStore, Wid } from '../../whatsapp';

/**
* Get a contact by id
*
* @example
* ```javascript
* await WPP.contact.get('[number]@c.us');
* ```
*
* @category Contact
*/

export async function get(
contactId: string | Wid
): Promise<ContactModel | undefined> {
const wid = assertWid(contactId);

return ContactStore.get(wid);
}
3 changes: 2 additions & 1 deletion src/contact/functions/index.ts
@@ -1,5 +1,5 @@
/*!
* Copyright 2021 WPPConnect Team
* 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.
Expand All @@ -14,6 +14,7 @@
* limitations under the License.
*/

export { get } from './get';
export { getBusinessProfile } from './getBusinessProfile';
export { getCommonGroups } from './getCommonGroups';
export { getProfilePictureUrl } from './getProfilePictureUrl';
Expand Down

0 comments on commit 0c31d37

Please sign in to comment.