Mark offer as clear

        :param offer_id: the offer id
        :return Response
761050
def mark_offer_as_clear(self, offer_id):
        
        return self._create_put_request(
            resource=OFFERS,
            billomat_id=offer_id,
            command=CLEAR,
        )
1185409
def _clearQuantity(self, offbids, gen):
        
        # Filter out offers/bids not applicable to the generator in question.
        gOffbids = [offer for offer in offbids if offer.generator == gen]

        # Offers/bids within valid price limits (not withheld).
        valid = [ob for ob in gOffbids if not ob.withheld]

        # Sort offers by price in ascending order and bids in decending order.
        valid.sort(key=lambda ob: ob.price, reverse=[False, True][gen.is_load])

        acceptedQty = 0.0
        for ob in valid:
            # Compute the fraction of the block accepted.
            accepted = (ob.totalQuantity - acceptedQty) / ob.quantity

            # Clip to the range 0-1.
            if accepted > 1.0:
                accepted = 1.0
            elif accepted < 1.0e-05:
                accepted = 0.0

            ob.clearedQuantity = accepted * ob.quantity

            ob.accepted = (accepted > 0.0)

            # Log the event.
#            if ob.accepted:
#                logger.info("%s [%s, %.3f, %.3f] accepted at %.2f MW." %
#                    (ob.__class__.__name__, ob.generator.name, ob.quantity,
#                     ob.price, ob.clearedQuantity))
#            else:
#                logger.info("%s [%s, %.3f, %.3f] rejected." %
#                    (ob.__class__.__name__, ob.generator.name, ob.quantity,
#                     ob.price))

            # Increment the accepted quantity.
            acceptedQty += ob.quantity
877763
async def write_deal(self, **params):
		
		if params.get("message"):
			params = json.loads(params.get("message", "{}"))
		
		if not params:
			return {"error":400, "reason":"Missed required fields"}

		cid = int(params.get("cid", 0))
		access_type = params.get("access_type")
		buyer = params.get("buyer")
		seller = params.get("seller")
		price = params.get("price")
		coinid = params.get("coinid")

		try:
			coinid = coinid.replace("TEST", "")
		except:
			pass

		if not all([cid, access_type, buyer, seller, price]):
			return {"error":400, "reason":"Missed required fields"}

		database = client[coinid]
		collection = database[settings.DEAL]
		await collection.insert_one({
				"cid":cid,
				"access_type": access_type,
				"buyer":buyer,
				"seller":seller,
				"price":price,
				"coinid":coinid
			})
		result = await collection.find_one({"cid":cid, "buyer":buyer})

		return {i:result[i] for i in result if i != "_id"}
829166
def get_all_items_of_offer(self, offer_id):
        
        return self._iterate_through_pages(
            get_function=self.get_items_of_offer_per_page,
            resource=OFFER_ITEMS,
            **{'offer_id': offer_id}
        )
620161
def receive_accept(self, msg):
        '''
        
        '''
        if self.promised_id is None or msg.proposal_id >= self.promised_id:
            self.promised_id = msg.proposal_id
            self.accepted_id = msg.proposal_id
            self.accepted_value = msg.proposal_value
            return Accepted(self.network_uid, msg.proposal_id, msg.proposal_value)
        else:
            return Nack(self.network_uid, msg.from_uid, msg.proposal_id, self.promised_id)
1147820
def get_mark(self, mark_id):
        
        if mark_id in self.idx:
            return Cmarkable(self.idx[mark_id], self.type)
        else:
            return None
761070
def mark_received(self, visibility_timeout=None):
        
        if visibility_timeout:
            visibility_timeout = int(visibility_timeout)
        else:
            visibility_timeout = 0

        if not self.approximate_first_receive_timestamp:
            self.approximate_first_receive_timestamp = int(unix_time_millis())

        self.approximate_receive_count += 1

        # Make message visible again in the future unless its
        # destroyed.
        if visibility_timeout:
            self.change_visibility(visibility_timeout)

        self.receipt_handle = generate_receipt_handle()
