drewtempelmeyer/tax_cloud — pull request #15 by soulcutter (2013-03-01 23:28:17+00:00)
Title: Always send correct format Date to API

I was having issues using tax_cloud in my app because the API expects a certain date format which I have localized in my application to a different date format. The solution was to wrap TaxCloud::Transaction requests' date attributes with something that tries to put Dates into the correct format.

Along the way I cleaned up a typo and a bug in the tests (see individual commits for details).

Oh, also I changed the cart_id and order_id to be random so that you can run tests against the real api multiple times, as one is wont to do while working on code that changes how requests work.

For posterity, here is an example of the error I was getting:

```
SOAP request: https://api.taxcloud.net/1.0/TaxCloud.asmx
SOAPAction: "http://taxcloud.net/AuthorizedWithCapture", Content-Type: text/xml;charset=UTF-8, Content-Length: 711
2qx3KpH3j3WWeaxFs5nGDA==TpOZnEe25okZkoUapeCZtg==103/01/201303/01/2013352F6AE046F45BD4-3D40-4ADC-9EAB-54BB4FDD162E
HTTPI executes HTTP POST using the net_http adapter
SOAP response (status 500):
soap:ClientSystem.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (1, 503). ---> System.FormatException: The string '03/01/2013' is not a valid AllXsd value.
at System.Xml.XmlConvert.ToDateTime(String s, XmlDateTimeSerializationMode dateTimeOption)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read38_AuthorizedWithCapture()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer16.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
TaxCloud::Errors::SoapError:
Problem:
System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (1, 503). ---> System.FormatException: The string '03/01/2013' is not a valid AllXsd value.
Summary:
The server returned a soap:Client error.
Resolution:
Review the parameters passed to the request.
```