FastAPI-based REST API designed for managing customer orders. It includes authentication and authorization using Auth0 via OAuth2.0 and OpenID Connect (OIDC). The application supports creating customers and orders, with SMS notifications sent to customers upon order creation using Africa's Talking API.
# FastAPI Application
This is a FastAPI application with SMS functionality using Africa's Talking API.
## Prerequisites
- Python 3.7+
- pip (Python package installer)
## Installation
1. Clone the repository:
```
git clone git@github.com:Clemo97/customer-fast-api.git
cd customer-fast-api
```
2. Create a virtual environment:
```
python -m venv venv
```
3. Activate the virtual environment:
- On Windows:
```
venv\Scripts\activate
```
- On macOS and Linux:
```
source venv/bin/activate
```
4. Install the required dependencies:
```
pip install -r requirements.txt
```
## Configuration
1. Create a `.env` file in the root directory of the project.
2. Add the following environment variables to the `.env` file:
```
AUTH0_DOMAIN=your_auth0_domain
API_AUDIENCE=your_api_audience
AUTH0_CLIENT_ID=your_auth0_client_id
AUTH0_CLIENT_SECRET=your_auth0_client_secret
CALLBACK_URL=your_callback_url
AFRICAS_TALKING_API_KEY=your_africas_talking_api_key
SQLALCHEMY_DATABASE_URL=your_database_url
```
Replace the placeholder values with your actual credentials and configuration.
## Running the Application
1. Ensure your virtual environment is activated.
2. Run the FastAPI application:
```
uvicorn main:app --reload
```
3. Open your web browser and navigate to `
customer-fast-api.onrender.…` to access the API.
## Getting an Access Token
1. Visit `
customer-fast-api.onrender.…` to get authenticated in order to receive your `access token`.
2. Use acess token in postman to interact with /api/customers and /api/orders endpoints
```
curl --location '
customer-fast-api.onrender.…' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json'
```
curl command to make orders
```
curl --location '
customer-fast-api.onrender.…' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ' \
--data '{
"item": "Pork Sausages",
"amount": 609.00}'
```
3. SMS i …