Download the PHP package rpsimao/invoicexpress-api without Composer
On this page you can find all versions of the php package rpsimao/invoicexpress-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rpsimao/invoicexpress-api
More information about rpsimao/invoicexpress-api
Files in rpsimao/invoicexpress-api
Package invoicexpress-api
Short Description Laravel Package to interact with InvoiceXpress API
License MIT
Homepage https://github.com/rpsimao/invoicexpress-api
Informations about the package invoicexpress-api
[]() []() []()
Laravel InvoiceXpress API
Laravel package to interact with InvoiceXpress API
**Tested with Laravel 5.5.***
Table of Contents
- 1 - Installation
- 1.1 - Publish configuration
- 1.2 - Migrations
- 2 - Configuration
- 3 - Usage
- 3.1 - Eloquent Model
- 3.1.1 - One-to-One relationship with Laravel::Auth()
- 3.2 - Interact with the API
- 4 - Tests
- 5 - Messages
- 5.1 - Error messages
- 5.2 - Success Messages
1 - Installation
Via Composer
In your config/app.php, register Providers and the Facade (Not needed for Laravel 5.5 upwards)
1.1 - Publish configuration
In the configuration file, all the API endpoints are accessible, so for example you need to generate an invoice PDF:
All endpoints are generic like: 'api/pdf/{invoice-id}.xml'
, so there is a helper function for replacing the generic endpoint with the real value:
The first argument MUST be an array, and the number of the itens to replace, must match the items to be replaced in the endpoint. If not an exception is raised, and a fatal error is thrown.
1.2 - Migrations
2 - Configuration
Add to your .env file your API Key and Account name
These will be read by the config file:
If you do not want to put your API key in the .env file, or prefer to get it on every request, you can call the
getAPIKey()
method. This way you can change the API key in your account frequently and not need to update the app.In the config file
invoicexpress
, there are 2 empty fields['username', 'password']
so you can put the username/password there, if you want.
3 - Usage
Check the documentation for the params of the actions.
See: [ https://invoicexpress.com/api/overview ]()
There are 2 Classes for working with the API:
3.1 - Eloquent Model
It has one custom function, for retrieve all your customers and put them into the DB.
You can make a cron job for retrieving them periodically.
If you pass the true
flag, the function inserts the clients into the database. False
or none, returns an array with all your clients.
If the client already exists, it updates the values.
3.1.1 - One-to-One relationship with Laravel::Auth()
If you wish to have a relationship between the InvoiceXpress and your app Users, do the following:
In your Users Model, add the following method:
You now have a one-to-one relationship. Now you only have to insert the user_id in the InvoiceXpress table.
3.2 - Interact with the API
4 - Tests
Currently there are 4 tests available.
- A GET Request to Retrieve all Clients
- A PUT Request to Update Client Information
- A GET Request for retrieve your API key
- A GET Request for generate a Invoice PDF
For them to work, you have to fill with you own credentials | data:
Then you can run the tests:
If all goes well, you should receive:
5 - Messages
By default all Error / Success messages are returned in XML format.
If you wish to change to JSON, just add the setMsgFormat()
method and pass the JSON flag:
5.1 - Error messages
Theapi_code
and api_msg
are the real messages that the InvoiceXpress API returns, the others are just for debugging.
The debugging tags only appears if in the .env file: APP_DEBUG=true
This is how the Error Messages are returned:
XML
JSON
5.2 - Success Messages
This is how the Success Messages are returned:
XML
JSON
All versions of invoicexpress-api with dependencies
guzzlehttp/guzzle Version ^6.2.1
guzzlehttp/psr7 Version ^1.4.1
guzzlehttp/promises Version ~1.0
laravel/framework Version 5.8.*
illuminate/support Version 5.8.*
spatie/array-to-xml Version ^2.5