forked from organicmaps/organicmaps
generate opentable URL by using sponsored id
This commit is contained in:
parent
6837b68533
commit
58d5238d15
9 changed files with 47 additions and 7 deletions
|
@ -52,6 +52,7 @@ else
|
|||
#define BOOKING_SECRET ""
|
||||
#define UBER_SERVER_TOKEN ""
|
||||
#define UBER_CLIENT_ID ""
|
||||
#define OPENTABLE_AFFILATE_ID ""
|
||||
#define TRACKING_REALTIME_HOST ""
|
||||
#define TRACKING_REALTIME_PORT 0
|
||||
#define TRACKING_HISTORICAL_HOST ""
|
||||
|
|
|
@ -55,7 +55,6 @@ void OpentableDataset::PreprocessMatchedOsmObject(ObjectId const matchedObjId, F
|
|||
auto restaurant = GetObjectById(matchedObjId);
|
||||
auto & metadata = params.GetMetadata();
|
||||
metadata.Set(feature::Metadata::FMD_SPONSORED_ID, strings::to_string(restaurant.m_id.Get()));
|
||||
metadata.Set(feature::Metadata::FMD_WEBSITE, restaurant.m_descUrl);
|
||||
|
||||
// params.AddAddress(restaurant.address);
|
||||
// TODO(mgsergio): addr:full ???
|
||||
|
|
|
@ -74,6 +74,8 @@
|
|||
#include "geometry/rect2d.hpp"
|
||||
#include "geometry/triangle2d.hpp"
|
||||
|
||||
#include "partners_api/opentable_api.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
#include "base/math.hpp"
|
||||
#include "base/scope_guard.hpp"
|
||||
|
@ -792,14 +794,17 @@ void Framework::FillInfoFromFeatureType(FeatureType const & ft, place_page::Info
|
|||
if (ftypes::IsBookingChecker::Instance()(ft))
|
||||
{
|
||||
info.m_sponsoredType = SponsoredType::Booking;
|
||||
string const & baseUrl = info.GetMetadata().Get(feature::Metadata::FMD_WEBSITE);
|
||||
info.m_sponsoredUrl = GetBookingApi().GetBookingUrl(baseUrl);
|
||||
auto const & baseUrl = info.GetMetadata().Get(feature::Metadata::FMD_WEBSITE);
|
||||
info.m_sponsoredUrl = GetBookingApi().GetBookHotelUrl(baseUrl);
|
||||
info.m_sponsoredDescriptionUrl = GetBookingApi().GetDescriptionUrl(baseUrl);
|
||||
}
|
||||
else if (ftypes::IsOpentableChecker::Instance()(ft))
|
||||
{
|
||||
info.m_sponsoredType = SponsoredType::Opentable;
|
||||
info.m_sponsoredUrl = info.GetMetadata().Get(feature::Metadata::FMD_WEBSITE);
|
||||
auto const & sponsoredId = info.GetMetadata().Get(feature::Metadata::FMD_SPONSORED_ID);
|
||||
auto const & url = opentable::Api::GetBookTableUrl(sponsoredId);
|
||||
info.m_sponsoredUrl = url;
|
||||
info.m_sponsoredDescriptionUrl = url;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ BookingApi::BookingApi() : m_affiliateId(BOOKING_AFFILIATE_ID), m_testingMode(fa
|
|||
m_apiUrl = "https://" + ss.str() + "@distribution-xml.booking.com/json/bookings.";
|
||||
}
|
||||
|
||||
string BookingApi::GetBookingUrl(string const & baseUrl, string const & /* lang */) const
|
||||
string BookingApi::GetBookHotelUrl(string const & baseUrl, string const & /* lang */) const
|
||||
{
|
||||
return GetDescriptionUrl(baseUrl) + "#availability";
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ public:
|
|||
static constexpr const char kDefaultCurrency[1] = {0};
|
||||
|
||||
BookingApi();
|
||||
string GetBookingUrl(string const & baseUrl, string const & lang = string()) const;
|
||||
string GetBookHotelUrl(string const & baseUrl, string const & lang = string()) const;
|
||||
string GetDescriptionUrl(string const & baseUrl, string const & lang = string()) const;
|
||||
inline void SetTestingMode(bool testing) { m_testingMode = testing; }
|
||||
|
||||
|
|
21
partners_api/opentable_api.cpp
Normal file
21
partners_api/opentable_api.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include "partners_api/opentable_api.hpp"
|
||||
|
||||
#include "std/sstream.hpp"
|
||||
|
||||
#include "private.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
auto const kOpentableBaseUrl = "http://www.opentable.com/restaurant/profile/";
|
||||
} // namespace
|
||||
|
||||
namespace opentable
|
||||
{
|
||||
// static
|
||||
string Api::GetBookTableUrl(string const & restaurantId)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << kOpentableBaseUrl << restaurantId << "?ref=" << OPENTABLE_AFFILATE_ID;
|
||||
return ss.str();
|
||||
}
|
||||
} // namespace opentable
|
12
partners_api/opentable_api.hpp
Normal file
12
partners_api/opentable_api.hpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include "std/string.hpp"
|
||||
|
||||
namespace opentable
|
||||
{
|
||||
class Api
|
||||
{
|
||||
public:
|
||||
static string GetBookTableUrl(string const & restaurantId);
|
||||
};
|
||||
} // namespace opentable
|
|
@ -10,8 +10,10 @@ include($$ROOT_DIR/common.pri)
|
|||
|
||||
SOURCES += \
|
||||
booking_api.cpp \
|
||||
opentable_api.cpp \
|
||||
uber_api.cpp \
|
||||
|
||||
HEADERS += \
|
||||
booking_api.hpp \
|
||||
opentable_api.hpp \
|
||||
uber_api.hpp \
|
||||
|
|
|
@ -6,7 +6,7 @@ UNIT_TEST(Booking_SmokeTest)
|
|||
{
|
||||
BookingApi api;
|
||||
|
||||
string url = api.GetBookingUrl("http://someurl.com");
|
||||
string url = api.GetBookHotelUrl("http://someurl.com");
|
||||
TEST(!url.empty(), ());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue