Add product_id/create_at/created_by fields for product
This commit is contained in:
parent
9ed0fdf468
commit
497c535de1
|
@ -118,6 +118,7 @@ class AddProduct(Resource):
|
||||||
product_uuid = uuid4().hex
|
product_uuid = uuid4().hex
|
||||||
product_key = "/v1/products/{}".format(product_uuid)
|
product_key = "/v1/products/{}".format(product_uuid)
|
||||||
product_value = {
|
product_value = {
|
||||||
|
"product_id": product_key,
|
||||||
"name": data["product_name"],
|
"name": data["product_name"],
|
||||||
"description": data["product_description"],
|
"description": data["product_description"],
|
||||||
"type": data["product_type"],
|
"type": data["product_type"],
|
||||||
|
@ -125,12 +126,16 @@ class AddProduct(Resource):
|
||||||
"recurring_period": data["product_recurring_period"],
|
"recurring_period": data["product_recurring_period"],
|
||||||
"minimum_subscription_period":
|
"minimum_subscription_period":
|
||||||
data["product_minimum_subscription_period"] if
|
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)))
|
logging.debug("Adding product data: {}".format(str(product_value)))
|
||||||
client.put(product_key, product_value, value_in_json=True)
|
client.put(product_key, product_value, value_in_json=True)
|
||||||
return {"message":
|
return {"message":
|
||||||
"Product {} created".format(data['product_name'])}, 200
|
"Product {} created. Product ID = {}".format(
|
||||||
|
data['product_name'], product_key
|
||||||
|
)}, 200
|
||||||
except KeyError as ke:
|
except KeyError as ke:
|
||||||
logging.error("KeyError occurred. details = {}".format(str(ke)))
|
logging.error("KeyError occurred. details = {}".format(str(ke)))
|
||||||
return {"message":
|
return {"message":
|
||||||
|
|
Loading…
Reference in New Issue