Class: Chargify::Allocation
- Defined in:
- lib/chargify_api_ares/resources/allocation.rb
Defined Under Namespace
Classes: Payment
Class Method Summary collapse
- .bulk_create(opts = {}) ⇒ Object
- .bulk_create_prefix(opts = {}) ⇒ Object
- .with_json_format(&block) ⇒ Object
Methods inherited from Base
Class Method Details
.bulk_create(opts = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/chargify_api_ares/resources/allocation.rb', line 12 def self.bulk_create(opts = {}) return [] if opts[:allocations].blank? subscription_id = opts.delete(:subscription_id) raise ArgumentError, 'subscription_id required' if subscription_id.nil? with_json_format do |format| response = connection.post( bulk_create_prefix(subscription_id: subscription_id), format.encode(opts), headers ) instantiate_collection(format.decode(response.body)) end end |
.bulk_create_prefix(opts = {}) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/chargify_api_ares/resources/allocation.rb', line 5 def self.bulk_create_prefix(opts = {}) subscription_id = opts[:subscription_id] raise ArgumentError, 'subscription_id required' if subscription_id.nil? "/subscriptions/#{subscription_id}/allocations.#{format.extension}" end |
.with_json_format(&block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/chargify_api_ares/resources/allocation.rb', line 28 def self.with_json_format(&block) # Force json processing for this api request json_format = ActiveResource::Formats[:json] orig_format = connection.format begin connection.format = json_format block.call(json_format) ensure connection.format = orig_format end end |