Class: Chartmogul::V1::Import::Invoices

Inherits:
Base
  • Object
show all
Defined in:
lib/chartmogul/v1/import/invoices.rb

Constant Summary collapse

BASE_URI =
"#{BASE_URI}/import/customers"

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Instance Method Details

#create(customer_id, invoices = []) ⇒ Object

Public: Import Invoices.

See: dev.chartmogul.com/docs/invoices

customer_id - The String/Integer ChartMogul ID of the customer.

Specified as part of the URL.

invoices - The Array options used to create a Invoices (default: []).

Examples

client.import.customers.invoices.create 'foo', [
  {
     "external_id": "INV0001",
     "date": "2015-11-01 00:00:00",
     "currency": "USD",
     "due_date": "2015-11-15 00:00:00",
     "line_items": [
       {
         "type": "subscription",
         "subscription_external_id": "sub_0001",
         "plan_uuid":"pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
         "service_period_start": "2015-11-01 00:00:00",
         "service_period_end": "2015-12-01 00:00:00",
         "amount_in_cents": 5000,
         "quantity": 1,
         "discount_code": "PSO86",
         "discount_amount_in_cents": 1000,
         "tax_amount_in_cents": 900
       },
       {
         "type": "one_time",
         "description": "Setup Fees",
         "amount_in_cents": 2500,
         "quantity": 1,
         "discount_code": "PSO86",
         "discount_amount_in_cents": 500,
         "tax_amount_in_cents": 450
       }
     ],
     "transactions": [
       {
         "date": "2015-11-05 00:14:23",
         "type": "payment",
         "result": "successful"
       }
     ]
  }
]

Returns the instance of Chartmogul::V1::Request.



56
57
58
59
60
61
62
# File 'lib/chartmogul/v1/import/invoices.rb', line 56

def create(customer_id, invoices = [])
  Chartmogul::V1::Request.new("#{BASE_URI}/#{customer_id}/invoices",
    body:    { invoices: invoices },
    method:  :post,
    userpwd: client.userpwd,
  )
end