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 = {}, opts = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/vindi/api_operations/create.rb', line 6 def create(params = {}, opts = {}) headers = {} headers["Idempotency-Key"] = opts[:idempotency_key] if opts[:idempotency_key] headers.merge!(opts[:headers]) if opts[:headers] response = Client.request(:post, endpoint, params, headers) 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 |