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

// PaymentsSaveStarGiftRequest represents TL type `payments.saveStarGift#2a2a697c`.
// Display or remove a received gift »¹ from our profile.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// See https://core.telegram.org/method/payments.saveStarGift for reference.
type PaymentsSaveStarGiftRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, hides the gift from our profile.
	Unsave bool
	// The gift to display or remove.
	Stargift InputSavedStarGiftClass
}

// PaymentsSaveStarGiftRequestTypeID is TL type id of PaymentsSaveStarGiftRequest.
const PaymentsSaveStarGiftRequestTypeID = 0x2a2a697c

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

func ( *PaymentsSaveStarGiftRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Unsave == false) {
		return false
	}
	if !(.Stargift == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsSaveStarGiftRequest from given interface.
func ( *PaymentsSaveStarGiftRequest) ( interface {
	() ( bool)
	() ( InputSavedStarGiftClass)
}) {
	.Unsave = .()
	.Stargift = .()
}

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

// TypeName returns name of type in TL schema.
func (*PaymentsSaveStarGiftRequest) () string {
	return "payments.saveStarGift"
}

// TypeInfo returns info about TL type.
func ( *PaymentsSaveStarGiftRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.saveStarGift",
		ID:   PaymentsSaveStarGiftRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Unsave",
			SchemaName: "unsave",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Stargift",
			SchemaName: "stargift",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *PaymentsSaveStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.saveStarGift#2a2a697c as nil")
	}
	.PutID(PaymentsSaveStarGiftRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsSaveStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.saveStarGift#2a2a697c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.saveStarGift#2a2a697c: field flags: %w", )
	}
	if .Stargift == nil {
		return fmt.Errorf("unable to encode payments.saveStarGift#2a2a697c: field stargift is nil")
	}
	if  := .Stargift.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.saveStarGift#2a2a697c: field stargift: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PaymentsSaveStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.saveStarGift#2a2a697c to nil")
	}
	if  := .ConsumeID(PaymentsSaveStarGiftRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode payments.saveStarGift#2a2a697c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsSaveStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.saveStarGift#2a2a697c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.saveStarGift#2a2a697c: field flags: %w", )
		}
	}
	.Unsave = .Flags.Has(0)
	{
		,  := DecodeInputSavedStarGift()
		if  != nil {
			return fmt.Errorf("unable to decode payments.saveStarGift#2a2a697c: field stargift: %w", )
		}
		.Stargift = 
	}
	return nil
}

// SetUnsave sets value of Unsave conditional field.
func ( *PaymentsSaveStarGiftRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Unsave = true
	} else {
		.Flags.Unset(0)
		.Unsave = false
	}
}

// GetUnsave returns value of Unsave conditional field.
func ( *PaymentsSaveStarGiftRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetStargift returns value of Stargift field.
func ( *PaymentsSaveStarGiftRequest) () ( InputSavedStarGiftClass) {
	if  == nil {
		return
	}
	return .Stargift
}

// PaymentsSaveStarGift invokes method payments.saveStarGift#2a2a697c returning error if any.
// Display or remove a received gift »¹ from our profile.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// Possible errors:
//
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//	400 SAVED_ID_EMPTY: The passed inputSavedStarGiftChat.saved_id is empty.
//	400 STARGIFT_OWNER_INVALID: You cannot transfer or sell a gift owned by another user.
//	400 USER_ID_INVALID: The provided user ID is invalid.
//
// See https://core.telegram.org/method/payments.saveStarGift for reference.
func ( *Client) ( context.Context,  *PaymentsSaveStarGiftRequest) (bool, error) {
	var  BoolBox

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