Skip to content

Commit

Permalink
Items support (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
labhvam5 authored May 18, 2023
1 parent 80f2687 commit 32cf0b0
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
24 changes: 24 additions & 0 deletions netsuitesdk/api/items.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from .base import ApiBase
from netsuitesdk.internal.utils import PaginatedSearch
import logging

logger = logging.getLogger(__name__)

class Items(ApiBase):

def __init__(self, ns_client):
ApiBase.__init__(self, ns_client=ns_client, type_name='Item')

def get_all_generator(self, is_inactive=False):
# Get Only Active Items using SearchBooleanField
record_type_search_field = self.ns_client.SearchBooleanField(searchValue=is_inactive)
basic_search = self.ns_client.basic_search_factory('Item', isInactive=record_type_search_field)

paginated_search = PaginatedSearch(
client=self.ns_client,
type_name='Item',
basic_search=basic_search,
pageSize=20
)

return self._paginated_search_generator(paginated_search=paginated_search)
2 changes: 2 additions & 0 deletions netsuitesdk/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .api.tax_items import TaxItems
from .api.tax_groups import TaxGroups
from .api.price_level import PriceLevel
from .api.items import Items
from .internal.client import NetSuiteClient


Expand Down Expand Up @@ -77,3 +78,4 @@ def __init__(self, account, consumer_key, consumer_secret, token_key, token_secr
self.credit_memos = CreditMemos(ns_client)
self.price_level = PriceLevel(ns_client)
self.usages = Usage(ns_client)
self.items = Items(ns_client)
1 change: 1 addition & 0 deletions netsuitesdk/internal/netsuite_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'SearchMultiSelectField',
'SearchDateField',
'SearchLongField',
'SearchBooleanField',
'Status',
'StatusDetail',
'TokenPassport',
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.16.6',
version='2.17.0',
author='Siva Narayanan',
author_email='[email protected]',
description='Python SDK for accessing the NetSuite SOAP webservice',
Expand Down
9 changes: 9 additions & 0 deletions test/integration/test_items.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import logging
import pytest

logger = logging.getLogger(__name__)

def test_get(nc):
data = nc.items.get_all()
logger.debug('data = %s', data)
assert data, 'get all didnt work'
4 changes: 2 additions & 2 deletions test/internal/test_upsert.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_currency(ns):
return ns.get(recordType='currency', internalId='1')

def get_employee(ns):
return ns.get(recordType='employee', internalId='1648')
return ns.get(recordType='employee', internalId='3482')

def test_upsert_vendor_bill(ns):
vendor_ref = ns.RecordRef(type='vendor', internalId=get_vendor(ns).internalId)
Expand Down Expand Up @@ -121,7 +121,7 @@ def test_upsert_journal_entry(ns):
def test_upsert_expense_report(ns):
employee_ref = ns.RecordRef(type='employee', internalId=get_employee(ns).internalId)
bill_account_ref = ns.RecordRef(type='account', internalId=25)
cat_account_ref = ns.RecordRef(type='account', internalId='1')
cat_account_ref = ns.RecordRef(type='account', internalId='3')
loc_ref = ns.RecordRef(type='location', internalId=get_location(ns).internalId)
dep_ref = ns.RecordRef(type='department', internalId=get_department(ns).internalId)
class_ref = ns.RecordRef(type='classification', internalId=get_department(ns).internalId)
Expand Down

0 comments on commit 32cf0b0

Please sign in to comment.