def restlet(script_id, payload, deploy=1, log_level=None, config_path=DEFAULT_INI_PATH, config_section=DEFAULT_INI_SECTION): """Make requests to restlets""" _set_log_level(log_level) conf = config.from_ini(path=config_path, section=config_section) ns = netsuite.NetSuite(conf) if not payload: payload = None elif payload == '-': payload = json.load(sys.stdin) else: payload = json.loads(payload) resp = ns.restlet.raw_request( script_id=script_id, deploy=deploy, payload=payload, raise_on_bad_status=False, ) return resp.text
def _get_rest_api_or_error(config: config.Config): ns = netsuite.NetSuite(config) try: return ns.rest_api # Cached property that initializes NetSuiteRestApi except RuntimeError as ex: parser.error(str(ex))
def interact(log_level=None, config_path=DEFAULT_INI_PATH, config_section=DEFAULT_INI_SECTION): """Starts a REPL to enable live interaction with NetSuite webservices""" _set_log_level(log_level) conf = config.from_ini(path=config_path, section=config_section) ns = netsuite.NetSuite(conf) user_ns = {'ns': ns} banner1 = """Welcome to Netsuite WS client interactive mode Available vars: `ns` - NetSuite client Example usage: ws_results = ns.getList('customer', internalIds=[1337]) restlet_results = ns.restlet.request(987) """ IPython.embed( user_ns=user_ns, banner1=banner1, config=traitlets.config.Config(colors='LightBG'), # To fix no colored input we pass in `using=False` # See: https://github.com/ipython/ipython/issues/11523 # TODO: Remove once this is fixed upstream using=False, )
def interact( log_level: 'The log level to use' = None, config_path: 'The config file to get settings from.' = DEFAULT_INI_PATH, config_section: 'The config section to get settings from.' = DEFAULT_INI_SECTION, ): """Starts a REPL to enable live interaction with NetSuite webservices""" _set_log_level(log_level) conf = config.from_ini(path=config_path, section=config_section) ns = netsuite.NetSuite(conf, sandbox=True) # print(ns.getList('customer', internalIds=['11397'])) user_ns = {'ns': ns} banner1 = """Welcome to Netsuite WS client interactive mode Available vars: `ns` - NetSuite client Example usage: results = ns.getList('customer', internalIds=[1337]) """ IPython.embed(user_ns=user_ns, banner1=banner1, config=traitlets.config.Config(colors='LightBG'))
def restlet(config, args) -> str: ns = netsuite.NetSuite(config) if not args.payload: payload = None elif args.payload == "-": with sys.stdin as fh: payload = json.loads(fh.read()) else: payload = json.loads(args.payload) resp = ns.restlet.raw_request( script_id=args.script_id, deploy=args.deploy, payload=payload, raise_on_bad_status=False, ) return resp.text
def interact(config, args): ns = netsuite.NetSuite(config) user_ns = {"ns": ns} banner1 = """Welcome to Netsuite WS client interactive mode Available vars: `ns` - NetSuite client Example usage: ws_results = ns.getList('customer', internalIds=[1337]) restlet_results = ns.restlet.request(987) rest_api_results = await ns.rest_api.get("/record/v1/salesOrder") """ IPython.embed( user_ns=user_ns, banner1=banner1, config=traitlets.config.Config(colors="LightBG"), # To fix no colored input we pass in `using=False` # See: https://github.com/ipython/ipython/issues/11523 # TODO: Remove once this is fixed upstream using=False, )
def test_netsuite_wsdl_url(dummy_config): ns = netsuite.NetSuite(dummy_config) assert ns.wsdl_url == 'https://webservices.sandbox.netsuite.com/wsdl/v2017_2_0/netsuite.wsdl'
def test_netsuite_hostname(dummy_config): ns = netsuite.NetSuite(dummy_config) assert ns.hostname == 'webservices.sandbox.netsuite.com'
def test_netsuite_wsdl_url(dummy_config): ns = netsuite.NetSuite(dummy_config) assert ns.wsdl_url == 'https://123456.suitetalk.api.netsuite.com/wsdl/v2018_1_0/netsuite.wsdl'
def test_netsuite_hostname(dummy_config): ns = netsuite.NetSuite(dummy_config) assert ns.hostname == '123456.suitetalk.api.netsuite.com'