/// <summary>
        /// Processes the response.
        /// </summary>
        /// <returns>The response.</returns>
        /// <param name="responseTask">Response task.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        private T ProcessResponse <T>(Task <HttpResponseMessage> responseTask) where T : Response
        {
            HttpResponseMessage httpResponse = responseTask.Result;

            if (HttpStatusCode.OK.Equals(httpResponse.StatusCode))
            {
                Task <string> responseBody = httpResponse.Content.ReadAsStringAsync();
                Response      response     = JsonConvert.DeserializeObject <T>(responseBody.Result);
                return((T)response);
            }
            else if (HttpStatusCode.BadRequest.Equals(httpResponse.StatusCode) ||
                     HttpStatusCode.InternalServerError.Equals(httpResponse.StatusCode))
            {
                Task <string> responseBody = httpResponse.Content.ReadAsStringAsync();
                WilddogError  wilddogError = JsonConvert.DeserializeObject <WilddogError>(responseBody.Result);
                return((T)Activator.CreateInstance(typeof(T), new object[] { false, wilddogError }));
            }
            else
            {
                WilddogError wilddogError = new WilddogError(httpResponse.StatusCode.ToString(), "");
                return((T)Activator.CreateInstance(typeof(T), new object[] { false, wilddogError }));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Wilddog.Sms.Http.BalanceResponse"/> class.
 /// </summary>
 /// <param name="success">If set to <c>true</c> success.</param>
 /// <param name="wilddogError">Wilddog error.</param>
 public BalanceResponse(bool success, WilddogError wilddogError) : base(success, wilddogError)
 {
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Wilddog.Sms.Http.Response"/> class.
 /// </summary>
 /// <param name="success">If set to <c>true</c> success.</param>
 /// <param name="wilddogError">Wilddog error.</param>
 public Response(bool success, WilddogError wilddogError)
 {
     this.Success      = success;
     this.WilddogError = wilddogError;
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Wilddog.Sms.Http.StatusResponse"/> class.
 /// </summary>
 /// <param name="success">If set to <c>true</c> success.</param>
 /// <param name="wilddogError">Wilddog error.</param>
 public StatusResponse(bool success, WilddogError wilddogError) : base(success, wilddogError)
 {
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Wilddog.Sms.Http.SubmitResponse"/> class.
 /// </summary>
 /// <param name="success">If set to <c>true</c> success.</param>
 /// <param name="wilddogError">Wilddog error.</param>
 public SubmitResponse(bool success, WilddogError wilddogError) : base(success, wilddogError)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Wilddog.Sms.Http.CheckCodeResponse"/> class.
 /// </summary>
 /// <param name="success">If set to <c>true</c> success.</param>
 /// <param name="wilddogError">Wilddog error.</param>
 public CheckCodeResponse(bool success, WilddogError wilddogError) : base(success, wilddogError)
 {
 }