def validateToken(self, token): userDao = UserDao() user = userDao.getUser(token) if user == None: return ResponseHelper.generateErrorResponse("Invalid token") else: return user
def validateToken(self, token): userDao = UserDao() try: user = userDao.getUser(token) if user == None: return ResponseHelper.generateErrorResponse("Invalid token") return user except Exception as ex: return ResponseHelper.generateErrorResponse( '''Valid user exception: {}'''.format(str(ex)))
def execute(self): print("*********** Price Automatically is executed ***********") skudao = SkuDao() skus = skudao.getAll() if (skus == None): return userDao = UserDao() user = userDao.getUser("token") for sku in skus: enemies = self.getEnemies(sku['link']) self.priceAlgorithm(enemies, user, sku)
def validateToken(self, token): if (StringUtils.isEmpty(token)): return None, "Invalid token" try: userDao = UserDao() user = userDao.getUser(token) if user == None: return None, "Invalid token" return user, None except Exception as ex: return None, '''Valid user exception: {}'''.format(str(ex))
def doUpdatePrice(self, sku, newSpecialPrice): sku['updated_at'] = int(round(time.time())) sku['special_price'] = newSpecialPrice # Update internal database skuDao = SkuDao() skuDao.update(sku) # Update external database userDao = UserDao() temporaryUser = userDao.getUser("token") lazadaSkuApi = LazadaSkuApi() lazadaProduct = lazadaSkuApi.updateProductSpecialPrice( sku, temporaryUser, newSpecialPrice) print("*********** Price Automatically do updated price ***********") print("Sku: ", sku['sku'], "/nnew special price: ", newSpecialPrice)
def getUser(self, token): userDao = UserDao() return userDao.getUser(token)