Ejemplo n.º 1
0
 def put(self, shop_id):
     abort_if_not_authorized()
     args = parser.parse_args()
     content_type = args.get('Content-Type', 'application/json')
     accept_type = args.get('Accept', 'application/json')
     shop_ids_to_update = []
     shop_ids_to_update.append(shop_id)
     shops_to_update = []
     if 'application/x-www-form-urlencoded' in content_type or 'application/x-www-form-urlencoded' in accept_type:
         shop = request.form
     elif 'application/json' in content_type or 'application/json' in accept_type:
         shop = request.json
     else:
         shop = request.json
     if isinstance(shop, list) is True:
         shops_to_update = shop
     elif isinstance(shop, dict) is True:
         shops_to_update.append(shop)
     result = ECommerceDBHelper().update_shops(shop_ids_to_update,
                                               shops_to_update)
     return {
         'type': 'PUT',
         'result': result,
         'data': shops_to_update
     }, result['errcode']
Ejemplo n.º 2
0
 def delete(self, shop_id):
     abort_if_not_authorized()
     args = parser.parse_args()
     content_type = args.get('Content-Type', 'application/json')
     accept_type = args.get('Accept', 'application/json')
     product_ids_to_delete = []
     products_deleted = []
     if 'application/x-www-form-urlencoded' in content_type or 'application/x-www-form-urlencoded' in accept_type:
         product_ids = request.form
     elif 'application/json' in content_type or 'application/json' in accept_type:
         product_ids = request.json
     else:
         product_ids = request.json
     if isinstance(product_ids, list) is True:
         product_ids_to_delete = product_ids
     elif isinstance(product_ids, dict) is True:
         product_ids_to_delete.append(product_ids)
     result = ECommerceDBHelper().delete_products(shop_id,
                                                  product_ids_to_delete,
                                                  products_deleted)
     return {
         'type': 'DELETE',
         'result': result,
         'data': products_deleted
     }, result['errcode']
Ejemplo n.º 3
0
 def get(self):
     abort_if_not_authorized()
     shops_read = []
     result = ECommerceDBHelper().read_shops(None, shops_read)
     return {
         'type': 'GET',
         'result': result,
         'data': shops_read
     }, result['errcode']
Ejemplo n.º 4
0
 def get(self, shop_id):
     abort_if_not_authorized()
     products_read = []
     result = ECommerceDBHelper().read_products(shop_id, None,
                                                products_read)
     return {
         'type': 'GET',
         'result': result,
         'data': products_read
     }, result['errcode']
Ejemplo n.º 5
0
 def get(self, shop_id):
     abort_if_not_authorized()
     shop_ids_to_read = []
     shop_ids_to_read.append(shop_id)
     shops_read = []
     result = ECommerceDBHelper().read_shops(shop_ids_to_read, shops_read)
     return {
         'type': 'GET',
         'result': result,
         'data': shops_to_create
     }, result['errcode']
Ejemplo n.º 6
0
 def delete(self, shop_id):
     abort_if_not_authorized()
     shop_ids_to_delete = []
     shop_ids_to_delete.append(shop_id)
     shops_deleted = []
     result = ECommerceDBHelper().delete_shops(shop_ids_to_delete,
                                               shops_deleted)
     return {
         'type': 'DELETE',
         'result': result,
         'data': shops_deleted
     }, result['errcode']