@wazo/sdk 0.43.10 → 0.43.11

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.
@@ -4,7 +4,12 @@ type Response = {
4
4
  destination: string;
5
5
  enabled: boolean;
6
6
  };
7
- export const FORWARD_KEYS = {
7
+ export type ForwardName = 'busy' | 'noanswer' | 'unconditional';
8
+ export const FORWARD_KEYS: {
9
+ BUSY: 'busy';
10
+ NO_ANSWER: 'noanswer';
11
+ UNCONDITIONAL: 'unconditional';
12
+ } = {
8
13
  BUSY: 'busy',
9
14
  NO_ANSWER: 'noanswer',
10
15
  UNCONDITIONAL: 'unconditional',
@@ -12,16 +17,16 @@ export const FORWARD_KEYS = {
12
17
  type ForwardOptionArguments = {
13
18
  destination?: string;
14
19
  enabled?: boolean;
15
- key?: string;
20
+ key?: ForwardName;
16
21
  };
17
22
  export default class ForwardOption {
18
23
  destination: string | undefined;
19
24
 
20
25
  enabled: boolean | undefined;
21
26
 
22
- key: string | undefined;
27
+ key: ForwardName | undefined;
23
28
 
24
- static parse(plain: Response, key: string): ForwardOption {
29
+ static parse(plain: Response, key: ForwardName): ForwardOption {
25
30
  return new ForwardOption({
26
31
  destination: plain.destination || '',
27
32
  enabled: plain.enabled,
@@ -1,6 +1,22 @@
1
1
  import moment from 'moment';
2
2
  import newFrom from '../utils/new-from';
3
3
 
4
+ export const VoicemailFolder = {
5
+ NEW: 'new',
6
+ OLD: 'old',
7
+ URGENT: 'urgent',
8
+ OTHER: 'other',
9
+ } as const;
10
+
11
+ const VoicemailFolderMapping = {
12
+ [VoicemailFolder.NEW]: 1,
13
+ [VoicemailFolder.OLD]: 2,
14
+ [VoicemailFolder.URGENT]: 3,
15
+ [VoicemailFolder.OTHER]: 4,
16
+ } as const;
17
+
18
+ export type VoicemailFolderType = typeof VoicemailFolder[keyof typeof VoicemailFolder];
19
+
4
20
  type MessageResponse = {
5
21
  caller_id_name: string;
6
22
  caller_id_num: string;
@@ -17,7 +33,7 @@ export type Response = {
17
33
  folders: Array<{
18
34
  id: string;
19
35
  name: string;
20
- type: string;
36
+ type: VoicemailFolderType;
21
37
  messages: Array<MessageResponse>;
22
38
  }>;
23
39
  };
@@ -57,7 +73,7 @@ export default class Voicemail {
57
73
  name: plain.caller_id_name,
58
74
  number: plain.caller_id_num,
59
75
  },
60
- unread: plain.folder ? plain.folder.type === 'new' : null,
76
+ unread: plain.folder ? plain.folder.type === VoicemailFolder.NEW : null,
61
77
  });
62
78
  }
63
79
 
@@ -66,8 +82,8 @@ export default class Voicemail {
66
82
  return [];
67
83
  }
68
84
 
69
- const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
70
- const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
85
+ const plainUnread = plain.folders.filter(folder => folder.type === VoicemailFolder.NEW)[0].messages;
86
+ const plainRead = plain.folders.filter(folder => folder.type === VoicemailFolder.OLD)[0].messages;
71
87
  const unread = plainUnread.map(message => Voicemail.parse(message)).map(voicemail => voicemail.makeAsUnRead());
72
88
  const read = plainRead.map(message => Voicemail.parse(message)).map(voicemail => voicemail.acknowledge());
73
89
  return [...unread, ...read];
@@ -77,6 +93,10 @@ export default class Voicemail {
77
93
  return newFrom(profile, Voicemail);
78
94
  }
79
95
 
96
+ static getFolderMappingFromType(folder: VoicemailFolderType) {
97
+ return VoicemailFolderMapping[folder];
98
+ }
99
+
80
100
  constructor({
81
101
  id,
82
102
  date,
package/src/index.ts CHANGED
@@ -19,7 +19,7 @@ export { default as Line } from './domain/Line';
19
19
  export { default as NotificationOptions } from './domain/NotificationOptions';
20
20
  export { default as Profile, STATE as PROFILE_STATE, LINE_STATE } from './domain/Profile';
21
21
  export { default as Session } from './domain/Session';
22
- export { default as Voicemail } from './domain/Voicemail';
22
+ export { default as Voicemail, VoicemailFolder, VoicemailFolderType } from './domain/Voicemail';
23
23
  export { default as Relocation } from './domain/Relocation';
24
24
  export { default as Room } from './domain/Room';
25
25
  export { default as CallSession } from './domain/CallSession';