api_statistics_data_deserialize.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "api/api_statistics_data_deserialize.h"
  8. #include "data/data_statistics_chart.h"
  9. #include "statistics/statistics_data_deserialize.h"
  10. namespace Api {
  11. Data::StatisticalGraph StatisticalGraphFromTL(const MTPStatsGraph &tl) {
  12. return tl.match([&](const MTPDstatsGraph &d) {
  13. using namespace Statistic;
  14. const auto zoomToken = d.vzoom_token().has_value()
  15. ? qs(*d.vzoom_token()).toUtf8()
  16. : QByteArray();
  17. return Data::StatisticalGraph{
  18. StatisticalChartFromJSON(qs(d.vjson().data().vdata()).toUtf8()),
  19. zoomToken,
  20. };
  21. }, [&](const MTPDstatsGraphAsync &data) {
  22. return Data::StatisticalGraph{
  23. .zoomToken = qs(data.vtoken()).toUtf8(),
  24. };
  25. }, [&](const MTPDstatsGraphError &data) {
  26. return Data::StatisticalGraph{ .error = qs(data.verror()) };
  27. });
  28. }
  29. } // namespace Api