From 4a88a46459f03315a3da2dcf64750e1e57475aaa Mon Sep 17 00:00:00 2001 From: ruuushhh <66899387+ruuushhh@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:19:00 +0530 Subject: [PATCH] Location get support and Employee create support added (#7) --- dynamics/apis/__init__.py | 4 +++- dynamics/apis/employees.py | 8 ++++++++ dynamics/apis/locations.py | 17 +++++++++++++++++ dynamics/core/client.py | 7 +++++-- setup.py | 2 +- 5 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 dynamics/apis/locations.py diff --git a/dynamics/apis/__init__.py b/dynamics/apis/__init__.py index a623199..78b4ac0 100644 --- a/dynamics/apis/__init__.py +++ b/dynamics/apis/__init__.py @@ -7,6 +7,7 @@ from .invoice_line_items import PurchaseInvoiceLineItems from .attachments import Attachments from .employees import Employees +from .locations import Locations __all__ = [ 'Companies', @@ -17,5 +18,6 @@ 'JournalLineItem', 'PurchaseInvoiceLineItems', 'Attachments', - 'Employees' + 'Employees', + 'Locations' ] diff --git a/dynamics/apis/employees.py b/dynamics/apis/employees.py index 4206b1a..00b45eb 100644 --- a/dynamics/apis/employees.py +++ b/dynamics/apis/employees.py @@ -15,3 +15,11 @@ def get_all(self, **kwargs): return self._get_request({ **kwargs }, Employees.GET_EMPLOYEES)['value'] + + def post(self, data): + """ + Create Employee + :param data: + :return: + """ + return self._post_request(data, Employees.POST_EMPLOYEES) diff --git a/dynamics/apis/locations.py b/dynamics/apis/locations.py new file mode 100644 index 0000000..3f0044f --- /dev/null +++ b/dynamics/apis/locations.py @@ -0,0 +1,17 @@ +from .api_base import ApiBase + + +class Locations(ApiBase): + """Class for Locations APIs.""" + + GET_LOCATIONS = '/locations' + POST_LOCATIONS = '/locations' + + def get_all(self, **kwargs): + """ + Get all locations + :return: returns all companies + """ + return self._get_request({ + **kwargs + }, Locations.GET_LOCATIONS)['value'] diff --git a/dynamics/core/client.py b/dynamics/core/client.py index 89d04b2..56c84d1 100644 --- a/dynamics/core/client.py +++ b/dynamics/core/client.py @@ -43,6 +43,7 @@ def __init__( self.purchase_invoice_line_items = PurchaseInvoiceLineItems() self.attachments = Attachments() self.employees = Employees() + self.locations = Locations() # Get and set the access token access_token = self.__refresh_access_token() @@ -65,7 +66,8 @@ def update_access_token(self, access_token: str): self.journal_line_items, self.purchase_invoice_line_items, self.attachments, - self.employees + self.employees, + self.locations ] # Update access tokens in all API instances @@ -90,7 +92,8 @@ def set_server_url(self): self.journal_line_items, self.purchase_invoice_line_items, self.attachments, - self.employees + self.employees, + self.locations ] # Set base URL for all API instances diff --git a/setup.py b/setup.py index 001d372..55254a3 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='ms-dynamics-business-central-sdk', - version='1.1.0', + version='1.2.0', author='Shwetabh Kumar', author_email='shwetabh.kumar@fyle.in', description='Python SDK for accessing Dynamics APIs',