mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Working on docs
This commit is contained in:
parent
b1cf5183a9
commit
8fa5d15aa9
68
docs/api.rst
Normal file
68
docs/api.rst
Normal file
@ -0,0 +1,68 @@
|
||||
API
|
||||
===
|
||||
|
||||
Invoice Ninja provides a REST based API, `click here <https://app.invoiceninja.com/api-docs#/>`_ to see the full list of methods available.
|
||||
|
||||
To access the API you first need to create a token using the "Tokens” page under "Advanced Settings”.
|
||||
|
||||
.. TIP:: We provide a PHP SDK which make it easier to work with the API: https://github.com/invoiceninja/sdk-php
|
||||
|
||||
.. NOTE:: Replace ninja.dev with https://app.invoiceninja.com to access a hosted account.
|
||||
|
||||
Reading Data
|
||||
""""""""""""
|
||||
|
||||
Here’s an example of reading the list of clients using cURL from the command line.
|
||||
|
||||
``curl -X GET ninja.dev/api/v1/clients -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
|
||||
For invoices, quotes, tasks and payments simply change the object type. ie,
|
||||
|
||||
``curl -X GET ninja.dev/api/v1/invoices -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
|
||||
To load a single record specify the Id in the URL. Note: you can add ?invoice_number=0001 to search invoices by invoice number.
|
||||
|
||||
``curl -X GET ninja.dev/api/v1/invoices/1 -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
|
||||
You can download a PDF using the following URL
|
||||
|
||||
``curl -X GET ninja.dev/api/v1/download/1 -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
|
||||
Creating Data
|
||||
"""""""""""""
|
||||
|
||||
Here’s an example of creating a client. Note that email address is a property of the client’s contact not the client itself.
|
||||
|
||||
``curl -X POST ninja.dev/api/v1/clients -H "Content-Type:application/json" -d '{"name":"Client","contact":{"email":"test@gmail.com"}}' -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
|
||||
You can also update a client by specifying a value for ‘id’. Next, here’s an example of creating an invoice.
|
||||
|
||||
``curl -X POST ninja.dev/api/v1/invoices -H "Content-Type:application/json" -d '{"client_id":"1", "invoice_items":[{"product_key": "ITEM", "notes":"Test", "cost":10, "qty":1}]}' -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
|
||||
If the product_key is set and matches an existing record the product fields will be auto-populated. If the email field is set then we’ll search for a matching client. If no matches are found a new client will be created. To email the invoice set email_invoice to true.
|
||||
|
||||
To set the invoice date field you can either use the "invoice_date” field passing a date formatted the same way the company is configured or use "invoice_date_sql” to pass a SQL formatted date (ie, "YYYY-MM-DD”).
|
||||
|
||||
Emailing Invoices
|
||||
"""""""""""""""""
|
||||
|
||||
To email an invoice use the email_invoice command passing the id of the invoice.
|
||||
|
||||
``curl -X POST ninja.dev/api/v1/email_invoice -H "Content-Type:application/json" -d '{"id":1}' -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest"``
|
||||
|
||||
Optional Settings
|
||||
"""""""""""""""""
|
||||
|
||||
The following are optional query parameter settings:
|
||||
|
||||
- serializer: Either array (the default) or json. If json is selected the data is returned using the `JSON API <http://jsonapi.org/>`_ format.
|
||||
- include: A comma-separated list of nested relationships to include.
|
||||
- client_id: If set the results will be filtered by the client.
|
||||
- page: The page number of results to return when the results are paginated.
|
||||
- per_page: The number of results to return per page.
|
||||
- updated_at: Timestamp used as a filter to only show recently updated records.
|
||||
|
||||
Subscriptions
|
||||
"""""""""""""
|
||||
|
||||
You can use subscriptions to have Invoice Ninja POST newly created records to a third-party application. To enable this feature you need to manually add a record to the subscriptions table. To determine the event_id find the associated EVENT_CREATE_ value from app/Constants.php.
|
48
docs/developer_guide.rst
Normal file
48
docs/developer_guide.rst
Normal file
@ -0,0 +1,48 @@
|
||||
Developer Guide
|
||||
===============
|
||||
|
||||
This guide will provide an overview of Invoice Ninja. If anything’s unclear please send us an email, we’re always working to improve it.
|
||||
|
||||
The application is written in PHP using the `Laravel <http://laravel.com/>`_ framework, the full list of libraries can be found on our `GitHub <https://github.com/invoiceninja/invoiceninja>`_ page.
|
||||
|
||||
If you’re running the app for your own use you can white label the client portal and emails by purchasing an annual white label license from within the application. If you’d like to white label the admin pages to re-sell the application please send us an email to learn about our `affiliate program <https://github.com/invoiceninja/invoiceninja#affiliates-programs>`_.
|
||||
|
||||
We try to follow the `PSR-2 <http://www.php-fig.org/psr/psr-2/>`_ style guidelines and are using the `Git-Flow <http://nvie.com/posts/a-successful-git-branching-model/>`_ model of branching and releasing, please create pull requests against the develop branch.
|
||||
|
||||
Code
|
||||
""""
|
||||
|
||||
When setting up the app you can choose to either use the self hosted zip or checkout the code from GitHub. The zip includes all third party libraries, whereas checking out the code from GitHub requires using Composer and Bower.
|
||||
|
||||
We use Gulp to concatenate the JavasScript and CSS files. After making any changes you need to run gulp to re-generate the files.
|
||||
|
||||
Most of the system tables are cached (ie, currencies, languages, etc). If you make any changes you need to clear the cache either by loading any page with ?clear_cache=true added at the end of the URL.
|
||||
|
||||
Database
|
||||
""""""""
|
||||
|
||||
The following are the main entities, you can browse the `app/Models <https://github.com/invoiceninja/invoiceninja/tree/master/app/Models>`_ folder for the complete list.
|
||||
|
||||
- Accounts +users
|
||||
- Clients +contacts
|
||||
- Invoices +invoice_items
|
||||
- Payments
|
||||
- Credits
|
||||
|
||||
The best places to start when reviewing the code are `app/Http/routes.php <https://github.com/invoiceninja/invoiceninja/blob/master/app/Http/routes.php>`_ and `app/Providers/EventServiceProvider.php <https://github.com/invoiceninja/invoiceninja/blob/master/app/Providers/EventServiceProvider.php>`_.
|
||||
|
||||
To enable each account to have it’s own incrementing Ids (ie, /clients/1) all account entity classes extend the custom EntityModel.php class. This gives each entity a public_id field. You can read more about it in `this post <http://hillelcoren.com/2014/02/11/friendly-urls-with-per-account-incrementing-ids-in-laravel/>`_.
|
||||
|
||||
All actions are tracked in the activities table. Example of actions are creating a client, viewing an invoice or entering a payment. This is implemented using Laravel model events. An example can be seen at the bottom of `app/Models/Invoice.php <https://github.com/invoiceninja/invoiceninja/blob/master/app/Models/Invoice.php>`_.
|
||||
|
||||
Laravel supplies `soft delete <http://laravel.com/docs/4.2/eloquent#soft-deleting>`_ functionality, however in order to ensure referential integrity records are only deleted when a user cancels their account. To support this we’ve added an is_deleted field. When the deleted_at field is set the entity has been archived, when is_deleted is true the entity has been deleted.
|
||||
|
||||
Automated Tests
|
||||
"""""""""""""""
|
||||
|
||||
To run the `Codeception <http://codeception.com/>`_ tests you’ll need to install `PhantomJS <http://phantomjs.org/>`_.
|
||||
|
||||
- Create config file: ``cp tests/_bootstrap.php.default tests/_bootstrap.php``
|
||||
- Create test user: ``php artisan db:seed --class=UserTableSeeder``
|
||||
- Start the PhantomJS web server: ``phantomjs --webdriver=4444``
|
||||
- Run the tests: ``sudo ./vendor/codeception/codeception/codecept run --debug``
|
@ -47,4 +47,6 @@ Want to find out everything there is to know about how to use your Invoice Ninja
|
||||
configure
|
||||
update
|
||||
iphone_app
|
||||
api
|
||||
developer_guide
|
||||
custom_modules
|
||||
|
Loading…
x
Reference in New Issue
Block a user