// Code generated by gotdgen, DO NOT EDIT. package tdapi 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{} ) // ResendCodeReasonUserRequest represents TL type `resendCodeReasonUserRequest#e5a8c880`. type ResendCodeReasonUserRequest struct { } // ResendCodeReasonUserRequestTypeID is TL type id of ResendCodeReasonUserRequest. const ResendCodeReasonUserRequestTypeID = 0xe5a8c880 // construct implements constructor of ResendCodeReasonClass. func (r ResendCodeReasonUserRequest) construct() ResendCodeReasonClass { return &r } // Ensuring interfaces in compile-time for ResendCodeReasonUserRequest. var ( _ bin.Encoder = &ResendCodeReasonUserRequest{} _ bin.Decoder = &ResendCodeReasonUserRequest{} _ bin.BareEncoder = &ResendCodeReasonUserRequest{} _ bin.BareDecoder = &ResendCodeReasonUserRequest{} _ ResendCodeReasonClass = &ResendCodeReasonUserRequest{} ) func (r *ResendCodeReasonUserRequest) Zero() bool { if r == nil { return true } return true } // String implements fmt.Stringer. func (r *ResendCodeReasonUserRequest) String() string { if r == nil { return "ResendCodeReasonUserRequest(nil)" } type Alias ResendCodeReasonUserRequest return fmt.Sprintf("ResendCodeReasonUserRequest%+v", Alias(*r)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*ResendCodeReasonUserRequest) TypeID() uint32 { return ResendCodeReasonUserRequestTypeID } // TypeName returns name of type in TL schema. func (*ResendCodeReasonUserRequest) TypeName() string { return "resendCodeReasonUserRequest" } // TypeInfo returns info about TL type. func (r *ResendCodeReasonUserRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "resendCodeReasonUserRequest", ID: ResendCodeReasonUserRequestTypeID, } if r == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{} return typ } // Encode implements bin.Encoder. func (r *ResendCodeReasonUserRequest) Encode(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't encode resendCodeReasonUserRequest#e5a8c880 as nil") } b.PutID(ResendCodeReasonUserRequestTypeID) return r.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (r *ResendCodeReasonUserRequest) EncodeBare(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't encode resendCodeReasonUserRequest#e5a8c880 as nil") } return nil } // Decode implements bin.Decoder. func (r *ResendCodeReasonUserRequest) Decode(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't decode resendCodeReasonUserRequest#e5a8c880 to nil") } if err := b.ConsumeID(ResendCodeReasonUserRequestTypeID); err != nil { return fmt.Errorf("unable to decode resendCodeReasonUserRequest#e5a8c880: %w", err) } return r.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (r *ResendCodeReasonUserRequest) DecodeBare(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't decode resendCodeReasonUserRequest#e5a8c880 to nil") } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (r *ResendCodeReasonUserRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if r == nil { return fmt.Errorf("can't encode resendCodeReasonUserRequest#e5a8c880 as nil") } b.ObjStart() b.PutID("resendCodeReasonUserRequest") b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (r *ResendCodeReasonUserRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if r == nil { return fmt.Errorf("can't decode resendCodeReasonUserRequest#e5a8c880 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("resendCodeReasonUserRequest"); err != nil { return fmt.Errorf("unable to decode resendCodeReasonUserRequest#e5a8c880: %w", err) } default: return b.Skip() } return nil }) } // ResendCodeReasonVerificationFailed represents TL type `resendCodeReasonVerificationFailed#1f952dc1`. type ResendCodeReasonVerificationFailed struct { // Cause of the verification failure, for example, "PLAY_SERVICES_NOT_AVAILABLE", // "APNS_RECEIVE_TIMEOUT", or "APNS_INIT_FAILED" ErrorMessage string } // ResendCodeReasonVerificationFailedTypeID is TL type id of ResendCodeReasonVerificationFailed. const ResendCodeReasonVerificationFailedTypeID = 0x1f952dc1 // construct implements constructor of ResendCodeReasonClass. func (r ResendCodeReasonVerificationFailed) construct() ResendCodeReasonClass { return &r } // Ensuring interfaces in compile-time for ResendCodeReasonVerificationFailed. var ( _ bin.Encoder = &ResendCodeReasonVerificationFailed{} _ bin.Decoder = &ResendCodeReasonVerificationFailed{} _ bin.BareEncoder = &ResendCodeReasonVerificationFailed{} _ bin.BareDecoder = &ResendCodeReasonVerificationFailed{} _ ResendCodeReasonClass = &ResendCodeReasonVerificationFailed{} ) func (r *ResendCodeReasonVerificationFailed) Zero() bool { if r == nil { return true } if !(r.ErrorMessage == "") { return false } return true } // String implements fmt.Stringer. func (r *ResendCodeReasonVerificationFailed) String() string { if r == nil { return "ResendCodeReasonVerificationFailed(nil)" } type Alias ResendCodeReasonVerificationFailed return fmt.Sprintf("ResendCodeReasonVerificationFailed%+v", Alias(*r)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*ResendCodeReasonVerificationFailed) TypeID() uint32 { return ResendCodeReasonVerificationFailedTypeID } // TypeName returns name of type in TL schema. func (*ResendCodeReasonVerificationFailed) TypeName() string { return "resendCodeReasonVerificationFailed" } // TypeInfo returns info about TL type. func (r *ResendCodeReasonVerificationFailed) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "resendCodeReasonVerificationFailed", ID: ResendCodeReasonVerificationFailedTypeID, } if r == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ErrorMessage", SchemaName: "error_message", }, } return typ } // Encode implements bin.Encoder. func (r *ResendCodeReasonVerificationFailed) Encode(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't encode resendCodeReasonVerificationFailed#1f952dc1 as nil") } b.PutID(ResendCodeReasonVerificationFailedTypeID) return r.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (r *ResendCodeReasonVerificationFailed) EncodeBare(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't encode resendCodeReasonVerificationFailed#1f952dc1 as nil") } b.PutString(r.ErrorMessage) return nil } // Decode implements bin.Decoder. func (r *ResendCodeReasonVerificationFailed) Decode(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't decode resendCodeReasonVerificationFailed#1f952dc1 to nil") } if err := b.ConsumeID(ResendCodeReasonVerificationFailedTypeID); err != nil { return fmt.Errorf("unable to decode resendCodeReasonVerificationFailed#1f952dc1: %w", err) } return r.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (r *ResendCodeReasonVerificationFailed) DecodeBare(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't decode resendCodeReasonVerificationFailed#1f952dc1 to nil") } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode resendCodeReasonVerificationFailed#1f952dc1: field error_message: %w", err) } r.ErrorMessage = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (r *ResendCodeReasonVerificationFailed) EncodeTDLibJSON(b tdjson.Encoder) error { if r == nil { return fmt.Errorf("can't encode resendCodeReasonVerificationFailed#1f952dc1 as nil") } b.ObjStart() b.PutID("resendCodeReasonVerificationFailed") b.Comma() b.FieldStart("error_message") b.PutString(r.ErrorMessage) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (r *ResendCodeReasonVerificationFailed) DecodeTDLibJSON(b tdjson.Decoder) error { if r == nil { return fmt.Errorf("can't decode resendCodeReasonVerificationFailed#1f952dc1 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("resendCodeReasonVerificationFailed"); err != nil { return fmt.Errorf("unable to decode resendCodeReasonVerificationFailed#1f952dc1: %w", err) } case "error_message": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode resendCodeReasonVerificationFailed#1f952dc1: field error_message: %w", err) } r.ErrorMessage = value default: return b.Skip() } return nil }) } // GetErrorMessage returns value of ErrorMessage field. func (r *ResendCodeReasonVerificationFailed) GetErrorMessage() (value string) { if r == nil { return } return r.ErrorMessage } // ResendCodeReasonClassName is schema name of ResendCodeReasonClass. const ResendCodeReasonClassName = "ResendCodeReason" // ResendCodeReasonClass represents ResendCodeReason generic type. // // Example: // // g, err := tdapi.DecodeResendCodeReason(buf) // if err != nil { // panic(err) // } // switch v := g.(type) { // case *tdapi.ResendCodeReasonUserRequest: // resendCodeReasonUserRequest#e5a8c880 // case *tdapi.ResendCodeReasonVerificationFailed: // resendCodeReasonVerificationFailed#1f952dc1 // default: panic(v) // } type ResendCodeReasonClass interface { bin.Encoder bin.Decoder bin.BareEncoder bin.BareDecoder construct() ResendCodeReasonClass // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. TypeID() uint32 // TypeName returns name of type in TL schema. TypeName() string // String implements fmt.Stringer. String() string // Zero returns true if current object has a zero value. Zero() bool EncodeTDLibJSON(b tdjson.Encoder) error DecodeTDLibJSON(b tdjson.Decoder) error } // DecodeResendCodeReason implements binary de-serialization for ResendCodeReasonClass. func DecodeResendCodeReason(buf *bin.Buffer) (ResendCodeReasonClass, error) { id, err := buf.PeekID() if err != nil { return nil, err } switch id { case ResendCodeReasonUserRequestTypeID: // Decoding resendCodeReasonUserRequest#e5a8c880. v := ResendCodeReasonUserRequest{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ResendCodeReasonClass: %w", err) } return &v, nil case ResendCodeReasonVerificationFailedTypeID: // Decoding resendCodeReasonVerificationFailed#1f952dc1. v := ResendCodeReasonVerificationFailed{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ResendCodeReasonClass: %w", err) } return &v, nil default: return nil, fmt.Errorf("unable to decode ResendCodeReasonClass: %w", bin.NewUnexpectedID(id)) } } // DecodeTDLibJSONResendCodeReason implements binary de-serialization for ResendCodeReasonClass. func DecodeTDLibJSONResendCodeReason(buf tdjson.Decoder) (ResendCodeReasonClass, error) { id, err := buf.FindTypeID() if err != nil { return nil, err } switch id { case "resendCodeReasonUserRequest": // Decoding resendCodeReasonUserRequest#e5a8c880. v := ResendCodeReasonUserRequest{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode ResendCodeReasonClass: %w", err) } return &v, nil case "resendCodeReasonVerificationFailed": // Decoding resendCodeReasonVerificationFailed#1f952dc1. v := ResendCodeReasonVerificationFailed{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode ResendCodeReasonClass: %w", err) } return &v, nil default: return nil, fmt.Errorf("unable to decode ResendCodeReasonClass: %w", tdjson.NewUnexpectedID(id)) } } // ResendCodeReason boxes the ResendCodeReasonClass providing a helper. type ResendCodeReasonBox struct { ResendCodeReason ResendCodeReasonClass } // Decode implements bin.Decoder for ResendCodeReasonBox. func (b *ResendCodeReasonBox) Decode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("unable to decode ResendCodeReasonBox to nil") } v, err := DecodeResendCodeReason(buf) if err != nil { return fmt.Errorf("unable to decode boxed value: %w", err) } b.ResendCodeReason = v return nil } // Encode implements bin.Encode for ResendCodeReasonBox. func (b *ResendCodeReasonBox) Encode(buf *bin.Buffer) error { if b == nil || b.ResendCodeReason == nil { return fmt.Errorf("unable to encode ResendCodeReasonClass as nil") } return b.ResendCodeReason.Encode(buf) } // DecodeTDLibJSON implements bin.Decoder for ResendCodeReasonBox. func (b *ResendCodeReasonBox) DecodeTDLibJSON(buf tdjson.Decoder) error { if b == nil { return fmt.Errorf("unable to decode ResendCodeReasonBox to nil") } v, err := DecodeTDLibJSONResendCodeReason(buf) if err != nil { return fmt.Errorf("unable to decode boxed value: %w", err) } b.ResendCodeReason = v return nil } // EncodeTDLibJSON implements bin.Encode for ResendCodeReasonBox. func (b *ResendCodeReasonBox) EncodeTDLibJSON(buf tdjson.Encoder) error { if b == nil || b.ResendCodeReason == nil { return fmt.Errorf("unable to encode ResendCodeReasonClass as nil") } return b.ResendCodeReason.EncodeTDLibJSON(buf) }