Completed
Push — master ( 8e01eb...25ec60 )
by Muhammad Dyas
17s queued 12s
created

MessageDialogCard.create   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
1
import BaseCard from './BaseCard';
2
import {chat_v1 as chatV1} from 'googleapis/build/src/apis/chat/v1';
3
import {MessageDialogConfig} from '../helpers/interfaces';
4
5
export default class MessageDialogCard extends BaseCard {
6
  private readonly config: MessageDialogConfig;
7
8
  constructor(config: MessageDialogConfig) {
9
    super();
10
    this.config = config;
11
  }
12
13
  create(): chatV1.Schema$GoogleAppsCardV1Card {
14
    this.buildHeader();
15
    this.buildSections();
16
    return this.card;
17
  }
18
19
  buildHeader() {
20
    this.card.header = {
21
      'title': this.config.title,
22
      'subtitle': this.config.message,
23
      'imageUrl': this.config.imageUrl,
24
      'imageType': 'CIRCLE',
25
    };
26
  }
27
28
  buildSections() {
29
    this.card.sections = [
30
      {
31
        'widgets': [
32
          {
33
            'divider': {},
34
          },
35
          {
36
            'divider': {},
37
          },
38
          {
39
            'divider': {},
40
          },
41
          {
42
            'divider': {},
43
          },
44
          {
45
            'textParagraph': {
46
              'text': 'If you have any problems, questions, or feedback, ' +
47
                'please feel free to post them <a href="https://github.com/dyaskur/google-chat-poll/issues">here</a> ',
48
            },
49
          }],
50
      }];
51
  }
52
}
53