from script.script_c import Script

if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description=
        'Consent offers on a specific domain. In order to disallow or not consent a domain to receive offers you just need to run the test without the --consent flag.'
    )

    parser.add_argument('--cookie',
                        required=True,
                        help='Input your namebase cookie (namebase-main).')
    parser.add_argument('--domain',
                        dest='domain',
                        required=True,
                        type=str,
                        help='Domain to consent offers or not.')
    parser.add_argument(
        '--consent',
        dest='consent',
        required=False,
        action='store_true',
        default=False,
        help=
        'Whether to consent offers or not. Use --consent to consent offers and dont use this flag to unconsent/disallow offers.'
    )

    args = parser.parse_args()
    marketplace = marketplace.Marketplace(namebase_cookie=args.cookie)
    script = Script(marketplace)
    script.consent_potential_offers(domain=args.domain, consent=args.consent)
예제 #2
0
    negotiations = domain_history['negotiations']
    for negotiation in negotiations:
        history = negotiation['history']
        for hist in history['bids']:
            amount = hist['amount']
            id = hist['bidId']
            isAccepted = hist['isAccepted']
            if id == bestBidId and not isAccepted:
                return {"id": id, "amount": float(amount)}

    return {}


if __name__ == '__main__':
    cookie = 'your cookie'
    m = marketplace.Marketplace(namebase_cookie=cookie)
    offers = m.get_offers()
    threshold = 8
    for offer in offers:
        ownerId = offer['ownerId']
        history = m.get_offers_domain_history(domainOwnerId=ownerId)
        bestBidId = history['negotiations'][0]['bestBidId']
        if bestBidId:
            best_offer = get_best_offer(bestBidId=bestBidId,
                                        domain_history=history)
            offerAmount = best_offer['amount']
            id = best_offer['id']
            should_accept = should_accept_offer(offerAmount=offerAmount,
                                                threshold=threshold)
            if should_accept:
                res = m.accept_offer(offer_id=id)