Skip to content

Commit

Permalink
Adding option for incremental fetch of Employees (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shwetabhk authored Aug 28, 2023
1 parent 43eeb1e commit 99d9884
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions netsuitesdk/api/employees.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from collections import OrderedDict

from netsuitesdk.internal.utils import PaginatedSearch

from .base import ApiBase
import logging

Expand All @@ -10,6 +12,36 @@ class Employees(ApiBase):
def __init__(self, ns_client):
ApiBase.__init__(self, ns_client=ns_client, type_name='Employee')

def get_all_generator(self, is_inactive=False, last_modified_date_query={
'search_value',
'operator',
}):
# Get Only Employee Items using SearchBooleanField
record_type_search_field = self.ns_client.SearchBooleanField(searchValue=is_inactive)

date_search = None
if 'search_value' in last_modified_date_query and 'operator' in last_modified_date_query:
if last_modified_date_query['search_value'] and last_modified_date_query['operator']:
date_search = self.ns_client.SearchDateField(
searchValue=last_modified_date_query['search_value'],
operator=last_modified_date_query['operator']
)

basic_search = self.ns_client.basic_search_factory(
type_name='Employee',
isInactive=record_type_search_field,
lastModifiedDate=date_search
)

paginated_search = PaginatedSearch(
client=self.ns_client,
type_name='Employee',
basic_search=basic_search,
pageSize=500
)

return self._paginated_search_generator(paginated_search=paginated_search)

def post(self, data) -> OrderedDict:
assert data['externalId'], 'missing external id'
employee = self.ns_client.Employee(externalId=data['externalId'])
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='netsuitesdk',
version='2.19.2',
version='2.20.0',
author='Siva Narayanan',
author_email='[email protected]',
description='Python SDK for accessing the NetSuite SOAP webservice',
Expand Down

0 comments on commit 99d9884

Please sign in to comment.