Passed
Pull Request — master (#2)
by Muhammad Dyas
02:13
created

src/cards/BaseCard.ts   A

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 36
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 28
mnd 0
bc 0
fnc 3
dl 0
loc 36
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A BaseCard.make 0 5 1
A BaseCard.buildMessage 0 3 1
A BaseCard.buildSections 0 2 1
1
import {chat_v1 as chatV1} from 'googleapis/build/src/apis/chat/v1';
2
3
interface Card {
4
  buildHeader?(): void;
5
6
  buildSections(): void;
7
8
  buildButtons?(): void;
9
10
  buildFooter?(): void;
11
12
  make(): chatV1.Schema$CardWithId;
13
}
14
15
export abstract class BaseCard implements Card {
16
  private id: string = 'cardId';
17
  private _content: chatV1.Schema$GoogleAppsCardV1Section[] = [];
18
19
  protected card: chatV1.Schema$GoogleAppsCardV1Card = {
20
    sections: this._content,
21
  };
22
23
  abstract buildSections(): void;
24
25
  make(): chatV1.Schema$CardWithId {
26
    return {
27
      'cardId': this.id,
28
      'card': this.card,
29
    };
30
  }
31
32
  buildMessage(): chatV1.Schema$Message {
33
    return {cardsV2: [this.make()]};
34
  }
35
}
36