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