Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding option for incremental fetch of Employees #122

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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