1919 ReportTimeEntry ,
2020)
2121from .exceptions import MethodNotAllowed , NotSupported
22+ from .response import ReportTimeEntriesList
2223
2324
2425class BaseRepository (Api ):
@@ -29,6 +30,7 @@ class BaseRepository(Api):
2930 EXCLUDED_METHODS = ()
3031 ADDITIONAL_PARAMS = {}
3132 DATA_CONTAINER = {}
33+ LIST_RESPONSE = None
3234
3335 def __init__ (self , base_url = None , auth = None ):
3436 super ().__init__ (base_url = base_url , auth = auth )
@@ -109,12 +111,17 @@ def _list(self, _url, entity_class, data_key: str = None, **kwargs):
109111 params .update (self .ADDITIONAL_PARAMS .get ("list" , {}))
110112
111113 response = self .get (_url , params = params )
112- data = response .json ()
114+ response_body = response .json ()
115+
116+ data = response_body
113117 data_key = data_key or self .DATA_CONTAINER .get ("list" , None )
114118 if data_key :
115119 data = data [data_key ]
116120 if data :
117- return [entity_class (** entity ) for entity in data ]
121+ value = [entity_class (** entity ) for entity in data ]
122+ if self .LIST_RESPONSE :
123+ value = self .LIST_RESPONSE (value , response_body )
124+ return value
118125
119126 def list (self , ** kwargs ):
120127 if "list" in self .EXCLUDED_METHODS :
@@ -185,6 +192,7 @@ class ReportTimeEntries(BaseRepository):
185192 DATA_CONTAINER = {"list" : "data" }
186193 LIST_URL = "details"
187194 ENTITY_CLASS = ReportTimeEntry
195+ LIST_RESPONSE = ReportTimeEntriesList
188196
189197
190198class Users (BaseRepository ):
0 commit comments