Пример #1
0
        public async Task <MessagingApplication> CreateMessagingApplicationAsync(IrisAuthData authData,
                                                                                 CreateMessagingApplicationData data, CancellationToken?cancellationToken = null)
        {
            var app = new MessagingApplication
            {
                ApplicationId = await CreateApplication(authData, data, cancellationToken),
                LocationId    = await CreateLocation(authData, data, cancellationToken)
            };

            await EnableSms(authData, data.SmsOptions, app, cancellationToken);
            await EnableMms(authData, data.MmsOptions, app, cancellationToken);
            await AssignApplicationToLocation(authData, app, cancellationToken);

            return(app);
        }
Пример #2
0
        internal async Task <string> CreateLocation(IrisAuthData authData, CreateMessagingApplicationData data,
                                                    CancellationToken?cancellationToken = null)
        {
            var xml = new XDocument(
                new XElement("SipPeer",
                             new XElement("PeerName", data.LocationName),
                             new XElement("IsDefaultPeer", data.IsDefaultLocation)
                             )
                );

            var(_, response) = await MakeRequestAsync(authData, HttpMethod.Post, $"/sites/{authData.SubaccountId}/sippeers",
                                                      xml, false, cancellationToken);

            using (response)
            {
                return((response.Headers.Location ?? new Uri("http://localhost")).AbsolutePath.Split('/').LastOrDefault());
            }
        }
Пример #3
0
        internal async Task <string> CreateApplication(IrisAuthData authData, CreateMessagingApplicationData data,
                                                       CancellationToken?cancellationToken = null)
        {
            var xml = new XDocument(
                new XElement("Application",
                             new XElement("AppName", data.Name),
                             new XElement("CallbackUrl", data.CallbackUrl),
                             new XElement("CallBackCreds",
                                          data.CallbackAuthData == null
              ? null
              : new[]
            {
                new XElement("UserId", data.CallbackAuthData.UserName),
                new XElement("Password", data.CallbackAuthData.Password)
            })
                             )
                );

            var(doc, _) = await MakeRequestAsync(authData, HttpMethod.Post, "/applications", xml, true, cancellationToken);

            return(doc.Descendants("ApplicationId").First().Value);
        }