1111 BadMemory ,
1212 BadRequestError ,
1313 FewMemory ,
14+ InvalidAccessToken ,
1415 InvalidDisplayName ,
1516 InvalidMain ,
1617 InvalidMemory ,
@@ -64,7 +65,7 @@ def __repr__(self):
6465 return f'{ Response .__name__ } ({ self .data } )'
6566
6667
67- def _get_upload_error (code : str ) -> type [RequestError ]:
68+ def _get_upload_error (code : str ) -> type [RequestError ] | None :
6869 errors = {
6970 'FEW_MEMORY' : FewMemory ,
7071 'BAD_MEMORY' : BadMemory ,
@@ -78,10 +79,11 @@ def _get_upload_error(code: str) -> type[RequestError]:
7879 'MISSING_MEMORY' : MissingMemory ,
7980 'INVALID_VERSION' : InvalidVersion ,
8081 'MISSING_VERSION' : MissingVersion ,
82+ 'INVALID_ACCESS_TOKEN' : InvalidAccessToken ,
8183 }
8284 error_class = errors .get (code , None )
8385 if error_class is None :
84- return RequestError
86+ return
8587 else :
8688 return error_class
8789
@@ -138,13 +140,6 @@ async def request(self, route: Router, **kwargs) -> Response | bytes:
138140
139141 if status_code == 200 :
140142 logger .debug (msg = 'request to route: ' , extra = extra )
141- if code and route .endpoint in (
142- Endpoint .commit (),
143- Endpoint .upload (),
144- ):
145- error = _get_upload_error (
146- code ,
147- )
148143 extra .pop ('code' )
149144 response : Response = Response (data = data , route = route )
150145 elif status_code == 404 :
@@ -165,6 +160,9 @@ async def request(self, route: Router, **kwargs) -> Response | bytes:
165160 error = TooManyRequests
166161 else :
167162 error = RequestError
163+
164+ if _ := _get_upload_error (code ):
165+ error = _
168166 if error :
169167 raise error (
170168 ** extra_error_kwargs ,
@@ -375,7 +373,7 @@ async def get_statistics(self) -> Response:
375373 The get_statistics function returns the statistics of the current
376374 market.
377375
378- :param self: Access the attributes and methods of a class
376+ :param self: Represent the instance of a class
379377 :return: A Response object
380378 """
381379 route : Router = Router (Endpoint .statistics ())
@@ -392,6 +390,37 @@ async def get_app_data(self, app_id: str) -> Response:
392390 get data
393391 :return: A Response object
394392 """
395- route : Router = Router (Endpoint ('APP_DATA' ), app_id = app_id )
393+ route : Router = Router (Endpoint .app_data (), app_id = app_id )
394+ response : Response = await self .request (route )
395+ return response
396+
397+ async def get_last_deploys (self , app_id : str ) -> Response :
398+ """
399+ The get_last_deploys function returns the last deploys of an
400+ application.
401+
402+ :param self: Represent the instance of a class
403+ :param app_id: str: Specify the application id
404+ :return: A Response object
405+ """
406+ route : Router = Router (Endpoint .last_deploys (), app_id = app_id )
396407 response : Response = await self .request (route )
397408 return response
409+
410+ async def create_github_integration (
411+ self , app_id : str , github_access_token : str
412+ ) -> Response :
413+ """
414+ The create_github_integration function returns a webhook to integrate
415+ with a GitHub repository.
416+
417+ :param self: Represent the instance of a class
418+ :param app_id: str: Identify the app that you want to create a GitHub
419+ integration for
420+ :param github_access_token: str: Authenticate the user
421+ :return: A response object
422+ """
423+ route : Router = Router (Endpoint .github_integration (), app_id = app_id )
424+ body = {'access_token' : github_access_token }
425+ response : Response = await self .request (route , json = body )
426+ return response
0 commit comments