(self, endpoint, print_info=None, paginated=False)
| 46 | # API GET call. |
| 47 | # If paginated, gather and concat the output for each page in the endpoint. |
| 48 | def __api_GET(self, endpoint, print_info=None, paginated=False): |
| 49 | if not print_info: |
| 50 | print_info = "API::GET(" + endpoint + ")" |
| 51 | if paginated: |
| 52 | i = 1 |
| 53 | out = [] |
| 54 | while True: |
| 55 | response = self.__api_call( |
| 56 | requests.get, |
| 57 | endpoint + "?page=" + str(i), |
| 58 | print_info + " (page " + str(i) + ")", |
| 59 | ) |
| 60 | if response is None: |
| 61 | return None |
| 62 | if len(response) == 0: |
| 63 | return out |
| 64 | out += response |
| 65 | i += 1 |
| 66 | else: |
| 67 | return self.__api_call(requests.get, endpoint, print_info) |
| 68 | |
| 69 | # API POST call. |
| 70 | # Data should be passed in as a map. The map will be converted to string. |
no test coverage detected