orpythonsdk (1.3.0)
Installation
pip install --index-url --extra-index-url https://pypi.org/simple orpythonsdkAbout this package
Python SDK for the OnRamp public API.
OnRamp Python SDK
Python client for the OnRamp public API.
Install
python -m pip install --extra-index-url https://git.onramp-solutions.com/api/packages/OnRampSDK/pypi/simple orpythonsdk
The install also includes a short example at examples/main.py.
Basic Usage
from orpythonsdk import OnRampAPI
api = OnRampAPI("https://onramp.customer.com/ProductionCopy/")
api.APILogin("api_user", "api_password")
print(api.SessionID)
api.KeepSessionAlive()
api.LogOut()
APILogin stores the session ID on the OnRampAPI instance. Most methods use that stored session, so callers do not need to pass sess into every API call.
To attach to an existing session:
api = OnRampAPI("https://onramp.customer.com/ProductionCopy/")
API Queries
Use RunAPIQuery for registered API queries.
Use a dictionary when the query parameters are named in OnRamp.
rows = api.RunAPIQuery("QL-10000008", {"param_name": "param_value"})
for row in rows:
print(row)
Use a list as args when the query expects indexed or positional parameters.
customers = api.RunAPIQuery("Q-10010176", ["1/1/1900"])
for customer in customers:
print(customer["cusm_id"], customer["cusm_name"])
If a registered query performs an action and returns Executed, RunAPIQuery returns that response. If the response is neither an array nor Executed, the SDK raises an exception.
Screen Calls
from orpythonsdk import ORApiScreenMode, ORApiScreenOKCancel
screen = api.ScreenLoad("S2431")
api.ScreenEnterFrame(screen, "01")
api.ScreenEnterMode(screen, ORApiScreenMode.Add)
api.ScreenSetControlValue(screen, "01-01-01", "TaskID ID")
api.ScreenSetControlValue(screen, "01-01-02", "TaskID Desc")
api.ScreenOKCancel(screen, ORApiScreenOKCancel.OK)
errors = api.ScreenGetCurrentErrors(screen)
api.CloseScreen(screen)
Message Boxes And Files
Some screen actions can trigger modal message boxes. Use SetAutoMsgBoxAnswer to choose the automatic answer for future prompts in the current session.
from orpythonsdk import ORApiAutoAnswerMsgBoxOption
api.SetAutoMsgBoxAnswer(ORApiAutoAnswerMsgBoxOption.Yes)
# Do work that may trigger a modal prompt.
api.SetAutoMsgBoxAnswer(ORApiAutoAnswerMsgBoxOption.NoneOption)
The setting is sticky for the session. Reset it to NoneOption when finished.
File Download
screen = api.ScreenLoad("S2431")
file_name = api.ScreenGetControlValue(screen, "01-01-03")
api.ScreenGetControlFile(screen, "01-01-03", f"C:\\Temp\\{file_name}")
api.CloseScreen(screen)
Example Code
After install, look at the shipped example file:
python -c "import sysconfig, pathlib; print(pathlib.Path(sysconfig.get_paths()['purelib']) / 'examples' / 'main.py')"
That file shows a compact end-to-end sample for:
- login
RunAPIQuery- screen calls
- file download
- logout
Edit the URL, username, and password in examples/main.py for your environment before running it.
Package Source
C:\TFS\Common\ORPythonSDK
Package publishing is handled by OnRamp maintainers from the TFS source folder.