// 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{} ) // SMSJob represents TL type `smsJob#e6a1eeb8`. // Info about an SMS job. // // See https://core.telegram.org/constructor/smsJob for reference. type SMSJob struct { // Job ID JobID string // Destination phone number PhoneNumber string // Text Text string } // SMSJobTypeID is TL type id of SMSJob. const SMSJobTypeID = 0xe6a1eeb8 // Ensuring interfaces in compile-time for SMSJob. var ( _ bin.Encoder = &SMSJob{} _ bin.Decoder = &SMSJob{} _ bin.BareEncoder = &SMSJob{} _ bin.BareDecoder = &SMSJob{} ) func (s *SMSJob) Zero() bool { if s == nil { return true } if !(s.JobID == "") { return false } if !(s.PhoneNumber == "") { return false } if !(s.Text == "") { return false } return true } // String implements fmt.Stringer. func (s *SMSJob) String() string { if s == nil { return "SMSJob(nil)" } type Alias SMSJob return fmt.Sprintf("SMSJob%+v", Alias(*s)) } // FillFrom fills SMSJob from given interface. func (s *SMSJob) FillFrom(from interface { GetJobID() (value string) GetPhoneNumber() (value string) GetText() (value string) }) { s.JobID = from.GetJobID() s.PhoneNumber = from.GetPhoneNumber() s.Text = from.GetText() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*SMSJob) TypeID() uint32 { return SMSJobTypeID } // TypeName returns name of type in TL schema. func (*SMSJob) TypeName() string { return "smsJob" } // TypeInfo returns info about TL type. func (s *SMSJob) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "smsJob", ID: SMSJobTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "JobID", SchemaName: "job_id", }, { Name: "PhoneNumber", SchemaName: "phone_number", }, { Name: "Text", SchemaName: "text", }, } return typ } // Encode implements bin.Encoder. func (s *SMSJob) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode smsJob#e6a1eeb8 as nil") } b.PutID(SMSJobTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *SMSJob) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode smsJob#e6a1eeb8 as nil") } b.PutString(s.JobID) b.PutString(s.PhoneNumber) b.PutString(s.Text) return nil } // Decode implements bin.Decoder. func (s *SMSJob) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode smsJob#e6a1eeb8 to nil") } if err := b.ConsumeID(SMSJobTypeID); err != nil { return fmt.Errorf("unable to decode smsJob#e6a1eeb8: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *SMSJob) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode smsJob#e6a1eeb8 to nil") } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode smsJob#e6a1eeb8: field job_id: %w", err) } s.JobID = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode smsJob#e6a1eeb8: field phone_number: %w", err) } s.PhoneNumber = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode smsJob#e6a1eeb8: field text: %w", err) } s.Text = value } return nil } // GetJobID returns value of JobID field. func (s *SMSJob) GetJobID() (value string) { if s == nil { return } return s.JobID } // GetPhoneNumber returns value of PhoneNumber field. func (s *SMSJob) GetPhoneNumber() (value string) { if s == nil { return } return s.PhoneNumber } // GetText returns value of Text field. func (s *SMSJob) GetText() (value string) { if s == nil { return } return s.Text }