public void GetCallsCallIdTest()
        {
            // TODO: add unit test for the method 'GetCallsCallId'
            string callId   = null; // TODO: replace null with proper value
            var    response = instance.GetCallsCallId(callId);

            Assert.IsInstanceOf <CallConversation> (response, "response is CallConversation");
        }
        private void ProcessVoicemail()
        {
            // Check Voicemail
            var vmApi   = new VoicemailApi();
            var convApi = new ConversationsApi();
            var vms     = vmApi.GetMessages();
            VoicemailMediaInfo vmMedia;

            foreach (VoicemailMessage vm in vms.Entities.Where(x => !(x.Read ?? false)))        // Unread VMs only
            {
                DateTime vmDate = vm.CreatedDate != null ? ((DateTime)vm.CreatedDate).ToLocalTime() : DateTime.Now;

                Log("VM from " + vm.CallerAddress + " at " + vmDate);

                // Check for Group attribute so we know where to send it (use default if nothing found)
                string group      = "unknown";
                string groupEmail = DefaultRecipientEmail;
                var    call       = convApi.GetCallsCallId(vm.Conversation.Id);

                CallMediaParticipant participant = null;
                try
                {
                    participant = call.Participants.First(x => x.Attributes != null && x.Attributes.ContainsKey("Group"));
                }
                catch { }

                if (participant != null)
                {
                    group = participant.Attributes["Group"];

                    // Try to look up the email for this group in Settings. If it's not found, just move on with the default
                    try
                    {
                        groupEmail = Properties.Settings.Default[group].ToString();
                    }
                    catch { }
                }
                else
                {
                    participant = call.Participants[0];
                }

                // Download the WAV file
                string fileName;
                vmMedia = vmApi.GetMessagesMessageIdMedia(vm.Id, "WAV");
                using (var client = new WebClient())
                {
                    fileName = Path.GetTempPath() +
                               "PureCloud_VM_" + group + "_" +
                               vmDate.ToString("yyyyMMdd-HHmmss") + ".wav";

                    client.DownloadFile(vmMedia.MediaFileUri, fileName);
                }

                // Email to the proper group
                string callerName = (vm.CallerName ?? participant.Name ?? vm.CallerAddress);
                string subject    = "Voicemail from " + callerName;
                string body       = ComposeVoicemailEmail(vmDate, group, vm.CallerAddress, callerName);
                SendEmail(groupEmail, EmailFromAddress, body, subject, fileName);
                Log("    Sent to " + group + ": " + groupEmail);

                // Mark the VM as read so it won't get sent again next time
                vm.Read = true;
                vmApi.PutMessagesMessageId(vm.Id, vm);
            }
        }