Ejemplo n.º 1
0
        /// <summary>
        /// Sends WAP Push to ATamp;T service.
        /// </summary>
        /// <param name="phoneNumber">Phone number to send WAP Push to.</param>
        /// <param name="url">Service URL.</param>
        /// <param name="alertText">Alert text.</param>
        /// <returns>Returns Task as a result of asynchronous operation. Task result is response identifier.</returns>
        public async Task <string> Send(string phoneNumber, string url, string alertText)
        {
            var             service = new WapPushService(Settings);
            WapPushResponse resp    = await service.Send(phoneNumber, url, alertText);

            return(resp.Id);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Event that invokes send wap API of MS SDK wrapper library.
 /// </summary>
 /// <param name="sender">sender that invoked this event</param>
 /// <param name="e">eventargs of the button</param>
 protected void SendWAPButton_Click(object sender, EventArgs e)
 {
     try
     {
         WapPushResponse wapResponse = this.requestFactory.SendWapPush(txtAddressWAPPush.Text.Trim().ToString(), txtUrl.Text, txtAlert.Text);
         this.DrawPanelForSuccess(wapPanel, wapResponse.Id.ToString());
     }
     catch (ArgumentException ex)
     {
         this.DrawPanelForFailure(wapPanel, ex.Message);
     }
     catch (InvalidResponseException ex)
     {
         this.DrawPanelForFailure(wapPanel, ex.Body);
     }
     catch (Exception ex)
     {
         this.DrawPanelForFailure(wapPanel, ex.ToString());
     }
 }
        /// <summary>
        /// Sends new WAP Push via REST to AT&amp;T.
        /// </summary>
        /// <param name="phoneNumber">Phone number to send WAP Push to.</param>
        /// <param name="url">Service URL.</param>
        /// <param name="alertText">Alert text.</param>
        /// <returns>Instance of <see cref="WapPushResponse"/> with sent WAP Push response information.</returns>
        public async Task <WapPushResponse> Send(string phoneNumber, string url, string alertText)
        {
            Argument.ExpectNotNullOrWhiteSpace(() => phoneNumber);
            Argument.ExpectNotNullOrWhiteSpace(() => url);

            string wapData  = BuildServiceInitiation(alertText, url);
            string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x", CultureInfo.InvariantCulture);

            CreateContentTypeHeader(boundary);
            string parameters = phoneNumber + "subject=" + Uri.EscapeUriString("Title") + "&priority=High&content-type=" + Uri.EscapeUriString("application/xml");
            string body       = BuildWapPushData(boundary, parameters, wapData);
            var    content    = new StringContent(body);

            content.Headers.ContentType = CreateContentTypeHeader(boundary);

            string strResponse = await SendContentRequest(HttpMethod.Post, SendRelativeUrl, content);

            WapPushResponse response = WapPushResponse.Parse(strResponse);

            return(response);
        }