Silly orders endpoint
This commit is contained in:
parent
b51b006bd1
commit
aff2241f2c
2 changed files with 18 additions and 9 deletions
|
|
@ -11,5 +11,6 @@ def check_health():
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def explode():
|
def show_orders():
|
||||||
print("Pew bam boom")
|
controllers.show_orders()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,19 @@ from woocommerce import API
|
||||||
API_CONFIG = dotenv_values(
|
API_CONFIG = dotenv_values(
|
||||||
dotenv_path=Path.home() / Path(".camisatoshi-wordpress-reports/.env")
|
dotenv_path=Path.home() / Path(".camisatoshi-wordpress-reports/.env")
|
||||||
)
|
)
|
||||||
|
WC_API = API(
|
||||||
|
url=API_CONFIG["URL"],
|
||||||
|
consumer_key=API_CONFIG["CONSUMER_KEY"],
|
||||||
|
consumer_secret=API_CONFIG["CONSUMER_SECRET"],
|
||||||
|
version=API_CONFIG["VERSION"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def check_health():
|
def check_health():
|
||||||
print(f"Connecting to the configured woocomerce at {API_CONFIG['URL']}")
|
print(f"Connecting to the configured woocomerce at {API_CONFIG['URL']}")
|
||||||
wc_api = API(
|
|
||||||
url=API_CONFIG["URL"],
|
|
||||||
consumer_key=API_CONFIG["CONSUMER_KEY"],
|
|
||||||
consumer_secret=API_CONFIG["CONSUMER_SECRET"],
|
|
||||||
version=API_CONFIG["VERSION"],
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
api_reported_version = wc_api.get("").json()["namespace"]
|
api_reported_version = WC_API.get("").json()["namespace"]
|
||||||
except:
|
except:
|
||||||
raise ConnectionError(
|
raise ConnectionError(
|
||||||
"There was an issue connecting to the woocomerce API."
|
"There was an issue connecting to the woocomerce API."
|
||||||
|
|
@ -28,3 +28,11 @@ def check_health():
|
||||||
print(f"Version reported by the API itself: {api_reported_version}")
|
print(f"Version reported by the API itself: {api_reported_version}")
|
||||||
|
|
||||||
print("Connection successful. The API is reachable.")
|
print("Connection successful. The API is reachable.")
|
||||||
|
|
||||||
|
|
||||||
|
def show_orders():
|
||||||
|
print(
|
||||||
|
WC_API.get(
|
||||||
|
"orders", params={"after": "2023-07-21T18:02:23+00:00"}
|
||||||
|
).json()
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue