Giter VIP home page Giter VIP logo

ballerina-integration-demo's Introduction

Ballerina HTTP service for telecommunication data backend

This Ballerina-based HTTP service serves as the backend for an telecommunication service provider. It processes a JSON array containing new telecom package request details and performs the following tasks upon receipt:

  1. Computes and transforms the input payload into the necessary output payload.
  2. Utilizes OpenAI for risk analysis of the provided policy.
  3. Updates a Google Sheet with the Plan ID, Customer Name, Annual Payment, and Additional Services.

Prerequisites

Ballerina

  1. Download and install Ballerina Swan Lake
  2. Visual Studio Code with the Ballerina extension installed.

Other

  1. Create a Google Account and obtain the tokens by following the blog.Using OAuth 2.0 to access Google APIs
  2. Create the sample MySQL database and populate data with the db.sql script as follows.
mysql -u root -p < /path/to/db.sql
  1. Create a new Google sheet with the following structure. The sheet name is packages.

Input JSON structure

{
    "id": "TEL987654321",
    "customer": {
        "firstName": "Bob",
        "lastName": "Smith",
        "email": "[email protected]",
        "phoneNumber": "+1 (987) 654-3210",
        "address": {
            "street": "456 Telecom Lane",
            "city": "Techville",
            "state": "NY",
            "zipCode": "54321"
        }
    },
    "serviceDetails": {
        "serviceType": "Mobile Plan",
        "activationDate": "2023-11-15",
        "contractExpirationDate": "2024-11-15",
        "monthlyFee": 50.00,
        "initialPayment": 100.00,
        "additionalServices": [
            "Unlimited Data",
            "International Roaming"
        ]
    }
}

Output JSON structure

{
    "planId": "TEL987654321",
    "user": {
        "name": "Bob Smith",
        "email": "[email protected]",
        "phoneNumber": "+1 (987) 654-3210"
    },
    "serviceSummary": {
        "serviceType": "Mobile Plan",
        "activationDate": "2023-11-15",
        "contractExpirationDate": "2024-11-15",
        "annualPayment": 700.00,
        "additionalServices": "Unlimited Data, International Roaming"
    }
}

Configurations

The Config.toml file content is as follows. Add the proper values.

sheetsToken = "" # Type of STRING
sheetsName = ""	# Type of STRING
sheetsId = ""	# Type of STRING

host = ""	# Type of STRING
user = ""	# Type of STRING
password = ""	# Type of STRING
database = ""	# Type of STRING

Sample input

[
    {
        "id": "TEL987654321",
        "customer": {
            "firstName": "Bob",
            "lastName": "Smith",
            "email": "[email protected]",
            "phoneNumber": "+1 (987) 654-3210",
            "address": {
                "street": "456 Telecom Lane",
                "city": "Techville",
                "state": "NY",
                "zipCode": "54321"
            }
        },
        "serviceDetails": {
            "serviceType": "Mobile Plan",
            "activationDate": "2023-11-15",
            "contractExpirationDate": "2024-11-15",
            "monthlyFee": 50.00,
            "initialPayment": 100.00,
            "additionalServices": [
                "Unlimited Data",
                "International Roaming"
            ]
        }
    },
    {
        "id": "TEL123456789",
        "customer": {
            "firstName": "Alice",
            "lastName": "Johnson",
            "email": "[email protected]",
            "phoneNumber": "+1 (123) 456-7890",
            "address": {
                "street": "123 Main St",
                "city": "Anytown",
                "state": "CA",
                "zipCode": "12345"
            }
        },
        "serviceDetails": {
            "serviceType": "Broadband Internet",
            "activationDate": "2023-10-01",
            "contractExpirationDate": "2024-10-01",
            "monthlyFee": 70.00,
            "initialPayment": 120.00,
            "additionalServices": [
                "Router Rental",
                "24/7 Customer Support"
            ]
        }
    },
    {
        "id": "TEL555555555",
        "customer": {
            "firstName": "Charlie",
            "lastName": "Brown",
            "email": "[email protected]",
            "phoneNumber": "+1 (555) 555-5555",
            "address": {
                "street": "789 Tech Blvd",
                "city": "Digital City",
                "state": "TX",
                "zipCode": "98765"
            }
        },
        "serviceDetails": {
            "serviceType": "Home Phone",
            "activationDate": "2023-09-01",
            "contractExpirationDate": "2024-09-01",
            "monthlyFee": 30.00,
            "initialPayment": 50.00,
            "additionalServices": [
                "Voicemail",
                "Call Waiting"
            ]
        }
    },
    {
        "id": "TEL888888888",
        "customer": {
            "firstName": "David",
            "lastName": "Jones",
            "email": "[email protected]",
            "phoneNumber": "+1 (888) 888-8888",
            "address": {
                "street": "567 Connection St",
                "city": "Linkville",
                "state": "WA",
                "zipCode": "56789"
            }
        },
        "serviceDetails": {
            "serviceType": "Fiber Optic Internet",
            "activationDate": "2023-12-01",
            "contractExpirationDate": "2024-12-01",
            "monthlyFee": 90.00,
            "initialPayment": 150.00,
            "additionalServices": [
                "Gigabit Speed",
                "Free Installation"
            ]
        }
    },
    {
        "id": "TEL999999999",
        "customer": {
            "firstName": "Eva",
            "lastName": "Miller",
            "email": "[email protected]",
            "phoneNumber": "+1 (999) 999-9999",
            "address": {
                "street": "987 Network Ave",
                "city": "Connectville",
                "state": "FL",
                "zipCode": "43210"
            }
        },
        "serviceDetails": {
            "serviceType": "Wireless Hotspot",
            "activationDate": "2023-08-15",
            "contractExpirationDate": "2024-08-15",
            "monthlyFee": 40.00,
            "initialPayment": 80.00,
            "additionalServices": [
                "Unlimited Data",
                "Portable Router"
            ]
        }
    }
]

