-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from HPInc/chore-add-source-order-samples
chore(samples): add source order request samples
- Loading branch information
Showing
2 changed files
with
81 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,41 @@ | ||
#!/usr/bin/python | ||
|
||
__author__ = "HPInc." | ||
|
||
# | ||
# DELETE ME! | ||
# Import parent directory to the sys.path to be able to load OneflowSDK | ||
# | ||
|
||
import sys, os | ||
|
||
current = os.path.dirname(os.path.realpath(__file__)) | ||
parent = os.path.dirname(current) | ||
sys.path.append(parent) | ||
|
||
# | ||
# Cancel source order request logic | ||
# | ||
|
||
import json, os | ||
from OneflowSDK import OneflowSDK | ||
|
||
# credentials and endpoint | ||
token = os.environ["ONEFLOW_TOKEN"] | ||
secret = os.environ["ONEFLOW_SECRET"] | ||
endpoint = "https://pro-api.oneflowcloud.com" | ||
|
||
# OneflowSDK instance | ||
client = OneflowSDK(endpoint, token, secret) | ||
|
||
# specific api call | ||
source_name = "CHANGE_ME_YOUR_SOURCE_NAME" | ||
source_order_id = "CHANGE_ME_YOUR_SOURCE_ORDER_ID" | ||
|
||
api_path = "/api/order/{source_name}/{source_order_id}/cancel".format(source_name=source_name, source_order_id=source_order_id) | ||
|
||
# make the PUT request to the endpoint | ||
r = client.request("PUT", api_path) | ||
|
||
# output the results | ||
print("result", r) |
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,40 @@ | ||
#!/usr/bin/python | ||
|
||
__author__ = "HPInc." | ||
|
||
# | ||
# DELETE ME! | ||
# Import parent directory to the sys.path to be able to load OneflowSDK | ||
# | ||
|
||
import sys, os | ||
|
||
current = os.path.dirname(os.path.realpath(__file__)) | ||
parent = os.path.dirname(current) | ||
sys.path.append(parent) | ||
|
||
# | ||
# Get source order request logic | ||
# | ||
|
||
import json, os | ||
from OneflowSDK import OneflowSDK | ||
|
||
# credentials and endpoint | ||
token = os.environ["ONEFLOW_TOKEN"] | ||
secret = os.environ["ONEFLOW_SECRET"] | ||
endpoint = "https://pro-api.oneflowcloud.com" | ||
|
||
# OneflowSDK instance | ||
client = OneflowSDK(endpoint, token, secret) | ||
|
||
# specific api call | ||
source_order_id = "CHANGE_ME_YOUR_SOURCE_ORDER_ID" | ||
|
||
api_path = "/api/order/bysourceid/{source_order_id}".format(source_order_id=source_order_id) | ||
|
||
# make the GET request to the endpoint | ||
r = client.request("GET", api_path) | ||
|
||
# output the results | ||
print("result", r) |