diff --git a/src/contact/functions/get.ts b/src/contact/functions/get.ts new file mode 100644 index 0000000000..f281df7540 --- /dev/null +++ b/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 { + const wid = assertWid(contactId); + + return ContactStore.get(wid); +} diff --git a/src/contact/functions/index.ts b/src/contact/functions/index.ts index 4e217cb63b..1c252bc81b 100644 --- a/src/contact/functions/index.ts +++ b/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. @@ -14,6 +14,7 @@ * limitations under the License. */ +export { get } from './get'; export { getBusinessProfile } from './getBusinessProfile'; export { getCommonGroups } from './getCommonGroups'; export { getProfilePictureUrl } from './getProfilePictureUrl';