sim-node-lib 0.4.62 → 0.4.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,16 +8,12 @@ declare type Button = {
8
8
  text: string;
9
9
  actionUrl: string;
10
10
  };
11
- declare type GoogleChatMessage = {
12
- text?: string;
13
- cards?: any[];
14
- };
15
11
  declare class GoogleChatMessageBuilder {
16
12
  private message;
17
13
  withText(text: string): GoogleChatMessageBuilder;
18
14
  withCardHeader(header: CardHeader): GoogleChatMessageBuilder;
19
15
  withTextParagraph(text: string): GoogleChatMessageBuilder;
20
16
  withButton(button: Button): GoogleChatMessageBuilder;
21
- build(): GoogleChatMessage;
17
+ stringfy(): string;
22
18
  }
23
19
  export default GoogleChatMessageBuilder;
@@ -9,19 +9,19 @@ class GoogleChatMessageBuilder {
9
9
  return this;
10
10
  }
11
11
  withCardHeader(header) {
12
- if (!this.message.cards) {
13
- this.message.cards = [];
12
+ if (!this.message.cardsV2) {
13
+ this.message.cardsV2 = [];
14
14
  }
15
15
  const card = {
16
16
  header: {
17
17
  title: header.title,
18
18
  subtitle: header.subtitle,
19
19
  imageUrl: header.imageUrl,
20
- imageStyle: header.imageStyle || "IMAGE",
20
+ imageStyle: header.imageStyle || 'IMAGE',
21
21
  },
22
22
  sections: [],
23
23
  };
24
- this.message.cards.push(card);
24
+ this.message.cardsV2.push(card);
25
25
  return this;
26
26
  }
27
27
  withTextParagraph(text) {
@@ -29,10 +29,10 @@ class GoogleChatMessageBuilder {
29
29
  const section = {
30
30
  widgets: [{ textParagraph: paragraph }],
31
31
  };
32
- if (!this.message.cards || this.message.cards.length === 0) {
33
- throw new Error("Nenhum card criado. Adicione um card antes de adicionar uma seção.");
32
+ if (!this.message.cardsV2 || this.message.cardsV2.length === 0) {
33
+ throw new Error('Nenhum card criado. Adicione um card antes de adicionar uma seção.');
34
34
  }
35
- this.message.cards[this.message.cards.length - 1].sections.push(section);
35
+ this.message.cardsV2[this.message.cardsV2.length - 1].sections.push(section);
36
36
  return this;
37
37
  }
38
38
  withButton(button) {
@@ -53,14 +53,14 @@ class GoogleChatMessageBuilder {
53
53
  const section = {
54
54
  widgets: [buttonWidget],
55
55
  };
56
- if (!this.message.cards || this.message.cards.length === 0) {
57
- throw new Error("Nenhum card criado. Adicione um card antes de adicionar um botão.");
56
+ if (!this.message.cardsV2 || this.message.cardsV2.length === 0) {
57
+ throw new Error('Nenhum card criado. Adicione um card antes de adicionar um botão.');
58
58
  }
59
- this.message.cards[this.message.cards.length - 1].sections.push(section);
59
+ this.message.cardsV2[this.message.cardsV2.length - 1].sections.push(section);
60
60
  return this;
61
61
  }
62
- build() {
63
- return this.message;
62
+ stringfy() {
63
+ return JSON.stringify(this.message, null, 2);
64
64
  }
65
65
  }
66
66
  exports.default = GoogleChatMessageBuilder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim-node-lib",
3
- "version": "0.4.62",
3
+ "version": "0.4.63",
4
4
  "description": "Library from SIMLabs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",