225 lines
4.8 KiB
Go
Generated
225 lines
4.8 KiB
Go
Generated
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package tg
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
|
|
"go.uber.org/multierr"
|
|
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
|
|
)
|
|
|
|
// 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 (t *TodoCompletion) Zero() bool {
|
|
if t == nil {
|
|
return true
|
|
}
|
|
if !(t.ID == 0) {
|
|
return false
|
|
}
|
|
if !(t.CompletedBy == nil) {
|
|
return false
|
|
}
|
|
if !(t.Date == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (t *TodoCompletion) String() string {
|
|
if t == nil {
|
|
return "TodoCompletion(nil)"
|
|
}
|
|
type Alias TodoCompletion
|
|
return fmt.Sprintf("TodoCompletion%+v", Alias(*t))
|
|
}
|
|
|
|
// FillFrom fills TodoCompletion from given interface.
|
|
func (t *TodoCompletion) FillFrom(from interface {
|
|
GetID() (value int)
|
|
GetCompletedBy() (value PeerClass)
|
|
GetDate() (value int)
|
|
}) {
|
|
t.ID = from.GetID()
|
|
t.CompletedBy = from.GetCompletedBy()
|
|
t.Date = from.GetDate()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*TodoCompletion) TypeID() uint32 {
|
|
return TodoCompletionTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*TodoCompletion) TypeName() string {
|
|
return "todoCompletion"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (t *TodoCompletion) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "todoCompletion",
|
|
ID: TodoCompletionTypeID,
|
|
}
|
|
if t == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "ID",
|
|
SchemaName: "id",
|
|
},
|
|
{
|
|
Name: "CompletedBy",
|
|
SchemaName: "completed_by",
|
|
},
|
|
{
|
|
Name: "Date",
|
|
SchemaName: "date",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (t *TodoCompletion) Encode(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode todoCompletion#221bb5e4 as nil")
|
|
}
|
|
b.PutID(TodoCompletionTypeID)
|
|
return t.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (t *TodoCompletion) EncodeBare(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode todoCompletion#221bb5e4 as nil")
|
|
}
|
|
b.PutInt(t.ID)
|
|
if t.CompletedBy == nil {
|
|
return fmt.Errorf("unable to encode todoCompletion#221bb5e4: field completed_by is nil")
|
|
}
|
|
if err := t.CompletedBy.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode todoCompletion#221bb5e4: field completed_by: %w", err)
|
|
}
|
|
b.PutInt(t.Date)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (t *TodoCompletion) Decode(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode todoCompletion#221bb5e4 to nil")
|
|
}
|
|
if err := b.ConsumeID(TodoCompletionTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode todoCompletion#221bb5e4: %w", err)
|
|
}
|
|
return t.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (t *TodoCompletion) DecodeBare(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode todoCompletion#221bb5e4 to nil")
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode todoCompletion#221bb5e4: field id: %w", err)
|
|
}
|
|
t.ID = value
|
|
}
|
|
{
|
|
value, err := DecodePeer(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode todoCompletion#221bb5e4: field completed_by: %w", err)
|
|
}
|
|
t.CompletedBy = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode todoCompletion#221bb5e4: field date: %w", err)
|
|
}
|
|
t.Date = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetID returns value of ID field.
|
|
func (t *TodoCompletion) GetID() (value int) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.ID
|
|
}
|
|
|
|
// GetCompletedBy returns value of CompletedBy field.
|
|
func (t *TodoCompletion) GetCompletedBy() (value PeerClass) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.CompletedBy
|
|
}
|
|
|
|
// GetDate returns value of Date field.
|
|
func (t *TodoCompletion) GetDate() (value int) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.Date
|
|
}
|