def run(self): for i in range(10): job = fake.job() image_url = "https://via.placeholder.com/150/" + fake.safe_hex_color( ).replace("#", "") + "/000000?Text=" + job ProductRepository.create(title=job, description=fake.paragraph( nb_sentences=3, variable_nb_sentences=True, ext_word_list=None), price=fake.pydecimal(left_digits=2, right_digits=5, positive=True), image_url=image_url)
def post(title, description, price, image_url): """ Create an product based on the sent information """ product = ProductRepository.create(title=title, description=description, price=price, image_url=image_url) return jsonify(product.json)
def post(self): """ Create Product """ request_json = request.get_json(silent=True) name: str = request_json['name'] desc: str = request_json['desc'] try: response = ProductRepository.create(name, desc) return response, 200 except Exception as e: response = jsonify(e.to_dict()) response.status_code = e.status_code return response
def post(name, brand, price, category, subcategory, subsubcategory, description=None, image=None, rating=None, units_sold=0): """ Create an product based on the sent information """ product = ProductRepository.create(name, brand, price, category, subcategory, subsubcategory, description, image, rating, units_sold) return jsonify({'product': product.json})