Passed
Push — master ( 33b817...bb2a4c )
by Muhammad Dyas
01:42
created

BaseHandler.getAnnotationByType   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
1
import {chat_v1 as chatV1} from 'googleapis/build/src/apis/chat/v1';
2
3
export default abstract class BaseHandler {
4
  protected event: chatV1.Schema$DeprecatedEvent;
5
6
  constructor(event: chatV1.Schema$DeprecatedEvent) {
7
    this.event = event;
8
  }
9
10
  protected getAnnotations(): chatV1.Schema$Annotation[] {
11
    return this.event.message?.annotations ?? [];
12
  }
13
14
  protected getAnnotationByType(type: string): chatV1.Schema$Annotation | undefined {
15
    return this.getAnnotations().find((annotation) => annotation.type === type);
16
  }
17
18
  public abstract process(): chatV1.Schema$Message | Promise<chatV1.Schema$Message>;
19
}
20