blob: 484152f1f129676a5f1126372596a9881d1694d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#pragma once
#include "partners_api/utils.hpp"
#include "geometry/latlon.hpp"
#include "geometry/rect2d.hpp"
#include "base/worker_thread.hpp"
#include <cstdint>
#include <functional>
#include <string>
#include <vector>
namespace cian
{
extern std::string const kBaseUrl;
class RawApi
{
public:
static partners_api::http::Result GetRentNearby(m2::RectD const & rect,
std::string const & url = kBaseUrl);
};
struct RentOffer
{
std::string m_flatType;
uint8_t m_roomsCount = 0;
double m_priceRur = 0.0;
uint8_t m_floorNumber = 0;
uint8_t m_floorsCount = 0;
std::string m_url;
std::string m_address;
// No need to use offer when it is not fully filled.
bool IsValid() const
{
return !m_flatType.empty() && m_roomsCount && m_priceRur != 0.0 && m_floorNumber &&
m_floorsCount && !m_url.empty() && !m_address.empty();
}
};
struct RentPlace
{
ms::LatLon m_latlon;
std::string m_url;
std::vector<RentOffer> m_offers;
};
class Api
{
public:
using RentNearbyCallback =
std::function<void(std::vector<RentPlace> const & places, uint64_t const requestId)>;
using ErrorCallback = std::function<void(int httpCode, uint64_t const requestId)>;
explicit Api(std::string const & baseUrl = kBaseUrl);
virtual ~Api();
uint64_t GetRentNearby(ms::LatLon const & latlon, RentNearbyCallback const & onSuccess,
ErrorCallback const & onError);
static bool IsCitySupported(std::string const & city);
static std::string const & GetMainPageUrl();
private:
uint64_t m_requestId = 0;
std::string m_baseUrl;
base::WorkerThread m_worker;
};
} // namespace cian
|