move gotd fork into repo. (#111)
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
This commit is contained in:
@@ -0,0 +1,219 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// AccountVerifyEmailRequest represents TL type `account.verifyEmail#32da4cf`.
|
||||
// Verify an email address.
|
||||
//
|
||||
// See https://core.telegram.org/method/account.verifyEmail for reference.
|
||||
type AccountVerifyEmailRequest struct {
|
||||
// Verification purpose
|
||||
Purpose EmailVerifyPurposeClass
|
||||
// Email verification code or token
|
||||
Verification EmailVerificationClass
|
||||
}
|
||||
|
||||
// AccountVerifyEmailRequestTypeID is TL type id of AccountVerifyEmailRequest.
|
||||
const AccountVerifyEmailRequestTypeID = 0x32da4cf
|
||||
|
||||
// Ensuring interfaces in compile-time for AccountVerifyEmailRequest.
|
||||
var (
|
||||
_ bin.Encoder = &AccountVerifyEmailRequest{}
|
||||
_ bin.Decoder = &AccountVerifyEmailRequest{}
|
||||
_ bin.BareEncoder = &AccountVerifyEmailRequest{}
|
||||
_ bin.BareDecoder = &AccountVerifyEmailRequest{}
|
||||
)
|
||||
|
||||
func (v *AccountVerifyEmailRequest) Zero() bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
if !(v.Purpose == nil) {
|
||||
return false
|
||||
}
|
||||
if !(v.Verification == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (v *AccountVerifyEmailRequest) String() string {
|
||||
if v == nil {
|
||||
return "AccountVerifyEmailRequest(nil)"
|
||||
}
|
||||
type Alias AccountVerifyEmailRequest
|
||||
return fmt.Sprintf("AccountVerifyEmailRequest%+v", Alias(*v))
|
||||
}
|
||||
|
||||
// FillFrom fills AccountVerifyEmailRequest from given interface.
|
||||
func (v *AccountVerifyEmailRequest) FillFrom(from interface {
|
||||
GetPurpose() (value EmailVerifyPurposeClass)
|
||||
GetVerification() (value EmailVerificationClass)
|
||||
}) {
|
||||
v.Purpose = from.GetPurpose()
|
||||
v.Verification = from.GetVerification()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*AccountVerifyEmailRequest) TypeID() uint32 {
|
||||
return AccountVerifyEmailRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*AccountVerifyEmailRequest) TypeName() string {
|
||||
return "account.verifyEmail"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (v *AccountVerifyEmailRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "account.verifyEmail",
|
||||
ID: AccountVerifyEmailRequestTypeID,
|
||||
}
|
||||
if v == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Purpose",
|
||||
SchemaName: "purpose",
|
||||
},
|
||||
{
|
||||
Name: "Verification",
|
||||
SchemaName: "verification",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (v *AccountVerifyEmailRequest) Encode(b *bin.Buffer) error {
|
||||
if v == nil {
|
||||
return fmt.Errorf("can't encode account.verifyEmail#32da4cf as nil")
|
||||
}
|
||||
b.PutID(AccountVerifyEmailRequestTypeID)
|
||||
return v.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (v *AccountVerifyEmailRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if v == nil {
|
||||
return fmt.Errorf("can't encode account.verifyEmail#32da4cf as nil")
|
||||
}
|
||||
if v.Purpose == nil {
|
||||
return fmt.Errorf("unable to encode account.verifyEmail#32da4cf: field purpose is nil")
|
||||
}
|
||||
if err := v.Purpose.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode account.verifyEmail#32da4cf: field purpose: %w", err)
|
||||
}
|
||||
if v.Verification == nil {
|
||||
return fmt.Errorf("unable to encode account.verifyEmail#32da4cf: field verification is nil")
|
||||
}
|
||||
if err := v.Verification.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode account.verifyEmail#32da4cf: field verification: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (v *AccountVerifyEmailRequest) Decode(b *bin.Buffer) error {
|
||||
if v == nil {
|
||||
return fmt.Errorf("can't decode account.verifyEmail#32da4cf to nil")
|
||||
}
|
||||
if err := b.ConsumeID(AccountVerifyEmailRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode account.verifyEmail#32da4cf: %w", err)
|
||||
}
|
||||
return v.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (v *AccountVerifyEmailRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if v == nil {
|
||||
return fmt.Errorf("can't decode account.verifyEmail#32da4cf to nil")
|
||||
}
|
||||
{
|
||||
value, err := DecodeEmailVerifyPurpose(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode account.verifyEmail#32da4cf: field purpose: %w", err)
|
||||
}
|
||||
v.Purpose = value
|
||||
}
|
||||
{
|
||||
value, err := DecodeEmailVerification(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode account.verifyEmail#32da4cf: field verification: %w", err)
|
||||
}
|
||||
v.Verification = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPurpose returns value of Purpose field.
|
||||
func (v *AccountVerifyEmailRequest) GetPurpose() (value EmailVerifyPurposeClass) {
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return v.Purpose
|
||||
}
|
||||
|
||||
// GetVerification returns value of Verification field.
|
||||
func (v *AccountVerifyEmailRequest) GetVerification() (value EmailVerificationClass) {
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return v.Verification
|
||||
}
|
||||
|
||||
// AccountVerifyEmail invokes method account.verifyEmail#32da4cf returning error if any.
|
||||
// Verify an email address.
|
||||
//
|
||||
// Possible errors:
|
||||
//
|
||||
// 400 EMAIL_INVALID: The specified email is invalid.
|
||||
// 400 EMAIL_NOT_ALLOWED: The specified email cannot be used to complete the operation.
|
||||
// 400 EMAIL_VERIFY_EXPIRED: The verification email has expired.
|
||||
// 400 PHONE_NUMBER_INVALID: The phone number is invalid.
|
||||
//
|
||||
// See https://core.telegram.org/method/account.verifyEmail for reference.
|
||||
func (c *Client) AccountVerifyEmail(ctx context.Context, request *AccountVerifyEmailRequest) (AccountEmailVerifiedClass, error) {
|
||||
var result AccountEmailVerifiedBox
|
||||
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.EmailVerified, nil
|
||||
}
|
||||
Reference in New Issue
Block a user