This Laravel 10 application allows individuals to create a business by providing a name and a hook_url. Upon creation, they receive a response containing their business information and a generated api_key for subsequent requests.
- Business Creation: Create a business by passing a name and a
hook_url. - Joke Delivery: Schedule a joke to be sent to the registered
hook_urlwith a 10-second delay. - Retrieve Jokes: Retrieve all jokes received by a business.
Route: /business
Method: POST
Request Body:
{
"name": "Awesome Business",
"hook_url": "http://localhost/client2/public/api/webhook-receiving-url"
}Response:
{
"success": true,
"message": "Business Created",
"data": {
"id": "9c7f6504-3bee-4331-a8e1-b1221b846f0b",
"business": "Awesome Business",
"hook_url": "http://localhost/client2/public/api/webhook-receiving-url",
"api_key": "Lbpax73GUPST1SjQfVJxPJjqBPD0hgEY"
}
}Route: /send-joke
Method: POST
Response:
{
"success": true,
"message": 200,
"data": "Joke delivery scheduled in 10 seconds"
}Route: /jokes
Method: GET
Response:
[
{
"id": 1,
"joke": "Why don't scientists trust atoms? Because they make up everything!",
"business_id": "9c7f6504-3bee-4331-a8e1-b1221b846f0b"
},
...
]You can test the endpoints using Postman or any other API testing tool.
- Business: A business has many jokes.
- Joke: A joke belongs to a business.
- The job for sending jokes runs with Redis as the queue connection.
- A 10-second delay is implemented before the job is dispatched.
- The job is configured to retry 3 times in case of failure.
laravel-webhook-serverprovides configurations for the number of tries and the duration between tries.
- Clone the repository:
git clone https://github.com/your-repo/your-project.git
- Navigate to the project directory:
cd your-project - Install dependencies:
composer install
- Set up your
.envfile. - Run migrations:
php artisan migrate
- Start the Redis server and activate the queue worker:
redis-server php artisan queue:work
- Start the development server:
php artisan serve
This project is licensed under the MIT License.