-
-
Save chinnurtb/10075993 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "smaato_exchange_connector.h" | |
| #include "rtbkit/plugins/bid_request/openrtb_bid_request.h" | |
| #include "rtbkit/plugins/exchange/http_auction_handler.h" | |
| #include "rtbkit/core/agent_configuration/agent_config.h" | |
| #include "openrtb/openrtb_parsing.h" | |
| #include "soa/types/json_printing.h" | |
| #include <boost/any.hpp> | |
| #include <boost/lexical_cast.hpp> | |
| #include "jml/utils/file_functions.h" | |
| using namespace std; | |
| using namespace Datacratic; | |
| namespace RTBKIT { | |
| SmaatoExchangeConnector::SmaatoExchangeConnector(ServiceBase & owner, const std::string & name) : HttpExchangeConnector(name, owner) { | |
| this->auctionResource = "/auctions"; | |
| this->auctionVerb = "POST"; | |
| } | |
| SmaatoExchangeConnector::SmaatoExchangeConnector(const std::string & name, std::shared_ptr<ServiceProxies> proxies):HttpExchangeConnector(name, proxies) { | |
| this->auctionResource = "/auctions"; | |
| this->auctionVerb = "POST"; | |
| } | |
| ExchangeConnector::ExchangeCompatibility | |
| SmaatoExchangeConnector:: | |
| getCampaignCompatibility(const AgentConfig & config, | |
| bool includeReasons) const { | |
| ExchangeCompatibility result; | |
| result.setCompatible(); | |
| return result; | |
| } | |
| ExchangeConnector::ExchangeCompatibility | |
| SmaatoExchangeConnector:: | |
| getCreativeCompatibility(const Creative & creative, bool includeReasons) const { | |
| ExchangeCompatibility result; | |
| result.setCompatible(); | |
| return result; | |
| } | |
| /*double SmaatoExchangeConnector::getTimeAvailableMs(HttpAuctionHandler & connection, | |
| const HttpHeader & header, | |
| const std::string & payload) { | |
| static const string toFind = "\"tmax\":"; | |
| string::size_type pos = payload.find(toFind); | |
| if (pos == string::npos) { | |
| cerr << "tmax not found in request, using default value" << endl; | |
| return 100.0; | |
| } | |
| int tmax = atoi(payload.c_str() + pos + toFind.length()); | |
| return tmax; | |
| }*/ | |
| std::shared_ptr<BidRequest> SmaatoExchangeConnector::parseBidRequest(HttpAuctionHandler & connection, | |
| const HttpHeader & header, | |
| const std::string & payload) { | |
| std::shared_ptr<BidRequest> res; | |
| // Check json content-type | |
| // Check x-openrtb-version header | |
| cerr << "smaato exchange got request" << endl << header << endl << payload << endl; | |
| // Parse bid request | |
| ML::Parse_Context context("Bid Request", payload.c_str(), payload.size()); | |
| res.reset(OpenRtbBidRequestParser::parseBidRequest(context, exchangeName(), exchangeName())); | |
| cerr << res->toJson() << endl; | |
| return res; | |
| } | |
| HttpResponse SmaatoExchangeConnector::getResponse(const HttpAuctionHandler & connection, | |
| const HttpHeader & requestHeader, | |
| const Auction & auction) const | |
| { | |
| // Check Auction Error | |
| cerr << "getResponse..." << endl; | |
| OpenRTB::BidResponse response; | |
| std::ostringstream stream; | |
| return HttpResponse(200, "application/json", stream.str()); | |
| } | |
| void | |
| SmaatoExchangeConnector:: | |
| setSeatBid(Auction const & auction, | |
| int spotNum, | |
| OpenRTB::BidResponse & response) const { | |
| } | |
| } // namespace RTBKIT | |
| namespace { | |
| using namespace RTBKIT; | |
| struct Init { | |
| Init() { | |
| ExchangeConnector::registerFactory<SmaatoExchangeConnector>(); | |
| } | |
| } init; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment