This challenge involves creating a simple yet efficient Laravel application to track user interactions through an API. The project consists of two primary components:
- API Endpoints: To track user visits and update their interaction.
- API Endpoints: Get Interaction Statistics
- PHP: ^8.1
- Laravel: ^9.19
Clone the project from the repository main branch and run the following commands:
composer install
npm install
cp .env.example .env
php artisan key:generate
echo "API_KEY=your-api-key" >> .env
php artisan:migrate
php artisan:serve
- Endpoint:
POST /auth/login
- Description: Authenticate a user.
- Request:
- Body:
email
(string, required): User's email.password
(string, required): User's password.
- Body:
- Response:
token
(string): Authentication token.
- Endpoint:
POST /auth/signup
- Description: Register a new user.
- Request:
- Body:
name
(string, not required): User's name.email
(string, required): User's email.password
(string, required): User's password.
- Body:
- Response:
token
(string): Authentication token.user
(JSON): Authentication token.
- Endpoint:
GET /user/interactions
- Description: Get a list of all interactions for the authenticated user.
- Authentication: Bearer Token
- Endpoint:
POST /user/interactions
- Description: Create a new interaction.
- Request:
- Body:
name
(string, required): Interaction name.label
(string, required): Interaction label.- Additional interaction details.
- Body:
- Authentication: Bearer Token
- Endpoint:
PUT /user/interactions/{id}
- Description: Update an existing interaction.
- Request:
- Body:
name
(string, required): Updated interaction name.label
(string, required): Updated interaction label.
- Body:
- Authentication: Bearer Token
- Endpoint:
DELETE /user/interactions/{id}
- Description: Delete an existing interaction.
- Authentication: Bearer Token
- Endpoint:
POST /user/interactions/{interaction}/events
- Description: Simulate an event for a specific interaction.
- Request:
- Body:
event_type
(string, required): Type of the event.
- Body:
- Authentication: Bearer Token
- Endpoint:
GET /user/interactions/{interaction}/statistics
- Description: Get statistics for a specific interaction.
- Query Parameters:
start_date
(string, optional): Start date for filtering statistics.end_date
(string, optional): End date for filtering statistics.
- Authentication: Bearer Token