Total Complexity | 6 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import remarkParse from 'remark-parse'; |
||
18 | export default class Telegraph { |
||
19 | constructor(token) { |
||
20 | this.api = new Api(token); |
||
21 | } |
||
22 | |||
23 | async send(title, message, variables) { |
||
24 | const mdTitle = fill(title, variables); |
||
25 | const mdMessage = fill(message, variables); |
||
26 | |||
27 | const content = await unified() |
||
28 | .use(remarkParse) |
||
29 | .use(remarkTelegraph) |
||
30 | .process(mdMessage); |
||
31 | |||
32 | const page = await this.api.createPage(mdTitle, String(content)); |
||
33 | |||
34 | return dumpPage(page); |
||
35 | } |
||
36 | |||
37 | async authorize() { |
||
38 | const account = await this.api.createAccount('Semantic Release Telegram'); |
||
39 | |||
40 | this.api.setToken(account.access_token); |
||
41 | |||
42 | return account.access_token; |
||
43 | } |
||
44 | |||
45 | async test() { |
||
46 | const account = await this.api.getAccountInfo(); |
||
47 | |||
48 | return dumpAccount(account); |
||
49 | } |
||
50 | } |
||
51 | |||
52 |