@wazo/sdk 0.38.7 → 0.38.8
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.
- package/dist/wazo-sdk.js +2 -2
- package/esm/__tests__/api-client.test.js +142 -2
- package/esm/__tests__/web-rtc-client.test.js +227 -27
- package/esm/api/calld.js +8 -0
- package/esm/api/confd.js +134 -2
- package/esm/api-client.js +142 -2
- package/esm/checker/Checker.js +183 -24
- package/esm/checker/checks/aor.js +142 -2
- package/esm/checker/checks/api.js +142 -2
- package/esm/checker/checks/index.js +183 -24
- package/esm/checker/checks/wazo-websocket.js +2 -0
- package/esm/checker/checks/webrtc-transport.js +181 -24
- package/esm/checker/checks/webrtc.js +181 -24
- package/esm/domain/AdHocAPIConference.js +142 -2
- package/esm/domain/Features.js +142 -2
- package/esm/domain/Meeting.js +18 -0
- package/esm/domain/MeetingAuthorization.js +70 -0
- package/esm/domain/Phone/CTIPhone.js +142 -2
- package/esm/domain/__tests__/Meeting.test.js +87 -1
- package/esm/domain/__tests__/MeetingAuthorization.test.js +109 -0
- package/esm/index.js +226 -27
- package/esm/service/CallApi.js +142 -2
- package/esm/service/getApiClient.js +142 -2
- package/esm/simple/Auth.js +226 -27
- package/esm/simple/Configuration.js +226 -27
- package/esm/simple/Directory.js +142 -2
- package/esm/simple/Phone.js +226 -27
- package/esm/simple/Websocket.js +3 -0
- package/esm/simple/index.js +226 -27
- package/esm/simple/room/LocalParticipant.js +226 -27
- package/esm/simple/room/Participant.js +226 -27
- package/esm/simple/room/RemoteParticipant.js +226 -27
- package/esm/simple/room/Room.js +226 -27
- package/esm/simple/room/SipRoom.js +226 -27
- package/esm/simple/room/Stream.js +226 -27
- package/esm/simple/room/__tests__/Participant.test.js +14747 -0
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +226 -27
- package/esm/simple/utils.js +226 -27
- package/esm/utils/__tests__/object.test.js +57 -0
- package/esm/utils/__tests__/string.test.js +30 -0
- package/esm/utils/object.js +24 -0
- package/esm/utils/string.js +10 -0
- package/esm/web-rtc-client.js +181 -24
- package/esm/websocket-client.js +3 -1
- package/lib/__tests__/api-client.test.js +142 -2
- package/lib/__tests__/web-rtc-client.test.js +227 -27
- package/lib/api/calld.js +8 -0
- package/lib/api/confd.js +134 -2
- package/lib/api-client.js +142 -2
- package/lib/checker/Checker.js +183 -24
- package/lib/checker/checks/aor.js +142 -2
- package/lib/checker/checks/api.js +142 -2
- package/lib/checker/checks/index.js +183 -24
- package/lib/checker/checks/wazo-websocket.js +2 -0
- package/lib/checker/checks/webrtc-transport.js +181 -24
- package/lib/checker/checks/webrtc.js +181 -24
- package/lib/domain/AdHocAPIConference.js +142 -2
- package/lib/domain/Features.js +142 -2
- package/lib/domain/Meeting.js +18 -0
- package/lib/domain/MeetingAuthorization.js +79 -0
- package/lib/domain/Phone/CTIPhone.js +142 -2
- package/lib/domain/__tests__/Meeting.test.js +87 -1
- package/lib/domain/__tests__/MeetingAuthorization.test.js +111 -0
- package/lib/index.js +226 -27
- package/lib/service/CallApi.js +142 -2
- package/lib/service/getApiClient.js +142 -2
- package/lib/simple/Auth.js +226 -27
- package/lib/simple/Configuration.js +226 -27
- package/lib/simple/Directory.js +142 -2
- package/lib/simple/Phone.js +226 -27
- package/lib/simple/Websocket.js +3 -0
- package/lib/simple/index.js +226 -27
- package/lib/simple/room/LocalParticipant.js +226 -27
- package/lib/simple/room/Participant.js +226 -27
- package/lib/simple/room/RemoteParticipant.js +226 -27
- package/lib/simple/room/Room.js +226 -27
- package/lib/simple/room/SipRoom.js +226 -27
- package/lib/simple/room/Stream.js +226 -27
- package/lib/simple/room/__tests__/Participant.test.js +14757 -0
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +226 -27
- package/lib/simple/utils.js +226 -27
- package/lib/utils/__tests__/object.test.js +59 -0
- package/lib/utils/__tests__/string.test.js +32 -0
- package/lib/utils/object.js +28 -0
- package/lib/utils/string.js +14 -0
- package/lib/web-rtc-client.js +181 -24
- package/lib/websocket-client.js +3 -0
- package/package.json +2 -2
- package/src/__tests__/web-rtc-client.test.js +46 -3
- package/src/api/calld.js +8 -0
- package/src/api/confd.js +43 -2
- package/src/domain/Meeting.js +20 -0
- package/src/domain/MeetingAuthorization.js +67 -0
- package/src/domain/__tests__/Meeting.test.js +70 -1
- package/src/domain/__tests__/MeetingAuthorization.test.js +58 -0
- package/src/simple/room/Participant.js +40 -0
- package/src/simple/room/Room.js +2 -2
- package/src/simple/room/SipRoom.js +1 -1
- package/src/simple/room/__tests__/Participant.test.js +81 -0
- package/src/types/WebSocketMessage.js +7 -1
- package/src/utils/__tests__/object.test.js +35 -0
- package/src/utils/__tests__/string.test.js +23 -0
- package/src/utils/object.js +15 -0
- package/src/utils/string.js +8 -0
- package/src/web-rtc-client.js +39 -22
- package/src/websocket-client.js +2 -0
|
@@ -3591,6 +3591,70 @@ class ExternalApp {
|
|
|
3591
3591
|
|
|
3592
3592
|
//
|
|
3593
3593
|
|
|
3594
|
+
class MeetingAuthorization {
|
|
3595
|
+
|
|
3596
|
+
|
|
3597
|
+
|
|
3598
|
+
|
|
3599
|
+
|
|
3600
|
+
|
|
3601
|
+
constructor({
|
|
3602
|
+
meetingUuid,
|
|
3603
|
+
uuid,
|
|
3604
|
+
userUuid,
|
|
3605
|
+
userName,
|
|
3606
|
+
} = {}) {
|
|
3607
|
+
this.meetingUuid = meetingUuid;
|
|
3608
|
+
this.uuid = uuid;
|
|
3609
|
+
this.userUuid = userUuid;
|
|
3610
|
+
this.userName = userName;
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
setStatus(status ) {
|
|
3614
|
+
this.status = status;
|
|
3615
|
+
}
|
|
3616
|
+
|
|
3617
|
+
getStatus() {
|
|
3618
|
+
return this.status;
|
|
3619
|
+
}
|
|
3620
|
+
|
|
3621
|
+
static parse(plain ) {
|
|
3622
|
+
const {
|
|
3623
|
+
meeting_uuid: meetingUuid,
|
|
3624
|
+
uuid,
|
|
3625
|
+
guest_uuid: userUuid,
|
|
3626
|
+
guest_name: userName,
|
|
3627
|
+
} = plain;
|
|
3628
|
+
|
|
3629
|
+
return new MeetingAuthorization({
|
|
3630
|
+
meetingUuid,
|
|
3631
|
+
uuid,
|
|
3632
|
+
userUuid,
|
|
3633
|
+
userName,
|
|
3634
|
+
});
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
static parseMany(items ) {
|
|
3638
|
+
if (!items) {
|
|
3639
|
+
return [];
|
|
3640
|
+
}
|
|
3641
|
+
return items.map(MeetingAuthorization.parse);
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
|
|
3645
|
+
//
|
|
3646
|
+
|
|
3647
|
+
|
|
3648
|
+
|
|
3649
|
+
|
|
3650
|
+
|
|
3651
|
+
|
|
3652
|
+
|
|
3653
|
+
|
|
3654
|
+
|
|
3655
|
+
|
|
3656
|
+
|
|
3657
|
+
|
|
3594
3658
|
|
|
3595
3659
|
|
|
3596
3660
|
|
|
@@ -3601,6 +3665,7 @@ class ExternalApp {
|
|
|
3601
3665
|
|
|
3602
3666
|
|
|
3603
3667
|
|
|
3668
|
+
|
|
3604
3669
|
|
|
3605
3670
|
|
|
3606
3671
|
class Meeting {
|
|
@@ -3615,6 +3680,8 @@ class Meeting {
|
|
|
3615
3680
|
|
|
3616
3681
|
|
|
3617
3682
|
|
|
3683
|
+
|
|
3684
|
+
|
|
3618
3685
|
|
|
3619
3686
|
static parse(plain ) {
|
|
3620
3687
|
return new Meeting({
|
|
@@ -3627,6 +3694,7 @@ class Meeting {
|
|
|
3627
3694
|
extension: plain.exten,
|
|
3628
3695
|
persistent: plain.persistent,
|
|
3629
3696
|
creationTime: moment(plain.creation_time).toDate(),
|
|
3697
|
+
requireAuthorization: plain.require_authorization,
|
|
3630
3698
|
});
|
|
3631
3699
|
}
|
|
3632
3700
|
|
|
@@ -3651,6 +3719,7 @@ class Meeting {
|
|
|
3651
3719
|
extension,
|
|
3652
3720
|
persistent,
|
|
3653
3721
|
creationTime,
|
|
3722
|
+
requireAuthorization,
|
|
3654
3723
|
} = {}) {
|
|
3655
3724
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3656
3725
|
this.uri = uri;
|
|
@@ -3661,6 +3730,7 @@ class Meeting {
|
|
|
3661
3730
|
this.extension = extension;
|
|
3662
3731
|
this.persistent = persistent;
|
|
3663
3732
|
this.creationTime = creationTime;
|
|
3733
|
+
this.requireAuthorization = requireAuthorization;
|
|
3664
3734
|
|
|
3665
3735
|
// Useful to compare instead of instanceof with minified code
|
|
3666
3736
|
this.type = 'Meeting';
|
|
@@ -3671,8 +3741,32 @@ class Meeting {
|
|
|
3671
3741
|
const [username, secret] = atob(this.guestSipAuthorization).split(':');
|
|
3672
3742
|
return { username, secret };
|
|
3673
3743
|
}
|
|
3744
|
+
|
|
3674
3745
|
}
|
|
3675
3746
|
|
|
3747
|
+
//
|
|
3748
|
+
|
|
3749
|
+
const camelToUnderscore = (key ) => {
|
|
3750
|
+
if (typeof key !== 'string') {
|
|
3751
|
+
throw new Error('Input is not a string');
|
|
3752
|
+
}
|
|
3753
|
+
return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
3754
|
+
};
|
|
3755
|
+
|
|
3756
|
+
//
|
|
3757
|
+
|
|
3758
|
+
const convertKeysFromCamelToUnderscore = (args ) => {
|
|
3759
|
+
if (!args || typeof args !== 'object' || Array.isArray(args)) {
|
|
3760
|
+
throw new Error('Input is not an object');
|
|
3761
|
+
}
|
|
3762
|
+
|
|
3763
|
+
return Object.keys(args).reduce((acc, key) => {
|
|
3764
|
+
acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
|
|
3765
|
+
? convertKeysFromCamelToUnderscore(args[key]) : args[key];
|
|
3766
|
+
return acc;
|
|
3767
|
+
}, {});
|
|
3768
|
+
};
|
|
3769
|
+
|
|
3676
3770
|
/* */
|
|
3677
3771
|
|
|
3678
3772
|
var confdMethods = (client , baseUrl ) => ({
|
|
@@ -3741,8 +3835,18 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3741
3835
|
getMyMeetings: () =>
|
|
3742
3836
|
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
3743
3837
|
|
|
3744
|
-
createMyMeeting: (
|
|
3745
|
-
client
|
|
3838
|
+
createMyMeeting: (args ) =>
|
|
3839
|
+
client
|
|
3840
|
+
.post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
|
|
3841
|
+
.then(Meeting.parse),
|
|
3842
|
+
|
|
3843
|
+
updateMyMeeting: (meetingUuid , data ) =>
|
|
3844
|
+
client.put(
|
|
3845
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}`,
|
|
3846
|
+
convertKeysFromCamelToUnderscore(data),
|
|
3847
|
+
null,
|
|
3848
|
+
ApiRequester.successResponseParser,
|
|
3849
|
+
),
|
|
3746
3850
|
|
|
3747
3851
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3748
3852
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3750,8 +3854,36 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3750
3854
|
getMeeting: (meetingUuid ) =>
|
|
3751
3855
|
client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
3752
3856
|
|
|
3857
|
+
meetingAuthorizations: (meetingUuid ) =>
|
|
3858
|
+
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
|
|
3859
|
+
|
|
3860
|
+
meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
|
|
3861
|
+
client.put(
|
|
3862
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
|
|
3863
|
+
{},
|
|
3864
|
+
null,
|
|
3865
|
+
ApiRequester.successResponseParser,
|
|
3866
|
+
),
|
|
3867
|
+
|
|
3868
|
+
meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
|
|
3869
|
+
client.put(
|
|
3870
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
|
|
3871
|
+
{},
|
|
3872
|
+
null,
|
|
3873
|
+
ApiRequester.successResponseParser,
|
|
3874
|
+
),
|
|
3875
|
+
|
|
3753
3876
|
guestGetMeeting: (meetingUuid ) =>
|
|
3754
3877
|
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
3878
|
+
|
|
3879
|
+
guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
|
|
3880
|
+
client
|
|
3881
|
+
.post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
|
|
3882
|
+
.then(MeetingAuthorization.parse),
|
|
3883
|
+
|
|
3884
|
+
guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
|
|
3885
|
+
client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
|
|
3886
|
+
|
|
3755
3887
|
});
|
|
3756
3888
|
|
|
3757
3889
|
//
|
|
@@ -4620,6 +4752,14 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
4620
4752
|
getMeetingParticipantsAsUser: async (meetingUuid ) =>
|
|
4621
4753
|
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
|
|
4622
4754
|
|
|
4755
|
+
banMeetingParticipant: (meetingUuid , participantUuid ) =>
|
|
4756
|
+
client.delete(
|
|
4757
|
+
`${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
|
|
4758
|
+
null,
|
|
4759
|
+
null,
|
|
4760
|
+
ApiRequester.successResponseParser,
|
|
4761
|
+
),
|
|
4762
|
+
|
|
4623
4763
|
listTrunks: () => client.get(`${baseUrl}/trunks`),
|
|
4624
4764
|
|
|
4625
4765
|
mute: (callId ) =>
|
|
@@ -13,6 +13,17 @@ var newFrom = (instance , ToClass ) => {
|
|
|
13
13
|
|
|
14
14
|
//
|
|
15
15
|
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
16
27
|
|
|
17
28
|
|
|
18
29
|
|
|
@@ -23,6 +34,7 @@ var newFrom = (instance , ToClass ) => {
|
|
|
23
34
|
|
|
24
35
|
|
|
25
36
|
|
|
37
|
+
|
|
26
38
|
|
|
27
39
|
|
|
28
40
|
class Meeting {
|
|
@@ -37,6 +49,8 @@ class Meeting {
|
|
|
37
49
|
|
|
38
50
|
|
|
39
51
|
|
|
52
|
+
|
|
53
|
+
|
|
40
54
|
|
|
41
55
|
static parse(plain ) {
|
|
42
56
|
return new Meeting({
|
|
@@ -49,6 +63,7 @@ class Meeting {
|
|
|
49
63
|
extension: plain.exten,
|
|
50
64
|
persistent: plain.persistent,
|
|
51
65
|
creationTime: moment(plain.creation_time).toDate(),
|
|
66
|
+
requireAuthorization: plain.require_authorization,
|
|
52
67
|
});
|
|
53
68
|
}
|
|
54
69
|
|
|
@@ -73,6 +88,7 @@ class Meeting {
|
|
|
73
88
|
extension,
|
|
74
89
|
persistent,
|
|
75
90
|
creationTime,
|
|
91
|
+
requireAuthorization,
|
|
76
92
|
} = {}) {
|
|
77
93
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
78
94
|
this.uri = uri;
|
|
@@ -83,6 +99,7 @@ class Meeting {
|
|
|
83
99
|
this.extension = extension;
|
|
84
100
|
this.persistent = persistent;
|
|
85
101
|
this.creationTime = creationTime;
|
|
102
|
+
this.requireAuthorization = requireAuthorization;
|
|
86
103
|
|
|
87
104
|
// Useful to compare instead of instanceof with minified code
|
|
88
105
|
this.type = 'Meeting';
|
|
@@ -93,11 +110,78 @@ class Meeting {
|
|
|
93
110
|
const [username, secret] = atob(this.guestSipAuthorization).split(':');
|
|
94
111
|
return { username, secret };
|
|
95
112
|
}
|
|
113
|
+
|
|
96
114
|
}
|
|
97
115
|
|
|
98
116
|
//
|
|
99
117
|
|
|
118
|
+
const rawCreationTime = '2021-12-21T15:56:42.880Z';
|
|
119
|
+
|
|
100
120
|
describe('Meeting domain', () => {
|
|
121
|
+
it('should retain its values when parsed', () => {
|
|
122
|
+
const args = {
|
|
123
|
+
guest_sip_authorization: 'some-guest-sip-authorization',
|
|
124
|
+
ingress_http_uri: 'some-uri',
|
|
125
|
+
name: 'some-name',
|
|
126
|
+
owner_uuids: ['some-owner-uuid'],
|
|
127
|
+
port: 'some-port',
|
|
128
|
+
uuid: 'some-uuid',
|
|
129
|
+
exten: 'some-exten',
|
|
130
|
+
persistent: true,
|
|
131
|
+
creation_time: rawCreationTime,
|
|
132
|
+
require_authorization: true,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const meeting = Meeting.parse(args);
|
|
136
|
+
const {
|
|
137
|
+
uri,
|
|
138
|
+
uuid,
|
|
139
|
+
name,
|
|
140
|
+
port,
|
|
141
|
+
extension,
|
|
142
|
+
persistent,
|
|
143
|
+
ownerUuids,
|
|
144
|
+
creationTime,
|
|
145
|
+
requireAuthorization,
|
|
146
|
+
} = meeting;
|
|
147
|
+
|
|
148
|
+
expect(uri).toEqual(args.ingress_http_uri);
|
|
149
|
+
expect(uuid).toEqual(args.uuid);
|
|
150
|
+
expect(name).toEqual(args.name);
|
|
151
|
+
expect(port).toEqual(args.port);
|
|
152
|
+
expect(extension).toEqual(args.exten);
|
|
153
|
+
expect(persistent).toEqual(args.persistent);
|
|
154
|
+
expect(ownerUuids).toEqual(args.owner_uuids);
|
|
155
|
+
expect(creationTime).toEqual(moment(rawCreationTime).toDate());
|
|
156
|
+
expect(requireAuthorization).toEqual(args.require_authorization);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('should retain its values when instantiated', () => {
|
|
160
|
+
const keys = [
|
|
161
|
+
'uuid',
|
|
162
|
+
'name',
|
|
163
|
+
'guestSipAuthorization',
|
|
164
|
+
'ownerUuids',
|
|
165
|
+
'port',
|
|
166
|
+
'uri',
|
|
167
|
+
'extension',
|
|
168
|
+
'persistent',
|
|
169
|
+
'creationTime',
|
|
170
|
+
'requireAuthorization',
|
|
171
|
+
];
|
|
172
|
+
|
|
173
|
+
const args = keys.reduce((acc, key) => {
|
|
174
|
+
acc[key] = `some-${key}`;
|
|
175
|
+
return acc;
|
|
176
|
+
}, {});
|
|
177
|
+
|
|
178
|
+
const meeting = new Meeting(args);
|
|
179
|
+
|
|
180
|
+
keys.forEach(key =>
|
|
181
|
+
// $FlowFixMe
|
|
182
|
+
expect(meeting[key]).toEqual(`some-${key}`));
|
|
183
|
+
});
|
|
184
|
+
|
|
101
185
|
it('can return username and secret from an base64 encrypted string', () => {
|
|
102
186
|
const USERNAME = 'username';
|
|
103
187
|
const SECRET = 'secret';
|
|
@@ -112,6 +196,7 @@ describe('Meeting domain', () => {
|
|
|
112
196
|
uuid: '',
|
|
113
197
|
exten: '',
|
|
114
198
|
persistent: false,
|
|
199
|
+
require_authorization: false,
|
|
115
200
|
};
|
|
116
201
|
|
|
117
202
|
const meeting = Meeting.parse(args);
|
|
@@ -124,7 +209,7 @@ describe('Meeting domain', () => {
|
|
|
124
209
|
|
|
125
210
|
it('should return a date from a string', () => {
|
|
126
211
|
const args = {
|
|
127
|
-
creation_time:
|
|
212
|
+
creation_time: rawCreationTime,
|
|
128
213
|
guest_sip_authorization: '',
|
|
129
214
|
ingress_http_uri: '',
|
|
130
215
|
name: '',
|
|
@@ -133,6 +218,7 @@ describe('Meeting domain', () => {
|
|
|
133
218
|
uuid: '',
|
|
134
219
|
exten: '',
|
|
135
220
|
persistent: false,
|
|
221
|
+
require_authorization: false,
|
|
136
222
|
};
|
|
137
223
|
|
|
138
224
|
const { creationTime } = Meeting.parse(args);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
class MeetingAuthorization {
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
constructor({
|
|
11
|
+
meetingUuid,
|
|
12
|
+
uuid,
|
|
13
|
+
userUuid,
|
|
14
|
+
userName,
|
|
15
|
+
} = {}) {
|
|
16
|
+
this.meetingUuid = meetingUuid;
|
|
17
|
+
this.uuid = uuid;
|
|
18
|
+
this.userUuid = userUuid;
|
|
19
|
+
this.userName = userName;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
setStatus(status ) {
|
|
23
|
+
this.status = status;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getStatus() {
|
|
27
|
+
return this.status;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static parse(plain ) {
|
|
31
|
+
const {
|
|
32
|
+
meeting_uuid: meetingUuid,
|
|
33
|
+
uuid,
|
|
34
|
+
guest_uuid: userUuid,
|
|
35
|
+
guest_name: userName,
|
|
36
|
+
} = plain;
|
|
37
|
+
|
|
38
|
+
return new MeetingAuthorization({
|
|
39
|
+
meetingUuid,
|
|
40
|
+
uuid,
|
|
41
|
+
userUuid,
|
|
42
|
+
userName,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static parseMany(items ) {
|
|
47
|
+
if (!items) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
return items.map(MeetingAuthorization.parse);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe('MeetingAuthorization', () => {
|
|
55
|
+
describe('parse', () => {
|
|
56
|
+
it('should parse a raw input', () => {
|
|
57
|
+
const rawAuthorization = {
|
|
58
|
+
created_at: 'today',
|
|
59
|
+
meeting_uuid: 'meeting_uuid',
|
|
60
|
+
uuid: 'uuid',
|
|
61
|
+
guest_uuid: 'guest_uuid',
|
|
62
|
+
guest_name: 'guest_name',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const authorization = {
|
|
66
|
+
meetingUuid: rawAuthorization.meeting_uuid,
|
|
67
|
+
uuid: rawAuthorization.uuid,
|
|
68
|
+
userUuid: rawAuthorization.guest_uuid,
|
|
69
|
+
userName: rawAuthorization.guest_name,
|
|
70
|
+
status: undefined,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const response = MeetingAuthorization.parse(rawAuthorization);
|
|
74
|
+
expect(response).toEqual(authorization);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('parseMany', () => {
|
|
79
|
+
it('should parse multiple raw inputs', () => {
|
|
80
|
+
const rawAuthorizations = [
|
|
81
|
+
{
|
|
82
|
+
created_at: 'today1',
|
|
83
|
+
meeting_uuid: 'meeting_uuid1',
|
|
84
|
+
uuid: 'uuid1',
|
|
85
|
+
guest_uuid: 'guest_uuid1',
|
|
86
|
+
guest_name: 'guest_name1',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
created_at: 'today2',
|
|
90
|
+
meeting_uuid: 'meeting_uuid2',
|
|
91
|
+
uuid: 'uuid2',
|
|
92
|
+
guest_uuid: 'guest_uuid2',
|
|
93
|
+
guest_name: 'guest_name2',
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
const authorizations = rawAuthorizations.map(rawAuthorization => ({
|
|
98
|
+
meetingUuid: rawAuthorization.meeting_uuid,
|
|
99
|
+
uuid: rawAuthorization.uuid,
|
|
100
|
+
userUuid: rawAuthorization.guest_uuid,
|
|
101
|
+
userName: rawAuthorization.guest_name,
|
|
102
|
+
status: undefined,
|
|
103
|
+
}));
|
|
104
|
+
|
|
105
|
+
const response = MeetingAuthorization.parseMany(rawAuthorizations);
|
|
106
|
+
expect(response).toEqual(authorizations);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|