FIXED headers are built and returned properly

This commit is contained in:
Andrew Bryant 2024-02-10 11:06:25 -05:00
parent a9b38d8515
commit 713613e2c6

View File

@ -29,7 +29,7 @@ class InvoiceNinja(object):
api_token: str = str()): api_token: str = str()):
self.endpoint_url = '{}/{}'.format(endpoint_url, self.API_V1) self.endpoint_url = '{}/{}'.format(endpoint_url, self.API_V1)
self.api_token = api_token self.api_token = api_token
self.headers = dict() self.headers = self.build_headers()
def _get_url_for(self, endpoint: str = 'ping'): def _get_url_for(self, endpoint: str = 'ping'):
''' '''
@ -57,14 +57,14 @@ class InvoiceNinja(object):
'X-API-TOKEN': self.api_token, 'X-API-TOKEN': self.api_token,
'X-Requested-With': 'XMLHttpRequest'} 'X-Requested-With': 'XMLHttpRequest'}
return self.headers.update(headers) return headers
def ping(self): def ping(self):
''' '''
Ping Invoice Ninja instance. Ping Invoice Ninja instance.
''' '''
server_response = requests.get(url=self._get_url_for(), server_response = requests.get(url=self._get_url_for(),
headers=self.build_headers()) headers=self.headers)
if server_response.ok: if server_response.ok:
return True return True