Example #1
0
        public async Task AddJoiner(int id, int joinerId, string joinerName, string joinerPhone, bool joinerPositiveStart, bool joinerUnmute, bool?joinerAnnounceEnter, bool?joinerAnnounceLeave, bool?joinerAnnounceMute, bool?joinerAnnounceUnmute)
        {
            var client = new swaggerClient(VoiceUrl, new HttpClient());
            var joinerAnnouncements = new List <AnnouncementType>();

            if (joinerAnnounceEnter.HasValue && joinerAnnounceEnter.Value)
            {
                joinerAnnouncements.Add(AnnouncementType.Join);
            }
            if (joinerAnnounceLeave.HasValue && joinerAnnounceLeave.Value)
            {
                joinerAnnouncements.Add(AnnouncementType.Leave);
            }
            if (joinerAnnounceMute.HasValue && joinerAnnounceMute.Value)
            {
                joinerAnnouncements.Add(AnnouncementType.Mute);
            }
            if (joinerAnnounceUnmute.HasValue && joinerAnnounceUnmute.Value)
            {
                joinerAnnouncements.Add(AnnouncementType.Unmute);
            }
            try
            {
                await client.Joiners2Async($"{Prefix}{id}", new NewJoiner
                {
                    Name  = joinerName,
                    Phone = joinerPhone,
                    RequirePositiveStart = joinerPositiveStart,
                    RequireUnmute        = joinerUnmute,
                    SystemId             = joinerId.ToString(),
                    Announcements        = joinerAnnouncements
                });

                _ = Log(id, "info", $"Joiner ({joinerId}/{joinerName}/{joinerPhone}) added to call");
            }
            catch (Exception e)
            {
                _ = Log(id, "error", $"Failed to add joiner {joinerPhone} to call due to error {e.GetType().Name}: {e.Message}");
                throw;
            }
        }