Skip to content

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.

Notifications You must be signed in to change notification settings

MaheswaranT/Django-web-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webhook Receiver and Forwarder

Overview

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.

Features

  • 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.

Setup

Prerequisites

  • Python 3.x
  • Django 3.x
  • Django REST Framework
  • Requests library

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/yourrepository.git
    cd yourrepository
  2. Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install dependencies:

    pip install -r requirements.txt
  4. Apply migrations:

    python manage.py makemigrations
    python manage.py migrate
  5. Run the server:

    python manage.py runserver

Configuration:

  • Database Configuration: Update the DATABASES setting in webhook_project/settings.py if you are using a database other than SQLite.

API Endpoints

Account Endpoints

  • 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>/

Destination Endpoints

  • 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>/

Special Endpoints

  • 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"
    }

Usage

  1. Create an Account:
  • Send a POST request to /accounts/ with the required fields.
  1. Create a Destination:
  • Send a POST request to /destinations/ linked to the created account.
  1. Receive Data:
  • Send a POST request to /server/incoming_data with the JSON data and CL-X-TOKEN header.
  1. Retrieve Destinations:
  • Send a GET request to /accounts/<account_id>/destinations.

Contributing

Feel free to submit issues, fork the repository and send pull requests!

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages