This project is a simple application that build by me to fulfill the intership selection at PT. Digdaya Olah Teknologi Indonesia
I use a Laravel Framework 5.8 that need this requirement:
- PHP >= 7.1.3
- BCMath PHP Extension
- Composer
- Ctype PHP Extension
- cURL PHP Extension
- JSON PHP Extension
- Mbstring PHP Extension
- OpenSSL PHP Extension
- PDO PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
- Clone this repository
- Copy
.env.example
to.env
and update RajaOngkir API Key and Package with your own - Run
composer install
- You can start the development server using command
php artisan serve
- Start development server using command
php artisan serve
- Open
http://127.0.0.1:8000/task-one
- See the result of default array in JSON format
-
Input an array that contains an integer collection as
array
GET parameter separates by commas (,
) and open it. -
See the results in JSON format
- Get all provinces :
http://127.0.0.1:8000/api/provinces
- Get province by province id :
http://127.0.0.1:8000/api/provinces/{provinceId}
- Search province by province name :
http://127.0.0.1:8000/api/provinces?keyword={keyword}
- Get cities belongs to province id :
http://127.0.0.1:8000/api/provinces/{provinceId}/cities
- Get city belongs to province id by city id :
http://127.0.0.1:8000/api/provinces/{provinceId}/cities/{cityId}
- Search cities belongs to province id by city name :
http://127.0.0.1:8000/api/provinces/{provinceId}/cities?keyword={keyword}
In a successful response, API will return a response with HTTP Status Code 2xx and JSON in this format:
{
"success": true,
"message": "Request success.",
"data": {
"province_id": "1",
"province": "Bali",
}
}
data key in the response must be either a single resource or an array of resource
Then, in a failed response, API will return a response with HTTP Status Code 4xx or 5xx and JSON in this format:
{
"success": false,
"message": "Request failed.",
"errors": [
"province_id": "Province ID is invalid.",
"city_id": "City ID is invalid.",
]
}
errors key in the failed response must be an array that every key is taken from the request body key and value declare the error message