Total Complexity | 5 |
Complexity/F | 5 |
Lines of Code | 21 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* eslint-disable security/detect-object-injection */ |
||
2 | import { axiosResponse, axiosError } from './utils'; |
||
3 | |||
4 | export default function (opts) { |
||
5 | if (opts.method === 'POST' && opts.url.match('sendMessage')) { |
||
6 | return axiosResponse(); |
||
7 | } |
||
8 | |||
9 | if (opts.url.match('getChat')) { |
||
10 | if (opts.data.chat_id === 400) { |
||
11 | throw axiosError('Request failed with status code 400', { 'ok': false, 'error_code': 400, 'description': 'Bad Request: chat not found' }); |
||
12 | } |
||
13 | |||
14 | return axiosResponse({ username: 'thick' }); |
||
15 | } |
||
16 | |||
17 | if (opts.url.match('sendDocument')) { |
||
18 | return axiosResponse(); |
||
19 | } |
||
20 | |||
21 | throw new Error('unknown telegram method'); |
||
22 | } |
||
23 |