-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add example project for soap requests
- Loading branch information
1 parent
1b2d4d6
commit 352bdd6
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import argparse | ||
import asyncio | ||
|
||
from netsuite import Config | ||
from netsuite.constants import DEFAULT_INI_PATH, DEFAULT_INI_SECTION | ||
from netsuite.soap_api.client import NetSuiteSoapApi | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-p", "--config-path", default=DEFAULT_INI_PATH, dest="path") | ||
parser.add_argument( | ||
"-c", "--config-section", default=DEFAULT_INI_SECTION, dest="section" | ||
) | ||
|
||
|
||
async def main(): | ||
args = parser.parse_args() | ||
|
||
config = Config.from_ini(**vars(args)) | ||
api = NetSuiteSoapApi(config) | ||
|
||
resp1 = await api.getList("customer", internalIds=[1]) | ||
print(resp1) | ||
|
||
# Re-use same connection | ||
async with api: | ||
resp2 = await api.getList("salesOrder", internalIds=[1]) | ||
resp3 = await api.getList("salesOrder", internalIds=[2]) | ||
|
||
print(resp2) | ||
print(resp3) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |