This is a Laravel application that provides an invoicing API.
-
Clone the repository:
git clone https://github.com/MDeeee/invoices-app.git
-
Navigate to the project directory:
cd yourrepository
-
Install the dependencies:
composer install
-
Copy the example environment file and make the required configuration changes in the
.env
file:cp .env.example .env
-
Generate a new application key:
php artisan key:generate
-
Run the database migrations (Set the database connection in
.env
before migrating):php artisan migrate
-
Seed the database with some test data:
php artisan db:seed
this command will create 3 admins ([email protected],[email protected],[email protected]) 3 customers ([email protected],[email protected],[email protected]) 3 users for each customer ([email protected],[email protected],[email protected],[email protected],[email protected] ...) and 3 sessions for each user
Password for admin, customer and user: 12345678
You can run the tests for the application using the following command:
php artisan test
You can import the Postman collection to test the API endpoints. The collection is located in the postman
directory in the root of the project.
environment variables:
- base url: http://localhost/api/v1
- token:
You can view the database diagram at the following link:
https://drawsql.app/teams/mdee/diagrams/invoices-app
This application provides an invoicing API with the following endpoints:
Note only Admin can create invoces for customers
-
Create Invoice:
POST /api/v1/admin/invoices
This endpoint creates a new invoice. It accepts a JSON body with the following fields:
start_date
: The start date of the invoice period.end_date
: The end date of the invoice period.customer_id
: The ID of the customer for whom the invoice is being created.
Example request:
{ "start_date": "2023-01-01", "end_date": "2023-02-01", "customer_id": 1 }
Example response:
{ "invoice_id": 1 }
-
Get Invoice:
GET /api/v1/admin/invoices/{id}
This endpoint retrieves the details of an invoice. Replace {id} with the ID of the invoice you want to retrieve.
Example response:
{ "invoice_id": 1, "customer_id": 1, "start_date": "2023-01-01", "end_date": "2023-02-01", "total_amount": 1000, "details": [ // ... ] }
-
Admin Login:
POST /api/v1/admin/auth/login
This endpoint get admin account information and create Bearer Token to use it on any request
-
User Login:
POST /api/v1/user/auth/login
This endpoint get user account information and create Bearer Token to use it on any request
-
Customer Login:
POST /api/v1/customer/auth/login
This endpoint get customer account information and create Bearer Token to use it on any request