// 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{} ) // SetBusinessConnectedBotRequest represents TL type `setBusinessConnectedBot#acf17ef0`. type SetBusinessConnectedBotRequest struct { // Connection settings for the bot Bot BusinessConnectedBot } // SetBusinessConnectedBotRequestTypeID is TL type id of SetBusinessConnectedBotRequest. const SetBusinessConnectedBotRequestTypeID = 0xacf17ef0 // Ensuring interfaces in compile-time for SetBusinessConnectedBotRequest. var ( _ bin.Encoder = &SetBusinessConnectedBotRequest{} _ bin.Decoder = &SetBusinessConnectedBotRequest{} _ bin.BareEncoder = &SetBusinessConnectedBotRequest{} _ bin.BareDecoder = &SetBusinessConnectedBotRequest{} ) func (s *SetBusinessConnectedBotRequest) Zero() bool { if s == nil { return true } if !(s.Bot.Zero()) { return false } return true } // String implements fmt.Stringer. func (s *SetBusinessConnectedBotRequest) String() string { if s == nil { return "SetBusinessConnectedBotRequest(nil)" } type Alias SetBusinessConnectedBotRequest return fmt.Sprintf("SetBusinessConnectedBotRequest%+v", Alias(*s)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*SetBusinessConnectedBotRequest) TypeID() uint32 { return SetBusinessConnectedBotRequestTypeID } // TypeName returns name of type in TL schema. func (*SetBusinessConnectedBotRequest) TypeName() string { return "setBusinessConnectedBot" } // TypeInfo returns info about TL type. func (s *SetBusinessConnectedBotRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "setBusinessConnectedBot", ID: SetBusinessConnectedBotRequestTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "Bot", SchemaName: "bot", }, } return typ } // Encode implements bin.Encoder. func (s *SetBusinessConnectedBotRequest) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode setBusinessConnectedBot#acf17ef0 as nil") } b.PutID(SetBusinessConnectedBotRequestTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *SetBusinessConnectedBotRequest) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode setBusinessConnectedBot#acf17ef0 as nil") } if err := s.Bot.Encode(b); err != nil { return fmt.Errorf("unable to encode setBusinessConnectedBot#acf17ef0: field bot: %w", err) } return nil } // Decode implements bin.Decoder. func (s *SetBusinessConnectedBotRequest) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode setBusinessConnectedBot#acf17ef0 to nil") } if err := b.ConsumeID(SetBusinessConnectedBotRequestTypeID); err != nil { return fmt.Errorf("unable to decode setBusinessConnectedBot#acf17ef0: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *SetBusinessConnectedBotRequest) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode setBusinessConnectedBot#acf17ef0 to nil") } { if err := s.Bot.Decode(b); err != nil { return fmt.Errorf("unable to decode setBusinessConnectedBot#acf17ef0: field bot: %w", err) } } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *SetBusinessConnectedBotRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { return fmt.Errorf("can't encode setBusinessConnectedBot#acf17ef0 as nil") } b.ObjStart() b.PutID("setBusinessConnectedBot") b.Comma() b.FieldStart("bot") if err := s.Bot.EncodeTDLibJSON(b); err != nil { return fmt.Errorf("unable to encode setBusinessConnectedBot#acf17ef0: field bot: %w", err) } b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *SetBusinessConnectedBotRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { return fmt.Errorf("can't decode setBusinessConnectedBot#acf17ef0 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("setBusinessConnectedBot"); err != nil { return fmt.Errorf("unable to decode setBusinessConnectedBot#acf17ef0: %w", err) } case "bot": if err := s.Bot.DecodeTDLibJSON(b); err != nil { return fmt.Errorf("unable to decode setBusinessConnectedBot#acf17ef0: field bot: %w", err) } default: return b.Skip() } return nil }) } // GetBot returns value of Bot field. func (s *SetBusinessConnectedBotRequest) GetBot() (value BusinessConnectedBot) { if s == nil { return } return s.Bot } // SetBusinessConnectedBot invokes method setBusinessConnectedBot#acf17ef0 returning error if any. func (c *Client) SetBusinessConnectedBot(ctx context.Context, bot BusinessConnectedBot) error { var ok Ok request := &SetBusinessConnectedBotRequest{ Bot: bot, } if err := c.rpc.Invoke(ctx, request, &ok); err != nil { return err } return nil }