Skip to content

Commit

Permalink
Added BaseCustomrest and Wilayah
Browse files Browse the repository at this point in the history
  • Loading branch information
hexatester committed Aug 8, 2021
1 parent fdda51d commit c33a927
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dapodik/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from .auth import BaseAuth
from .rest import BaseRest
from .customrest import BaseCustomrest
from .validasi import BaseValidasi
from .peserta_didik import BasePesertaDidik
from .gtk import BaseGtk
Expand All @@ -19,6 +20,7 @@

__all__ = [
"BaseAuth",
"BaseCustomrest",
"BaseGtk",
"BasePesertaDidik",
"BaseRest",
Expand Down
5 changes: 5 additions & 0 deletions dapodik/customrest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .wilayah import Wilayah

from .base import BaseCustomrest

__all__ = ["BaseCustomrest", "Wilayah"]
22 changes: 22 additions & 0 deletions dapodik/customrest/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from typing import List

from dapodik.base import BaseDapodik
from dapodik.utils.helper import cached

from . import Wilayah


class BaseCustomrest(BaseDapodik):
@cached("kecamatan")
def kecamatan(
self, query: str, page: int = 1, start: int = 0, limit: int = 50
) -> List[Wilayah]:
return self._get_rest(
"kecamatan",
List[Wilayah],
page,
start,
limit,
query=self._query(query=query),
prefix="customrest/",
)
29 changes: 29 additions & 0 deletions dapodik/customrest/wilayah.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import attr
from datetime import datetime
from typing import Optional


@attr.dataclass(frozen=True, slots=True)
class Wilayah:
kode_wilayah: str
nama: str
id_level_wilayah: int
mst_kode_wilayah: str
negara_id: str
asal_wilayah: str
kode_bps: str
kode_dagri: str
kode_keu: str
id_prov: Optional[int]
id_kabkota: Optional[int]
id_kec: Optional[int]
a_desa: int
a_kelurahan: int
a_35: int
a_urban: int
kategori_desa_id: Optional[int]
create_date: datetime
last_update: datetime
expired_date: Optional[datetime]
last_sync: datetime
nama_kabupaten: str
2 changes: 2 additions & 0 deletions dapodik/dapodik.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from . import BaseAuth
from . import BaseRest
from . import BaseCustomrest
from . import BaseValidasi
from . import BasePesertaDidik
from . import BaseGtk
Expand All @@ -14,6 +15,7 @@
class Dapodik(
BaseAuth,
BaseRest,
BaseCustomrest,
BaseValidasi,
BasePesertaDidik,
BaseGtk,
Expand Down
13 changes: 13 additions & 0 deletions tests/test_customrest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import attr

from dapodik.base import BaseDapodik
from dapodik.customrest import BaseCustomrest
from dapodik.customrest import Wilayah


def test_base_customresr():
assert issubclass(BaseCustomrest, BaseDapodik)


def test_member():
assert attr.has(Wilayah)

0 comments on commit c33a927

Please sign in to comment.