From 6ef4175162bc9d73ec72bbfd22e835461f6b6b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20M=2E=20Sehnem?= Date: Mon, 28 Feb 2022 18:59:28 -0500 Subject: [PATCH 1/2] fix salesOrders pagination --- setup.py | 2 +- tap_netsuite/netsuite/transaction_entities.py | 36 ++++++++----------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/setup.py b/setup.py index 6c642e5..3ba70c5 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name='tap-netsuite', - version='1.5.11', + version='1.5.12', description='Singer.io tap for extracting data from the NetSuite SOAP', author='hotglue', url='https://hotglue.xyz/', diff --git a/tap_netsuite/netsuite/transaction_entities.py b/tap_netsuite/netsuite/transaction_entities.py index 4c6c7bd..e9eb549 100644 --- a/tap_netsuite/netsuite/transaction_entities.py +++ b/tap_netsuite/netsuite/transaction_entities.py @@ -44,7 +44,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): search_record = self.ns_client.basic_search_factory(type_name="Customer", lastModifiedDate=last_modified_date) ps = PaginatedSearch(client=self.ns_client, type_name='Customer', pageSize=page_size, @@ -63,7 +63,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='InventoryItem', operator='contains') search_record = self.ns_client.basic_search_factory(type_name="Item", recordType=record_type_search_field, @@ -85,7 +85,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='Opportunity', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', recordType=record_type_search_field, lastModifiedDate=last_modified_date) @@ -103,19 +103,11 @@ class SalesOrders(ApiBase): def __init__(self, ns_client): ApiBase.__init__(self, ns_client=ns_client, type_name='salesOrder') self.require_lastModified_date = True - - @staticmethod - def page_generator(paginated_search): - if paginated_search.num_records != 0: - num_pages = paginated_search.total_pages - for p in range(1, num_pages + 1): - paginated_search.goto_page(p) - yield paginated_search.records def get_all(self, last_modified_date=None): return self.get_all_generator(last_modified_date=last_modified_date) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='SalesOrder', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', lastModifiedDate=last_modified_date, @@ -125,7 +117,7 @@ def get_all_generator(self, page_size=100, last_modified_date=None): type_name='Transaction', pageSize=page_size) - return self.page_generator(paginated_search) + return self._paginated_search_to_generator(paginated_search=paginated_search) def post(self, data) -> OrderedDict: return None @@ -139,7 +131,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='InventoryTransfer', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', recordType=record_type_search_field, @@ -163,7 +155,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): search_record = self.ns_client.basic_search_factory(type_name="Item", lastModifiedDate=last_modified_date) ps = PaginatedSearch(client=self.ns_client, type_name='Item', pageSize=page_size, @@ -182,7 +174,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='InventoryAdjustment', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', recordType=record_type_search_field, @@ -205,7 +197,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='VendorBill', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', recordType=record_type_search_field, @@ -227,7 +219,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='VendorPayment', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', recordType=record_type_search_field, @@ -251,7 +243,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='JournalEntry', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', lastModifiedDate=last_modified_date, @@ -313,7 +305,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='Invoice', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', lastModifiedDate=last_modified_date, @@ -339,7 +331,7 @@ def __init__(self, ns_client): def get_all(self, last_modified_date=None): return self.get_all_generator(last_modified_date=last_modified_date) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='CreditMemo', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', lastModifiedDate=last_modified_date, @@ -364,7 +356,7 @@ def __init__(self, ns_client): def get_all(self, last_modified_date=None): return self.get_all_generator(last_modified_date=last_modified_date) - def get_all_generator(self, page_size=100, last_modified_date=None): + def get_all_generator(self, page_size=300, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='PurchaseOrder', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', lastModifiedDate=last_modified_date, From 331909e1880ece1dccfabee921b4c1102514fac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20M=2E=20Sehnem?= Date: Mon, 28 Feb 2022 19:02:40 -0500 Subject: [PATCH 2/2] pagesize --- tap_netsuite/netsuite/transaction_entities.py | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tap_netsuite/netsuite/transaction_entities.py b/tap_netsuite/netsuite/transaction_entities.py index e9eb549..07a8b1d 100644 --- a/tap_netsuite/netsuite/transaction_entities.py +++ b/tap_netsuite/netsuite/transaction_entities.py @@ -44,7 +44,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): search_record = self.ns_client.basic_search_factory(type_name="Customer", lastModifiedDate=last_modified_date) ps = PaginatedSearch(client=self.ns_client, type_name='Customer', pageSize=page_size, @@ -63,7 +63,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='InventoryItem', operator='contains') search_record = self.ns_client.basic_search_factory(type_name="Item", recordType=record_type_search_field, @@ -85,7 +85,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='Opportunity', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', recordType=record_type_search_field, lastModifiedDate=last_modified_date) @@ -107,7 +107,7 @@ def __init__(self, ns_client): def get_all(self, last_modified_date=None): return self.get_all_generator(last_modified_date=last_modified_date) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='SalesOrder', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', lastModifiedDate=last_modified_date, @@ -131,7 +131,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='InventoryTransfer', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', recordType=record_type_search_field, @@ -155,7 +155,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): search_record = self.ns_client.basic_search_factory(type_name="Item", lastModifiedDate=last_modified_date) ps = PaginatedSearch(client=self.ns_client, type_name='Item', pageSize=page_size, @@ -174,7 +174,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='InventoryAdjustment', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', recordType=record_type_search_field, @@ -197,7 +197,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='VendorBill', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', recordType=record_type_search_field, @@ -219,7 +219,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='VendorPayment', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', recordType=record_type_search_field, @@ -243,7 +243,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='JournalEntry', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', lastModifiedDate=last_modified_date, @@ -305,7 +305,7 @@ def get_all(self, last_modified_date=None): return list(self.get_all_generator() if last_modified_date is None else self.get_all_generator( last_modified_date=last_modified_date)) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='Invoice', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', lastModifiedDate=last_modified_date, @@ -331,7 +331,7 @@ def __init__(self, ns_client): def get_all(self, last_modified_date=None): return self.get_all_generator(last_modified_date=last_modified_date) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='CreditMemo', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', lastModifiedDate=last_modified_date, @@ -356,7 +356,7 @@ def __init__(self, ns_client): def get_all(self, last_modified_date=None): return self.get_all_generator(last_modified_date=last_modified_date) - def get_all_generator(self, page_size=300, last_modified_date=None): + def get_all_generator(self, page_size=200, last_modified_date=None): record_type_search_field = self.ns_client.SearchStringField(searchValue='PurchaseOrder', operator='contains') basic_search = self.ns_client.basic_search_factory('Transaction', lastModifiedDate=last_modified_date,