View Source Regional (indonesian_id v1.1.0)
Functions for looking up regional codes based on Permendagri No. 72/2019.
Summary
Functions
Find city by province and city codes.
Find district by province, city, and district codes.
Find province by code.
Find subdistrict by province, city, district, and subdistrict codes.
Types
Functions
@spec find_city(map()) :: regional_data()
Find city by province and city codes.
Returns {:ok, %{city_data}}
if the city is found, otherwise {:error, "City data not found"}
.
Examples
iex> Regional.find_city(%{province_code: "72", city_code: "10"})
{:ok, %{"code" => "10", "type" => "Kabupaten", "name" => "Sigi"}}
@spec find_district(map()) :: regional_data()
Find district by province, city, and district codes.
Returns {:ok, %{district_data}}
if the district is found, otherwise
{:error, "District data not found"}
.
Examples
iex> Regional.find_district(%{province_code: "72", city_code: "10", district_code: "14"})
{:ok, %{"code" => "14", "type" => "Kecamatan", "name" => "Marawola"}}
@spec find_province(map()) :: regional_data()
Find province by code.
Returns {:ok, %{province_data}}
if the province is found, otherwise
{:error, "Province data not found"}
.
Examples
iex> Regional.find_province(%{province_code: "72"})
{:ok, %{"code" => "72", "name" => "Sulawesi Tengah"}}
@spec find_subdistrict(map()) :: regional_data()
Find subdistrict by province, city, district, and subdistrict codes.
Returns {:ok, %{subdistrict_data}}
if the subdistrict is found, otherwise
{:error, "Subdistrict data not found"}
.
Examples
iex> Regional.find_subdistrict(%{province_code: "72", city_code: "10", district_code: "14", subdistrict_code: "2007"})
{:ok, %{"code" => "2007", "type" => "Desa", "name" => "Tinggede"}}