|
| 1 | +# PlanVenture API Testing Examples |
| 2 | + |
| 3 | +## Getting Started |
| 4 | + |
| 5 | +### 1. First, register and login to get an access token: |
| 6 | + |
| 7 | +```bash |
| 8 | +# Register |
| 9 | +curl -X POST http://localhost:5000/auth/register \ |
| 10 | + -H "Content-Type: application/json" \ |
| 11 | + -d '{"email":"[email protected]","password":"password123"}' |
| 12 | + |
| 13 | +# Login |
| 14 | +curl -X POST http://localhost:5000/auth/login \ |
| 15 | + -H "Content-Type: application/json" \ |
| 16 | + -d '{"email":"[email protected]","password":"password123"}' |
| 17 | +``` |
| 18 | + |
| 19 | +Save the `access_token` from the response. |
| 20 | + |
| 21 | +### 2. Test Trip Routes |
| 22 | + |
| 23 | +#### Create a Trip |
| 24 | + |
| 25 | +```bash |
| 26 | +curl -X POST http://localhost:5000/trips \ |
| 27 | + -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ |
| 28 | + -H "Content-Type: application/json" \ |
| 29 | + -d @examples/trips_examples.json |
| 30 | +``` |
| 31 | + |
| 32 | +Or use specific examples: |
| 33 | + |
| 34 | +```bash |
| 35 | +# Full trip with itinerary |
| 36 | +curl -X POST http://localhost:5000/trips \ |
| 37 | + -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ |
| 38 | + -H "Content-Type: application/json" \ |
| 39 | + -d '{ |
| 40 | + "destination": "Paris, France", |
| 41 | + "start_date": "2025-06-15", |
| 42 | + "end_date": "2025-06-22", |
| 43 | + "latitude": 48.8566, |
| 44 | + "longitude": 2.3522, |
| 45 | + "itinerary": "Day 1: Eiffel Tower..." |
| 46 | + }' |
| 47 | +``` |
| 48 | + |
| 49 | +#### Get All Trips |
| 50 | + |
| 51 | +```bash |
| 52 | +curl -X GET http://localhost:5000/trips \ |
| 53 | + -H "Authorization: Bearer YOUR_ACCESS_TOKEN" |
| 54 | +``` |
| 55 | + |
| 56 | +#### Get Specific Trip |
| 57 | + |
| 58 | +```bash |
| 59 | +curl -X GET http://localhost:5000/trips/1 \ |
| 60 | + -H "Authorization: Bearer YOUR_ACCESS_TOKEN" |
| 61 | +``` |
| 62 | + |
| 63 | +#### Update a Trip |
| 64 | + |
| 65 | +```bash |
| 66 | +curl -X PUT http://localhost:5000/trips/1 \ |
| 67 | + -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ |
| 68 | + -H "Content-Type: application/json" \ |
| 69 | + -d '{"destination": "Paris & Nice, France"}' |
| 70 | +``` |
| 71 | + |
| 72 | +#### Delete a Trip |
| 73 | + |
| 74 | +```bash |
| 75 | +curl -X DELETE http://localhost:5000/trips/1 \ |
| 76 | + -H "Authorization: Bearer YOUR_ACCESS_TOKEN" |
| 77 | +``` |
| 78 | + |
| 79 | +### 3. Using the Test Script |
| 80 | + |
| 81 | +Make the script executable and run it: |
| 82 | + |
| 83 | +```bash |
| 84 | +chmod +x examples/test_trips.sh |
| 85 | +./examples/test_trips.sh YOUR_ACCESS_TOKEN |
| 86 | +``` |
| 87 | + |
| 88 | +## API Endpoints Summary |
| 89 | + |
| 90 | +| Method | Endpoint | Description | Auth Required | |
| 91 | +| ------ | ---------------- | -------------------- | ------------- | |
| 92 | +| POST | `/auth/register` | Register new user | No | |
| 93 | +| POST | `/auth/login` | Login user | No | |
| 94 | +| GET | `/auth/me` | Get current user | Yes | |
| 95 | +| POST | `/auth/logout` | Logout user | Yes | |
| 96 | +| GET | `/trips` | Get all user's trips | Yes | |
| 97 | +| POST | `/trips` | Create new trip | Yes | |
| 98 | +| GET | `/trips/:id` | Get specific trip | Yes | |
| 99 | +| PUT | `/trips/:id` | Update trip | Yes | |
| 100 | +| DELETE | `/trips/:id` | Delete trip | Yes | |
0 commit comments