Skip to content

Commit

Permalink
Location get support and Employee create support added (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruuushhh authored Oct 4, 2023
1 parent da3e46c commit 4a88a46
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
4 changes: 3 additions & 1 deletion dynamics/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .invoice_line_items import PurchaseInvoiceLineItems
from .attachments import Attachments
from .employees import Employees
from .locations import Locations

__all__ = [
'Companies',
Expand All @@ -17,5 +18,6 @@
'JournalLineItem',
'PurchaseInvoiceLineItems',
'Attachments',
'Employees'
'Employees',
'Locations'
]
8 changes: 8 additions & 0 deletions dynamics/apis/employees.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
17 changes: 17 additions & 0 deletions dynamics/apis/locations.py
Original file line number Diff line number Diff line change
@@ -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']
7 changes: 5 additions & 2 deletions dynamics/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
description='Python SDK for accessing Dynamics APIs',
Expand Down

0 comments on commit 4a88a46

Please sign in to comment.