# Vespistith Caravan APIs
---
## Error response example
### Schema validation failed errors
```json=
{
"errors": {
"detail": {
"phone_number": [
"can't be blank"
]
},
"code": "SCHEMA_VALIDATION_FAILED"
}
}
```
### Other errors
```json=
{
"errors": {
"detail": "เบอร์ซ้ำจ้า",
"code": "DUPLICATED_PHONE_NUMBER"
}
}
```
## API: Get Me
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpont}/api/accounts.me
Required Auth: ✅
```
### Headers
```
Authorization: Bearer ACCESS_TOKEN
```
### Request
No request body required
### Response
```json=
{
"data": {
"id": "uuid"
"phone_number": "0835671919",
"phone_number_verified_at": "now()",
"reference_code": "ABCD1234",
"qr_code": "0835671919ABCD1234 |> Base64"
}
}
```
## API: Validate Steps
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpoint}/api/enrollments.validateSteps
```
### Headers
```
Authorization: Bearer ACCESS_TOKEN
```
### Request
No request body required
### Response
```json=
{
"data": [
{
"name": "profile",
"completed": true
},
{
"name": "contact",
"completed": true
},
]
}
```
## API: Check Phone Number Existed
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpoint}/api/accounts.validatePhoneNumber
Required Auth: ❌
```
### Request
```json=
{
"phone_number": "0835671919"
}
```
### Response
```json=
{
"data": {
"phone_number_existed": true
}
}
```
## API: Login (Request OTP)
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpoint}/api/accounts.login
Required Auth: ❌
```
### Request
```json=
{
"phone_number": "0833333333"
}
```
### Response
```json=
{
"data": {
"already_signup": true,
"phone_number": "0835671919",
"reference_number": "F8UAM"
}
}
```
## API: Verify Login (Verify OTP)
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpont}/api/accounts.verifyLogin
Required Auth: ❌
```
### Request
```json=
{
"phone_number": "083567xxxx",
"reference_number": "NFHA6",
"otp": "1637",
"marketing_consent": true
}
```
### Response
```json=
{
"data": {
"id": "095013db-0781-4486-969a-59779e1cfe53",
"phone_number": "083567xxxx",
"access_token": "ACCESS_TOKEN",
"marketing_consent": false,
"phone_number_verified_at": "2023-09-17T14:16:10.160933Z",
"reference_code": "MSCSGBCV",
"reference_code_qr": "BASE64_QR_CODE"
}
}
```
## API: Cleanup Phone Number
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpont}/api/accounts.accounts.cleanupPhoneNumber
Required Auth: ❌
```
### Request
```json=
{
"phone_number": "083567xxxx"
}
```
### Response
```json=
{
"data": {
"status": "success"
}
}
```
## API: Update User Profile
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpont}/api/accounts.updateProfile
Required Auth: ✅
```
### Request
```json=
{
"profile": {
"first_name": "fnnnn",
"last_name": "lnnnn",
"birthday": "1994-12-31",
"gender": "male | female | other",
"national_card_id": "1501100000000"
}
}
```
### Response
```json=
// Same as accounts.me API
```
## API: Update User Contact
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpont}/api/accounts.updateContact
Required Auth: ✅
```
### Request
```json=
{
"contact": {
"email": "tim@pita.com",
"line_id": "timlnwza",
"address": "asdasdasd",
"subdistrict": "Phra Khanong"
"district": "Khlong Toei",
"province": "Bangkok",
"postal_code": "10110"
}
}
```
### Response
```json=
// Same as Accounts.me
```
## API: Update User Vehicle (Modern)
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpont}/api/vehicles.updateModern
Required Auth: ✅
```
### Request
```json=
{
"vehicle": {
"vin_number": "123456",
"model": "LX / vintage",
"club": "Lnwza"
"image": "https://gg"
}
}
```
### Response
```json=
// Same as accounts.me
```
## API: Update User Vehicle (Vintage)
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpont}/api/vehicles.updateVintage
Required Auth: ✅
```
### Request
```json=
## Update Vehicle Vintage Duplicate
curl -X "POST" "http://localhost:4000/api/vehicles.updateVintage" \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: multipart/form-data; charset=utf-8; boundary=__X_PAW_BOUNDARY__' \
-F "image=https://files.vespisticaravan.com/users/31f9fd3b-b624-463c-b761-84661a614ec7/79ed1db7-0d1d-49db-a825-3e2b0d650483.jpg" \
-F "vin_number=12345678901234567" \
-F "model=LX125 i-Get" \
-F "club=wildrift" \
-F "image_file=@/Users/sukino/Downloads/mirai_on_fire.jpg"
```
### Response
```json=
// Same as accounts.me
```
## API: Update User Caravans
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpont}/api/caravans.update
Required Auth: ✅
```
```json=
{
"caravan": {
"shirt_size": "XL",
"pickup_point_area": "North",
"pickup_point_dealer_id": "907289d0-21d0-4be7-a8be-6652b5f1c368",
"has_companion": true,
"companion_shirt_size": "XL"
}
}
```
### Response
```json=
// Same as Accounts.me
```
## API: Search Vehicle
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpoint}/api/vehicles.searchVinNumber
Required Auth: ✅
```
### Request
```json=
{
"vin_number": "RP8M82222KV015610"
}
```
### Response
```json=
{
"data": {
"model": "Primavera S 150 i-Get ABS M.GRAY",
"vin_number": "RP8M82222KV015610"
}
}
```
## API: List Active Dealers
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpoint}/api/dealers.list
Required Auth: ❌
```
### Request
```json=
{
"area": "north" // optional, can be null
}
```
### Response
```json=
{
"data": [
{
"id": "907289d0-21d0-4be7-a8be-6652b5f1c368",
"name": "Dealer 1 - North",
"area": "north"
},
{
"id": "9d6f7e80-32cb-4c8b-a203-27fe75608f25",
"name": "Dealer 2 - North",
"area": "north"
},
{
"id": "4a6d8a81-3a74-4543-af34-60f323505fea",
"name": "Dealer 3 - South",
"area": "south"
}
]
}
```
## API: Upload Files
- [x] Ready to integrate on staging
### Endpoint
```
POST: {endpoint}/api/attachments.upload
Required Auth: ✅
```
### Request
```json=
curl -X "POST" "http://localhost:4000/api/attachments.upload" \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'Content-Type: multipart/form-data; charset=utf-8;' \
-F "file=/Users/sukino/Downloads/mirai_on_fire.jpg"
```
### Response
```json=
{
"data": {
"id": "f95e699c-5e5c-4871-87a6-558ce46f44f0",
"path": "users/31f9fd3b-b624-463c-b761-84661a614ec7/e6b050ff-a4ac-4416-a291-0a069503b592.jpg",
"user_id": "31f9fd3b-b624-463c-b761-84661a614ec7",
"acl": "public_read",
"original_name": "mirai_on_fire.jpg",
"note": null,
"public_url": "https://files.vespisticaravan.com/users/31f9fd3b-b624-463c-b761-84661a614ec7/e6b050ff-a4ac-4416-a291-0a069503b592.jpg"
}
}
```
หยิบ `public_url` ไปใช้ได้เลย