Add product_id/create_at/created_by fields for product
This commit is contained in:
parent
9ed0fdf468
commit
497c535de1
1 changed files with 7 additions and 2 deletions
|
@ -118,6 +118,7 @@ class AddProduct(Resource):
|
|||
product_uuid = uuid4().hex
|
||||
product_key = "/v1/products/{}".format(product_uuid)
|
||||
product_value = {
|
||||
"product_id": product_key,
|
||||
"name": data["product_name"],
|
||||
"description": data["product_description"],
|
||||
"type": data["product_type"],
|
||||
|
@ -125,12 +126,16 @@ class AddProduct(Resource):
|
|||
"recurring_period": data["product_recurring_period"],
|
||||
"minimum_subscription_period":
|
||||
data["product_minimum_subscription_period"] if
|
||||
data["product_type"] == "recurring" else 0
|
||||
data["product_type"] == "recurring" else 0,
|
||||
"created_at": int(time.time()),
|
||||
"created_by": data["name"]
|
||||
}
|
||||
logging.debug("Adding product data: {}".format(str(product_value)))
|
||||
client.put(product_key, product_value, value_in_json=True)
|
||||
return {"message":
|
||||
"Product {} created".format(data['product_name'])}, 200
|
||||
"Product {} created. Product ID = {}".format(
|
||||
data['product_name'], product_key
|
||||
)}, 200
|
||||
except KeyError as ke:
|
||||
logging.error("KeyError occurred. details = {}".format(str(ke)))
|
||||
return {"message":
|
||||
|
|
Loading…
Reference in a new issue