@@ -40,6 +40,7 @@ class GitHubApp():
4040 private_key = None
4141
4242 def __init__ (self ):
43+ self .domain = os .environ .get ('GITHUB_API_DOMAIN' , 'api.github.com' )
4344 self .session = requests .Session ()
4445 self .session .auth = JWTAuth (
4546 iss = os .environ ['APP_ID' ],
@@ -53,24 +54,24 @@ def read_private_key(self):
5354 self .private_key = fp .read ()
5455 return self .private_key
5556
56- def _request (self , method , url ):
57- self .response = self .session .request (method , url )
57+ def _request (self , method , path ):
58+ self .response = self .session .request (method , 'https://{}/{}' . format ( self . domain , path ) )
5859 return self .response .json ()
5960
60- def _get (self , url ):
61- return self ._request ('GET' , url )
61+ def _get (self , path ):
62+ return self ._request ('GET' , path )
6263
63- def _post (self , url ):
64- return self ._request ('POST' , url )
64+ def _post (self , path ):
65+ return self ._request ('POST' , path )
6566
6667 def get_app (self ):
67- return self ._get ('https://api.github.com/ app' )
68+ return self ._get ('app' )
6869
6970 def get_installations (self ):
70- return self ._get ('https://api.github.com/ app/installations' )
71+ return self ._get ('app/installations' )
7172
7273 def get_installation_access_token (self , installation_id ):
73- return self ._post ('https://api.github.com/ installations/{}/access_tokens'
74+ return self ._post ('installations/{}/access_tokens'
7475 .format (installation_id ))
7576
7677if __name__ == '__main__' :
0 commit comments