1374049
def get_all_comments_of_offer(self, offer_id):
        
        return self._iterate_through_pages(
            get_function=self.get_comments_of_offer_per_page,
            resource=OFFER_COMMENTS,
            **{'offer_id': offer_id}
        )
561026
def bids_to_you(self):
        '''
        
        '''
        headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain",'Referer': 'http://'+self.domain+'/team_news.phtml',"User-Agent": user_agent}
        req = self.session.get('http://'+self.domain+'/exchangemarket.phtml?viewoffers_x=',headers=headers).content
        soup = BeautifulSoup(req)
        table = []
        for i in soup.find('table',{'class','tablecontent03'}).find_all('tr')[1:]:
            player,owner,team,price,bid_date,trans_date,status = self._parse_bid_table(i)
            table.append([player,owner,team,price,bid_date,trans_date,status])
        return table
182511
async def update_offer(self, **params):
		
		logging.debug("\n\n -- Update offer. ")
		if params.get("message"):
			params = json.loads(params.get("message", "{}"))
		
		if not params:
			return {"error":400, "reason":"Missed required fields"}

		# Check if required fields exists
		txid = params.get("txid")
		coinid = params.get("coinid").upper()

		try:
			coinid = coinid.replace("TEST", "")
		except:
			pass

		# Try to find offer with account id and cid
		database = client[coinid]
		offer_db = database[settings.OFFER]
		offer = await offer_db.find_one({"txid":txid})
		logging.debug("\n\n -- Try to get offer. ")
		logging.debug(offer)
		if not offer:
			return {"error":404, 
					"reason":"Offer with txid %s not found" % txid }

		# Update offer
		await offer_db.find_one_and_update(
							{"txid":txid}, {"$set":{"confirmed":1}})

		# Get updated offer
		updated = await offer_db.find_one({"txid":txid})

		return {i:updated[i] for i in updated if i != "_id"}
1019476
def receive_prepare(self, msg):
        '''
        
        '''
        if self.promised_id is None or msg.proposal_id >= self.promised_id:
            self.promised_id = msg.proposal_id
            return Promise(self.network_uid, msg.from_uid, self.promised_id, self.accepted_id, self.accepted_value)
        else:
            return Nack(self.network_uid, msg.from_uid, msg.proposal_id, self.promised_id)
325625
def clear_incident(self, id, **kwargs):
        
        resp = self._put(
            self._u(self._INCIDENT_ENDPOINT_SUFFIX, id, 'clear'),
            None,
            **kwargs
        )
        resp.raise_for_status()
        return resp
642402
def get(self, **params):
        '''
        
        '''
        return self.client.get('/v2/shopping/hotel-offers/{0}'
                               .format(self.offer_id), **params)
1096875
def offer_simple(pool, answer, rationale, student_id, options):
    
    existing = pool.setdefault(answer, {})
    if len(existing) >= get_max_size(pool, len(options), POOL_ITEM_LENGTH_SIMPLE):
        student_id_to_remove = random.choice(existing.keys())
        del existing[student_id_to_remove]
    existing[student_id] = {}
    pool[answer] = existing
310316
def __request_mark_sent(self, requestId):
        """"""
        with self.__requests:
            try:
                req = self.__requests[requestId]
            except KeyError:
                # request might have had a response already have been removed by receiving thread
                pass
            else:
                req.exception = None
                req._send_time = monotonic()
817441
def get_items_of_offer_per_page(self, offer_id, per_page=1000, page=1):
        
        return self._get_resource_per_page(
            resource=OFFER_ITEMS,
            per_page=per_page,
            page=page,
            params={'offer_id': offer_id},
        )
663789
def get_markable(self,markable_id):
        
        if markable_id in self.idx:
            return Cmarkable(self.idx[markable_id],self.type)
        else:
            return None