Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add rest API for all available resources #22

Merged
merged 23 commits into from
Sep 24, 2023
Merged

Conversation

feryardiant
Copy link
Contributor

@feryardiant feryardiant commented Sep 8, 2023

Provinces

Get all provinces

GET {APP_URL}/nusa/provinces

  • Query Params :

    Field Type Option Description
    codes numeric[] optional Fetch only specified province code
    search string optional Search province by a keyword
  • Example :

    • GET http://localhost:8000/nusa/provinces
      {
        "data": [
          {
            "code": 33,
            "name": "Jawa Tengah",
            "latitude": -6.9934809206806,
            "longitude": 110.42024335421,
            "coordinates": [...],
            "postal_codes": [...],
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/provinces?page=1",
          "last": "http://localhost:8000/nusa/provinces?page=3",
          "prev": null,
          "next": "http://localhost:8000/nusa/provinces?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 3,
          "links": [
            {
              "url": null,
              "label": "« Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/provinces?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost/nusa/provinces?page=2",
              "label": "Next »",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/provinces",
          "per_page": 15,
          "to": 15,
          "total": 34
        }
      }

Show a province

GET {APP_URL}/nusa/provinces/{province}

  • Route Param : {province} province code

  • Example :

    • GET http://localhost:8000/nusa/provinces/33
      {
        "data": {
          "code": 33,
          "name": "Jawa Tengah",
          "latitude": -6.9934809206806,
          "longitude": 110.42024335421,
          "coordinates": [...],
          "postal_codes": [...],
        },
        "meta": {}
      }

Get all regencies in a province

GET {APP_URL}/nusa/provinces/{province}/regencies

  • Route Param : {province} province code

  • Example :

    • GET http://localhost:8000/nusa/provinces/33/regencies
      {
        "data": [
          {
            "code": 3375,
            "province_code": 33,
            "name": "Kota Pekalongan",
            "latitude": -6.8969497174987,
            "longitude": 109.66208089654,
            "coordinates": [...],
            "postal_codes": [...],
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/provinces/33/regencies?page=1",
          "last": "http://localhost:8000/nusa/provinces/33/regencies?page=3",
          "prev": null,
          "next": "http://localhost:8000/nusa/provinces/33/regencies?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 3,
          "links": [
            {
              "url": null,
              "label": "« Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/provinces/33/regencies?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost/nusa/provinces/33/regencies?page=2",
              "label": "Next »",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/provinces/33/regencies",
          "per_page": 15,
          "to": 15,
          "total": 35
        }
      }

Get all districts in a province

GET {APP_URL}/nusa/provinces/{province}/districts

  • Route Param : {province} province code

  • Example :

    • GET http://localhost:8000/nusa/provinces/33/districts
      {
        "data": [
          {
            "code": 330101,
            "regency_code": 3301,
            "province_code": 33,
            "name": "Kedungreja",
            "postal_codes": [
              53263
            ]
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/provinces/33/districts?page=1",
          "last": "http://localhost:8000/nusa/provinces/33/districts?page=39",
          "prev": null,
          "next": "http://localhost/nusa/provinces/33/districts?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 39,
          "links": [
            {
              "url": null,
              "label": "« Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/provinces/33/districts?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost/nusa/provinces/33/districts?page=2",
              "label": "Next »",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/provinces/33/districts",
          "per_page": 15,
          "to": 15,
          "total": 576
        }
      }

Get all villages in a province

GET {APP_URL}/nusa/provinces/{province}/villages

  • Route Param : {province} province code

  • Example :

    • GET http://localhost:8000/nusa/provinces/33/villages
      {
        "data": [
          {
            "code": 3301012001,
            "district_code": 330101,
            "regency_code": 3301,
            "province_code": 33,
            "name": "Tambakreja",
            "postal_code": 53263,
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/provinces/33/villages?page=1",
          "last": "http://localhost:8000/nusa/provinces/33/villages?page=571",
          "prev": null,
          "next": "http://localhost:8000/nusa/provinces/33/villages?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 571,
          "links": [
            {
              "url": null,
              "label": "« Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/provinces/33/villages?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost:8000/nusa/provinces/33/villages?page=2",
              "label": "Next »",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/provinces/33/villages",
          "per_page": 15,
          "to": 15,
          "total": 8562
        }
      }

Regencies

Get all regencies

GET {APP_URL}/nusa/regencies

  • Query Params :

    Field Type Option Description
    codes numeric[] optional Fetch only specified regency code
    search string optional Search regency by a keyword
  • Example :

    • GET http://localhost:8000/nusa/regencies
      {
        "data": [
          {
            "code": 3375,
            "province_code": 33,
            "name": "Kota Pekalongan",
            "latitude": -6.8969497174987,
            "longitude": 109.66208089654,
            "coordinates": [...],
            "postal_codes": [...],
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/regencies?page=1",
          "last": "http://localhost:8000/nusa/regencies?page=35",
          "prev": null,
          "next": "http://localhost:8000/nusa/regencies?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 35,
          "links": [
            {
              "url": null,
              "label": "« Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/regencies?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost/nusa/regencies?page=2",
              "label": "Next »",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/regencies",
          "per_page": 15,
          "to": 15,
          "total": 514
        }
      }

Show a regency

GET {APP_URL}/nusa/regencies/{regency}

  • Route Param : {regency} regency code

  • Example :

    • GET http://localhost:8000/nusa/regencies/3375
      {
        "data": {
          "code": 3375,
          "province_code": 33,
          "name": "Kota Pekalongan",
          "latitude": -6.8969497174987,
          "longitude": 109.66208089654,
          "coordinates": [...],
          "postal_codes": [...],
        },
        "meta": {}
      }

Get all districts in a regency

GET {APP_URL}/nusa/regencies/{regency}/districts

  • Route Param : {regency} regency code

  • Example :

    • GET http://localhost:8000/nusa/regencies/3375/districts
      {
        "data": [
          {
            "code": 337501,
            "regency_code": 3375,
            "province_code": 33,
            "name": "Pekalongan Barat",
            "postal_codes": [
              51111
              51112
              51113
              51116
              51117
              51151
            ]
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/regencies/3375/districts?page=1",
          "last": "http://localhost:8000/nusa/regencies/3375/districts?page=1",
          "prev": null,
          "next": null,
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 1,
          "links": [
            {
              "url": null,
              "label": "« Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/regencies/3375/districts?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": null,
              "label": "Next »",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/regencies/3375/districts",
          "per_page": 15,
          "to": 4,
          "total": 4
        }
      }

Get all villages in a regency

GET {APP_URL}/nusa/regencies/{regency}/villages

  • Route Param : {regency} regency code

  • Example :

    • GET http://localhost:8000/nusa/regencies/3375/villages
      {
        "data": [
          {
            "code": 3375011002,
            "district_code": 337501,
            "regency_code": 3375,
            "province_code": 33,
            "name": "Medono",
            "postal_code": 51111,
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/regencies/3375/villages?page=1",
          "last": "http://localhost:8000/nusa/regencies/3375/villages?page=2",
          "prev": null,
          "next": "http://localhost:8000/nusa/regencies/3375/villages?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 2,
          "links": [
            {
              "url": null,
              "label": "« Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/regencies/3375/villages?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost:8000/nusa/regencies/3375/villages?page=2",
              "label": "Next »",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/regencies/3375/villages",
          "per_page": 15,
          "to": 15,
          "total": 27
        }
      }

Districts

Get all districts

GET {APP_URL}/nusa/districts

  • Query Params :

    Field Type Option Description
    codes numeric[] optional Fetch only specified district code
    search string optional Search district by a keyword
  • Example :

    • GET http://localhost:8000/nusa/districts
      {
        "data": [
          {
            "code": 110101,
            "regency_code": 1101,
            "province_code": 11,
            "name": "Bakongan",
            "postal_codes": [
              23773
            ],
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/districts?page=1",
          "last": "http://localhost:8000/nusa/districts?page=485",
          "prev": null,
          "next": "http://localhost:8000/nusa/districts?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 485,
          "links": [
            {
              "url": null,
              "label": "« Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/districts?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost:8000/nusa/districts?page=2",
              "label": "Next »",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/districts",
          "per_page": 15,
          "to": 15,
          "total": 7266
        }
      }

Show a district

GET {APP_URL}/nusa/districts/{district}

  • Route Param : {district} district code

  • Example :

    • GET http://localhost:8000/nusa/districts/337503
      {
        "data": {
          "code": 337503,
          "regency_code": 3375,
          "province_code": 33,
          "name": "Pekalongan Utara",
          "postal_codes": [
            51141
            51143
            51146
            51147
            51148
            51149
          ],
        },
        "meta": {}
      }

Get all villages in a district

GET {APP_URL}/nusa/districts/{district}/villages

  • Route Param : {district} district code

  • Example :

    • GET http://localhost:8000/nusa/districts/337503/villages
      {
        "data": [
          {
            "code": 3375031002,
            "district_code": 337503,
            "regency_code": 3375,
            "province_code": 33,
            "name": "Krapyak",
            "postal_code": 51147,
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/districts/337503/villages?page=1",
          "last": "http://localhost:8000/nusa/districts/337503/villages?page=1",
          "prev": null,
          "next": null,
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 1,
          "links": [
            {
              "url": null,
              "label": "« Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/districts/337503/villages?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": null,
              "label": "Next »",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/districts/337503/villages",
          "per_page": 15,
          "to": 7,
          "total": 7
        }
      }

Villages

Get all villages

GET {APP_URL}/nusa/villages

  • Query Params :

    Field Type Option Description
    codes numeric[] optional Fetch only specified village code
    search string optional Search village by a keyword
  • Example :

    • GET http://localhost:8000/nusa/villages
      {
        "data": [
          {
            "code": 1101012001,
            "district_code": 110101,
            "regency_code": 1101,
            "province_code": 11,
            "name": "Keude Bakongan",
            "postal_code": 23773,
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/villages?page=1",
          "last": "http://localhost:8000/nusa/villages?page=5565",
          "prev": null,
          "next": "http://localhost:8000/nusa/villages?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 5565,
          "links": [
            {
              "url": null,
              "label": "« Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/villages?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost:8000/nusa/villages?page=2",
              "label": "Next »",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/villages",
          "per_page": 15,
          "to": 15,
          "total": 83467
        }
      }

Get a village

GET {APP_URL}/nusa/villages/{village}

  • Route Param : {village} village code

  • Example :

    • GET http://localhost:8000/nusa/villages/3375031006
      {
        "data": {
          "code": 3375031006,
          "district_code": 337503,
          "regency_code": 3375,
          "province_code": 33,
          "name": "Padukuhan Kraton",
          "postal_code": 51146,
        },
        "meta": {}
      }

@feryardiant feryardiant added api Things that consumed by another program enhancement New feature or request integration When multiple functionalities should works together labels Sep 8, 2023
@feryardiant feryardiant self-assigned this Sep 8, 2023
@feryardiant feryardiant requested a review from a team September 8, 2023 03:59
feryardiant and others added 18 commits September 9, 2023 01:02
Signed-off-by: Fery Wardiyanto <[email protected]>
Signed-off-by: Fery Wardiyanto <[email protected]>
Bumps [laravel/pint](https://github.com/laravel/pint) from 1.12.0 to 1.13.1.
- [Release notes](https://github.com/laravel/pint/releases)
- [Changelog](https://github.com/laravel/pint/blob/main/CHANGELOG.md)
- [Commits](laravel/pint@v1.12.0...v1.13.1)

---
updated-dependencies:
- dependency-name: laravel/pint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [orchestra/testbench](https://github.com/orchestral/testbench) from 8.10.0 to 8.10.1.
- [Release notes](https://github.com/orchestral/testbench/releases)
- [Changelog](https://github.com/orchestral/testbench/blob/develop/CHANGELOG-8.x.md)
- [Commits](orchestral/testbench@v8.10.0...v8.10.1)

---
updated-dependencies:
- dependency-name: orchestra/testbench
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
…-1.13.1

chore(deps-dev): bump laravel/pint from 1.12.0 to 1.13.1
…stbench-8.10.1

chore(deps-dev): bump orchestra/testbench from 8.10.0 to 8.10.1
Signed-off-by: Fery Wardiyanto <[email protected]>
* main:
  chore(deps-dev): bump laravel/pint from 1.12.0 to 1.13.1
  chore(deps-dev): bump orchestra/testbench from 8.10.0 to 8.10.2
@feryardiant
Copy link
Contributor Author

Provinces

Get all provinces

GET {APP_URL}/nusa/provinces

  • Query Params :

    Field Type Option Description
    codes numeric[] optional Fetch only specified province code
    search string optional Search province by a keyword
  • Example :

    • GET http://localhost:8000/nusa/provinces
      {
        "data": [
          {
            "code": 33,
            "name": "Jawa Tengah",
            "latitude": -6.9934809206806,
            "longitude": 110.42024335421,
            "coordinates": [...],
            "postal_codes": [...],
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/provinces?page=1",
          "last": "http://localhost:8000/nusa/provinces?page=3",
          "prev": null,
          "next": "http://localhost:8000/nusa/provinces?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 3,
          "links": [
            {
              "url": null,
              "label": "&laquo; Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/provinces?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost/nusa/provinces?page=2",
              "label": "Next &raquo;",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/provinces",
          "per_page": 15,
          "to": 15,
          "total": 34
        }
      }

Show a province

GET {APP_URL}/nusa/provinces/{province}

  • Route Param : {province} province code

  • Example :

    • GET http://localhost:8000/nusa/provinces/33
      {
        "data": {
          "code": 33,
          "name": "Jawa Tengah",
          "latitude": -6.9934809206806,
          "longitude": 110.42024335421,
          "coordinates": [...],
          "postal_codes": [...],
        },
        "meta": {}
      }

Get all regencies in a province

GET {APP_URL}/nusa/provinces/{province}/regencies

  • Route Param : {province} province code

  • Example :

    • GET http://localhost:8000/nusa/provinces/33/regencies
      {
        "data": [
          {
            "code": 3375,
            "province_code": 33,
            "name": "Kota Pekalongan",
            "latitude": -6.8969497174987,
            "longitude": 109.66208089654,
            "coordinates": [...],
            "postal_codes": [...],
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/provinces/33/regencies?page=1",
          "last": "http://localhost:8000/nusa/provinces/33/regencies?page=3",
          "prev": null,
          "next": "http://localhost:8000/nusa/provinces/33/regencies?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 3,
          "links": [
            {
              "url": null,
              "label": "&laquo; Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/provinces/33/regencies?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost/nusa/provinces/33/regencies?page=2",
              "label": "Next &raquo;",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/provinces/33/regencies",
          "per_page": 15,
          "to": 15,
          "total": 35
        }
      }

Get all districts in a province

GET {APP_URL}/nusa/provinces/{province}/districts

  • Route Param : {province} province code

  • Example :

    • GET http://localhost:8000/nusa/provinces/33/districts
      {
        "data": [
          {
            "code": 330101,
            "regency_code": 3301,
            "province_code": 33,
            "name": "Kedungreja",
            "postal_codes": [
              53263
            ]
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/provinces/33/districts?page=1",
          "last": "http://localhost:8000/nusa/provinces/33/districts?page=39",
          "prev": null,
          "next": "http://localhost/nusa/provinces/33/districts?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 39,
          "links": [
            {
              "url": null,
              "label": "&laquo; Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/provinces/33/districts?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost/nusa/provinces/33/districts?page=2",
              "label": "Next &raquo;",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/provinces/33/districts",
          "per_page": 15,
          "to": 15,
          "total": 576
        }
      }

Get all villages in a province

GET {APP_URL}/nusa/provinces/{province}/villages

  • Route Param : {province} province code

  • Example :

    • GET http://localhost:8000/nusa/provinces/33/villages
      {
        "data": [
          {
            "code": 3301012001,
            "district_code": 330101,
            "regency_code": 3301,
            "province_code": 33,
            "name": "Tambakreja",
            "postal_code": 53263,
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/provinces/33/villages?page=1",
          "last": "http://localhost:8000/nusa/provinces/33/villages?page=571",
          "prev": null,
          "next": "http://localhost:8000/nusa/provinces/33/villages?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 571,
          "links": [
            {
              "url": null,
              "label": "&laquo; Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/provinces/33/villages?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost:8000/nusa/provinces/33/villages?page=2",
              "label": "Next &raquo;",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/provinces/33/villages",
          "per_page": 15,
          "to": 15,
          "total": 8562
        }
      }

@feryardiant
Copy link
Contributor Author

Regencies

Get all regencies

GET {APP_URL}/nusa/regencies

  • Query Params :

    Field Type Option Description
    codes numeric[] optional Fetch only specified regency code
    search string optional Search regency by a keyword
  • Example :

    • GET http://localhost:8000/nusa/regencies
      {
        "data": [
          {
            "code": 3375,
            "province_code": 33,
            "name": "Kota Pekalongan",
            "latitude": -6.8969497174987,
            "longitude": 109.66208089654,
            "coordinates": [...],
            "postal_codes": [...],
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/regencies?page=1",
          "last": "http://localhost:8000/nusa/regencies?page=35",
          "prev": null,
          "next": "http://localhost:8000/nusa/regencies?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 35,
          "links": [
            {
              "url": null,
              "label": "&laquo; Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/regencies?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost/nusa/regencies?page=2",
              "label": "Next &raquo;",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/regencies",
          "per_page": 15,
          "to": 15,
          "total": 514
        }
      }

Show a regency

GET {APP_URL}/nusa/regencies/{regency}

  • Route Param : {regency} regency code

  • Example :

    • GET http://localhost:8000/nusa/regencies/3375
      {
        "data": {
          "code": 3375,
          "province_code": 33,
          "name": "Kota Pekalongan",
          "latitude": -6.8969497174987,
          "longitude": 109.66208089654,
          "coordinates": [...],
          "postal_codes": [...],
        },
        "meta": {}
      }

Get all districts in a regency

GET {APP_URL}/nusa/regencies/{regency}/districts

  • Route Param : {regency} regency code

  • Example :

    • GET http://localhost:8000/nusa/regencies/3375/districts
      {
        "data": [
          {
            "code": 337501,
            "regency_code": 3375,
            "province_code": 33,
            "name": "Pekalongan Barat",
            "postal_codes": [
              51111
              51112
              51113
              51116
              51117
              51151
            ]
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/regencies/3375/districts?page=1",
          "last": "http://localhost:8000/nusa/regencies/3375/districts?page=1",
          "prev": null,
          "next": null,
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 1,
          "links": [
            {
              "url": null,
              "label": "&laquo; Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/regencies/3375/districts?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": null,
              "label": "Next &raquo;",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/regencies/3375/districts",
          "per_page": 15,
          "to": 4,
          "total": 4
        }
      }

Get all villages in a regency

GET {APP_URL}/nusa/regencies/{regency}/villages

  • Route Param : {regency} regency code

  • Example :

    • GET http://localhost:8000/nusa/regencies/3375/villages
      {
        "data": [
          {
            "code": 3375011002,
            "district_code": 337501,
            "regency_code": 3375,
            "province_code": 33,
            "name": "Medono",
            "postal_code": 51111,
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/regencies/3375/villages?page=1",
          "last": "http://localhost:8000/nusa/regencies/3375/villages?page=2",
          "prev": null,
          "next": "http://localhost:8000/nusa/regencies/3375/villages?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 2,
          "links": [
            {
              "url": null,
              "label": "&laquo; Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/regencies/3375/villages?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost:8000/nusa/regencies/3375/villages?page=2",
              "label": "Next &raquo;",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/regencies/3375/villages",
          "per_page": 15,
          "to": 15,
          "total": 27
        }
      }

@feryardiant
Copy link
Contributor Author

feryardiant commented Sep 24, 2023

Districts

Get all districts

GET {APP_URL}/nusa/districts

  • Query Params :

    Field Type Option Description
    codes numeric[] optional Fetch only specified district code
    search string optional Search district by a keyword
  • Example :

    • GET http://localhost:8000/nusa/districts
      {
        "data": [
          {
            "code": 110101,
            "regency_code": 1101,
            "province_code": 11,
            "name": "Bakongan",
            "postal_codes": [
              23773
            ],
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/districts?page=1",
          "last": "http://localhost:8000/nusa/districts?page=485",
          "prev": null,
          "next": "http://localhost:8000/nusa/districts?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 485,
          "links": [
            {
              "url": null,
              "label": "&laquo; Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/districts?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost:8000/nusa/districts?page=2",
              "label": "Next &raquo;",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/districts",
          "per_page": 15,
          "to": 15,
          "total": 7266
        }
      }

Show a district

GET {APP_URL}/nusa/districts/{district}

  • Route Param : {district} district code

  • Example :

    • GET http://localhost:8000/nusa/districts/337503
      {
        "data": {
          "code": 337503,
          "regency_code": 3375,
          "province_code": 33,
          "name": "Pekalongan Utara",
          "postal_codes": [
            51141
            51143
            51146
            51147
            51148
            51149
          ],
        },
        "meta": {}
      }

Get all villages in a district

GET {APP_URL}/nusa/districts/{district}/villages

  • Route Param : {district} district code

  • Example :

    • GET http://localhost:8000/nusa/districts/337503/villages
      {
        "data": [
          {
            "code": 3375031002,
            "district_code": 337503,
            "regency_code": 3375,
            "province_code": 33,
            "name": "Krapyak",
            "postal_code": 51147,
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/districts/337503/villages?page=1",
          "last": "http://localhost:8000/nusa/districts/337503/villages?page=1",
          "prev": null,
          "next": null,
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 1,
          "links": [
            {
              "url": null,
              "label": "&laquo; Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/districts/337503/villages?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": null,
              "label": "Next &raquo;",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/districts/337503/villages",
          "per_page": 15,
          "to": 7,
          "total": 7
        }
      }

@feryardiant
Copy link
Contributor Author

Villages

Get all villages

GET {APP_URL}/nusa/villages

  • Query Params :

    Field Type Option Description
    codes numeric[] optional Fetch only specified village code
    search string optional Search village by a keyword
  • Example :

    • GET http://localhost:8000/nusa/villages
      {
        "data": [
          {
            "code": 1101012001,
            "district_code": 110101,
            "regency_code": 1101,
            "province_code": 11,
            "name": "Keude Bakongan",
            "postal_code": 23773,
          },
          { ... }
        ],
        "links": {
          "first": "http://localhost:8000/nusa/villages?page=1",
          "last": "http://localhost:8000/nusa/villages?page=5565",
          "prev": null,
          "next": "http://localhost:8000/nusa/villages?page=2",
        },
        "meta": {
          "current_page": 1,
          "from": 1,
          "last_page": 5565,
          "links": [
            {
              "url": null,
              "label": "&laquo; Previous",
              "active": false,
            },
            {
              "url": "http://localhost:8000/nusa/villages?page=1",
              "label": "1",
              "active": true,
            },
            { ... },
            {
              "url": "http://localhost:8000/nusa/villages?page=2",
              "label": "Next &raquo;",
              "active": false,
            },
          ],
          "path": "http://localhost:8000/nusa/villages",
          "per_page": 15,
          "to": 15,
          "total": 83467
        }
      }

Get a village

GET {APP_URL}/nusa/villages/{village}

  • Route Param : {village} village code

  • Example :

    • GET http://localhost:8000/nusa/villages/3375031006
      {
        "data": {
          "code": 3375031006,
          "district_code": 337503,
          "regency_code": 3375,
          "province_code": 33,
          "name": "Padukuhan Kraton",
          "postal_code": 51146,
        },
        "meta": {}
      }

Impacted routes:
- `provinces.regencies`
- `provinces.districts`
- `provinces.villages`

Signed-off-by: Fery Wardiyanto <[email protected]>
@feryardiant feryardiant changed the title [WIP] Feat: Add rest API for all available resources Feat: Add rest API for all available resources Sep 24, 2023
@feryardiant feryardiant merged commit 0be5da7 into main Sep 24, 2023
1 check passed
@feryardiant feryardiant deleted the feat-api-routes branch September 24, 2023 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Things that consumed by another program enhancement New feature or request integration When multiple functionalities should works together
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

1 participant