// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// 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{}
)

// MessagesGetPollVotesRequest represents TL type `messages.getPollVotes#b86e380e`.
// Get poll results for non-anonymous polls
//
// See https://core.telegram.org/method/messages.getPollVotes for reference.
type MessagesGetPollVotesRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Chat where the poll was sent
	Peer InputPeerClass
	// Message ID
	ID int
	// Get only results for the specified poll option
	//
	// Use SetOption and GetOption helpers.
	Option []byte
	// Offset for results, taken from the next_offset field of messages.votesListĀ¹,
	// initially an empty string. Note: if no more results are available, the method call
	// will return an empty next_offset; thus, avoid providing the next_offset returned in
	// messages.votesListĀ² if it is empty, to avoid an infinite loop.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/messages.votesList
	//  2) https://core.telegram.org/constructor/messages.votesList
	//
	// Use SetOffset and GetOffset helpers.
	Offset string
	// Number of results to return
	Limit int
}

// MessagesGetPollVotesRequestTypeID is TL type id of MessagesGetPollVotesRequest.
const MessagesGetPollVotesRequestTypeID = 0xb86e380e

// Ensuring interfaces in compile-time for MessagesGetPollVotesRequest.
var (
	_ bin.Encoder     = &MessagesGetPollVotesRequest{}
	_ bin.Decoder     = &MessagesGetPollVotesRequest{}
	_ bin.BareEncoder = &MessagesGetPollVotesRequest{}
	_ bin.BareDecoder = &MessagesGetPollVotesRequest{}
)

func ( *MessagesGetPollVotesRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Option == nil) {
		return false
	}
	if !(.Offset == "") {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *MessagesGetPollVotesRequest) () string {
	if  == nil {
		return "MessagesGetPollVotesRequest(nil)"
	}
	type  MessagesGetPollVotesRequest
	return fmt.Sprintf("MessagesGetPollVotesRequest%+v", (*))
}

// FillFrom fills MessagesGetPollVotesRequest from given interface.
func ( *MessagesGetPollVotesRequest) ( interface {
	() ( InputPeerClass)
	() ( int)
	() ( []byte,  bool)
	() ( string,  bool)
	() ( int)
}) {
	.Peer = .()
	.ID = .()
	if ,  := .();  {
		.Option = 
	}

	if ,  := .();  {
		.Offset = 
	}

	.Limit = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessagesGetPollVotesRequest) () uint32 {
	return MessagesGetPollVotesRequestTypeID
}

// TypeName returns name of type in TL schema.
func (*MessagesGetPollVotesRequest) () string {
	return "messages.getPollVotes"
}

// TypeInfo returns info about TL type.
func ( *MessagesGetPollVotesRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getPollVotes",
		ID:   MessagesGetPollVotesRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Option",
			SchemaName: "option",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesGetPollVotesRequest) () {
	if !(.Option == nil) {
		.Flags.Set(0)
	}
	if !(.Offset == "") {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesGetPollVotesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getPollVotes#b86e380e as nil")
	}
	.PutID(MessagesGetPollVotesRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesGetPollVotesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getPollVotes#b86e380e as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getPollVotes#b86e380e: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.getPollVotes#b86e380e: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getPollVotes#b86e380e: field peer: %w", )
	}
	.PutInt(.ID)
	if .Flags.Has(0) {
		.PutBytes(.Option)
	}
	if .Flags.Has(1) {
		.PutString(.Offset)
	}
	.PutInt(.Limit)
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesGetPollVotesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getPollVotes#b86e380e to nil")
	}
	if  := .ConsumeID(MessagesGetPollVotesRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.getPollVotes#b86e380e: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesGetPollVotesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getPollVotes#b86e380e to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.getPollVotes#b86e380e: field flags: %w", )
		}
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getPollVotes#b86e380e: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getPollVotes#b86e380e: field id: %w", )
		}
		.ID = 
	}
	if .Flags.Has(0) {
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getPollVotes#b86e380e: field option: %w", )
		}
		.Option = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getPollVotes#b86e380e: field offset: %w", )
		}
		.Offset = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getPollVotes#b86e380e: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

// GetPeer returns value of Peer field.
func ( *MessagesGetPollVotesRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetID returns value of ID field.
func ( *MessagesGetPollVotesRequest) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

// SetOption sets value of Option conditional field.
func ( *MessagesGetPollVotesRequest) ( []byte) {
	.Flags.Set(0)
	.Option = 
}

// GetOption returns value of Option conditional field and
// boolean which is true if field was set.
func ( *MessagesGetPollVotesRequest) () ( []byte,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Option, true
}

// SetOffset sets value of Offset conditional field.
func ( *MessagesGetPollVotesRequest) ( string) {
	.Flags.Set(1)
	.Offset = 
}

// GetOffset returns value of Offset conditional field and
// boolean which is true if field was set.
func ( *MessagesGetPollVotesRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Offset, true
}

// GetLimit returns value of Limit field.
func ( *MessagesGetPollVotesRequest) () ( int) {
	if  == nil {
		return
	}
	return .Limit
}

// MessagesGetPollVotes invokes method messages.getPollVotes#b86e380e returning error if any.
// Get poll results for non-anonymous polls
//
// Possible errors:
//
//	403 BROADCAST_FORBIDDEN: Channel poll voters and reactions cannot be fetched to prevent deanonymization.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	403 POLL_VOTE_REQUIRED: Cast a vote in the poll before calling this method.
//
// See https://core.telegram.org/method/messages.getPollVotes for reference.
func ( *Client) ( context.Context,  *MessagesGetPollVotesRequest) (*MessagesVotesList, error) {
	var  MessagesVotesList

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return &, nil
}