Skip to content

Commit

Permalink
Support for Location Entities and Generic Read By Query (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 authored Jul 5, 2021
1 parent 7e5d5b5 commit 6bb38aa
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ venv.bak/
# Test files
dry_run.py
test.py
test_scripts/
4 changes: 3 additions & 1 deletion sageintacctsdk/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .dimension_values import DimensionValues
from .tasks import Tasks
from .expense_payment_types import ExpensePaymentTypes
from .location_entities import LocationEntities

__all_ = [
'ApiBase',
Expand All @@ -50,5 +51,6 @@
'Dimensions',
'DimensionValues',
'Tasks',
'ExpensePaymentTypes'
'ExpensePaymentTypes',
'LocationEntities'
]
20 changes: 20 additions & 0 deletions sageintacctsdk/apis/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,26 @@ def count(self):
response = self.format_and_send_request(get_count)
return int(response['data']['@totalcount'])

def read_by_query(self, fields: list = None):
"""Read by Query from Sage Intacct
Parameters:
fields (list): Get selective fields to be returned. (optional).
Returns:
Dict.
"""
payload = {
'readByQuery': {
'object': self.__dimension,
'fields': ','.join(fields) if fields else '*',
'query': None,
'pagesize': '1000'
}
}

return self.format_and_send_request(payload)

def get(self, field: str, value: str, fields: list = None):
"""Get data from Sage Intacct based on filter.
Expand Down
32 changes: 32 additions & 0 deletions sageintacctsdk/apis/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,37 @@
'MEGAENTITYKEY',
'MEGAENTITYID',
'MEGAENTITYNAME'
],
'LOCATIONENTITY': [
'RECORDNO',
'LOCATIONID',
'NAME',
'REPORTPRINTAS',
'SUPERVISORID',
'FIRSTMONTH',
'FIRSTMONTHTAX',
'WEEKSTART',
'FEDERALID',
'STARTDATE',
'ENDDATE',
'STATUS',
'HAS_IE_RELATION',
'CUSTOMERID',
'CUSTOMERNAME',
'VENDORID',
'VENDORNAME',
'CURRENCY',
'TAXID',
'ENABLELEGALCONTACT',
'LEGALNAME',
'LEGALADDRESS1',
'LEGALADDRESS2',
'LEGALCITY',
'LEGALSTATE',
'LEGALZIPCODE',
'LEGALCOUNTRY',
'OPCOUNTRY',
'ADDRESSCOUNTRYDEFAULT',
'RECORD_URL'
]
}
10 changes: 10 additions & 0 deletions sageintacctsdk/apis/location_entities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
Sage Intacct Location Entities
"""
from .api_base import ApiBase


class LocationEntities(ApiBase):
"""Class for Location Entities APIs."""
def __init__(self):
ApiBase.__init__(self, dimension='LOCATIONENTITY')
6 changes: 5 additions & 1 deletion sageintacctsdk/sageintacctsdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .apis import ApiBase, Contacts, Locations, Employees, Accounts, ExpenseTypes, Attachments, ExpenseReports,\
Vendors, Bills, Projects, Departments, ChargeCardAccounts, ChargeCardTransactions, Customers, Items,\
APPayments, Reimbursements, CheckingAccounts, SavingsAccounts, Tasks, ExpensePaymentTypes, Dimensions,\
DimensionValues
DimensionValues, LocationEntities


class SageIntacctSDK:
Expand Down Expand Up @@ -52,6 +52,7 @@ def __init__(self, sender_id: str, sender_password: str, user_id: str, company_i
self.dimension_values = DimensionValues()
self.tasks = Tasks()
self.expense_payment_types = ExpensePaymentTypes()
self.location_entities = LocationEntities()

self.update_sender_id()
self.update_sender_password()
Expand Down Expand Up @@ -85,6 +86,7 @@ def update_sender_id(self):
self.dimension_values.set_sender_id(self.__sender_id)
self.tasks.set_sender_id(self.__sender_id)
self.expense_payment_types.set_sender_id(self.__sender_id)
self.location_entities.set_sender_id(self.__sender_id)

def update_sender_password(self):
"""
Expand Down Expand Up @@ -114,6 +116,7 @@ def update_sender_password(self):
self.dimension_values.set_sender_password(self.__sender_password)
self.tasks.set_sender_password(self.__sender_password)
self.expense_payment_types.set_sender_password(self.__sender_password)
self.location_entities.set_sender_password(self.__sender_password)

def update_session_id(self):
"""
Expand Down Expand Up @@ -144,3 +147,4 @@ def update_session_id(self):
self.dimension_values.set_session_id(self.__session_id)
self.tasks.set_session_id(self.__session_id)
self.expense_payment_types.set_session_id(self.__session_id)
self.location_entities.set_session_id(self.__session_id)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name='sageintacctsdk',
version='1.1.0',
version='1.2.0',
author='Ashwin T',
author_email='ashwin.t@fyle.in',
description='Python SDK for accessing Sage Intacct APIs',
Expand Down

0 comments on commit 6bb38aa

Please sign in to comment.