aboutsummaryrefslogtreecommitdiffhomepage
path: root/td/telegram/StarGiftAuctionState.h
blob: b80caeecb639d5fdce6a76b1445c921acc9c9afd (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
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2026
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once

#include "td/telegram/AuctionBidLevel.h"
#include "td/telegram/StarGiftAuctionRound.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UserId.h"

#include "td/utils/common.h"

namespace td {

class StarGiftAuctionUserState;
class Td;

class StarGiftAuctionState {
  bool is_not_modified_ = false;
  bool is_active_ = false;
  int32 start_date_ = 0;
  int32 end_date_ = 0;

  // active
  int32 version_ = 0;
  int64 min_bid_amount_ = 0;
  vector<AuctionBidLevel> bid_levels_;
  vector<UserId> top_bidder_user_ids_;
  vector<StarGiftAuctionRound> rounds_;
  int32 next_round_at_ = 0;
  int32 last_gift_num_ = 0;
  int32 gifts_left_ = 0;
  int32 current_round_ = 0;
  int32 total_rounds_ = 0;

  // finished
  int64 average_price_ = 0;
  int32 listed_count_ = 0;
  int32 fragment_listed_count_ = 0;
  string fragment_listed_url_;

  friend bool operator==(const StarGiftAuctionState &lhs, const StarGiftAuctionState &rhs);

 public:
  StarGiftAuctionState() = default;

  explicit StarGiftAuctionState(const telegram_api::object_ptr<telegram_api::StarGiftAuctionState> &state_ptr);

  bool is_not_modified() const {
    return is_not_modified_;
  }

  int32 get_version() const {
    return version_;
  }

  td_api::object_ptr<td_api::AuctionState> get_auction_state_object(Td *td,
                                                                    const StarGiftAuctionUserState &user_state) const;
};

bool operator==(const StarGiftAuctionState &lhs, const StarGiftAuctionState &rhs);

inline bool operator!=(const StarGiftAuctionState &lhs, const StarGiftAuctionState &rhs) {
  return !(lhs == rhs);
}

}  // namespace td