示例#1
0
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
示例#2
0
async def rest_api_patch(config, args) -> str:
    rest_api = _get_rest_api_or_error(config)
    with args.payload_file as fh:
        payload_str = fh.read()

    payload = json.loads(payload_str)

    resp = await rest_api.patch(args.subpath, json=payload)
    return json.dumps_str(resp)