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