@@ -40,6 +40,7 @@ class GitHubApp():
40
40
private_key = None
41
41
42
42
def __init__ (self ):
43
+ self .domain = os .environ .get ('GITHUB_API_DOMAIN' , 'api.github.com' )
43
44
self .session = requests .Session ()
44
45
self .session .auth = JWTAuth (
45
46
iss = os .environ ['APP_ID' ],
@@ -53,24 +54,24 @@ def read_private_key(self):
53
54
self .private_key = fp .read ()
54
55
return self .private_key
55
56
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 ) )
58
59
return self .response .json ()
59
60
60
- def _get (self , url ):
61
- return self ._request ('GET' , url )
61
+ def _get (self , path ):
62
+ return self ._request ('GET' , path )
62
63
63
- def _post (self , url ):
64
- return self ._request ('POST' , url )
64
+ def _post (self , path ):
65
+ return self ._request ('POST' , path )
65
66
66
67
def get_app (self ):
67
- return self ._get ('https://api.github.com/ app' )
68
+ return self ._get ('app' )
68
69
69
70
def get_installations (self ):
70
- return self ._get ('https://api.github.com/ app/installations' )
71
+ return self ._get ('app/installations' )
71
72
72
73
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'
74
75
.format (installation_id ))
75
76
76
77
if __name__ == '__main__' :
0 commit comments