Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c77d6b6
commit 25f21c0
Showing
3 changed files
with
307 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
export async function addNewLabel(req, res) { | ||
const { name, options } = req.body; | ||
if (!name) | ||
return res.status(401).send({ | ||
message: 'Name was not informed', | ||
}); | ||
|
||
try { | ||
const result = await req.client.addNewLabel(name, options); | ||
res.status(201).json({ status: 'success', response: result }); | ||
} catch (error) { | ||
res.status(500).json({ status: 'Error', message: 'Erro ao adicionar etiqueta.' }); | ||
} | ||
} | ||
|
||
export async function addOrRemoveLabels(req, res) { | ||
const { chatIds, options } = req.body; | ||
if (!chatIds || !options) | ||
return res.status(401).send({ | ||
message: 'chatIds or options was not informed', | ||
}); | ||
|
||
try { | ||
const result = await req.client.addOrRemoveLabels(chatIds, options); | ||
res.status(201).json({ status: 'success', response: result }); | ||
} catch (error) { | ||
res.status(500).json({ status: 'Error', message: 'Erro ao adicionar/deletar etiqueta.' }); | ||
} | ||
} | ||
|
||
export async function getAllLabels(req, res) { | ||
try { | ||
const result = await req.client.getAllLabels(); | ||
res.status(201).json({ status: 'success', response: result }); | ||
} catch (error) { | ||
res.status(500).json({ status: 'Error', message: 'Erro ao buscar etiquetas.' }); | ||
} | ||
} | ||
|
||
export async function deleteAllLabels(req, res) { | ||
try { | ||
const result = await req.client.deleteAllLabels(); | ||
res.status(201).json({ status: 'success', response: result }); | ||
} catch (error) { | ||
res.status(500).json({ status: 'Error', message: 'Erro ao deletar todas as etiquetas.' }); | ||
} | ||
} | ||
|
||
export async function deleteLabel(req, res) { | ||
const { id } = req.paramns; | ||
try { | ||
const result = await req.client.deleteLabel(id); | ||
res.status(201).json({ status: 'success', response: result }); | ||
} catch (error) { | ||
res.status(500).json({ status: 'Error', message: 'Erro ao deletar etiqueta.' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters