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

// PhoneSetCallRatingRequest represents TL type `phone.setCallRating#59ead627`.
// Rate a call, returns info about the rating message sent to the official VoIP bot.
//
// See https://core.telegram.org/method/phone.setCallRating for reference.
type PhoneSetCallRatingRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the user decided on their own initiative to rate the call
	UserInitiative bool
	// The call to rate
	Peer InputPhoneCall
	// Rating in 1-5 stars
	Rating int
	// An additional comment
	Comment string
}

// PhoneSetCallRatingRequestTypeID is TL type id of PhoneSetCallRatingRequest.
const PhoneSetCallRatingRequestTypeID = 0x59ead627

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

func ( *PhoneSetCallRatingRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.UserInitiative == false) {
		return false
	}
	if !(.Peer.Zero()) {
		return false
	}
	if !(.Rating == 0) {
		return false
	}
	if !(.Comment == "") {
		return false
	}

	return true
}

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

// FillFrom fills PhoneSetCallRatingRequest from given interface.
func ( *PhoneSetCallRatingRequest) ( interface {
	() ( bool)
	() ( InputPhoneCall)
	() ( int)
	() ( string)
}) {
	.UserInitiative = .()
	.Peer = .()
	.Rating = .()
	.Comment = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PhoneSetCallRatingRequest) () tdp.Type {
	 := tdp.Type{
		Name: "phone.setCallRating",
		ID:   PhoneSetCallRatingRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserInitiative",
			SchemaName: "user_initiative",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Rating",
			SchemaName: "rating",
		},
		{
			Name:       "Comment",
			SchemaName: "comment",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PhoneSetCallRatingRequest) () {
	if !(.UserInitiative == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PhoneSetCallRatingRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.setCallRating#59ead627 as nil")
	}
	.PutID(PhoneSetCallRatingRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneSetCallRatingRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.setCallRating#59ead627 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.setCallRating#59ead627: field flags: %w", )
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.setCallRating#59ead627: field peer: %w", )
	}
	.PutInt(.Rating)
	.PutString(.Comment)
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneSetCallRatingRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.setCallRating#59ead627 to nil")
	}
	if  := .ConsumeID(PhoneSetCallRatingRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode phone.setCallRating#59ead627: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneSetCallRatingRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.setCallRating#59ead627 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.setCallRating#59ead627: field flags: %w", )
		}
	}
	.UserInitiative = .Flags.Has(0)
	{
		if  := .Peer.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.setCallRating#59ead627: field peer: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode phone.setCallRating#59ead627: field rating: %w", )
		}
		.Rating = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode phone.setCallRating#59ead627: field comment: %w", )
		}
		.Comment = 
	}
	return nil
}

// SetUserInitiative sets value of UserInitiative conditional field.
func ( *PhoneSetCallRatingRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.UserInitiative = true
	} else {
		.Flags.Unset(0)
		.UserInitiative = false
	}
}

// GetUserInitiative returns value of UserInitiative conditional field.
func ( *PhoneSetCallRatingRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

// GetRating returns value of Rating field.
func ( *PhoneSetCallRatingRequest) () ( int) {
	if  == nil {
		return
	}
	return .Rating
}

// GetComment returns value of Comment field.
func ( *PhoneSetCallRatingRequest) () ( string) {
	if  == nil {
		return
	}
	return .Comment
}

// PhoneSetCallRating invokes method phone.setCallRating#59ead627 returning error if any.
// Rate a call, returns info about the rating message sent to the official VoIP bot.
//
// Possible errors:
//
//	400 CALL_PEER_INVALID: The provided call peer object is invalid.
//
// See https://core.telegram.org/method/phone.setCallRating for reference.
func ( *Client) ( context.Context,  *PhoneSetCallRatingRequest) (UpdatesClass, error) {
	var  UpdatesBox

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