Created
January 8, 2014 07:47
-
-
Save edwinv/8313238 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'curb' | |
# Create a new Curl instance with the correct accept and content-type headers | |
c = Curl::Easy.new do |curl| | |
curl.headers["Accept"] = "application/json" | |
curl.headers["Content-Type"] = "application/json" | |
curl.http_auth_types = Curl::CURLAUTH_BASIC | |
curl.userpwd = "username:password" | |
end | |
c.url = "http://subdomain.moneybird.nl/invoices.json" | |
# All information not supplied (like invoice_id, invoice_date and currency) | |
# are copied from the settings or other defaults are used. | |
new_invoice_json = '{ | |
"invoice":{ | |
"company_name":"TODO: Company", | |
"details_attributes":[ | |
{ | |
"amount":"10", | |
"description":"En nog eens 10 uur", | |
"row_order":1 | |
}, | |
{ | |
"amount":"17", | |
"description":"Zestien uur en drie kwartier met rowan gepraat", | |
"row_order":2 | |
}, | |
{ | |
"amount":"2", | |
"description":"Twee uur met rowan gepraat", | |
"row_order":3 | |
} | |
] | |
} | |
}' | |
# Create a post request | |
c.http_post(new_invoice_json) | |
# Check if the request is successfull | |
if c.response_code == 201 | |
puts "Created invoice successfully" | |
puts c.body_str | |
else | |
puts "Error creating invoice:" | |
puts c.body_str | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"invoice": { | |
"address1": null, | |
"address2": null, | |
"attention": null, | |
"city": null, | |
"company_name": "TODO: Company", | |
"concept_id": 7, | |
"contact_id": 8, | |
"country": null, | |
"created_at": "2014-01-08T08:46:01+01:00", | |
"currency": "EUR", | |
"customer_id": "8", | |
"description": "We verzoeken u vriendelijk het bovenstaande bedrag van {document.total_price} voor {document.due_date} te voldoen op onze bankrekening onder vermelding van het factuurnummer {document.invoice_id}. Voor vragen kunt u contact opnemen per e-mail.", | |
"discount": "0.0", | |
"due_date_interval": 14, | |
"exchange_rate": 1, | |
"firstname": null, | |
"id": 12, | |
"invoice_date": "2014-01-08", | |
"invoice_hash": "a72f9fbbefe4dd784f2a83afcdfe2b4c0de11927", | |
"invoice_id": null, | |
"invoice_profile_id": 1, | |
"invoice_profile_version_id": null, | |
"language": "en", | |
"lastname": null, | |
"original_estimate_id": null, | |
"original_invoice_id": null, | |
"po_number": null, | |
"prices_are_incl_tax": false, | |
"recurring_template_id": null, | |
"send_method": "email", | |
"show_customer_id": false, | |
"show_tax": true, | |
"show_tax_number": false, | |
"state": "draft", | |
"tax_number": null, | |
"total_price_excl_tax": "0.0", | |
"total_price_excl_tax_base": "0.0", | |
"total_price_incl_tax": "0.0", | |
"total_price_incl_tax_base": "0.0", | |
"updated_at": "2014-01-08T08:46:01+01:00", | |
"zipcode": null, | |
"contact_name": "", | |
"days_open": 0, | |
"email": "", | |
"invoice_email": "Geachte TODO: Company, \n\nIn de bijlage kunt u factuur {document.invoice_id} voor onze diensten vinden. Wij verzoeken u vriendelijk de factuur voor 22-01-2014 te voldoen.\n\nMet vriendelijke groet,\n\nParkietje B.V.", | |
"invoice_email_reminder": "Geachte TODO: Company, \n\nIn de bijlage kunt u een herinnering voor factuur {document.invoice_id} vinden. Deze factuur is op 22-01-2014 verlopen, maar helaas hebben wij nog geen betaling ontvangen. Wij verzoeken u vriendelijk de factuur binnen vijf dagen te voldoen.\n\nMet vriendelijke groet,\n\nParkietje B.V.", | |
"name": "TODO: Company", | |
"pay_url": "https://parkietje.moneybird.dev/invoice/68466ae0a02dde8c1f524ea9416267a2b280feb3/a72f9fbbefe4dd784f2a83afcdfe2b4c0de11927/pay", | |
"revision": 1389167161, | |
"total_discount": "-0.0", | |
"total_paid": 0, | |
"total_tax": "0.0", | |
"total_unpaid": "0.0", | |
"url": "https://parkietje.moneybird.dev/invoice/68466ae0a02dde8c1f524ea9416267a2b280feb3/a72f9fbbefe4dd784f2a83afcdfe2b4c0de11927", | |
"details": [ | |
{ | |
"amount": "10.0", | |
"created_at": "2014-01-08T08:46:01+01:00", | |
"description": "En nog eens 10 uur", | |
"id": 28, | |
"ledger_account_id": 12, | |
"price": "0.0", | |
"row_order": 1, | |
"tax_rate_id": 6, | |
"updated_at": "2014-01-08T08:46:01+01:00", | |
"amount_plain": "10", | |
"tax": "0.19", | |
"total_price_excl_tax": "0.0", | |
"total_price_incl_tax": "0.0" | |
}, | |
{ | |
"amount": "17.0", | |
"created_at": "2014-01-08T08:46:01+01:00", | |
"description": "Zestien uur en drie kwartier met rowan gepraat", | |
"id": 29, | |
"ledger_account_id": 12, | |
"price": "0.0", | |
"row_order": 2, | |
"tax_rate_id": 6, | |
"updated_at": "2014-01-08T08:46:01+01:00", | |
"amount_plain": "17", | |
"tax": "0.19", | |
"total_price_excl_tax": "0.0", | |
"total_price_incl_tax": "0.0" | |
}, | |
{ | |
"amount": "2.0", | |
"created_at": "2014-01-08T08:46:01+01:00", | |
"description": "Twee uur met rowan gepraat", | |
"id": 30, | |
"ledger_account_id": 12, | |
"price": "0.0", | |
"row_order": 3, | |
"tax_rate_id": 6, | |
"updated_at": "2014-01-08T08:46:01+01:00", | |
"amount_plain": "2", | |
"tax": "0.19", | |
"total_price_excl_tax": "0.0", | |
"total_price_incl_tax": "0.0" | |
} | |
], | |
"history": [ | |
{ | |
"action": "invoice_created", | |
"created_at": "2014-01-08T08:46:01+01:00", | |
"description": null, | |
"id": 23, | |
"updated_at": "2014-01-08T08:46:01+01:00", | |
"user_id": null | |
} | |
], | |
"payments": [] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment