Skip to content

Commit

Permalink
WIP: Add Taxon controller
Browse files Browse the repository at this point in the history
  • Loading branch information
JWCook committed Aug 1, 2021
1 parent d0f6553 commit 11a3a59
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
5 changes: 2 additions & 3 deletions pyinaturalist/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pyinaturalist.api_requests import RATE_LIMITER
from pyinaturalist.auth import get_access_token
from pyinaturalist.constants import TOKEN_EXPIRATION
from pyinaturalist.controllers import ObservationController
from pyinaturalist.controllers import ObservationController, TaxonController

logger = getLogger(__name__)

Expand Down Expand Up @@ -88,8 +88,7 @@ def __init__(

# Controllers
self.observations = ObservationController(self)
# self.taxa = TaxonController(self)
# etc.
self.taxa = TaxonController(self)

@property
def retry(self) -> Retry:
Expand Down
1 change: 1 addition & 0 deletions pyinaturalist/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa: F401
from pyinaturalist.controllers.base import BaseController, authenticated
from pyinaturalist.controllers.observations import ObservationController
from pyinaturalist.controllers.taxa import TaxonController
3 changes: 1 addition & 2 deletions pyinaturalist/controllers/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from pyinaturalist.constants import HistogramResponse, ListResponse
from pyinaturalist.controllers import BaseController, authenticated
from pyinaturalist.docs import document_controller_params
from pyinaturalist.models import LifeList, Observation, Taxon, User
from pyinaturalist.models.taxon import TaxonCounts
from pyinaturalist.models import LifeList, Observation, Taxon, TaxonCounts, User
from pyinaturalist.v1 import (
create_observation,
delete_observation,
Expand Down
15 changes: 15 additions & 0 deletions pyinaturalist/controllers/taxa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from typing import List

from pyinaturalist.controllers import BaseController
from pyinaturalist.docs import document_controller_params
from pyinaturalist.models import Observation, Taxon
from pyinaturalist.v1 import get_taxa


class TaxonController(BaseController):
"""Controller for taxon requests"""

@document_controller_params(get_taxa)
def search(self, **params) -> List[Observation]:
response = get_taxa(**params, **self.client.settings)
return Taxon.from_json_list(response) # type: ignore

0 comments on commit 11a3a59

Please sign in to comment.