From 7a0dce907dd640779326dd18f2b26ab6502d0b0f Mon Sep 17 00:00:00 2001 From: Cleiton Carvalho Date: Wed, 30 Aug 2023 19:32:35 -0300 Subject: [PATCH] feat: Added WPP.order.get function --- src/order/functions/get.ts | 34 ++++++++++++++++++++++++++++++++++ src/order/functions/index.ts | 17 +++++++++++++++++ src/order/index.ts | 17 +++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 src/order/functions/get.ts create mode 100644 src/order/functions/index.ts create mode 100644 src/order/index.ts diff --git a/src/order/functions/get.ts b/src/order/functions/get.ts new file mode 100644 index 0000000000..7608a03496 --- /dev/null +++ b/src/order/functions/get.ts @@ -0,0 +1,34 @@ +/*! + * 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 { WPPError } from '../../util'; +import { MsgKey, MsgStore } from '../../whatsapp'; +import { getOrderInfo } from '../../whatsapp/functions'; +/** + * Get info of your sended order + * + * @example + * ```javascript + * const orderInfo = await WPP.order.get(); + * ``` + * + * @return Your current catalog + */ +export async function get(msgId: string | MsgKey) { + const msg = MsgStore.get(msgId); + if (!msg) throw new WPPError('msg_not_found', 'Message not found'); + return await getOrderInfo(msg); +} diff --git a/src/order/functions/index.ts b/src/order/functions/index.ts new file mode 100644 index 0000000000..de7aee7a9f --- /dev/null +++ b/src/order/functions/index.ts @@ -0,0 +1,17 @@ +/*! + * 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. + */ + +export { get } from './get'; diff --git a/src/order/index.ts b/src/order/index.ts new file mode 100644 index 0000000000..15b554f601 --- /dev/null +++ b/src/order/index.ts @@ -0,0 +1,17 @@ +/*! + * 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. + */ + +export * from './functions';