def getTradeInInfo(self, _): start, end = self._tradeIn.getStartEndTimestamps() return { 'allowedVehicleLevels': self._tradeIn.getAllowedVehicleLevels(), 'startDate': timestampToISO(start), 'endDate': timestampToISO(end) } if self._tradeIn.isEnabled() else None
def makeActionFormatter(): fields = [Field('id', lambda actionInfo: actionInfo.getID()), Field('startDate', lambda actionInfo: time_utils.timestampToISO(actionInfo.getExactStartTime())), Field('endDate', lambda actionInfo: time_utils.timestampToISO(actionInfo.getExactFinishTime())), Field('name', lambda actionInfo: actionInfo.getTitle()), Field('description', lambda actionInfo: actionInfo.event.getDescription()), Field('triggerChainID', lambda actionInfo: actionInfo.getTriggerChainID()), Field('type', lambda actionInfo: actionInfo.discount.getName()), Field('params', _formatActionParams)] return Formatter(fields)
def _formatVehicleRestore(item): if item.isRestorePossible(): restoreInfo = item.restoreInfo restorePrice = item.restorePrice currency = restorePrice.getCurrency() if item.hasLimitedRestore(): restoreEndDate = time_utils.timestampToISO(restoreInfo.changedAt + restoreInfo.getRestoreTimeLeft()) else: restoreEndDate = None return {'price': {currency: restorePrice.getSignValue(currency)}, 'endDate': restoreEndDate} else: return
def getBalance(self, cmd): stats = self.itemsCache.items.stats premiumExpireLocalTime = time_utils.makeLocalServerTime( stats.activePremiumExpiryTime) if premiumExpireLocalTime: premiumExpireISOTime = time_utils.timestampToISO( premiumExpireLocalTime) else: premiumExpireISOTime = None response = formatBalance(stats) response.update({ 'walletStatus': formatWalletCurrencyStatuses(stats), 'premiumExpireDate': premiumExpireISOTime }) return response
def getBalance(self, cmd): stats = self.itemsCache.items.stats money = stats.actualMoney premiumExpireLocalTime = time_utils.makeLocalServerTime( stats.premiumExpiryTime) if premiumExpireLocalTime is not None: premiumExpireISOTime = time_utils.timestampToISO( premiumExpireLocalTime) else: premiumExpireISOTime = None balanceData = {'premiumExpireDate': premiumExpireISOTime} balanceData.update( {currency: money.get(currency, 0) for currency in Currency.ALL}) return balanceData