Welcome to mirror list, hosted at ThFree Co, Russian Federation.

promo_api.hpp « partners_api - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 33f20941cd59ef07eb7a8d0d1739cfb8a91c0daf (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once

#include "metrics/eye.hpp"

#include "platform/safe_callback.hpp"

#include "geometry/point2d.hpp"

#include <memory>
#include <string>
#include <vector>

#include "private.h"

namespace promo
{
struct Author
{
  std::string m_id;
  std::string m_name;
};
struct LuxCategory
{
  std::string m_name;
  std::string m_color;
};

struct CityGallery
{
  struct Item
  {
    std::string m_name;
    std::string m_url;
    std::string m_imageUrl;
    std::string m_access;
    std::string m_tier;
    Author m_author;
    LuxCategory m_luxCategory;
  };

  std::string m_moreUrl;
  std::vector<Item> m_items;
};

class WebApi
{
public:
  static bool GetCityGalleryById(std::string const & baseUrl, std::string const & id,
                                 std::string const & lang, std::string & result);
};

using CityGalleryCallback = platform::SafeCallback<void(CityGallery const & gallery)>;
using OnError = platform::SafeCallback<void()>;

class Api : public eye::Subscriber
{
public:
  class Delegate
  {
  public:
    virtual ~Delegate() = default;

    virtual std::string GetCityId(m2::PointD const & point) = 0;
  };

  explicit Api(std::string const & baseUrl = BOOKMARKS_CATALOG_FRONT_URL);

  void SetDelegate(std::unique_ptr<Delegate> delegate);
  void OnEnterForeground();
  bool NeedToShowAfterBooking() const;
  std::string GetPromoLinkAfterBooking(std::string const & lang) const;
  std::string GetPromoLinkForDownloader(std::string const & id, std::string const & lang) 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,
                      CityGalleryCallback const & onSuccess, OnError const & onError) const;

  // eye::Subscriber overrides:
  void OnMapObjectEvent(eye::MapObject const & poi) override;

private:
  std::unique_ptr<Delegate> m_delegate;

  std::string const m_baseUrl;
  std::string m_bookingPromoAwaitingForId;
};
}  // namespace promo