Total Complexity | 4 |
Complexity/F | 4 |
Lines of Code | 25 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* eslint-disable security/detect-object-injection */ |
||
2 | import { axiosResponse } from './utils'; |
||
3 | |||
4 | export default function (opts) { |
||
5 | if (opts.method === 'POST' && opts.url.match('createPage')) { |
||
6 | return axiosResponse({ |
||
7 | url : 'http://telegra.ph/my_page_url', |
||
8 | title : opts.data.title |
||
9 | }); |
||
10 | } |
||
11 | |||
12 | if (opts.method === 'GET' && opts.url.match('createAccount')) { |
||
13 | return axiosResponse({ |
||
14 | 'short_name' : opts.params.short_name, |
||
15 | 'access_token' : 'abc_abc' |
||
16 | }); |
||
17 | } |
||
18 | |||
19 | if (opts.method === 'GET' && opts.url.match('getAccountInfo')) { |
||
20 | return axiosResponse({ |
||
21 | 'short_name' : 'My_created_account' |
||
22 | }); |
||
23 | } |
||
24 | |||
25 | throw new Error(`unknown telegra.ph method: ${JSON.stringify(opts)}`); |
||
26 | } |
||
27 |