This Django web application allows you to create accounts and destinations, receive data, and forward it to multiple destinations using webhook URLs. The application is designed to manage accounts, each with unique attributes and multiple destinations, and handle incoming JSON data to be forwarded based on the account's configuration.
- Account Management: Create, read, update, and delete accounts.
- Destination Management: Create, read, update, and delete destinations linked to accounts.
- Data Handling: Receive JSON data and forward it to multiple destinations using specified HTTP methods and headers.
- Authentication: Authenticate incoming data using a secret token.
- Python 3.x
- Django 3.x
- Django REST Framework
- Requests library
-
Clone the repository:
git clone https://github.com/yourusername/yourrepository.git cd yourrepository
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Apply migrations:
python manage.py makemigrations python manage.py migrate
-
Run the server:
python manage.py runserver
- Database Configuration:
Update the
DATABASES
setting inwebhook_project/settings.py
if you are using a database other than SQLite.
-
List Accounts:
GET /accounts/
-
Create Account:
POST /accounts/ { "email": "example@example.com", "account_name": "Example Account", "website": "https://example.com" }
-
Retrieve Account:
GET /accounts/<id>/
-
Update Account:
PUT /accounts/<id>/ { "email": "newemail@example.com", "account_name": "New Account Name", "website": "https://newwebsite.com" }
-
Delete Account:
DELETE /accounts/<id>/
-
List Destinations:
GET /destinations/
-
Create Destination:
POST /destinations/ { "account": 1, "url": "https://destination.example.com/webhook", "http_method": "POST", "headers": { "APP_ID": "1234APPID1234", "APP_SECRET": "enwdj3bshwer43bjhjs9ereuinkjcnsiurew8s", "ACTION": "user.update", "Content-Type": "application/json", "Accept": "*" } }
-
Retrieve Destination:
GET /destinations/<id>/
-
Update Destination:
PUT /destinations/<id>/ { "url": "https://newdestination.example.com/webhook", "http_method": "PUT", "headers": { "APP_ID": "newAPPID1234", "APP_SECRET": "newsecret", "ACTION": "user.create", "Content-Type": "application/json", "Accept": "*" } }
-
Delete Destination:
DELETE /destinations/<id>/
-
Get Destinations by Account ID:
GET /accounts/<int:account_id>/destinations
-
Receive and Forward Data:
POST /server/incoming_data Headers: CL-X-TOKEN: <app_secret_token> { "name": "John Doe", "action": "update" }
- Create an Account:
- Send a POST request to
/accounts/
with the required fields.
- Create a Destination:
- Send a POST request to
/destinations/
linked to the created account.
- Receive Data:
- Send a POST request to
/server/incoming_data
with the JSON data andCL-X-TOKEN
header.
- Retrieve Destinations:
- Send a GET request to
/accounts/<account_id>/destinations
.
Feel free to submit issues, fork the repository and send pull requests!