1919 ReportTimeEntry ,
2020)
2121from .exceptions import MethodNotAllowed , NotSupported
22- from .response import ListResponse
2322
2423
2524class BaseRepository (Api ):
@@ -30,7 +29,6 @@ class BaseRepository(Api):
3029 EXCLUDED_METHODS = ()
3130 ADDITIONAL_PARAMS = {}
3231 DATA_CONTAINER = {}
33- RESPONSE_WRAPPER = {}
3432
3533 def __init__ (self , base_url = None , auth = None ):
3634 super ().__init__ (base_url = base_url , auth = auth )
@@ -111,15 +109,24 @@ def _list(self, _url, entity_class, data_key: str = None, **kwargs):
111109 params .update (self .ADDITIONAL_PARAMS .get ("list" , {}))
112110
113111 response = self .get (_url , params = params )
114- data = response .json ()
112+ response_body = response .json ()
113+ response_parameters = (
114+ "total_count" ,
115+ "per_page" ,
116+ "total_grand" ,
117+ "total_billable" ,
118+ "total_currencies" ,
119+ )
120+
121+ data = response_body
115122 data_key = data_key or self .DATA_CONTAINER .get ("list" , None )
116123 if data_key :
117124 data = data [data_key ]
118125 if data :
119126 result = [entity_class (** entity ) for entity in data ]
120- wrapper = self . RESPONSE_WRAPPER . get ( "list" )
121- if wrapper :
122- result = wrapper (result , response )
127+ for parameter in response_parameters :
128+ if parameter in response_body :
129+ setattr (result , parameter , response_body [ parameter ] )
123130 return result
124131
125132 def list (self , ** kwargs ):
@@ -191,7 +198,6 @@ class ReportTimeEntries(BaseRepository):
191198 DATA_CONTAINER = {"list" : "data" }
192199 LIST_URL = "details"
193200 ENTITY_CLASS = ReportTimeEntry
194- RESPONSE_WRAPPER = {"list" : ListResponse }
195201
196202
197203class Users (BaseRepository ):
0 commit comments