Skip to content

Commit

Permalink
Support for POST of Vendors and Employees (#42)
Browse files Browse the repository at this point in the history
Support for POST of Vendors and Employees
  • Loading branch information
Sravanksk authored Mar 1, 2021
1 parent 856908a commit 76f2c91
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 2 deletions.
34 changes: 34 additions & 0 deletions netsuitesdk/api/employees.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from collections import OrderedDict

from .base import ApiBase
import logging

Expand All @@ -7,3 +9,35 @@
class Employees(ApiBase):
def __init__(self, ns_client):
ApiBase.__init__(self, ns_client=ns_client, type_name='Employee')

def post(self, data) -> OrderedDict:
assert data['externalId'], 'missing external id'
employee = self.ns_client.Employee(externalId=data['externalId'])

employee['defaultExpenseReportCurrency'] = self.ns_client.RecordRef(**(data['defaultExpenseReportCurrency']))

employee['subsidiary'] = self.ns_client.RecordRef(**(data['subsidiary']))

employee['workCalendar'] = self.ns_client.RecordRef(**(data['workCalendar']))

if 'entityId' in data:
employee['entityId'] = data['entityId']

if 'firstName' in data:
employee['firstName'] = data['firstName']

if 'lastName' in data:
employee['lastName'] = data['lastName']

if 'email' in data:
employee['email'] = data['email']

if 'inheritIPRules' in data:
employee['inheritIPRules'] = data['inheritIPRules']

if 'payFrequency' in data:
employee['payFrequency'] = data['payFrequency']

logger.debug('able to create employee = %s', employee)
res = self.ns_client.upsert(employee)
return self._serialize(res)
37 changes: 37 additions & 0 deletions netsuitesdk/api/vendors.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
from collections import OrderedDict

from .base import ApiBase
import logging

logger = logging.getLogger(__name__)


class Vendors(ApiBase):
def __init__(self, ns_client):
ApiBase.__init__(self, ns_client=ns_client, type_name='Vendor')

def post(self, data) -> OrderedDict:
assert data['externalId'], 'missing external id'
vendor = self.ns_client.Vendor(externalId=data['externalId'])

vendor['currency'] = self.ns_client.RecordRef(**(data['currency']))

vendor['subsidiary'] = self.ns_client.RecordRef(**(data['subsidiary']))

vendor['representingSubsidiary'] = self.ns_client.RecordRef(**(data['representingSubsidiary']))

vendor['workCalendar'] = self.ns_client.RecordRef(**(data['workCalendar']))

if 'entityId' in data:
vendor['entityId'] = data['entityId']

if 'isPerson' in data:
vendor['isPerson'] = data['isPerson']

if 'companyName' in data:
vendor['companyName'] = data['companyName']

if 'firstName' in data:
vendor['firstName'] = data['firstName']

if 'lastName' in data:
vendor['lastName'] = data['lastName']

if 'email' in data:
vendor['email'] = data['email']

logger.debug('able to create vendor = %s', vendor)
res = self.ns_client.upsert(vendor)
return self._serialize(res)
3 changes: 2 additions & 1 deletion netsuitesdk/internal/netsuite_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@

# https://webservices.netsuite.com/xsd/lists/v2019_2_0/employees.xsd
'ns34': [
'EmployeeSearch'
'EmployeeSearch',
'Employee'
],

# urn:employees_2019_2.transactions.webservices.netsuite.com
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='1.14.0',
version='1.15.0',
author='Siva Narayanan',
author_email='[email protected]',
description='Python SDK for accessing the NetSuite SOAP webservice',
Expand Down

0 comments on commit 76f2c91

Please sign in to comment.