Sample cURL command

curl -X 'POST' \
  'http://localhost:9090/telco/packages' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '[
    {
        "id": "TEL987654321",
        "customer": {
            "firstName": "Bob",
            "lastName": "Smith",
            "email": "[email protected]",
            "phoneNumber": "+1 (987) 654-3210",
            "address": {
                "street": "456 Telecom Lane",
                "city": "Techville",
                "state": "NY",
                "zipCode": "54321"
            }
        },
        "serviceDetails": {
            "serviceType": "Mobile Plan",
            "activationDate": "2023-11-15",
            "contractExpirationDate": "2024-11-15",
            "monthlyFee": 50.00,
            "initialPayment": 100.00,
            "additionalServices": [
                "Unlimited Data",
                "International Roaming"
            ]
        }
    },
    {
        "id": "TEL123456789",
        "customer": {
            "firstName": "Alice",
            "lastName": "Johnson",
            "email": "[email protected]",
            "phoneNumber": "+1 (123) 456-7890",
            "address": {
                "street": "123 Main St",
                "city": "Anytown",
                "state": "CA",
                "zipCode": "12345"
            }
        },
        "serviceDetails": {
            "serviceType": "Broadband Internet",
            "activationDate": "2023-10-01",
            "contractExpirationDate": "2024-10-01",
            "monthlyFee": 70.00,
            "initialPayment": 120.00,
            "additionalServices": [
                "Router Rental",
                "24/7 Customer Support"
            ]
        }
    },
    {
        "id": "TEL555555555",
        "customer": {
            "firstName": "Charlie",
            "lastName": "Brown",
            "email": "[email protected]",
            "phoneNumber": "+1 (555) 555-5555",
            "address": {
                "street": "789 Tech Blvd",
                "city": "Digital City",
                "state": "TX",
                "zipCode": "98765"
            }
        },
        "serviceDetails": {
            "serviceType": "Home Phone",
            "activationDate": "2023-09-01",
            "contractExpirationDate": "2024-09-01",
            "monthlyFee": 30.00,
            "initialPayment": 50.00,
            "additionalServices": [
                "Voicemail",
                "Call Waiting"
            ]
        }
    },
    {
        "id": "TEL888888888",
        "customer": {
            "firstName": "David",
            "lastName": "Jones",
            "email": "[email protected]",
            "phoneNumber": "+1 (888) 888-8888",
            "address": {
                "street": "567 Connection St",
                "city": "Linkville",
                "state": "WA",
                "zipCode": "56789"
            }
        },
        "serviceDetails": {
            "serviceType": "Fiber Optic Internet",
            "activationDate": "2023-12-01",
            "contractExpirationDate": "2024-12-01",
            "monthlyFee": 90.00,
            "initialPayment": 150.00,
            "additionalServices": [
                "Gigabit Speed",
                "Free Installation"
            ]
        }
    },
    {
        "id": "TEL999999999",
        "customer": {
            "firstName": "Eva",
            "lastName": "Miller",
            "email": "[email protected]",
            "phoneNumber": "+1 (999) 999-9999",
            "address": {
                "street": "987 Network Ave",
                "city": "Connectville",
                "state": "FL",
                "zipCode": "43210"
            }
        },
        "serviceDetails": {
            "serviceType": "Wireless Hotspot",
            "activationDate": "2023-08-15",
            "contractExpirationDate": "2024-08-15",
            "monthlyFee": 40.00,
            "initialPayment": 80.00,
            "additionalServices": [
                "Unlimited Data",
                "Portable Router"
            ]
        }
    }
]
'

Ballerina visual features

Architecture view

Level 1 - Services

Level 2 - Resources

Level 3 - Types

Service designer

Sequence diagram

Data mapper

ballerina-integration-demo's People

Contributors

anupama-pathirage avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.