Ejemplo n.º 1
0
        private async Task <string> PostNcco(bool immediate, string externalId, ICollection <NCCO> nccos)
        {
            if (immediate)
            {
                _nccoQueue.Clear(externalId);
            }

            foreach (var ncco in nccos)
            {
                _nccoQueue.AddToQueue(externalId, ncco);
            }

            if (immediate || !_nccoQueue.IsCurrentlyExecuting(externalId))
            {
                var putNcco = new PutNcco
                {
                    Destination = new Destination
                    {
                        Url = new List <string> {
                            $"https://www.cmcardle75.co.uk:65432/nexmogetnccos?uuid={externalId}"
                        }
                    }
                };

                var body    = JsonConvert.SerializeObject(putNcco);
                var message = new HttpRequestMessage
                {
                    Method     = HttpMethod.Put,
                    Content    = new StringContent(body),
                    RequestUri = new System.Uri($"https://api.nexmo.com/v1/calls/{externalId}")
                };
                message.Headers.Authorization       = new AuthenticationHeaderValue("Bearer", Jwt.BearerToken);
                message.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                var response = await new HttpClient().SendAsync(message);
                var data     = await response.Content.ReadAsStringAsync();

                return(data);
            }

            return(string.Empty);
        }
Ejemplo n.º 2
0
        public IHttpActionResult NexmoGetNccos(string uuid)
        {
            Debug.WriteLine($"NexmoGetNccos {uuid}");
            var nccos = _nccoQueue.GetQueue(uuid);

            nccos.Add(new Notify {
                Payload = new Payload {
                    Data = "finishedExecuting"
                }
            });
            nccos.Add(new Conversation {
                Name = "conf_" + uuid
            });
            _nccoQueue.SetCurrentlyExecuting(uuid, true);
            _nccoQueue.Clear(uuid);

            Debug.Write(JsonConvert.SerializeObject(nccos));

            return(Ok(nccos));
        }