lib/Client.js   A
last analyzed

Size

Lines of Code 60

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
nc 1
dl 0
loc 60
rs 10
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A Client.js ➔ ??? 0 3 1
1
"use strict";
2
3
const sarahClient = require('./client/sarahClient');
4
const logger = require('./logger');
5
6
/**
7
 * Allow call to S.A.R.A.H. client
8
 */
9
class Client {
10
    /**
11
     * @public
12
     */
13
    constructor() {
14
        this.logger = logger;
15
    }
16
17
    /**
18
     * @public
19
     *
20
     * @param {string} textToSpeech
21
     *
22
     * @returns {Promise<null|Error>}
23
     */
24
    speak(textToSpeech) {
25
        if (!textToSpeech) {
26
            return Promise.resolve();
27
        }
28
29
        this.logger.debug(`Alfred will say "${textToSpeech}"`);
30
31
        return sarahClient({
32
            tts: textToSpeech,
33
            sync: true
34
        })
35
            .then(() => null)
36
        ;
37
    }
38
39
    /**
40
     * @public
41
     *
42
     * @returns {Promise<null|Error>}
43
     */
44
    listen() {
45
        return sarahClient({'listen': true})
46
            .then(() => null);
47
    }
48
49
    /**
50
     * @public
51
     *
52
     * @returns {Promise<null|Error>}
53
     */
54
    stopListening() {
55
        return sarahClient({'listen': false})
56
            .then(() => null);
57
    }
58
}
59
60
module.exports = Client;
61