AccountLocationsController API Documentation
Introduction
The AccountLocationsController class handles user location-related operations such as retrieving, creating, updating, and deleting locations associated with the user.
API Endpoints
1. Get Locations
Endpoint:
GET /api/profile/locations
Description:
Fetches the list of locations associated with the authenticated user. You can optionally filter by search or if the location is marked as main.
Request Example:
{
"search": "street name",
"main": true
}
Response Example (Success):
{
"status": true,
"message": "Locations Loaded Successfully",
"data": [
{
"id": 1,
"street": "123 Main St",
"city": "City Name",
"country": "Country Name",
"zip": "12345"
}
]
}
Response Example (Failure):
{
"status": false,
"message": "No locations found"
}
2. Create Location
Endpoint:
POST /api/profile/locations
Description:
Creates a new location for the authenticated user.
Request Example:
{
"street": "123 Main St",
"city_id": "1",
"country_id": "1",
"zip": "12345",
"lat": "40.7128",
"lng": "-74.0060"
}
Response Example (Success):
{
"status": true,
"message": "Location Created Successfully",
"data": {
"id": 1,
"street": "123 Main St",
"city": "City Name",
"country": "Country Name",
"zip": "12345"
}
}
Response Example (Failure):
{
"status": false,
"message": "Validation failed"
}
3. Get Specific Location
Endpoint:
GET /api/profile/locations/{location}
Description:
Fetches details of a specific location. The location must belong to the authenticated user.
Request Example:
{}
Response Example (Success):
{
"status": true,
"message": "Location Loaded Successfully",
"data": {
"id": 1,
"street": "123 Main St",
"city": "City Name",
"country": "Country Name",
"zip": "12345"
}
}
Response Example (Failure):
{
"status": false,
"message": "Sorry, You do not have access to this location"
}
4. Update Location
Endpoint:
POST /api/profile/locations/{location}
Description:
Updates the details of an existing location for the authenticated user.
Request Example:
{
"street": "456 Updated St",
"city_id": "1",
"country_id": "1",
"zip": "67890"
}
Response Example (Success):
{
"status": true,
"message": "Location Loaded Successfully",
"data": {
"id": 1,
"street": "456 Updated St",
"city": "City Name",
"country": "Country Name",
"zip": "67890"
}
}
Response Example (Failure):
{
"status": false,
"message": "Sorry, You do not have access to this location"
}
5. Delete Location
Endpoint:
DELETE /api/profile/locations/{location}
Description:
Deletes a specific location belonging to the authenticated user.
Request Example:
{}
Response Example (Success):
{
"status": true,
"message": "Location Deleted Successfully"
}
Response Example (Failure):
{
"status": false,
"message": "Sorry, You do not have access to this location"
}
Summary of Methods
- index() - Retrieves a list of locations associated with the authenticated user.
- store() - Creates a new location for the authenticated user.
- show() - Retrieves a specific location details for the authenticated user.
- update() - Updates the location details of an existing location.
- destroy() - Deletes a location from the authenticated user's locations.