(self, api_func, endpoint, print_info, data=None)
| 29 | |
| 30 | # Call the readme API. api_func should be a requests-based function. |
| 31 | def __api_call(self, api_func, endpoint, print_info, data=None): |
| 32 | print(print_info + "... ", end="") |
| 33 | response = api_func( |
| 34 | _readme_api_url + endpoint, |
| 35 | headers=self.__headers, |
| 36 | auth=HTTPBasicAuth(self.auth_token, ""), |
| 37 | data=data, |
| 38 | ) |
| 39 | if response.status_code not in [200, 201, 204]: |
| 40 | print("Error (code " + str(response.status_code) + "): " + response.text) |
| 41 | return None |
| 42 | else: |
| 43 | print() |
| 44 | return None if api_func == requests.delete else json.loads(response.text) |
| 45 | |
| 46 | # API GET call. |
| 47 | # If paginated, gather and concat the output for each page in the endpoint. |
no test coverage detected