示例#1
0
        public static string GetTaxCode(Params prms)
        {
            RestRequest request = new RestRequest("loctaxcode.asp", Method.POST);

            //request.AddHeader("Host", "app.pestpac.com");
            //request.AddHeader("Connection", "keep-alive");
            //request.AddHeader("Content-Length", "394");
            //request.AddHeader("Accept", "application/xml, text/xml, */*; q=0.01");

            /*request.AddHeader("Origin", "http://app.pestpac.com");
             * request.AddHeader("X-Requested-With", "XMLHttpRequest");
             * request.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36");
             * request.AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
             * request.AddHeader("DNT", "1");
             * request.AddHeader("Referer", "http://app.pestpac.com/location/add.asp");
             * request.AddHeader("Accept-Encoding", "gzip, deflate");
             * request.AddHeader("Accept-Language", "en-US,en;q=0.8");*/

            request = (RestRequest)request.AddXmlBody(prms);
            xmlTool2.RootElement = "response";
            var    response = client.Execute(request);
            string str      = xmlTool2.Deserialize <response>(response).taxcode;

            return(str);
        }
示例#2
0
        public IResult ImageSearch(string searchKeyword)
        {
            try
            {
                var client  = new RestClient(FlickerURL);
                var request = new RestRequest();
                request.Method = Method.GET;
                request.AddParameter(ConstantsUtility.RequestParameterTagsString, searchKeyword);

                // execute the request
                IRestResponse response = client.Execute(request);
                if (response.IsSuccessful)
                {
                    var content = response.Content; // raw content as string

                    //Desearialization
                    DotNetXmlDeserializer deserial = new DotNetXmlDeserializer();
                    var feed = deserial.Deserialize <FlickerFeed>(response);
                    feed.IsSuccessful = true;
                    return(feed);
                }
                else
                {
                    var feed = new FlickerFeed();
                    feed.IsSuccessful = false;
                    feed.ErrorMessage = response.ErrorMessage;
                    return(feed);
                }
            }
            catch
            {
                return(null);
            }
        }
        public void DeserializePaymentMethodsTest()
        {
            DotNetXmlDeserializer deserializer = new DotNetXmlDeserializer();

            RestResponse restResponse = new RestResponse();

            restResponse.Content = @"<paymentMethodsResponse>
                                           <code>SUCCESS</code>
                                           <paymentMethods>
                                              <paymentMethodComplete>
                                                 <id>193</id>
                                                 <description>COBRO_EXPRESS</description>
                                                 <country>AR</country>
                                              </paymentMethodComplete>
                                              <paymentMethodComplete>
                                                 <id>254</id>
                                                 <description>PSE</description>
                                                 <country>CO</country>
                                              </paymentMethodComplete>
                                              <paymentMethodComplete>
                                                 <id>139</id>
                                                 <description>AMEX</description>
                                                 <country>MX</country>
                                              </paymentMethodComplete>
                                              <paymentMethodComplete>
                                                 <id>250</id>
                                                 <description>VISA</description>
                                                 <country>CO</country>
                                              </paymentMethodComplete>
                                           </paymentMethods>
                                        </paymentMethodsResponse>";

            PaymentMethodsResponse response = deserializer.Deserialize <PaymentMethodsResponse>(restResponse);

            Assert.AreEqual(ResponseCode.SUCCESS, response.ResponseCode);
            Assert.AreEqual(4, response.PaymentMethods.Count);
            Assert.AreEqual("193", response.PaymentMethods[0].Id);
            Assert.AreEqual("COBRO_EXPRESS", response.PaymentMethods[0].Description);
            Assert.AreEqual(PaymentCountry.AR.ToString(), response.PaymentMethods[0].Country);
            Assert.AreEqual("254", response.PaymentMethods[1].Id);
            Assert.AreEqual("PSE", response.PaymentMethods[1].Description);
            Assert.AreEqual(PaymentCountry.CO.ToString(), response.PaymentMethods[1].Country);
            Assert.AreEqual("139", response.PaymentMethods[2].Id);
            Assert.AreEqual("AMEX", response.PaymentMethods[2].Description);
            Assert.AreEqual(PaymentCountry.MX.ToString(), response.PaymentMethods[2].Country);
            Assert.AreEqual("250", response.PaymentMethods[3].Id);
            Assert.AreEqual("VISA", response.PaymentMethods[3].Description);
            Assert.AreEqual(PaymentCountry.CO.ToString(), response.PaymentMethods[3].Country);
        }
        public void DeserializeExtraParameters()
        {
            DotNetXmlDeserializer deserializer = new DotNetXmlDeserializer();

            RestResponse restResponse = new RestResponse();

            restResponse.Content = @"<paymentResponse>
                                       <code>SUCCESS</code>
                                       <transactionResponse>
                                          <orderId>2448200</orderId>
                                          <transactionId>accdf6e8-03be-466c-9eca-561100b8d9ca</transactionId>
                                          <state>PENDING</state>
                                          <pendingReason>AWAITING_NOTIFICATION</pendingReason>
                                          <responseCode>PENDING_TRANSACTION_CONFIRMATION</responseCode>
                                          <extraParameters>
                                             <entry>
                                                <string>EXPIRATION_DATE</string>
                                                <date>2013-11-16T14:43:53</date>
                                             </entry>
                                             <entry>
                                                <string>REFERENCE</string>
                                                <int>2448200</int>
                                             </entry>
                                          </extraParameters>
                                       </transactionResponse>
                                    </paymentResponse>";

            PaymentResponse aymentResponse = deserializer.Deserialize <PaymentResponse>(restResponse);

            Assert.IsNotNull(aymentResponse.TransactionResponse.ExtraParameters);
            Assert.AreEqual(2, aymentResponse.TransactionResponse.ExtraParameters.Count);

            object obj = aymentResponse.TransactionResponse.ExtraParameters["EXPIRATION_DATE"];

            Assert.AreEqual("2013-11-16T14:43:53", obj);

            obj = aymentResponse.TransactionResponse.ExtraParameters["REFERENCE"];
            Assert.AreEqual("2448200", obj);
        }
        public void DeserializeReportTest()
        {
            string raw = @"<reportingResponse>
                               <code>SUCCESS</code>
                               <result>
                                  <payload class=""order"">
                                     <id>6073035</id>
                                     <accountId>8</accountId>
                                     <status>CAPTURED</status>
                                     <referenceCode>8c3dd156-b902-4a10-956f-06e35c7c9fe0-20v213c4ld3</referenceCode>
                                     <description>PlanRecu-72861 - 2c8axh8i9q6</description>
                                     <language>es</language>
                                     <buyer>
                                        <fullName>Javier Humberto Ortiz Molina</fullName>
                                        <emailAddress>[email protected]</emailAddress>
                                     </buyer>
                                     <transactions>
                                        <transaction>
                                           <id>c0c0eaad-9454-4c6a-b38f-9d750257c30c</id>
                                           <creditCard>
                                              <maskedNumber>416684******0786</maskedNumber>
                                              <name>Javier Humberto Ortiz Molina</name>
                                           </creditCard>
                                           <type>AUTHORIZATION_AND_CAPTURE</type>
                                           <paymentMethod>VISA</paymentMethod>
                                           <source>RECURRING_PAYMENTS</source>
                                           <paymentCountry>PA</paymentCountry>
                                           <transactionResponse>
                                              <state>APPROVED</state>
                                              <paymentNetworkResponseCode>00</paymentNetworkResponseCode>
                                              <trazabilityCode>332313563116</trazabilityCode>
                                              <authorizationCode>123456</authorizationCode>
                                              <responseCode>APPROVED</responseCode>
                                              <operationDate>2013-11-19T08:29:13</operationDate>
                                           </transactionResponse>
                                           <payer>
                                              <merchantPayerId>2c8axh8i9q6</merchantPayerId>
                                              <fullName>Javier Humberto Ortiz Molina</fullName>
                                              <emailAddress>[email protected]</emailAddress>
                                           </payer>
                                           <additionalValues>
                                              <entry>
                                                 <string>TX_ADDITIONAL_VALUE</string>
                                                 <additionalValue>
                                                    <value>0.00</value>
                                                    <currency>USD</currency>
                                                 </additionalValue>
                                              </entry>
                                              <entry>
                                                 <string>PM_ADDITIONAL_VALUE</string>
                                                 <additionalValue>
                                                    <value>0.00</value>
                                                    <currency>USD</currency>
                                                 </additionalValue>
                                              </entry>
                                              <entry>
                                                 <string>TX_TAX_RETURN_BASE</string>
                                                 <additionalValue>
                                                    <value>5.00</value>
                                                    <currency>USD</currency>
                                                 </additionalValue>
                                              </entry>
                                              <entry>
                                                 <string>PM_TAX</string>
                                                 <additionalValue>
                                                    <value>10.00</value>
                                                    <currency>USD</currency>
                                                 </additionalValue>
                                              </entry>
                                              <entry>
                                                 <string>TX_VALUE</string>
                                                 <additionalValue>
                                                    <value>131.00</value>
                                                    <currency>USD</currency>
                                                 </additionalValue>
                                              </entry>
                                              <entry>
                                                 <string>PM_TAX_RETURN_BASE</string>
                                                 <additionalValue>
                                                    <value>5.00</value>
                                                    <currency>USD</currency>
                                                 </additionalValue>
                                              </entry>
                                              <entry>
                                                 <string>TX_TAX</string>
                                                 <additionalValue>
                                                    <value>10.00</value>
                                                    <currency>USD</currency>
                                                 </additionalValue>
                                              </entry>
                                              <entry>
                                                 <string>PM_VALUE</string>
                                                 <additionalValue>
                                                    <value>131.00</value>
                                                    <currency>USD</currency>
                                                 </additionalValue>
                                              </entry>
                                              <entry>
                                                 <string>TX_NETWORK_VALUE</string>
                                                 <additionalValue>
                                                    <value>131.00</value>
                                                    <currency>USD</currency>
                                                 </additionalValue>
                                              </entry>
                                              <entry>
                                                 <string>COMMISSION_VALUE</string>
                                                 <additionalValue>
                                                    <value>6.05</value>
                                                    <currency>USD</currency>
                                                 </additionalValue>
                                              </entry>
                                              <entry>
                                                 <string>PM_NETWORK_VALUE</string>
                                                 <additionalValue>
                                                    <value>131.00</value>
                                                    <currency>USD</currency>
                                                 </additionalValue>
                                              </entry>
                                           </additionalValues>
                                           <extraParameters>
                                              <entry>
                                                 <string>INSTALLMENTS_NUMBER</string>
                                                 <string>2</string>
                                              </entry>
                                           </extraParameters>
                                        </transaction>
                                     </transactions>
                                     <additionalValues>
                                        <entry>
                                           <string>TX_ADDITIONAL_VALUE</string>
                                           <additionalValue>
                                              <value>0.00</value>
                                              <currency>USD</currency>
                                           </additionalValue>
                                        </entry>
                                        <entry>
                                           <string>PM_ADDITIONAL_VALUE</string>
                                           <additionalValue>
                                              <value>0.00</value>
                                              <currency>USD</currency>
                                           </additionalValue>
                                        </entry>
                                        <entry>
                                           <string>PM_TAX</string>
                                           <additionalValue>
                                              <value>10.00</value>
                                              <currency>USD</currency>
                                           </additionalValue>
                                        </entry>
                                        <entry>
                                           <string>TX_TAX_RETURN_BASE</string>
                                           <additionalValue>
                                              <value>5.00</value>
                                              <currency>USD</currency>
                                           </additionalValue>
                                        </entry>
                                        <entry>
                                           <string>TX_VALUE</string>
                                           <additionalValue>
                                              <value>131.00</value>
                                              <currency>USD</currency>
                                           </additionalValue>
                                        </entry>
                                        <entry>
                                           <string>TX_TAX</string>
                                           <additionalValue>
                                              <value>10.00</value>
                                              <currency>USD</currency>
                                           </additionalValue>
                                        </entry>
                                        <entry>
                                           <string>PM_TAX_RETURN_BASE</string>
                                           <additionalValue>
                                              <value>5.00</value>
                                              <currency>USD</currency>
                                           </additionalValue>
                                        </entry>
                                        <entry>
                                           <string>PM_VALUE</string>
                                           <additionalValue>
                                              <value>131.00</value>
                                              <currency>USD</currency>
                                           </additionalValue>
                                        </entry>
                                        <entry>
                                           <string>TX_NETWORK_VALUE</string>
                                           <additionalValue>
                                              <value>131.00</value>
                                              <currency>USD</currency>
                                           </additionalValue>
                                        </entry>
                                        <entry>
                                           <string>PM_NETWORK_VALUE</string>
                                           <additionalValue>
                                              <value>131.00</value>
                                              <currency>USD</currency>
                                           </additionalValue>
                                        </entry>
                                     </additionalValues>
                                  </payload>
                               </result>
                            </reportingResponse>";

            DotNetXmlDeserializer deserializer = new DotNetXmlDeserializer();

            RestResponse restResponse = new RestResponse();

            restResponse.Content = raw;
            OrderReportResponse response = deserializer.Deserialize <OrderReportResponse>(restResponse);

            Assert.IsNotNull(response);
            Assert.AreEqual(ResponseCode.SUCCESS, response.ResponseCode);
        }
示例#6
0
        public CurrencyRate[] GetCurrencyRates(IRestResponse response)
        {
            var genericData = xmlDeserializer.Deserialize <SDMXGenericData>(response);

            return(mapper.Map <CurrencyRate[]>(genericData));
        }