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