diff --git a/map/framework.cpp b/map/framework.cpp index b1a1533150..32a105759f 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -847,8 +847,10 @@ void Framework::FillInfoFromFeatureType(FeatureType const & ft, place_page::Info ASSERT(m_bookingApi, ()); info.m_sponsoredType = SponsoredType::Booking; auto const & baseUrl = info.GetMetadata().Get(feature::Metadata::FMD_WEBSITE); + auto const & hotelId = info.GetMetadata().Get(feature::Metadata::FMD_SPONSORED_ID); info.m_sponsoredUrl = m_bookingApi->GetBookHotelUrl(baseUrl); info.m_sponsoredDescriptionUrl = m_bookingApi->GetDescriptionUrl(baseUrl); + info.m_sponsoredReviewUrl = m_bookingApi->GetHotelReviewsUrl(hotelId, baseUrl); } else if (ftypes::IsOpentableChecker::Instance()(ft)) { diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp index 62cf01724e..560376195c 100644 --- a/map/place_page_info.cpp +++ b/map/place_page_info.cpp @@ -137,6 +137,7 @@ string Info::GetBookmarkCategoryName() const { return m_bookmarkCategoryName; } string const & Info::GetApiUrl() const { return m_apiUrl; } string const & Info::GetSponsoredUrl() const { return m_sponsoredUrl; } string const & Info::GetSponsoredDescriptionUrl() const { return m_sponsoredDescriptionUrl; } +string const & Info::GetSponsoredReviewUrl() const { return m_sponsoredReviewUrl; } string Info::GetRatingFormatted() const { diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp index c1bb6fa83b..82c9d2082c 100644 --- a/map/place_page_info.hpp +++ b/map/place_page_info.hpp @@ -73,6 +73,7 @@ public: string const & GetSponsoredUrl() const; string const & GetSponsoredDescriptionUrl() const; + string const & GetSponsoredReviewUrl() const; /// @returns formatted rating string for booking object, or empty if it isn't booking object string GetRatingFormatted() const; @@ -121,6 +122,7 @@ public: /// Sponsored feature urls. string m_sponsoredUrl; string m_sponsoredDescriptionUrl; + string m_sponsoredReviewUrl; /// Which country this MapObject is in. /// For a country point it will be set to topmost node for country. diff --git a/partners_api/booking_api.cpp b/partners_api/booking_api.cpp index 15a4e4e41c..32d34bf804 100644 --- a/partners_api/booking_api.cpp +++ b/partners_api/booking_api.cpp @@ -192,6 +192,9 @@ void FillHotelInfo(string const & src, HotelInfo & info) auto const reviewsArray = json_object_get(root.get(), "reviews"); info.m_reviews = ParseReviews(reviewsArray); + + my::FromJSONObjectOptionalField(root.get(), "reviews_url", info.m_reviewsParamsUrl); + ASSERT(!info.m_reviewsParamsUrl.empty(), ("Booking reviews url format was changed!")); } void FillPriceAndCurrency(string const & src, string const & currency, string & minPrice, @@ -265,14 +268,25 @@ bool RawApi::GetExtendedInfo(string const & hotelId, string const & lang, string string Api::GetBookHotelUrl(string const & baseUrl) const { + ASSERT(!baseUrl.empty(), ()); return GetDescriptionUrl(baseUrl) + "#availability"; } string Api::GetDescriptionUrl(string const & baseUrl) const { + ASSERT(!baseUrl.empty(), ()); return baseUrl + string("?aid=") + BOOKING_AFFILIATE_ID; } +string Api::GetHotelReviewsUrl(string const & hotelId, string const & baseUrl) const +{ + ASSERT(!baseUrl.empty(), ()); + ASSERT(!hotelId.empty(), ()); + ostringstream os; + os << GetDescriptionUrl(baseUrl) << "&tab=4&label=hotel-" << hotelId << "_reviews"; + return os.str(); +} + void Api::GetMinPrice(string const & hotelId, string const & currency, GetMinPriceCallback const & fn) { diff --git a/partners_api/booking_api.hpp b/partners_api/booking_api.hpp index 2b2885b914..ca9c600ad3 100644 --- a/partners_api/booking_api.hpp +++ b/partners_api/booking_api.hpp @@ -41,6 +41,7 @@ struct HotelInfo vector m_photos; vector m_facilities; vector m_reviews; + string m_reviewsParamsUrl; float m_score = 0.0; uint32_t m_scoreCount = 0; }; @@ -60,6 +61,7 @@ class Api public: string GetBookHotelUrl(string const & baseUrl) const; string GetDescriptionUrl(string const & baseUrl) const; + string GetHotelReviewsUrl(string const & hotelId, string const & baseUrl) const; // Real-time information methods (used for retriving rapidly changing information). // These methods send requests directly to Booking. void GetMinPrice(string const & hotelId, string const & currency, GetMinPriceCallback const & fn);