Пример #1
0
        internal HttpMessage CreateCreateCallRequest(IEnumerable <CommunicationIdentifierModel> targets, CommunicationIdentifierModel source, string callbackUri, IEnumerable <CallModality> requestedModalities, IEnumerable <EventSubscriptionType> requestedCallEvents, PhoneNumberIdentifierModel sourceAlternateIdentity, string subject)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Post;
            var uri = new RawRequestUriBuilder();

            uri.AppendRaw(endpoint, false);
            uri.AppendPath("/calling/calls", false);
            uri.AppendQuery("api-version", apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/json");
            var model = new CreateCallRequestInternal(targets.ToList(), source, callbackUri, requestedModalities.ToList(), requestedCallEvents.ToList())
            {
                SourceAlternateIdentity = sourceAlternateIdentity,
                Subject = subject
            };
            var content = new Utf8JsonRequestContent();

            content.JsonWriter.WriteObjectValue(model);
            request.Content = content;
            return(message);
        }
Пример #2
0
        internal HttpMessage CreateCreateCallRequest(IEnumerable <CommunicationIdentifierModel> targets, CommunicationIdentifierModel source, string callbackUri, PhoneNumberIdentifierModel alternateCallerId, string subject, IEnumerable <MediaType> requestedMediaTypes, IEnumerable <EventSubscriptionType> requestedCallEvents)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Post;
            var uri = new RawRequestUriBuilder();

            uri.AppendRaw(endpoint, false);
            uri.AppendPath("/calling/callConnections", false);
            uri.AppendQuery("api-version", apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/json");
            CreateCallRequestInternal createCallRequestInternal = new CreateCallRequestInternal(targets.ToList(), source, callbackUri)
            {
                AlternateCallerId = alternateCallerId,
                Subject           = subject
            };

            if (requestedMediaTypes != null)
            {
                foreach (var value in requestedMediaTypes)
                {
                    createCallRequestInternal.RequestedMediaTypes.Add(value);
                }
            }
            if (requestedCallEvents != null)
            {
                foreach (var value in requestedCallEvents)
                {
                    createCallRequestInternal.RequestedCallEvents.Add(value);
                }
            }
            var model   = createCallRequestInternal;
            var content = new Utf8JsonRequestContent();

            content.JsonWriter.WriteObjectValue(model);
            request.Content = content;
            return(message);
        }