chargify/chargify_api_ares — pull request #69 by laspluviosillas (2013-11-12 01:23:00+00:00)
Title: Proof of concept example of allocations JSON api submission.

This is in no way ready for merge but it's an example of how to integrate Chargify's allocations api with ActiveResource .. sort of.

Usage example:

```ruby
# Set all allocated components to 100.
s = Chargify::Subscription.find 4188755
components = s.components
components.each do |c|
components.allocated_quantity = 100
end
s.allocate_components components
```

It receives an array of Component objects and does the submission to Chargify to update those components. Works perfectly except for the response. In this case ActiveRecord expect's the POST response (which is in REST terminology a CREATE action) to return attributes for *one* resource not an *array* of resources, so ActiveRecord freaks out.

I overrid the method ActiveRecord uses to update its own object after `create` to load an array of Allocations, but it's not too pretty.

Anyways, food for thought, any ideas how to get around the non-RESTful nature of this API is more than welcome.