These commits add support for the one touch endpoint.
First I had to allow POSTing of data serialized in formats other than xml since the One Touch endpoint doesn't support xml for some reason, only application/x-www-form-urlencoded. I had to change things so that Resource.request() takes a newly created Request type rather than Response (I don't know why the data being sent to the API is called a Response). The new Request type has methods to serialize itself to xml, json, and a standard form encoded query string. It also lets subclasses specify which is their preferred serialization. The Resource.writeXml() method actually serializes the given Request object however the object prefers and sets the Content-Type appropriately.
Then I added the necessary classes to support creating approval requests, and then checking their status. There was some complication because of the way every response is wrapped in a hash, except when there's an error in which case the top level xml element is errors. I created a new class called HashWrapper which the new response classes inherit from. I also create a new Users.instanceFromXml() method which will create any HashWrapper from the given xml. It also takes care of when errors are returned instead. It will create a new object and then call obj.setErrors(errors) with the errors object and return the object.
There's a lot I had to shoe-horn in here to make it all work, and I'm not sure if this code should be merged as-is. I'd love some feedback, especially from other users of the API. I think there should be discussion about how to implement support for One Touch and other unsupported endpoints. Including scrapping the entire API as written and starting from scratch. It's very confusing to have Responses sent with the request, and for there to be the User, Users, and Users.User classes, and Token, Tokens, and Tokens.InternalToken.
These commits add support for the one touch endpoint.
First I had to allow
POST
ing of data serialized in formats other than xml since the One Touch endpoint doesn't support xml for some reason, onlyapplication/x-www-form-urlencoded
. I had to change things so thatResource.request()
takes a newly createdRequest
type rather thanResponse
(I don't know why the data being sent to the API is called aResponse
). The newRequest
type has methods to serialize itself to xml, json, and a standard form encoded query string. It also lets subclasses specify which is their preferred serialization. TheResource.writeXml()
method actually serializes the givenRequest
object however the object prefers and sets theContent-Type
appropriately.Then I added the necessary classes to support creating approval requests, and then checking their status. There was some complication because of the way every response is wrapped in a
hash
, except when there's an error in which case the top level xml element iserrors
. I created a new class calledHashWrapper
which the new response classes inherit from. I also create a newUsers.instanceFromXml()
method which will create anyHashWrapper
from the given xml. It also takes care of when errors are returned instead. It will create a new object and then callobj.setErrors(errors)
with the errors object and return the object.There's a lot I had to shoe-horn in here to make it all work, and I'm not sure if this code should be merged as-is. I'd love some feedback, especially from other users of the API. I think there should be discussion about how to implement support for One Touch and other unsupported endpoints. Including scrapping the entire API as written and starting from scratch. It's very confusing to have
Response
s sent with the request, and for there to be theUser
,Users
, andUsers.User
classes, andToken
,Tokens
, andTokens.InternalToken
.