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

// MessagesSendVoteRequest represents TL type `messages.sendVote#10ea6184`.
// Vote in a pollĀ¹
//
// Links:
//  1. https://core.telegram.org/constructor/poll
//
// See https://core.telegram.org/method/messages.sendVote for reference.
type MessagesSendVoteRequest struct {
	// The chat where the poll was sent
	Peer InputPeerClass
	// The message ID of the poll
	MsgID int
	// The options that were chosen
	Options [][]byte
}

// MessagesSendVoteRequestTypeID is TL type id of MessagesSendVoteRequest.
const MessagesSendVoteRequestTypeID = 0x10ea6184

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

func ( *MessagesSendVoteRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.MsgID == 0) {
		return false
	}
	if !(.Options == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSendVoteRequest from given interface.
func ( *MessagesSendVoteRequest) ( interface {
	() ( InputPeerClass)
	() ( int)
	() ( [][]byte)
}) {
	.Peer = .()
	.MsgID = .()
	.Options = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSendVoteRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.sendVote",
		ID:   MessagesSendVoteRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
		},
		{
			Name:       "Options",
			SchemaName: "options",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesSendVoteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendVote#10ea6184 as nil")
	}
	.PutID(MessagesSendVoteRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSendVoteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendVote#10ea6184 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.sendVote#10ea6184: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendVote#10ea6184: field peer: %w", )
	}
	.PutInt(.MsgID)
	.PutVectorHeader(len(.Options))
	for ,  := range .Options {
		.PutBytes()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSendVoteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sendVote#10ea6184 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendVote#10ea6184: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendVote#10ea6184: field msg_id: %w", )
		}
		.MsgID = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendVote#10ea6184: field options: %w", )
		}

		if  > 0 {
			.Options = make([][]byte, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Bytes()
			if  != nil {
				return fmt.Errorf("unable to decode messages.sendVote#10ea6184: field options: %w", )
			}
			.Options = append(.Options, )
		}
	}
	return nil
}

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

// GetMsgID returns value of MsgID field.
func ( *MessagesSendVoteRequest) () ( int) {
	if  == nil {
		return
	}
	return .MsgID
}

// GetOptions returns value of Options field.
func ( *MessagesSendVoteRequest) () ( [][]byte) {
	if  == nil {
		return
	}
	return .Options
}

// MessagesSendVote invokes method messages.sendVote#10ea6184 returning error if any.
// Vote in a pollĀ¹
//
// Links:
//  1. https://core.telegram.org/constructor/poll
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//	400 MESSAGE_POLL_CLOSED: Poll closed.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 OPTIONS_TOO_MUCH: Too many options provided.
//	400 OPTION_INVALID: Invalid option selected.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 REVOTE_NOT_ALLOWED: You cannot change your vote.
//
// See https://core.telegram.org/method/messages.sendVote for reference.
func ( *Client) ( context.Context,  *MessagesSendVoteRequest) (UpdatesClass, error) {
	var  UpdatesBox

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