Get orders in date range
This commit is contained in:
parent
aff2241f2c
commit
2fb57b5beb
2 changed files with 18 additions and 7 deletions
|
|
@ -11,6 +11,6 @@ def check_health():
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def show_orders():
|
def generate_um_report(start_date: str, end_date: str):
|
||||||
controllers.show_orders()
|
controllers.generate_um_report(start_date, end_date)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import datetime
|
||||||
|
from typing import List, Dict
|
||||||
|
|
||||||
from dotenv import dotenv_values
|
from dotenv import dotenv_values
|
||||||
from woocommerce import API
|
from woocommerce import API
|
||||||
|
|
@ -30,9 +32,18 @@ def check_health():
|
||||||
print("Connection successful. The API is reachable.")
|
print("Connection successful. The API is reachable.")
|
||||||
|
|
||||||
|
|
||||||
def show_orders():
|
def generate_um_report(start_date: str, end_date: str):
|
||||||
print(
|
|
||||||
WC_API.get(
|
orders_in_date_range = WC_API.get(
|
||||||
"orders", params={"after": "2023-07-21T18:02:23+00:00"}
|
endpoint="orders",
|
||||||
).json()
|
params={
|
||||||
|
"after": datetime.datetime.strptime(
|
||||||
|
start_date, "%Y-%m-%d"
|
||||||
|
).isoformat(),
|
||||||
|
"before": datetime.datetime.strptime(
|
||||||
|
end_date, "%Y-%m-%d"
|
||||||
|
).isoformat(),
|
||||||
|
"per_page": 100,
|
||||||
|
"status": "processing,completed",
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue