Module: Vindi::APIOperations::Create

Included in:
Bill, Charge, Customer, Discount, ExportBatch, ImportBatch, PaymentProfile, Plan, Product, ProductItem, Subscription, Transaction, Usage
Defined in:
lib/vindi/api_operations/create.rb

Instance Method Summary collapse

Instance Method Details

#create(params = {}) ⇒ Object



6
7
8
9
10
11
# File 'lib/vindi/api_operations/create.rb', line 6

def create(params = {})
  response = Client.request(:post, endpoint, params)
  singular_key = endpoint.end_with?("batches") ? endpoint.sub(/es$/, "").to_sym : endpoint.chomp("s").to_sym
  resource_attrs = response.key?(singular_key) ? response[singular_key] : response
  new(resource_attrs)
end