Skip to content

Commit

Permalink
Merge pull request #7 from HPInc/chore-add-source-order-samples
Browse files Browse the repository at this point in the history
chore(samples): add source order request samples
  • Loading branch information
joseandrespg authored Oct 15, 2024
2 parents b493fdd + 4853764 commit 99e1a8c
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
41 changes: 41 additions & 0 deletions samples/cancel-source-order.py
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)
40 changes: 40 additions & 0 deletions samples/get-source-order.py
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)

0 comments on commit 99e1a8c

Please sign in to comment.