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

// MessagesGetMessagesViewsRequest represents TL type `messages.getMessagesViews#5784d3e1`.
// Get and increase the view counter of a message sent or forwarded from a channelĀ¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/method/messages.getMessagesViews for reference.
type MessagesGetMessagesViewsRequest struct {
	// Peer where the message was found
	Peer InputPeerClass
	// ID of message
	ID []int
	// Whether to mark the message as viewed and increment the view counter
	Increment bool
}

// MessagesGetMessagesViewsRequestTypeID is TL type id of MessagesGetMessagesViewsRequest.
const MessagesGetMessagesViewsRequestTypeID = 0x5784d3e1

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

func ( *MessagesGetMessagesViewsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.ID == nil) {
		return false
	}
	if !(.Increment == false) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesGetMessagesViewsRequest from given interface.
func ( *MessagesGetMessagesViewsRequest) ( interface {
	() ( InputPeerClass)
	() ( []int)
	() ( bool)
}) {
	.Peer = .()
	.ID = .()
	.Increment = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesGetMessagesViewsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getMessagesViews",
		ID:   MessagesGetMessagesViewsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Increment",
			SchemaName: "increment",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesGetMessagesViewsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getMessagesViews#5784d3e1 as nil")
	}
	.PutID(MessagesGetMessagesViewsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesGetMessagesViewsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getMessagesViews#5784d3e1 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.getMessagesViews#5784d3e1: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getMessagesViews#5784d3e1: field peer: %w", )
	}
	.PutVectorHeader(len(.ID))
	for ,  := range .ID {
		.PutInt()
	}
	.PutBool(.Increment)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesGetMessagesViewsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getMessagesViews#5784d3e1 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getMessagesViews#5784d3e1: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getMessagesViews#5784d3e1: field id: %w", )
		}

		if  > 0 {
			.ID = make([]int, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Int()
			if  != nil {
				return fmt.Errorf("unable to decode messages.getMessagesViews#5784d3e1: field id: %w", )
			}
			.ID = append(.ID, )
		}
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getMessagesViews#5784d3e1: field increment: %w", )
		}
		.Increment = 
	}
	return nil
}

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

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

// GetIncrement returns value of Increment field.
func ( *MessagesGetMessagesViewsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Increment
}

// MessagesGetMessagesViews invokes method messages.getMessagesViews#5784d3e1 returning error if any.
// Get and increase the view counter of a message sent or forwarded from a channelĀ¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	406 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 CHAT_ID_INVALID: The provided chat id is invalid.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/messages.getMessagesViews for reference.
func ( *Client) ( context.Context,  *MessagesGetMessagesViewsRequest) (*MessagesMessageViews, error) {
	var  MessagesMessageViews

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