2
2
from __future__ import annotations
3
3
4
4
import asyncio
5
- import json
6
5
from typing import Any , Dict
7
6
8
7
import aiohttp
@@ -65,7 +64,15 @@ def __init__(
65
64
api_version : str | None = None ,
66
65
** kwargs : Dict [GitHubClientKwarg , Any ],
67
66
) -> None :
68
- """Initialise the GitHub API client."""
67
+ """
68
+ Initialise the GitHub API client.
69
+
70
+ **Arguments:**
71
+ `session`: The aiohttp client session to use for making requests.
72
+ `token`: The GitHub access token to use for authenticating requests. Can be a string or None.
73
+ `api_version`: The version of the GitHub API to use. Can be a string or None.
74
+
75
+ """
69
76
self ._base_request_data = GitHubBaseRequestDataModel (
70
77
token = token ,
71
78
api_version = api_version ,
@@ -79,16 +86,40 @@ async def async_call_api(
79
86
endpoint : str ,
80
87
* ,
81
88
data : Dict [str , Any ] | str | None = None ,
89
+ headers : Dict [str , Any ] | None = None ,
90
+ method : HttpMethod = HttpMethod .GET ,
91
+ params : Dict [str , Any ] | None = None ,
92
+ timeout : int | None = None ,
82
93
** kwargs : Dict [GitHubRequestKwarg , Any ],
83
94
) -> GitHubResponseModel :
84
- """Execute the API call."""
95
+ """
96
+ Makes an HTTP request to the specified endpoint using the specified parameters.
97
+
98
+ This method is asynchronous, meaning that it will not block the execution of the program while the request is being made and processed.
99
+
100
+ **Arguments**:
101
+
102
+ - `endpoint` (Required): The API endpoint to call.
103
+
104
+ **Optional arguments**:
105
+ - `endpoint`: The API endpoint to call.
106
+ - `data`: The data to include in the request body. Can be a dictionary, a string, or None.
107
+ - `headers`: The headers to include in the request. Can be a dictionary or None.
108
+ - `method`: The HTTP method to use for the request. Defaults to GET.
109
+ - `params`: The query parameters to include in the request. Can be a dictionary or None.
110
+ - `timeout`: The maximum amount of time to wait for the request to complete, in seconds. Can be an integer or None.
111
+
112
+ Returns:
113
+ A GitHubResponseModel object representing the API response.
114
+ """
85
115
request_arguments : Dict [str , Any ] = {
86
116
"url" : self ._base_request_data .request_url (endpoint ),
87
- "method" : kwargs .get (GitHubRequestKwarg .METHOD , HttpMethod . GET ).lower (),
88
- "params" : kwargs . get ( GitHubRequestKwarg . PARAMS )
89
- or kwargs .get (GitHubRequestKwarg .QUERY , {}),
90
- "timeout" : self ._base_request_data .timeout ,
117
+ "method" : kwargs .get (GitHubRequestKwarg .METHOD , method ).lower (),
118
+ "params" : params
119
+ or kwargs .get (GitHubRequestKwarg .PARAMS , kwargs . get ( GitHubRequestKwarg . QUERY , {}) ),
120
+ "timeout" : timeout or self ._base_request_data .timeout ,
91
121
"headers" : {
122
+ ** (headers or {}),
92
123
** self ._base_request_data .headers ,
93
124
** kwargs .get ("headers" , {}),
94
125
},
0 commit comments