// Code generated by gotdgen, DO NOT EDIT. package tg import ( "context" "errors" "fmt" "sort" "strings" "go.uber.org/multierr" "go.mau.fi/mautrix-telegram/pkg/gotd/bin" "go.mau.fi/mautrix-telegram/pkg/gotd/tdjson" "go.mau.fi/mautrix-telegram/pkg/gotd/tdp" "go.mau.fi/mautrix-telegram/pkg/gotd/tgerr" ) // No-op definition for keeping imports. var ( _ = bin.Buffer{} _ = context.Background() _ = fmt.Stringer(nil) _ = strings.Builder{} _ = errors.Is _ = multierr.AppendInto _ = sort.Ints _ = tdp.Format _ = tgerr.Error{} _ = tdjson.Encoder{} ) // StarGiftAuctionStateNotModified represents TL type `starGiftAuctionStateNotModified#fe333952`. // // See https://core.telegram.org/constructor/starGiftAuctionStateNotModified for reference. type StarGiftAuctionStateNotModified struct { } // StarGiftAuctionStateNotModifiedTypeID is TL type id of StarGiftAuctionStateNotModified. const StarGiftAuctionStateNotModifiedTypeID = 0xfe333952 // construct implements constructor of StarGiftAuctionStateClass. func (s StarGiftAuctionStateNotModified) construct() StarGiftAuctionStateClass { return &s } // Ensuring interfaces in compile-time for StarGiftAuctionStateNotModified. var ( _ bin.Encoder = &StarGiftAuctionStateNotModified{} _ bin.Decoder = &StarGiftAuctionStateNotModified{} _ bin.BareEncoder = &StarGiftAuctionStateNotModified{} _ bin.BareDecoder = &StarGiftAuctionStateNotModified{} _ StarGiftAuctionStateClass = &StarGiftAuctionStateNotModified{} ) func (s *StarGiftAuctionStateNotModified) Zero() bool { if s == nil { return true } return true } // String implements fmt.Stringer. func (s *StarGiftAuctionStateNotModified) String() string { if s == nil { return "StarGiftAuctionStateNotModified(nil)" } type Alias StarGiftAuctionStateNotModified return fmt.Sprintf("StarGiftAuctionStateNotModified%+v", Alias(*s)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*StarGiftAuctionStateNotModified) TypeID() uint32 { return StarGiftAuctionStateNotModifiedTypeID } // TypeName returns name of type in TL schema. func (*StarGiftAuctionStateNotModified) TypeName() string { return "starGiftAuctionStateNotModified" } // TypeInfo returns info about TL type. func (s *StarGiftAuctionStateNotModified) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "starGiftAuctionStateNotModified", ID: StarGiftAuctionStateNotModifiedTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{} return typ } // Encode implements bin.Encoder. func (s *StarGiftAuctionStateNotModified) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode starGiftAuctionStateNotModified#fe333952 as nil") } b.PutID(StarGiftAuctionStateNotModifiedTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *StarGiftAuctionStateNotModified) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode starGiftAuctionStateNotModified#fe333952 as nil") } return nil } // Decode implements bin.Decoder. func (s *StarGiftAuctionStateNotModified) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode starGiftAuctionStateNotModified#fe333952 to nil") } if err := b.ConsumeID(StarGiftAuctionStateNotModifiedTypeID); err != nil { return fmt.Errorf("unable to decode starGiftAuctionStateNotModified#fe333952: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *StarGiftAuctionStateNotModified) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode starGiftAuctionStateNotModified#fe333952 to nil") } return nil } // StarGiftAuctionState represents TL type `starGiftAuctionState#771a4e66`. // // See https://core.telegram.org/constructor/starGiftAuctionState for reference. type StarGiftAuctionState struct { // Version field of StarGiftAuctionState. Version int // StartDate field of StarGiftAuctionState. StartDate int // EndDate field of StarGiftAuctionState. EndDate int // MinBidAmount field of StarGiftAuctionState. MinBidAmount int64 // BidLevels field of StarGiftAuctionState. BidLevels []AuctionBidLevel // TopBidders field of StarGiftAuctionState. TopBidders []int64 // NextRoundAt field of StarGiftAuctionState. NextRoundAt int // LastGiftNum field of StarGiftAuctionState. LastGiftNum int // GiftsLeft field of StarGiftAuctionState. GiftsLeft int // CurrentRound field of StarGiftAuctionState. CurrentRound int // TotalRounds field of StarGiftAuctionState. TotalRounds int // Rounds field of StarGiftAuctionState. Rounds []StarGiftAuctionRoundClass } // StarGiftAuctionStateTypeID is TL type id of StarGiftAuctionState. const StarGiftAuctionStateTypeID = 0x771a4e66 // construct implements constructor of StarGiftAuctionStateClass. func (s StarGiftAuctionState) construct() StarGiftAuctionStateClass { return &s } // Ensuring interfaces in compile-time for StarGiftAuctionState. var ( _ bin.Encoder = &StarGiftAuctionState{} _ bin.Decoder = &StarGiftAuctionState{} _ bin.BareEncoder = &StarGiftAuctionState{} _ bin.BareDecoder = &StarGiftAuctionState{} _ StarGiftAuctionStateClass = &StarGiftAuctionState{} ) func (s *StarGiftAuctionState) Zero() bool { if s == nil { return true } if !(s.Version == 0) { return false } if !(s.StartDate == 0) { return false } if !(s.EndDate == 0) { return false } if !(s.MinBidAmount == 0) { return false } if !(s.BidLevels == nil) { return false } if !(s.TopBidders == nil) { return false } if !(s.NextRoundAt == 0) { return false } if !(s.LastGiftNum == 0) { return false } if !(s.GiftsLeft == 0) { return false } if !(s.CurrentRound == 0) { return false } if !(s.TotalRounds == 0) { return false } if !(s.Rounds == nil) { return false } return true } // String implements fmt.Stringer. func (s *StarGiftAuctionState) String() string { if s == nil { return "StarGiftAuctionState(nil)" } type Alias StarGiftAuctionState return fmt.Sprintf("StarGiftAuctionState%+v", Alias(*s)) } // FillFrom fills StarGiftAuctionState from given interface. func (s *StarGiftAuctionState) FillFrom(from interface { GetVersion() (value int) GetStartDate() (value int) GetEndDate() (value int) GetMinBidAmount() (value int64) GetBidLevels() (value []AuctionBidLevel) GetTopBidders() (value []int64) GetNextRoundAt() (value int) GetLastGiftNum() (value int) GetGiftsLeft() (value int) GetCurrentRound() (value int) GetTotalRounds() (value int) GetRounds() (value []StarGiftAuctionRoundClass) }) { s.Version = from.GetVersion() s.StartDate = from.GetStartDate() s.EndDate = from.GetEndDate() s.MinBidAmount = from.GetMinBidAmount() s.BidLevels = from.GetBidLevels() s.TopBidders = from.GetTopBidders() s.NextRoundAt = from.GetNextRoundAt() s.LastGiftNum = from.GetLastGiftNum() s.GiftsLeft = from.GetGiftsLeft() s.CurrentRound = from.GetCurrentRound() s.TotalRounds = from.GetTotalRounds() s.Rounds = from.GetRounds() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*StarGiftAuctionState) TypeID() uint32 { return StarGiftAuctionStateTypeID } // TypeName returns name of type in TL schema. func (*StarGiftAuctionState) TypeName() string { return "starGiftAuctionState" } // TypeInfo returns info about TL type. func (s *StarGiftAuctionState) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "starGiftAuctionState", ID: StarGiftAuctionStateTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "Version", SchemaName: "version", }, { Name: "StartDate", SchemaName: "start_date", }, { Name: "EndDate", SchemaName: "end_date", }, { Name: "MinBidAmount", SchemaName: "min_bid_amount", }, { Name: "BidLevels", SchemaName: "bid_levels", }, { Name: "TopBidders", SchemaName: "top_bidders", }, { Name: "NextRoundAt", SchemaName: "next_round_at", }, { Name: "LastGiftNum", SchemaName: "last_gift_num", }, { Name: "GiftsLeft", SchemaName: "gifts_left", }, { Name: "CurrentRound", SchemaName: "current_round", }, { Name: "TotalRounds", SchemaName: "total_rounds", }, { Name: "Rounds", SchemaName: "rounds", }, } return typ } // Encode implements bin.Encoder. func (s *StarGiftAuctionState) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode starGiftAuctionState#771a4e66 as nil") } b.PutID(StarGiftAuctionStateTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *StarGiftAuctionState) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode starGiftAuctionState#771a4e66 as nil") } b.PutInt(s.Version) b.PutInt(s.StartDate) b.PutInt(s.EndDate) b.PutLong(s.MinBidAmount) b.PutVectorHeader(len(s.BidLevels)) for idx, v := range s.BidLevels { if err := v.Encode(b); err != nil { return fmt.Errorf("unable to encode starGiftAuctionState#771a4e66: field bid_levels element with index %d: %w", idx, err) } } b.PutVectorHeader(len(s.TopBidders)) for _, v := range s.TopBidders { b.PutLong(v) } b.PutInt(s.NextRoundAt) b.PutInt(s.LastGiftNum) b.PutInt(s.GiftsLeft) b.PutInt(s.CurrentRound) b.PutInt(s.TotalRounds) b.PutVectorHeader(len(s.Rounds)) for idx, v := range s.Rounds { if v == nil { return fmt.Errorf("unable to encode starGiftAuctionState#771a4e66: field rounds element with index %d is nil", idx) } if err := v.Encode(b); err != nil { return fmt.Errorf("unable to encode starGiftAuctionState#771a4e66: field rounds element with index %d: %w", idx, err) } } return nil } // Decode implements bin.Decoder. func (s *StarGiftAuctionState) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode starGiftAuctionState#771a4e66 to nil") } if err := b.ConsumeID(StarGiftAuctionStateTypeID); err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *StarGiftAuctionState) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode starGiftAuctionState#771a4e66 to nil") } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field version: %w", err) } s.Version = value } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field start_date: %w", err) } s.StartDate = value } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field end_date: %w", err) } s.EndDate = value } { value, err := b.Long() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field min_bid_amount: %w", err) } s.MinBidAmount = value } { headerLen, err := b.VectorHeader() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field bid_levels: %w", err) } if headerLen > 0 { s.BidLevels = make([]AuctionBidLevel, 0, headerLen%bin.PreallocateLimit) } for idx := 0; idx < headerLen; idx++ { var value AuctionBidLevel if err := value.Decode(b); err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field bid_levels: %w", err) } s.BidLevels = append(s.BidLevels, value) } } { headerLen, err := b.VectorHeader() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field top_bidders: %w", err) } if headerLen > 0 { s.TopBidders = make([]int64, 0, headerLen%bin.PreallocateLimit) } for idx := 0; idx < headerLen; idx++ { value, err := b.Long() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field top_bidders: %w", err) } s.TopBidders = append(s.TopBidders, value) } } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field next_round_at: %w", err) } s.NextRoundAt = value } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field last_gift_num: %w", err) } s.LastGiftNum = value } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field gifts_left: %w", err) } s.GiftsLeft = value } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field current_round: %w", err) } s.CurrentRound = value } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field total_rounds: %w", err) } s.TotalRounds = value } { headerLen, err := b.VectorHeader() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field rounds: %w", err) } if headerLen > 0 { s.Rounds = make([]StarGiftAuctionRoundClass, 0, headerLen%bin.PreallocateLimit) } for idx := 0; idx < headerLen; idx++ { value, err := DecodeStarGiftAuctionRound(b) if err != nil { return fmt.Errorf("unable to decode starGiftAuctionState#771a4e66: field rounds: %w", err) } s.Rounds = append(s.Rounds, value) } } return nil } // GetVersion returns value of Version field. func (s *StarGiftAuctionState) GetVersion() (value int) { if s == nil { return } return s.Version } // GetStartDate returns value of StartDate field. func (s *StarGiftAuctionState) GetStartDate() (value int) { if s == nil { return } return s.StartDate } // GetEndDate returns value of EndDate field. func (s *StarGiftAuctionState) GetEndDate() (value int) { if s == nil { return } return s.EndDate } // GetMinBidAmount returns value of MinBidAmount field. func (s *StarGiftAuctionState) GetMinBidAmount() (value int64) { if s == nil { return } return s.MinBidAmount } // GetBidLevels returns value of BidLevels field. func (s *StarGiftAuctionState) GetBidLevels() (value []AuctionBidLevel) { if s == nil { return } return s.BidLevels } // GetTopBidders returns value of TopBidders field. func (s *StarGiftAuctionState) GetTopBidders() (value []int64) { if s == nil { return } return s.TopBidders } // GetNextRoundAt returns value of NextRoundAt field. func (s *StarGiftAuctionState) GetNextRoundAt() (value int) { if s == nil { return } return s.NextRoundAt } // GetLastGiftNum returns value of LastGiftNum field. func (s *StarGiftAuctionState) GetLastGiftNum() (value int) { if s == nil { return } return s.LastGiftNum } // GetGiftsLeft returns value of GiftsLeft field. func (s *StarGiftAuctionState) GetGiftsLeft() (value int) { if s == nil { return } return s.GiftsLeft } // GetCurrentRound returns value of CurrentRound field. func (s *StarGiftAuctionState) GetCurrentRound() (value int) { if s == nil { return } return s.CurrentRound } // GetTotalRounds returns value of TotalRounds field. func (s *StarGiftAuctionState) GetTotalRounds() (value int) { if s == nil { return } return s.TotalRounds } // GetRounds returns value of Rounds field. func (s *StarGiftAuctionState) GetRounds() (value []StarGiftAuctionRoundClass) { if s == nil { return } return s.Rounds } // MapRounds returns field Rounds wrapped in StarGiftAuctionRoundClassArray helper. func (s *StarGiftAuctionState) MapRounds() (value StarGiftAuctionRoundClassArray) { return StarGiftAuctionRoundClassArray(s.Rounds) } // StarGiftAuctionStateFinished represents TL type `starGiftAuctionStateFinished#972dabbf`. // // See https://core.telegram.org/constructor/starGiftAuctionStateFinished for reference. type StarGiftAuctionStateFinished struct { // Flags field of StarGiftAuctionStateFinished. Flags bin.Fields // StartDate field of StarGiftAuctionStateFinished. StartDate int // EndDate field of StarGiftAuctionStateFinished. EndDate int // AveragePrice field of StarGiftAuctionStateFinished. AveragePrice int64 // ListedCount field of StarGiftAuctionStateFinished. // // Use SetListedCount and GetListedCount helpers. ListedCount int // FragmentListedCount field of StarGiftAuctionStateFinished. // // Use SetFragmentListedCount and GetFragmentListedCount helpers. FragmentListedCount int // FragmentListedURL field of StarGiftAuctionStateFinished. // // Use SetFragmentListedURL and GetFragmentListedURL helpers. FragmentListedURL string } // StarGiftAuctionStateFinishedTypeID is TL type id of StarGiftAuctionStateFinished. const StarGiftAuctionStateFinishedTypeID = 0x972dabbf // construct implements constructor of StarGiftAuctionStateClass. func (s StarGiftAuctionStateFinished) construct() StarGiftAuctionStateClass { return &s } // Ensuring interfaces in compile-time for StarGiftAuctionStateFinished. var ( _ bin.Encoder = &StarGiftAuctionStateFinished{} _ bin.Decoder = &StarGiftAuctionStateFinished{} _ bin.BareEncoder = &StarGiftAuctionStateFinished{} _ bin.BareDecoder = &StarGiftAuctionStateFinished{} _ StarGiftAuctionStateClass = &StarGiftAuctionStateFinished{} ) func (s *StarGiftAuctionStateFinished) Zero() bool { if s == nil { return true } if !(s.Flags.Zero()) { return false } if !(s.StartDate == 0) { return false } if !(s.EndDate == 0) { return false } if !(s.AveragePrice == 0) { return false } if !(s.ListedCount == 0) { return false } if !(s.FragmentListedCount == 0) { return false } if !(s.FragmentListedURL == "") { return false } return true } // String implements fmt.Stringer. func (s *StarGiftAuctionStateFinished) String() string { if s == nil { return "StarGiftAuctionStateFinished(nil)" } type Alias StarGiftAuctionStateFinished return fmt.Sprintf("StarGiftAuctionStateFinished%+v", Alias(*s)) } // FillFrom fills StarGiftAuctionStateFinished from given interface. func (s *StarGiftAuctionStateFinished) FillFrom(from interface { GetStartDate() (value int) GetEndDate() (value int) GetAveragePrice() (value int64) GetListedCount() (value int, ok bool) GetFragmentListedCount() (value int, ok bool) GetFragmentListedURL() (value string, ok bool) }) { s.StartDate = from.GetStartDate() s.EndDate = from.GetEndDate() s.AveragePrice = from.GetAveragePrice() if val, ok := from.GetListedCount(); ok { s.ListedCount = val } if val, ok := from.GetFragmentListedCount(); ok { s.FragmentListedCount = val } if val, ok := from.GetFragmentListedURL(); ok { s.FragmentListedURL = val } } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*StarGiftAuctionStateFinished) TypeID() uint32 { return StarGiftAuctionStateFinishedTypeID } // TypeName returns name of type in TL schema. func (*StarGiftAuctionStateFinished) TypeName() string { return "starGiftAuctionStateFinished" } // TypeInfo returns info about TL type. func (s *StarGiftAuctionStateFinished) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "starGiftAuctionStateFinished", ID: StarGiftAuctionStateFinishedTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "StartDate", SchemaName: "start_date", }, { Name: "EndDate", SchemaName: "end_date", }, { Name: "AveragePrice", SchemaName: "average_price", }, { Name: "ListedCount", SchemaName: "listed_count", Null: !s.Flags.Has(0), }, { Name: "FragmentListedCount", SchemaName: "fragment_listed_count", Null: !s.Flags.Has(1), }, { Name: "FragmentListedURL", SchemaName: "fragment_listed_url", Null: !s.Flags.Has(1), }, } return typ } // SetFlags sets flags for non-zero fields. func (s *StarGiftAuctionStateFinished) SetFlags() { if !(s.ListedCount == 0) { s.Flags.Set(0) } if !(s.FragmentListedCount == 0) { s.Flags.Set(1) } if !(s.FragmentListedURL == "") { s.Flags.Set(1) } } // Encode implements bin.Encoder. func (s *StarGiftAuctionStateFinished) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode starGiftAuctionStateFinished#972dabbf as nil") } b.PutID(StarGiftAuctionStateFinishedTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *StarGiftAuctionStateFinished) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode starGiftAuctionStateFinished#972dabbf as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { return fmt.Errorf("unable to encode starGiftAuctionStateFinished#972dabbf: field flags: %w", err) } b.PutInt(s.StartDate) b.PutInt(s.EndDate) b.PutLong(s.AveragePrice) if s.Flags.Has(0) { b.PutInt(s.ListedCount) } if s.Flags.Has(1) { b.PutInt(s.FragmentListedCount) } if s.Flags.Has(1) { b.PutString(s.FragmentListedURL) } return nil } // Decode implements bin.Decoder. func (s *StarGiftAuctionStateFinished) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode starGiftAuctionStateFinished#972dabbf to nil") } if err := b.ConsumeID(StarGiftAuctionStateFinishedTypeID); err != nil { return fmt.Errorf("unable to decode starGiftAuctionStateFinished#972dabbf: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *StarGiftAuctionStateFinished) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode starGiftAuctionStateFinished#972dabbf to nil") } { if err := s.Flags.Decode(b); err != nil { return fmt.Errorf("unable to decode starGiftAuctionStateFinished#972dabbf: field flags: %w", err) } } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionStateFinished#972dabbf: field start_date: %w", err) } s.StartDate = value } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionStateFinished#972dabbf: field end_date: %w", err) } s.EndDate = value } { value, err := b.Long() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionStateFinished#972dabbf: field average_price: %w", err) } s.AveragePrice = value } if s.Flags.Has(0) { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionStateFinished#972dabbf: field listed_count: %w", err) } s.ListedCount = value } if s.Flags.Has(1) { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionStateFinished#972dabbf: field fragment_listed_count: %w", err) } s.FragmentListedCount = value } if s.Flags.Has(1) { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode starGiftAuctionStateFinished#972dabbf: field fragment_listed_url: %w", err) } s.FragmentListedURL = value } return nil } // GetStartDate returns value of StartDate field. func (s *StarGiftAuctionStateFinished) GetStartDate() (value int) { if s == nil { return } return s.StartDate } // GetEndDate returns value of EndDate field. func (s *StarGiftAuctionStateFinished) GetEndDate() (value int) { if s == nil { return } return s.EndDate } // GetAveragePrice returns value of AveragePrice field. func (s *StarGiftAuctionStateFinished) GetAveragePrice() (value int64) { if s == nil { return } return s.AveragePrice } // SetListedCount sets value of ListedCount conditional field. func (s *StarGiftAuctionStateFinished) SetListedCount(value int) { s.Flags.Set(0) s.ListedCount = value } // GetListedCount returns value of ListedCount conditional field and // boolean which is true if field was set. func (s *StarGiftAuctionStateFinished) GetListedCount() (value int, ok bool) { if s == nil { return } if !s.Flags.Has(0) { return value, false } return s.ListedCount, true } // SetFragmentListedCount sets value of FragmentListedCount conditional field. func (s *StarGiftAuctionStateFinished) SetFragmentListedCount(value int) { s.Flags.Set(1) s.FragmentListedCount = value } // GetFragmentListedCount returns value of FragmentListedCount conditional field and // boolean which is true if field was set. func (s *StarGiftAuctionStateFinished) GetFragmentListedCount() (value int, ok bool) { if s == nil { return } if !s.Flags.Has(1) { return value, false } return s.FragmentListedCount, true } // SetFragmentListedURL sets value of FragmentListedURL conditional field. func (s *StarGiftAuctionStateFinished) SetFragmentListedURL(value string) { s.Flags.Set(1) s.FragmentListedURL = value } // GetFragmentListedURL returns value of FragmentListedURL conditional field and // boolean which is true if field was set. func (s *StarGiftAuctionStateFinished) GetFragmentListedURL() (value string, ok bool) { if s == nil { return } if !s.Flags.Has(1) { return value, false } return s.FragmentListedURL, true } // StarGiftAuctionStateClassName is schema name of StarGiftAuctionStateClass. const StarGiftAuctionStateClassName = "StarGiftAuctionState" // StarGiftAuctionStateClass represents StarGiftAuctionState generic type. // // See https://core.telegram.org/type/StarGiftAuctionState for reference. // // Example: // // g, err := tg.DecodeStarGiftAuctionState(buf) // if err != nil { // panic(err) // } // switch v := g.(type) { // case *tg.StarGiftAuctionStateNotModified: // starGiftAuctionStateNotModified#fe333952 // case *tg.StarGiftAuctionState: // starGiftAuctionState#771a4e66 // case *tg.StarGiftAuctionStateFinished: // starGiftAuctionStateFinished#972dabbf // default: panic(v) // } type StarGiftAuctionStateClass interface { bin.Encoder bin.Decoder bin.BareEncoder bin.BareDecoder construct() StarGiftAuctionStateClass // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. TypeID() uint32 // TypeName returns name of type in TL schema. TypeName() string // String implements fmt.Stringer. String() string // Zero returns true if current object has a zero value. Zero() bool // AsModified tries to map StarGiftAuctionStateClass to ModifiedStarGiftAuctionState. AsModified() (ModifiedStarGiftAuctionState, bool) } // ModifiedStarGiftAuctionState represents Modified subset of StarGiftAuctionStateClass. type ModifiedStarGiftAuctionState interface { bin.Encoder bin.Decoder bin.BareEncoder bin.BareDecoder construct() StarGiftAuctionStateClass // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. TypeID() uint32 // TypeName returns name of type in TL schema. TypeName() string // String implements fmt.Stringer. String() string // Zero returns true if current object has a zero value. Zero() bool // StartDate field of StarGiftAuctionState. GetStartDate() (value int) // EndDate field of StarGiftAuctionState. GetEndDate() (value int) } // AsModified tries to map StarGiftAuctionStateNotModified to ModifiedStarGiftAuctionState. func (s *StarGiftAuctionStateNotModified) AsModified() (ModifiedStarGiftAuctionState, bool) { value, ok := (StarGiftAuctionStateClass(s)).(ModifiedStarGiftAuctionState) return value, ok } // AsModified tries to map StarGiftAuctionState to ModifiedStarGiftAuctionState. func (s *StarGiftAuctionState) AsModified() (ModifiedStarGiftAuctionState, bool) { value, ok := (StarGiftAuctionStateClass(s)).(ModifiedStarGiftAuctionState) return value, ok } // AsModified tries to map StarGiftAuctionStateFinished to ModifiedStarGiftAuctionState. func (s *StarGiftAuctionStateFinished) AsModified() (ModifiedStarGiftAuctionState, bool) { value, ok := (StarGiftAuctionStateClass(s)).(ModifiedStarGiftAuctionState) return value, ok } // DecodeStarGiftAuctionState implements binary de-serialization for StarGiftAuctionStateClass. func DecodeStarGiftAuctionState(buf *bin.Buffer) (StarGiftAuctionStateClass, error) { id, err := buf.PeekID() if err != nil { return nil, err } switch id { case StarGiftAuctionStateNotModifiedTypeID: // Decoding starGiftAuctionStateNotModified#fe333952. v := StarGiftAuctionStateNotModified{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode StarGiftAuctionStateClass: %w", err) } return &v, nil case StarGiftAuctionStateTypeID: // Decoding starGiftAuctionState#771a4e66. v := StarGiftAuctionState{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode StarGiftAuctionStateClass: %w", err) } return &v, nil case StarGiftAuctionStateFinishedTypeID: // Decoding starGiftAuctionStateFinished#972dabbf. v := StarGiftAuctionStateFinished{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode StarGiftAuctionStateClass: %w", err) } return &v, nil default: return nil, fmt.Errorf("unable to decode StarGiftAuctionStateClass: %w", bin.NewUnexpectedID(id)) } } // StarGiftAuctionState boxes the StarGiftAuctionStateClass providing a helper. type StarGiftAuctionStateBox struct { StarGiftAuctionState StarGiftAuctionStateClass } // Decode implements bin.Decoder for StarGiftAuctionStateBox. func (b *StarGiftAuctionStateBox) Decode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("unable to decode StarGiftAuctionStateBox to nil") } v, err := DecodeStarGiftAuctionState(buf) if err != nil { return fmt.Errorf("unable to decode boxed value: %w", err) } b.StarGiftAuctionState = v return nil } // Encode implements bin.Encode for StarGiftAuctionStateBox. func (b *StarGiftAuctionStateBox) Encode(buf *bin.Buffer) error { if b == nil || b.StarGiftAuctionState == nil { return fmt.Errorf("unable to encode StarGiftAuctionStateClass as nil") } return b.StarGiftAuctionState.Encode(buf) }