// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"github.com/gotd/td/bin"
	"github.com/gotd/td/tdjson"
	"github.com/gotd/td/tdp"
	"github.com/gotd/td/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{}
)

// MessagesSendScreenshotNotificationRequest represents TL type `messages.sendScreenshotNotification#c97df020`.
// Notify the other user in a private chat that a screenshot of the chat was taken
//
// See https://core.telegram.org/method/messages.sendScreenshotNotification for reference.
type MessagesSendScreenshotNotificationRequest struct {
	// Other user
	Peer InputPeerClass
	// ID of message that was screenshotted, can be 0
	ReplyToMsgID int
	// Random ID to avoid message resending
	RandomID int64
}

// MessagesSendScreenshotNotificationRequestTypeID is TL type id of MessagesSendScreenshotNotificationRequest.
const MessagesSendScreenshotNotificationRequestTypeID = 0xc97df020

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

func (s *MessagesSendScreenshotNotificationRequest) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.Peer == nil) {
		return false
	}
	if !(s.ReplyToMsgID == 0) {
		return false
	}
	if !(s.RandomID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSendScreenshotNotificationRequest from given interface.
func (s *MessagesSendScreenshotNotificationRequest) FillFrom(from interface {
	GetPeer() (value InputPeerClass)
	GetReplyToMsgID() (value int)
	GetRandomID() (value int64)
}) {
	s.Peer = from.GetPeer()
	s.ReplyToMsgID = from.GetReplyToMsgID()
	s.RandomID = from.GetRandomID()
}

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

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

// TypeInfo returns info about TL type.
func (s *MessagesSendScreenshotNotificationRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messages.sendScreenshotNotification",
		ID:   MessagesSendScreenshotNotificationRequestTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "ReplyToMsgID",
			SchemaName: "reply_to_msg_id",
		},
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *MessagesSendScreenshotNotificationRequest) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode messages.sendScreenshotNotification#c97df020 as nil")
	}
	b.PutID(MessagesSendScreenshotNotificationRequestTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *MessagesSendScreenshotNotificationRequest) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode messages.sendScreenshotNotification#c97df020 as nil")
	}
	if s.Peer == nil {
		return fmt.Errorf("unable to encode messages.sendScreenshotNotification#c97df020: field peer is nil")
	}
	if err := s.Peer.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messages.sendScreenshotNotification#c97df020: field peer: %w", err)
	}
	b.PutInt(s.ReplyToMsgID)
	b.PutLong(s.RandomID)
	return nil
}

// Decode implements bin.Decoder.
func (s *MessagesSendScreenshotNotificationRequest) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode messages.sendScreenshotNotification#c97df020 to nil")
	}
	if err := b.ConsumeID(MessagesSendScreenshotNotificationRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode messages.sendScreenshotNotification#c97df020: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *MessagesSendScreenshotNotificationRequest) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode messages.sendScreenshotNotification#c97df020 to nil")
	}
	{
		value, err := DecodeInputPeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messages.sendScreenshotNotification#c97df020: field peer: %w", err)
		}
		s.Peer = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messages.sendScreenshotNotification#c97df020: field reply_to_msg_id: %w", err)
		}
		s.ReplyToMsgID = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messages.sendScreenshotNotification#c97df020: field random_id: %w", err)
		}
		s.RandomID = value
	}
	return nil
}

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

// GetReplyToMsgID returns value of ReplyToMsgID field.
func (s *MessagesSendScreenshotNotificationRequest) GetReplyToMsgID() (value int) {
	if s == nil {
		return
	}
	return s.ReplyToMsgID
}

// GetRandomID returns value of RandomID field.
func (s *MessagesSendScreenshotNotificationRequest) GetRandomID() (value int64) {
	if s == nil {
		return
	}
	return s.RandomID
}

// MessagesSendScreenshotNotification invokes method messages.sendScreenshotNotification#c97df020 returning error if any.
// Notify the other user in a private chat that a screenshot of the chat was taken
//
// Possible errors:
//
//	400 INPUT_USER_DEACTIVATED: The specified user was deleted.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 YOU_BLOCKED_USER: You blocked this user.
//
// See https://core.telegram.org/method/messages.sendScreenshotNotification for reference.
func (c *Client) MessagesSendScreenshotNotification(ctx context.Context, request *MessagesSendScreenshotNotificationRequest) (UpdatesClass, error) {
	var result UpdatesBox

	if err := c.rpc.Invoke(ctx, request, &result); err != nil {
		return nil, err
	}
	return result.Updates, nil
}
