package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type PhoneSetCallRatingRequest struct {
Flags bin .Fields
UserInitiative bool
Peer InputPhoneCall
Rating int
Comment string
}
const PhoneSetCallRatingRequestTypeID = 0x59ead627
var (
_ bin .Encoder = &PhoneSetCallRatingRequest {}
_ bin .Decoder = &PhoneSetCallRatingRequest {}
_ bin .BareEncoder = &PhoneSetCallRatingRequest {}
_ bin .BareDecoder = &PhoneSetCallRatingRequest {}
)
func (s *PhoneSetCallRatingRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .UserInitiative == false ) {
return false
}
if !(s .Peer .Zero ()) {
return false
}
if !(s .Rating == 0 ) {
return false
}
if !(s .Comment == "" ) {
return false
}
return true
}
func (s *PhoneSetCallRatingRequest ) String () string {
if s == nil {
return "PhoneSetCallRatingRequest(nil)"
}
type Alias PhoneSetCallRatingRequest
return fmt .Sprintf ("PhoneSetCallRatingRequest%+v" , Alias (*s ))
}
func (s *PhoneSetCallRatingRequest ) FillFrom (from interface {
GetUserInitiative () (value bool )
GetPeer () (value InputPhoneCall )
GetRating () (value int )
GetComment () (value string )
}) {
s .UserInitiative = from .GetUserInitiative ()
s .Peer = from .GetPeer ()
s .Rating = from .GetRating ()
s .Comment = from .GetComment ()
}
func (*PhoneSetCallRatingRequest ) TypeID () uint32 {
return PhoneSetCallRatingRequestTypeID
}
func (*PhoneSetCallRatingRequest ) TypeName () string {
return "phone.setCallRating"
}
func (s *PhoneSetCallRatingRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "phone.setCallRating" ,
ID : PhoneSetCallRatingRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UserInitiative" ,
SchemaName : "user_initiative" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "Rating" ,
SchemaName : "rating" ,
},
{
Name : "Comment" ,
SchemaName : "comment" ,
},
}
return typ
}
func (s *PhoneSetCallRatingRequest ) SetFlags () {
if !(s .UserInitiative == false ) {
s .Flags .Set (0 )
}
}
func (s *PhoneSetCallRatingRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode phone.setCallRating#59ead627 as nil" )
}
b .PutID (PhoneSetCallRatingRequestTypeID )
return s .EncodeBare (b )
}
func (s *PhoneSetCallRatingRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode phone.setCallRating#59ead627 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.setCallRating#59ead627: field flags: %w" , err )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.setCallRating#59ead627: field peer: %w" , err )
}
b .PutInt (s .Rating )
b .PutString (s .Comment )
return nil
}
func (s *PhoneSetCallRatingRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode phone.setCallRating#59ead627 to nil" )
}
if err := b .ConsumeID (PhoneSetCallRatingRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode phone.setCallRating#59ead627: %w" , err )
}
return s .DecodeBare (b )
}
func (s *PhoneSetCallRatingRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode phone.setCallRating#59ead627 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode phone.setCallRating#59ead627: field flags: %w" , err )
}
}
s .UserInitiative = s .Flags .Has (0 )
{
if err := s .Peer .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode phone.setCallRating#59ead627: field peer: %w" , err )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode phone.setCallRating#59ead627: field rating: %w" , err )
}
s .Rating = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode phone.setCallRating#59ead627: field comment: %w" , err )
}
s .Comment = value
}
return nil
}
func (s *PhoneSetCallRatingRequest ) SetUserInitiative (value bool ) {
if value {
s .Flags .Set (0 )
s .UserInitiative = true
} else {
s .Flags .Unset (0 )
s .UserInitiative = false
}
}
func (s *PhoneSetCallRatingRequest ) GetUserInitiative () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *PhoneSetCallRatingRequest ) GetPeer () (value InputPhoneCall ) {
if s == nil {
return
}
return s .Peer
}
func (s *PhoneSetCallRatingRequest ) GetRating () (value int ) {
if s == nil {
return
}
return s .Rating
}
func (s *PhoneSetCallRatingRequest ) GetComment () (value string ) {
if s == nil {
return
}
return s .Comment
}
func (c *Client ) PhoneSetCallRating (ctx context .Context , request *PhoneSetCallRatingRequest ) (UpdatesClass , error ) {
var result UpdatesBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Updates , nil
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .