// 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{}
)

// SMSJobsGetStatusRequest represents TL type `smsjobs.getStatus#10a698e8`.
// Get SMS jobs status (official clients only).
//
// See https://core.telegram.org/method/smsjobs.getStatus for reference.
type SMSJobsGetStatusRequest struct {
}

// SMSJobsGetStatusRequestTypeID is TL type id of SMSJobsGetStatusRequest.
const SMSJobsGetStatusRequestTypeID = 0x10a698e8

// Ensuring interfaces in compile-time for SMSJobsGetStatusRequest.
var (
	_ bin.Encoder     = &SMSJobsGetStatusRequest{}
	_ bin.Decoder     = &SMSJobsGetStatusRequest{}
	_ bin.BareEncoder = &SMSJobsGetStatusRequest{}
	_ bin.BareDecoder = &SMSJobsGetStatusRequest{}
)

func (g *SMSJobsGetStatusRequest) Zero() bool {
	if g == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func (g *SMSJobsGetStatusRequest) String() string {
	if g == nil {
		return "SMSJobsGetStatusRequest(nil)"
	}
	type Alias SMSJobsGetStatusRequest
	return fmt.Sprintf("SMSJobsGetStatusRequest%+v", Alias(*g))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*SMSJobsGetStatusRequest) TypeID() uint32 {
	return SMSJobsGetStatusRequestTypeID
}

// TypeName returns name of type in TL schema.
func (*SMSJobsGetStatusRequest) TypeName() string {
	return "smsjobs.getStatus"
}

// TypeInfo returns info about TL type.
func (g *SMSJobsGetStatusRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "smsjobs.getStatus",
		ID:   SMSJobsGetStatusRequestTypeID,
	}
	if g == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (g *SMSJobsGetStatusRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode smsjobs.getStatus#10a698e8 as nil")
	}
	b.PutID(SMSJobsGetStatusRequestTypeID)
	return g.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (g *SMSJobsGetStatusRequest) EncodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode smsjobs.getStatus#10a698e8 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (g *SMSJobsGetStatusRequest) Decode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode smsjobs.getStatus#10a698e8 to nil")
	}
	if err := b.ConsumeID(SMSJobsGetStatusRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode smsjobs.getStatus#10a698e8: %w", err)
	}
	return g.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (g *SMSJobsGetStatusRequest) DecodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode smsjobs.getStatus#10a698e8 to nil")
	}
	return nil
}

// SMSJobsGetStatus invokes method smsjobs.getStatus#10a698e8 returning error if any.
// Get SMS jobs status (official clients only).
//
// Possible errors:
//
//	400 NOT_JOINED: The current user hasn't joined the Peer-to-Peer Login Program.
//
// See https://core.telegram.org/method/smsjobs.getStatus for reference.
func (c *Client) SMSJobsGetStatus(ctx context.Context) (*SMSJobsStatus, error) {
	var result SMSJobsStatus

	request := &SMSJobsGetStatusRequest{}
	if err := c.rpc.Invoke(ctx, request, &result); err != nil {
		return nil, err
	}
	return &result, nil
}
