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