Silly orders endpoint

This commit is contained in:
counterweight 2023-08-02 20:09:28 +02:00
parent b51b006bd1
commit aff2241f2c
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
2 changed files with 18 additions and 9 deletions

View file

@ -11,5 +11,6 @@ def check_health():
@app.command()
def explode():
print("Pew bam boom")
def show_orders():
controllers.show_orders()

View file

@ -6,19 +6,19 @@ from woocommerce import API
API_CONFIG = dotenv_values(
dotenv_path=Path.home() / Path(".camisatoshi-wordpress-reports/.env")
)
def check_health():
print(f"Connecting to the configured woocomerce at {API_CONFIG['URL']}")
wc_api = API(
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():
print(f"Connecting to the configured woocomerce at {API_CONFIG['URL']}")
try:
api_reported_version = wc_api.get("").json()["namespace"]
api_reported_version = WC_API.get("").json()["namespace"]
except:
raise ConnectionError(
"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("Connection successful. The API is reachable.")
def show_orders():
print(
WC_API.get(
"orders", params={"after": "2023-07-21T18:02:23+00:00"}
).json()
)