// 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{} ) // PhoneConfirmCallRequest represents TL type `phone.confirmCall#2efe1722`. // Complete phone call E2E encryption key exchange »¹ // // Links: // 1. https://core.telegram.org/api/end-to-end/voice-calls // // See https://core.telegram.org/method/phone.confirmCall for reference. type PhoneConfirmCallRequest struct { // The phone call Peer InputPhoneCall // Parameter for E2E encryption key exchange »¹ // // Links: // 1) https://core.telegram.org/api/end-to-end/voice-calls GA []byte // Key fingerprint KeyFingerprint int64 // Phone call settings Protocol PhoneCallProtocol } // PhoneConfirmCallRequestTypeID is TL type id of PhoneConfirmCallRequest. const PhoneConfirmCallRequestTypeID = 0x2efe1722 // Ensuring interfaces in compile-time for PhoneConfirmCallRequest. var ( _ bin.Encoder = &PhoneConfirmCallRequest{} _ bin.Decoder = &PhoneConfirmCallRequest{} _ bin.BareEncoder = &PhoneConfirmCallRequest{} _ bin.BareDecoder = &PhoneConfirmCallRequest{} ) func (c *PhoneConfirmCallRequest) Zero() bool { if c == nil { return true } if !(c.Peer.Zero()) { return false } if !(c.GA == nil) { return false } if !(c.KeyFingerprint == 0) { return false } if !(c.Protocol.Zero()) { return false } return true } // String implements fmt.Stringer. func (c *PhoneConfirmCallRequest) String() string { if c == nil { return "PhoneConfirmCallRequest(nil)" } type Alias PhoneConfirmCallRequest return fmt.Sprintf("PhoneConfirmCallRequest%+v", Alias(*c)) } // FillFrom fills PhoneConfirmCallRequest from given interface. func (c *PhoneConfirmCallRequest) FillFrom(from interface { GetPeer() (value InputPhoneCall) GetGA() (value []byte) GetKeyFingerprint() (value int64) GetProtocol() (value PhoneCallProtocol) }) { c.Peer = from.GetPeer() c.GA = from.GetGA() c.KeyFingerprint = from.GetKeyFingerprint() c.Protocol = from.GetProtocol() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*PhoneConfirmCallRequest) TypeID() uint32 { return PhoneConfirmCallRequestTypeID } // TypeName returns name of type in TL schema. func (*PhoneConfirmCallRequest) TypeName() string { return "phone.confirmCall" } // TypeInfo returns info about TL type. func (c *PhoneConfirmCallRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "phone.confirmCall", ID: PhoneConfirmCallRequestTypeID, } if c == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "Peer", SchemaName: "peer", }, { Name: "GA", SchemaName: "g_a", }, { Name: "KeyFingerprint", SchemaName: "key_fingerprint", }, { Name: "Protocol", SchemaName: "protocol", }, } return typ } // Encode implements bin.Encoder. func (c *PhoneConfirmCallRequest) Encode(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't encode phone.confirmCall#2efe1722 as nil") } b.PutID(PhoneConfirmCallRequestTypeID) return c.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (c *PhoneConfirmCallRequest) EncodeBare(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't encode phone.confirmCall#2efe1722 as nil") } if err := c.Peer.Encode(b); err != nil { return fmt.Errorf("unable to encode phone.confirmCall#2efe1722: field peer: %w", err) } b.PutBytes(c.GA) b.PutLong(c.KeyFingerprint) if err := c.Protocol.Encode(b); err != nil { return fmt.Errorf("unable to encode phone.confirmCall#2efe1722: field protocol: %w", err) } return nil } // Decode implements bin.Decoder. func (c *PhoneConfirmCallRequest) Decode(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't decode phone.confirmCall#2efe1722 to nil") } if err := b.ConsumeID(PhoneConfirmCallRequestTypeID); err != nil { return fmt.Errorf("unable to decode phone.confirmCall#2efe1722: %w", err) } return c.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (c *PhoneConfirmCallRequest) DecodeBare(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't decode phone.confirmCall#2efe1722 to nil") } { if err := c.Peer.Decode(b); err != nil { return fmt.Errorf("unable to decode phone.confirmCall#2efe1722: field peer: %w", err) } } { value, err := b.Bytes() if err != nil { return fmt.Errorf("unable to decode phone.confirmCall#2efe1722: field g_a: %w", err) } c.GA = value } { value, err := b.Long() if err != nil { return fmt.Errorf("unable to decode phone.confirmCall#2efe1722: field key_fingerprint: %w", err) } c.KeyFingerprint = value } { if err := c.Protocol.Decode(b); err != nil { return fmt.Errorf("unable to decode phone.confirmCall#2efe1722: field protocol: %w", err) } } return nil } // GetPeer returns value of Peer field. func (c *PhoneConfirmCallRequest) GetPeer() (value InputPhoneCall) { if c == nil { return } return c.Peer } // GetGA returns value of GA field. func (c *PhoneConfirmCallRequest) GetGA() (value []byte) { if c == nil { return } return c.GA } // GetKeyFingerprint returns value of KeyFingerprint field. func (c *PhoneConfirmCallRequest) GetKeyFingerprint() (value int64) { if c == nil { return } return c.KeyFingerprint } // GetProtocol returns value of Protocol field. func (c *PhoneConfirmCallRequest) GetProtocol() (value PhoneCallProtocol) { if c == nil { return } return c.Protocol } // PhoneConfirmCall invokes method phone.confirmCall#2efe1722 returning error if any. // Complete phone call E2E encryption key exchange »¹ // // Links: // 1. https://core.telegram.org/api/end-to-end/voice-calls // // Possible errors: // // 400 CALL_ALREADY_DECLINED: The call was already declined. // 400 CALL_PEER_INVALID: The provided call peer object is invalid. // // See https://core.telegram.org/method/phone.confirmCall for reference. func (c *Client) PhoneConfirmCall(ctx context.Context, request *PhoneConfirmCallRequest) (*PhonePhoneCall, error) { var result PhonePhoneCall if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } return &result, nil }