// 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{} ) // ExportedContactToken represents TL type `exportedContactToken#41bf109b`. // Describes a temporary profile link¹. // // Links: // 1. https://core.telegram.org/api/links#temporary-profile-links // // See https://core.telegram.org/constructor/exportedContactToken for reference. type ExportedContactToken struct { // The temporary profile link¹. // // Links: // 1) https://core.telegram.org/api/links#temporary-profile-links URL string // Its expiration date Expires int } // ExportedContactTokenTypeID is TL type id of ExportedContactToken. const ExportedContactTokenTypeID = 0x41bf109b // Ensuring interfaces in compile-time for ExportedContactToken. var ( _ bin.Encoder = &ExportedContactToken{} _ bin.Decoder = &ExportedContactToken{} _ bin.BareEncoder = &ExportedContactToken{} _ bin.BareDecoder = &ExportedContactToken{} ) func (e *ExportedContactToken) Zero() bool { if e == nil { return true } if !(e.URL == "") { return false } if !(e.Expires == 0) { return false } return true } // String implements fmt.Stringer. func (e *ExportedContactToken) String() string { if e == nil { return "ExportedContactToken(nil)" } type Alias ExportedContactToken return fmt.Sprintf("ExportedContactToken%+v", Alias(*e)) } // FillFrom fills ExportedContactToken from given interface. func (e *ExportedContactToken) FillFrom(from interface { GetURL() (value string) GetExpires() (value int) }) { e.URL = from.GetURL() e.Expires = from.GetExpires() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*ExportedContactToken) TypeID() uint32 { return ExportedContactTokenTypeID } // TypeName returns name of type in TL schema. func (*ExportedContactToken) TypeName() string { return "exportedContactToken" } // TypeInfo returns info about TL type. func (e *ExportedContactToken) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "exportedContactToken", ID: ExportedContactTokenTypeID, } if e == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "URL", SchemaName: "url", }, { Name: "Expires", SchemaName: "expires", }, } return typ } // Encode implements bin.Encoder. func (e *ExportedContactToken) Encode(b *bin.Buffer) error { if e == nil { return fmt.Errorf("can't encode exportedContactToken#41bf109b as nil") } b.PutID(ExportedContactTokenTypeID) return e.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (e *ExportedContactToken) EncodeBare(b *bin.Buffer) error { if e == nil { return fmt.Errorf("can't encode exportedContactToken#41bf109b as nil") } b.PutString(e.URL) b.PutInt(e.Expires) return nil } // Decode implements bin.Decoder. func (e *ExportedContactToken) Decode(b *bin.Buffer) error { if e == nil { return fmt.Errorf("can't decode exportedContactToken#41bf109b to nil") } if err := b.ConsumeID(ExportedContactTokenTypeID); err != nil { return fmt.Errorf("unable to decode exportedContactToken#41bf109b: %w", err) } return e.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (e *ExportedContactToken) DecodeBare(b *bin.Buffer) error { if e == nil { return fmt.Errorf("can't decode exportedContactToken#41bf109b to nil") } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode exportedContactToken#41bf109b: field url: %w", err) } e.URL = value } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode exportedContactToken#41bf109b: field expires: %w", err) } e.Expires = value } return nil } // GetURL returns value of URL field. func (e *ExportedContactToken) GetURL() (value string) { if e == nil { return } return e.URL } // GetExpires returns value of Expires field. func (e *ExportedContactToken) GetExpires() (value int) { if e == nil { return } return e.Expires }