Skip to main content

A package to dynamically interact with Netsuite SOAP Endpoints

Project description

simpletalk

This package simplifies the Netsuite SOAP Web Services by enabling you to pass dictionaries to the connector and have the structures dynamically pulled from the WSDL. Custom fields are dynamically retrieved from your Netsuite Organization and cached for 24 hours.

init()

The connection to Netsuite is handled through Netsuite's OAuth. This requires the account, consumer key, consumer secret, token id, token secret and optionally the application id. These can either be input as a dictionary:

from simpletalk import SimpleTalk

config = {'config':
            {'account': {account_id},
            'consumer_key': {consumer_key},
            'consumer_secret': {consumer_secret},
            'token_id': {token_id},
            'token_secret': {token_secret},
            'application_id': {application_id}}
         }
conn = SimpleTalk(config=config)

Or these can be set as environment variables. The package includes python-dotenv, so if they are in a .env file it will be able to access them, or they need to be in a location accessible to os.getenv().

.env

ACCOUNT = {account_id}
CONSUMER_KEY = {consumer_key},
CONSUMER_SECRET = {consumer_secret},
TOKEN_ID =  {token_id},
TOKEN_SECRET = {token_secret},
APPLICATION_ID = {application_id}}
from simpletalk import SimpleTalk

conn = SimpleTalk()

Finally you can pass in an existing connection from the netsuite package. You will need to look at that package for the credentials and configuration options.

from netsuite import client
from simpletalk import SimpleTalk

client = client()

conn = SimpleTalk(client=client)

You also have the option to pass in the version of the Netsuite API you want to use. The default is 2018.2.0.

create()

The create function allows you to pass in a python dictionary and the connector will convert it to the appropriate XML formatting including custom fields. -Make sure the keys in your dictionary exactly match the API names of fields and custom fields. -All reference fields need to have the internal id of the desired record in the value location. -Custom fields all need to be within a customFieldList dictionary.

from simpletalk import SimpleTalk

conn = SimpleTalk()

data = {'externalId': 345642,
        'location': 1,
        'customFieldList': {
            'custbody_example': 'value'
            }
        'itemList': [
            {'price': 100,
            'item': 341,
            'quantity': 1,
            'customFieldList':{
                'custcol_example': 'value'
            }},
            {'price': 56,
            'item': 214,
            'quantity': 30}
            ]
        }

conn.create('SalesOrder', data)

update()

The update function works in the same way as the create function, but requires the internalId to be set.

from simpletalk import SimpleTalk

conn = SimpleTalk()

data = {'internalId': 34546,
        'nullFieldList': ['email', 'firstName', 'lastName'],
        'companyName': 'Example'}

conn.update('Customer', data)

get()

Retrieves a record based on its internal, or external Id. If the record does not exist it will return None. Otherwise it will return the record in dictionary form with the customFieldList flattened into a dictionary like it is above.

from simpletalk import SimpleTalk

conn = SimpleTalk()

order = conn.get('SalesOrder', internalId = 43645362)

order = conn.get('SalesOrder', externalId = 36456454)

search()

This component has not been dynamic yet. It requires using the WSDL to build the search and then input it to the search function.

from simpletalk import SimpleTalk

conn = SimpleTalk()

sea = conn.client.Customization.CustomRecordSearch()
sea_basic = conn.client.Common.CustomRecordSearchBasic()
record_ref = conn.client.Core.RecordRef()
record_ref.internalId = 313  # internalId of the serial name table
sea_basic.recType = record_ref
sea_date = conn.client.Core.SearchDateField()
sea_date.searchValue = last_processed.strftime('%Y-%m-%dT%H:%M:%S%z')
sea_date.operator = 'after'
sea_basic.lastModified = sea_date
sea.basic = sea_basic

conn.search(sea)

build()

Takes the input data and formats it as a zeep object ready to be sent to Netsuite.

from simpletalk import SimpleTalk

conn = SimpleTalk()

data = {'internalId': 34546,
        'nullFieldList': ['email', 'firstName', 'lastName'],
        'companyName': 'Example'}

xml_data = conn.build('Customer', data)

view()

Takes an object as input and returns out its entire structure including custom fields and related lists. This is useful for exploring the WSDL.

from simpletalk import SimpleTalk

conn = SimpleTalk()

structure = conn.view('Customer')

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for SimpleTalk, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size SimpleTalk-0.0.1.tar.gz (10.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page