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

// PhoneSaveDefaultGroupCallJoinAsRequest represents TL type `phone.saveDefaultGroupCallJoinAs#575e1f8c`.
// Set the default peer that will be used to join a group call in a specific dialog.
//
// See https://core.telegram.org/method/phone.saveDefaultGroupCallJoinAs for reference.
type PhoneSaveDefaultGroupCallJoinAsRequest struct {
	// The dialog
	Peer InputPeerClass
	// The default peer that will be used to join group calls in this dialog, presenting
	// yourself as a specific user/channel.
	JoinAs InputPeerClass
}

// PhoneSaveDefaultGroupCallJoinAsRequestTypeID is TL type id of PhoneSaveDefaultGroupCallJoinAsRequest.
const PhoneSaveDefaultGroupCallJoinAsRequestTypeID = 0x575e1f8c

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

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

	return true
}

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

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

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

// TypeName returns name of type in TL schema.
func (*PhoneSaveDefaultGroupCallJoinAsRequest) () string {
	return "phone.saveDefaultGroupCallJoinAs"
}

// TypeInfo returns info about TL type.
func ( *PhoneSaveDefaultGroupCallJoinAsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "phone.saveDefaultGroupCallJoinAs",
		ID:   PhoneSaveDefaultGroupCallJoinAsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "JoinAs",
			SchemaName: "join_as",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PhoneSaveDefaultGroupCallJoinAsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.saveDefaultGroupCallJoinAs#575e1f8c as nil")
	}
	.PutID(PhoneSaveDefaultGroupCallJoinAsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneSaveDefaultGroupCallJoinAsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.saveDefaultGroupCallJoinAs#575e1f8c as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode phone.saveDefaultGroupCallJoinAs#575e1f8c: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.saveDefaultGroupCallJoinAs#575e1f8c: field peer: %w", )
	}
	if .JoinAs == nil {
		return fmt.Errorf("unable to encode phone.saveDefaultGroupCallJoinAs#575e1f8c: field join_as is nil")
	}
	if  := .JoinAs.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.saveDefaultGroupCallJoinAs#575e1f8c: field join_as: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneSaveDefaultGroupCallJoinAsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.saveDefaultGroupCallJoinAs#575e1f8c to nil")
	}
	if  := .ConsumeID(PhoneSaveDefaultGroupCallJoinAsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode phone.saveDefaultGroupCallJoinAs#575e1f8c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneSaveDefaultGroupCallJoinAsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.saveDefaultGroupCallJoinAs#575e1f8c to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode phone.saveDefaultGroupCallJoinAs#575e1f8c: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode phone.saveDefaultGroupCallJoinAs#575e1f8c: field join_as: %w", )
		}
		.JoinAs = 
	}
	return nil
}

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

// GetJoinAs returns value of JoinAs field.
func ( *PhoneSaveDefaultGroupCallJoinAsRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .JoinAs
}

// PhoneSaveDefaultGroupCallJoinAs invokes method phone.saveDefaultGroupCallJoinAs#575e1f8c returning error if any.
// Set the default peer that will be used to join a group call in a specific dialog.
//
// Possible errors:
//
//	400 JOIN_AS_PEER_INVALID: The specified peer cannot be used to join a group call.
//
// See https://core.telegram.org/method/phone.saveDefaultGroupCallJoinAs for reference.
func ( *Client) ( context.Context,  *PhoneSaveDefaultGroupCallJoinAsRequest) (bool, error) {
	var  BoolBox

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