From e14328c68b345ef3206d2487c52e5fd56073a0db Mon Sep 17 00:00:00 2001 From: awkawb Date: Sun, 17 Dec 2023 10:32:33 -0500 Subject: [PATCH] added gitignore --- .gitignore | 1 + invoice_ninja/__init__.py | 41 +++++++++------------------------------ 2 files changed, 10 insertions(+), 32 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/invoice_ninja/__init__.py b/invoice_ninja/__init__.py index 1d3c3f9..8058aa0 100644 --- a/invoice_ninja/__init__.py +++ b/invoice_ninja/__init__.py @@ -2,27 +2,6 @@ import requests class InvoiceNinja(object): API_V1 = 'api/v1' - ENDPOINT_URLS = { - 'clients': 'clients', - 'products': 'products', - 'invoices': 'invoices', - 'recurring invoices': 'recurring_invoices', - 'payments': 'payments', - 'quotes': 'quotes', - 'credits': 'credits', - 'reports': 'reports', - 'activities': 'activities', - 'charts': 'charts', - 'companies': 'companies', - 'documents': 'documents', - 'emails': 'emails', - 'expense': 'expenses', - 'export': 'export', - 'import': 'import_json', - 'ping': 'ping', - 'health check': 'health_check', - 'users': 'users' - } def __init__(self, endpoint_url: str = 'https://invoicing.co', @@ -31,19 +10,17 @@ class InvoiceNinja(object): self.api_token = api_token self.headers = dict() - def _get_url_for(self, endpoint: str = 'ping'): - ''' - Get complete URL for an endpoint. + def set_url(url: str): + self.endpoint_url = url - Endpoint URLs are appended to the Invoice Ninja base URL - and returned. - ''' - if endpoint in self.ENDPOINT_URLS: - return '{}/{}'.format(self.endpoint_url, - self.ENDPOINT_URLS[endpoint]) + def get_url(): + return self.endpoint_url - else: - raise KeyError('Endpoint URL not found') + def set_token(token: str): + self.api_token = token + + def get_token(): + return self.api_token #def _get_headers(self, headers: dict = dict()): def build_headers(self):