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

// MessagesSaveDefaultSendAsRequest represents TL type `messages.saveDefaultSendAs#ccfddf96`.
// Change the default peer that should be used when sending messages to a specific group
//
// See https://core.telegram.org/method/messages.saveDefaultSendAs for reference.
type MessagesSaveDefaultSendAsRequest struct {
	// Group
	Peer InputPeerClass
	// The default peer that should be used when sending messages to the group
	SendAs InputPeerClass
}

// MessagesSaveDefaultSendAsRequestTypeID is TL type id of MessagesSaveDefaultSendAsRequest.
const MessagesSaveDefaultSendAsRequestTypeID = 0xccfddf96

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

func ( *MessagesSaveDefaultSendAsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.SendAs == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSaveDefaultSendAsRequest from given interface.
func ( *MessagesSaveDefaultSendAsRequest) ( interface {
	() ( InputPeerClass)
	() ( InputPeerClass)
}) {
	.Peer = .()
	.SendAs = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSaveDefaultSendAsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.saveDefaultSendAs",
		ID:   MessagesSaveDefaultSendAsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "SendAs",
			SchemaName: "send_as",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesSaveDefaultSendAsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.saveDefaultSendAs#ccfddf96 as nil")
	}
	.PutID(MessagesSaveDefaultSendAsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSaveDefaultSendAsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.saveDefaultSendAs#ccfddf96 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.saveDefaultSendAs#ccfddf96: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.saveDefaultSendAs#ccfddf96: field peer: %w", )
	}
	if .SendAs == nil {
		return fmt.Errorf("unable to encode messages.saveDefaultSendAs#ccfddf96: field send_as is nil")
	}
	if  := .SendAs.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.saveDefaultSendAs#ccfddf96: field send_as: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSaveDefaultSendAsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.saveDefaultSendAs#ccfddf96 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.saveDefaultSendAs#ccfddf96: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.saveDefaultSendAs#ccfddf96: field send_as: %w", )
		}
		.SendAs = 
	}
	return nil
}

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

// GetSendAs returns value of SendAs field.
func ( *MessagesSaveDefaultSendAsRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .SendAs
}

// MessagesSaveDefaultSendAs invokes method messages.saveDefaultSendAs#ccfddf96 returning error if any.
// Change the default peer that should be used when sending messages to a specific group
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 SEND_AS_PEER_INVALID: You can't send messages as the specified peer.
//
// See https://core.telegram.org/method/messages.saveDefaultSendAs for reference.
func ( *Client) ( context.Context,  *MessagesSaveDefaultSendAsRequest) (bool, error) {
	var  BoolBox

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