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

// InputAppEvent represents TL type `inputAppEvent#1d1b1245`.
// Event that occurred in the application.
//
// See https://core.telegram.org/constructor/inputAppEvent for reference.
type InputAppEvent struct {
	// Client's exact timestamp for the event
	Time float64
	// Type of event
	Type string
	// Arbitrary numeric value for more convenient selection of certain event types, or
	// events referring to a certain object
	Peer int64
	// Details of the event
	Data JSONValueClass
}

// InputAppEventTypeID is TL type id of InputAppEvent.
const InputAppEventTypeID = 0x1d1b1245

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

func ( *InputAppEvent) () bool {
	if  == nil {
		return true
	}
	if !(.Time == 0) {
		return false
	}
	if !(.Type == "") {
		return false
	}
	if !(.Peer == 0) {
		return false
	}
	if !(.Data == nil) {
		return false
	}

	return true
}

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

// FillFrom fills InputAppEvent from given interface.
func ( *InputAppEvent) ( interface {
	() ( float64)
	() ( string)
	() ( int64)
	() ( JSONValueClass)
}) {
	.Time = .()
	.Type = .()
	.Peer = .()
	.Data = .()
}

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

// TypeName returns name of type in TL schema.
func (*InputAppEvent) () string {
	return "inputAppEvent"
}

// TypeInfo returns info about TL type.
func ( *InputAppEvent) () tdp.Type {
	 := tdp.Type{
		Name: "inputAppEvent",
		ID:   InputAppEventTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Time",
			SchemaName: "time",
		},
		{
			Name:       "Type",
			SchemaName: "type",
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Data",
			SchemaName: "data",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputAppEvent) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputAppEvent#1d1b1245 as nil")
	}
	.PutID(InputAppEventTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputAppEvent) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputAppEvent#1d1b1245 as nil")
	}
	.PutDouble(.Time)
	.PutString(.Type)
	.PutLong(.Peer)
	if .Data == nil {
		return fmt.Errorf("unable to encode inputAppEvent#1d1b1245: field data is nil")
	}
	if  := .Data.Encode();  != nil {
		return fmt.Errorf("unable to encode inputAppEvent#1d1b1245: field data: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *InputAppEvent) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputAppEvent#1d1b1245 to nil")
	}
	if  := .ConsumeID(InputAppEventTypeID);  != nil {
		return fmt.Errorf("unable to decode inputAppEvent#1d1b1245: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputAppEvent) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputAppEvent#1d1b1245 to nil")
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode inputAppEvent#1d1b1245: field time: %w", )
		}
		.Time = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputAppEvent#1d1b1245: field type: %w", )
		}
		.Type = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputAppEvent#1d1b1245: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := DecodeJSONValue()
		if  != nil {
			return fmt.Errorf("unable to decode inputAppEvent#1d1b1245: field data: %w", )
		}
		.Data = 
	}
	return nil
}

// GetTime returns value of Time field.
func ( *InputAppEvent) () ( float64) {
	if  == nil {
		return
	}
	return .Time
}

// GetType returns value of Type field.
func ( *InputAppEvent) () ( string) {
	if  == nil {
		return
	}
	return .Type
}

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

// GetData returns value of Data field.
func ( *InputAppEvent) () ( JSONValueClass) {
	if  == nil {
		return
	}
	return .Data
}