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

// TodoCompletion represents TL type `todoCompletion#221bb5e4`.
// A completed todo list »¹ item.
//
// Links:
//  1. https://core.telegram.org/api/todo
//
// See https://core.telegram.org/constructor/todoCompletion for reference.
type TodoCompletion struct {
	// The ID of the completed item.
	ID int
	// ID of the user that completed the item.
	CompletedBy PeerClass
	// When was the item completed.
	Date int
}

// TodoCompletionTypeID is TL type id of TodoCompletion.
const TodoCompletionTypeID = 0x221bb5e4

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

func ( *TodoCompletion) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.CompletedBy == nil) {
		return false
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills TodoCompletion from given interface.
func ( *TodoCompletion) ( interface {
	() ( int)
	() ( PeerClass)
	() ( int)
}) {
	.ID = .()
	.CompletedBy = .()
	.Date = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *TodoCompletion) () tdp.Type {
	 := tdp.Type{
		Name: "todoCompletion",
		ID:   TodoCompletionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "CompletedBy",
			SchemaName: "completed_by",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *TodoCompletion) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode todoCompletion#221bb5e4 as nil")
	}
	.PutID(TodoCompletionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *TodoCompletion) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode todoCompletion#221bb5e4 as nil")
	}
	.PutInt(.ID)
	if .CompletedBy == nil {
		return fmt.Errorf("unable to encode todoCompletion#221bb5e4: field completed_by is nil")
	}
	if  := .CompletedBy.Encode();  != nil {
		return fmt.Errorf("unable to encode todoCompletion#221bb5e4: field completed_by: %w", )
	}
	.PutInt(.Date)
	return nil
}

// Decode implements bin.Decoder.
func ( *TodoCompletion) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode todoCompletion#221bb5e4 to nil")
	}
	if  := .ConsumeID(TodoCompletionTypeID);  != nil {
		return fmt.Errorf("unable to decode todoCompletion#221bb5e4: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *TodoCompletion) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode todoCompletion#221bb5e4 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode todoCompletion#221bb5e4: field id: %w", )
		}
		.ID = 
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode todoCompletion#221bb5e4: field completed_by: %w", )
		}
		.CompletedBy = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode todoCompletion#221bb5e4: field date: %w", )
		}
		.Date = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *TodoCompletion) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

// GetCompletedBy returns value of CompletedBy field.
func ( *TodoCompletion) () ( PeerClass) {
	if  == nil {
		return
	}
	return .CompletedBy
}

// GetDate returns value of Date field.
func ( *TodoCompletion) () ( int) {
	if  == nil {
		return
	}
	return .Date
}