From ccde9d9f5b1e781bba80f4411885e82de26471a0 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 14 Sep 2019 13:23:11 +0530 Subject: [PATCH] Make command "product order" rather than "order product" --- commands/order.py | 0 commands/product.py | 15 +++++++++++++++ 2 files changed, 15 insertions(+) delete mode 100644 commands/order.py diff --git a/commands/order.py b/commands/order.py deleted file mode 100644 index e69de29..0000000 diff --git a/commands/product.py b/commands/product.py index 9bf6538..1a61ae6 100755 --- a/commands/product.py +++ b/commands/product.py @@ -47,3 +47,18 @@ def add(name, realm, seed, product_name, product_description, product_type, r = requests.post("{}/product/add".format(config('UCLOUD_PAY_SERVER')), json=data) print(load_dump_pretty(r.content)) + + +@product.command("order") +@click.option("--name", envvar="OTP_NAME", required=True) +@click.option("--realm", envvar="OTP_REALM", required=True) +@click.option("--seed", envvar="OTP_SEED", required=True) +@click.option("--product-id", help="The uuid of the product", required=True) +def order(name, realm, seed, product_id): + data = { + **OTPCredentials(name, realm, seed).get_json(), + "product_id": product_id + } + r = requests.post("{}/order/product".format(config('UCLOUD_PAY_SERVER')), + json=data) + print(load_dump_pretty(r.content)) \ No newline at end of file