Skip to content

Commit 8def23e

Browse files
authored
Update invoice_generator.py
Added API authentication now required by InvoiceGenerator
1 parent bc17e44 commit 8def23e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

invoice_generator.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class InvoiceGenerator:
1010
""" API Object for Invoice-Generator tool - https://invoice-generator.com/ """
1111

1212
URL = "https://invoice-generator.com"
13+
API_KEY = "SET_YOUR_API_KEY_HERE"
1314
DATE_FORMAT = "%d %b %Y"
1415
LOCALE = "fr_FR"
1516
TIMEZONE = "Europe/Paris"
@@ -117,7 +118,7 @@ def add_item(self, name=None, quantity=0, unit_cost=0.0, description=None):
117118
def download(self, file_path):
118119
""" Directly send the request and store the file on path """
119120
json_string = self._to_json()
120-
response = requests.post(InvoiceGenerator.URL, json=json.loads(json_string), stream=True, headers={'Accept-Language': InvoiceGenerator.LOCALE})
121+
response = requests.post(InvoiceGenerator.URL, json=json.loads(json_string), stream=True, headers={'Accept-Language': InvoiceGenerator.LOCALE, 'Authorization': f'Bearer {self.API_KEY}'})
121122
if response.status_code == 200:
122123
open(file_path, 'wb').write(response.content)
123124
else:

0 commit comments

Comments
 (0)