forked from organicmaps/organicmaps
[promo] signed ids are supported + GetMoreUrl method
This commit is contained in:
parent
59818455e3
commit
6f6f55e554
4 changed files with 24 additions and 3 deletions
|
@ -16,7 +16,9 @@ using namespace platform::tests_support;
|
|||
|
||||
namespace
|
||||
{
|
||||
std::string const kTestId = "TestId";
|
||||
// It should be compatible with test id on test server side at tools/python/ResponseProvider.py:150.
|
||||
// On server side this value is negative because of the prod server does not support unsigned values.
|
||||
std::string const kTestId = "13835058055282357840";
|
||||
|
||||
class ScopedEyeWithAsyncGuiThread : public AsyncGuiThread
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "platform/settings.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
#include "base/string_utils.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
|
@ -93,13 +94,22 @@ void ParseCityGallery(std::string const & src, promo::CityGallery & result)
|
|||
result.m_moreUrl.insert(0, BOOKMARKS_CATALOG_FRONT_URL);
|
||||
}
|
||||
|
||||
std::string ToSignedId(std::string const & id)
|
||||
{
|
||||
uint64_t unsignedId;
|
||||
if (!strings::to_uint64(id, unsignedId))
|
||||
unsignedId = 0;
|
||||
|
||||
return strings::to_string(static_cast<int64_t>(unsignedId));
|
||||
}
|
||||
|
||||
std::string MakeCityGalleryUrl(std::string const & baseUrl, std::string const & id,
|
||||
std::string const & lang)
|
||||
{
|
||||
ASSERT(!baseUrl.empty(), ());
|
||||
ASSERT_EQUAL(baseUrl.back(), '/', ());
|
||||
|
||||
return baseUrl + "gallery/v1/city/" + id + "/?lang=" + lang;
|
||||
return baseUrl + "gallery/v1/city/" + ToSignedId(id) + "/?lang=" + lang;
|
||||
}
|
||||
|
||||
void GetPromoCityGalleryImpl(std::string const & baseUrl, std::string const & id,
|
||||
|
@ -201,6 +211,14 @@ std::string Api::GetPromoLinkForDownloader(std::string const & id, std::string c
|
|||
return MakeCityGalleryUrl(m_baseUrl, id, lang);
|
||||
}
|
||||
|
||||
std::string Api::GetMoreUrl(std::string const & id) const
|
||||
{
|
||||
ASSERT(!m_baseUrl.empty(), ());
|
||||
ASSERT_EQUAL(m_baseUrl.back(), '/', ());
|
||||
|
||||
return m_baseUrl + "v2/mobilefront/city/" + ToSignedId(id);
|
||||
}
|
||||
|
||||
void Api::GetCityGallery(std::string const & id, std::string const & lang,
|
||||
CityGalleryCallback const & onSuccess, OnError const & onError) const
|
||||
{
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
bool NeedToShowAfterBooking() const;
|
||||
std::string GetPromoLinkAfterBooking(std::string const & lang) const;
|
||||
std::string GetPromoLinkForDownloader(std::string const & id, std::string const & lang) const;
|
||||
std::string GetMoreUrl(std::string const & id) const;
|
||||
void GetCityGallery(std::string const & id, std::string const & lang,
|
||||
CityGalleryCallback const & onSuccess, OnError const & onError) const;
|
||||
void GetCityGallery(m2::PointD const & point, std::string const & lang,
|
||||
|
|
|
@ -147,7 +147,7 @@ class ResponseProvider:
|
|||
"/partners/taxi_info": self.partners_yandex_taxi_info,
|
||||
"/partners/get-offers-in-bbox/": self.partners_rent_nearby,
|
||||
"/partners/CalculateByCoords": self.partners_calculate_by_coords,
|
||||
"/gallery/v1/city/TestId/": self.promo_gallery_city,
|
||||
"/gallery/v1/city/-4611686018427193776/": self.promo_gallery_city,
|
||||
}[url]()
|
||||
except:
|
||||
return self.test_404()
|
||||
|
|
Loading…
Add table
Reference in a new issue