braintree/braintree_ruby — pull request #55 by willglynn (2013-12-06 21:02:19+00:00)
Title: Allow transaction retrieval to return incomplete results

This continues discussion from #46 and #40.

Transaction search uses two endpoints: `/transactions/advanced_search_ids` which returns a list of IDs matching the search terms, and `/transactions/advanced_search` which is called once per page of results. Despite the fact that the `advanced_search_ids` response [specifies the page size](https://github.com/braintree/braintree_ruby/blob/master/lib/braintree/resource_collection.rb#L7), calls to `/transactions/advanced_search` can time out, throwing `Braintree::UnexpectedError: Unprocessable entity due to an invalid request`.

I suggested a solution: make `advanced_search` return whatever it can subject to resource contraints, and leave it to the client to make another request to continue. This is exactly what DynamoDB does with [BatchGetItem](http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchGetItem.html). I found that this could be added trivially and in a forwards-compatible manner, hence this pull request.

This is a small change to client code, but fixing this issue will require an update of `advanced_search`. If the request indicates `accept_incomplete_results=true`, `/transactions/advanced_search` must handle timeouts by returning a partial (or empty) result set instead of `422 Unprocessable Entity`.