public T DoRequest <T>()
 {
     //Annul
     if (typeof(T) == typeof(AnnulResponse))
     {
         var hostedAdminResponse = HostedAdminRequest.HostedAdminCall(GetEndPointBase(), PrepareRequest());
         return((T)(object)hostedAdminResponse.To(Annul.Response));
     }
     //CancelRecurSubscription
     //Confirm
     if (typeof(T) == typeof(ConfirmResponse))
     {
         var hostedAdminResponse = HostedAdminRequest.HostedAdminCall(GetEndPointBase(), PrepareRequest());
         return((T)(object)hostedAdminResponse.To(Confirm.Response));
     }
     //Credit
     if (typeof(T) == typeof(CreditResponse))
     {
         var hostedAdminResponse = HostedAdminRequest.HostedAdminCall(GetEndPointBase(), PrepareRequest());
         return((T)(object)hostedAdminResponse.To(Credit.Response));
     }
     //GetPaymentMethods
     //GetReconciliationReport
     //LowerAmount
     if (typeof(T) == typeof(LowerAmountResponse))
     {
         var hostedAdminResponse = HostedAdminRequest.HostedAdminCall(GetEndPointBase(), PrepareRequest());
         return((T)(object)hostedAdminResponse.To(LowerAmount.Response));
     }
     //Query
     if (typeof(T) == typeof(QueryResponse))
     {
         var hostedAdminResponse = HostedAdminRequest.HostedAdminCall(GetEndPointBase(), PrepareRequest());
         return((T)(object)hostedAdminResponse.To(Query.Response));
     }
     //Recur
     if (typeof(T) == typeof(RecurResponse))
     {
         var hostedAdminResponse = HostedAdminRequest.HostedAdminCall(GetEndPointBase(), PrepareRequest());
         return((T)(object)hostedAdminResponse.To(Recur.Response));
     }
     //Raw HostedAdminResponse
     if (typeof(T) == typeof(HostedAdminResponse))
     {
         var hostedAdminResponse = HostedAdminRequest.HostedAdminCall(GetEndPointBase(), PrepareRequest());
         return((T)(object)hostedAdminResponse);
     }
     //default catch-all
     throw new SveaWebPayException("unknown request type");
 }
        public static HostedAdminResponse HostedAdminCall(string targetAddress, HostedAdminRequest hostedRequest)
        {
            using (var client = new WebClient())
            {
                var response =
                    client.UploadValues(targetAddress, new NameValueCollection
                {
                    { "message", hostedRequest.MessageBase64Encoded },
                    { "mac", hostedRequest.Mac },
                    { "merchantid", hostedRequest.MerchantId }
                });

                var result = Encoding.UTF8.GetString(response);

                var hostedResponse = new HostedAdminResponse(result, hostedRequest.SecretWord, hostedRequest.MerchantId);

                return(hostedResponse);
            }
        }