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

// MessagesSetChatWallPaperRequest represents TL type `messages.setChatWallPaper#8ffacae1`.
// Set a custom wallpaper »¹ in a specific private chat with another user.
//
// Links:
//  1. https://core.telegram.org/api/wallpapers
//
// See https://core.telegram.org/method/messages.setChatWallPaper for reference.
type MessagesSetChatWallPaperRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Only for Premium¹ users, sets the specified wallpaper for both users of the chat,
	// without requiring confirmation from the other user.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	ForBoth bool
	// If we don't like the new wallpaper the other user of the chat has chosen for us using
	// the for_both flag, we can re-set our previous wallpaper just on our side using this
	// flag.
	Revert bool
	// The private chat where the wallpaper will be set
	Peer InputPeerClass
	// The wallpaper »¹, obtained as described in the wallpaper documentation »²; must
	// not be provided when installing a wallpaper obtained from a
	// messageActionSetChatWallPaper³ service message (id must be provided, instead).
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers
	//  2) https://core.telegram.org/api/wallpapers#uploading-wallpapers
	//  3) https://core.telegram.org/constructor/messageActionSetChatWallPaper
	//
	// Use SetWallpaper and GetWallpaper helpers.
	Wallpaper InputWallPaperClass
	// Wallpaper settings, obtained as described in the wallpaper documentation »¹ or from
	// messageActionSetChatWallPaper².wallpaper.settings.
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers#uploading-wallpapers
	//  2) https://core.telegram.org/constructor/messageActionSetChatWallPaper
	//
	// Use SetSettings and GetSettings helpers.
	Settings WallPaperSettings
	// If the wallpaper was obtained from a messageActionSetChatWallPaper¹ service message,
	// must contain the ID of that message.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/messageActionSetChatWallPaper
	//
	// Use SetID and GetID helpers.
	ID int
}

// MessagesSetChatWallPaperRequestTypeID is TL type id of MessagesSetChatWallPaperRequest.
const MessagesSetChatWallPaperRequestTypeID = 0x8ffacae1

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

func ( *MessagesSetChatWallPaperRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ForBoth == false) {
		return false
	}
	if !(.Revert == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Wallpaper == nil) {
		return false
	}
	if !(.Settings.Zero()) {
		return false
	}
	if !(.ID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSetChatWallPaperRequest from given interface.
func ( *MessagesSetChatWallPaperRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( InputPeerClass)
	() ( InputWallPaperClass,  bool)
	() ( WallPaperSettings,  bool)
	() ( int,  bool)
}) {
	.ForBoth = .()
	.Revert = .()
	.Peer = .()
	if ,  := .();  {
		.Wallpaper = 
	}

	if ,  := .();  {
		.Settings = 
	}

	if ,  := .();  {
		.ID = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSetChatWallPaperRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.setChatWallPaper",
		ID:   MessagesSetChatWallPaperRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ForBoth",
			SchemaName: "for_both",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Revert",
			SchemaName: "revert",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Wallpaper",
			SchemaName: "wallpaper",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Settings",
			SchemaName: "settings",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "ID",
			SchemaName: "id",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesSetChatWallPaperRequest) () {
	if !(.ForBoth == false) {
		.Flags.Set(3)
	}
	if !(.Revert == false) {
		.Flags.Set(4)
	}
	if !(.Wallpaper == nil) {
		.Flags.Set(0)
	}
	if !(.Settings.Zero()) {
		.Flags.Set(2)
	}
	if !(.ID == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesSetChatWallPaperRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setChatWallPaper#8ffacae1 as nil")
	}
	.PutID(MessagesSetChatWallPaperRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSetChatWallPaperRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setChatWallPaper#8ffacae1 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setChatWallPaper#8ffacae1: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.setChatWallPaper#8ffacae1: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setChatWallPaper#8ffacae1: field peer: %w", )
	}
	if .Flags.Has(0) {
		if .Wallpaper == nil {
			return fmt.Errorf("unable to encode messages.setChatWallPaper#8ffacae1: field wallpaper is nil")
		}
		if  := .Wallpaper.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.setChatWallPaper#8ffacae1: field wallpaper: %w", )
		}
	}
	if .Flags.Has(2) {
		if  := .Settings.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.setChatWallPaper#8ffacae1: field settings: %w", )
		}
	}
	if .Flags.Has(1) {
		.PutInt(.ID)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSetChatWallPaperRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setChatWallPaper#8ffacae1 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.setChatWallPaper#8ffacae1: field flags: %w", )
		}
	}
	.ForBoth = .Flags.Has(3)
	.Revert = .Flags.Has(4)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setChatWallPaper#8ffacae1: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(0) {
		,  := DecodeInputWallPaper()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setChatWallPaper#8ffacae1: field wallpaper: %w", )
		}
		.Wallpaper = 
	}
	if .Flags.Has(2) {
		if  := .Settings.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.setChatWallPaper#8ffacae1: field settings: %w", )
		}
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setChatWallPaper#8ffacae1: field id: %w", )
		}
		.ID = 
	}
	return nil
}

// SetForBoth sets value of ForBoth conditional field.
func ( *MessagesSetChatWallPaperRequest) ( bool) {
	if  {
		.Flags.Set(3)
		.ForBoth = true
	} else {
		.Flags.Unset(3)
		.ForBoth = false
	}
}

// GetForBoth returns value of ForBoth conditional field.
func ( *MessagesSetChatWallPaperRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetRevert sets value of Revert conditional field.
func ( *MessagesSetChatWallPaperRequest) ( bool) {
	if  {
		.Flags.Set(4)
		.Revert = true
	} else {
		.Flags.Unset(4)
		.Revert = false
	}
}

// GetRevert returns value of Revert conditional field.
func ( *MessagesSetChatWallPaperRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

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

// SetWallpaper sets value of Wallpaper conditional field.
func ( *MessagesSetChatWallPaperRequest) ( InputWallPaperClass) {
	.Flags.Set(0)
	.Wallpaper = 
}

// GetWallpaper returns value of Wallpaper conditional field and
// boolean which is true if field was set.
func ( *MessagesSetChatWallPaperRequest) () ( InputWallPaperClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Wallpaper, true
}

// SetSettings sets value of Settings conditional field.
func ( *MessagesSetChatWallPaperRequest) ( WallPaperSettings) {
	.Flags.Set(2)
	.Settings = 
}

// GetSettings returns value of Settings conditional field and
// boolean which is true if field was set.
func ( *MessagesSetChatWallPaperRequest) () ( WallPaperSettings,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Settings, true
}

// SetID sets value of ID conditional field.
func ( *MessagesSetChatWallPaperRequest) ( int) {
	.Flags.Set(1)
	.ID = 
}

// GetID returns value of ID conditional field and
// boolean which is true if field was set.
func ( *MessagesSetChatWallPaperRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .ID, true
}

// MessagesSetChatWallPaper invokes method messages.setChatWallPaper#8ffacae1 returning error if any.
// Set a custom wallpaper »¹ in a specific private chat with another user.
//
// Links:
//  1. https://core.telegram.org/api/wallpapers
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 WALLPAPER_INVALID: The specified wallpaper is invalid.
//	400 WALLPAPER_NOT_FOUND: The specified wallpaper could not be found.
//
// See https://core.telegram.org/method/messages.setChatWallPaper for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesSetChatWallPaperRequest) (UpdatesClass, error) {
	var  UpdatesBox

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