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

// PaymentsGetStarGiftAuctionAcquiredGiftsRequest represents TL type `payments.getStarGiftAuctionAcquiredGifts#6ba2cbec`.
//
// See https://core.telegram.org/method/payments.getStarGiftAuctionAcquiredGifts for reference.
type PaymentsGetStarGiftAuctionAcquiredGiftsRequest struct {
	// GiftID field of PaymentsGetStarGiftAuctionAcquiredGiftsRequest.
	GiftID int64
}

// PaymentsGetStarGiftAuctionAcquiredGiftsRequestTypeID is TL type id of PaymentsGetStarGiftAuctionAcquiredGiftsRequest.
const PaymentsGetStarGiftAuctionAcquiredGiftsRequestTypeID = 0x6ba2cbec

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

func (g *PaymentsGetStarGiftAuctionAcquiredGiftsRequest) Zero() bool {
	if g == nil {
		return true
	}
	if !(g.GiftID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsGetStarGiftAuctionAcquiredGiftsRequest from given interface.
func (g *PaymentsGetStarGiftAuctionAcquiredGiftsRequest) FillFrom(from interface {
	GetGiftID() (value int64)
}) {
	g.GiftID = from.GetGiftID()
}

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

// TypeName returns name of type in TL schema.
func (*PaymentsGetStarGiftAuctionAcquiredGiftsRequest) TypeName() string {
	return "payments.getStarGiftAuctionAcquiredGifts"
}

// TypeInfo returns info about TL type.
func (g *PaymentsGetStarGiftAuctionAcquiredGiftsRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "payments.getStarGiftAuctionAcquiredGifts",
		ID:   PaymentsGetStarGiftAuctionAcquiredGiftsRequestTypeID,
	}
	if g == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "GiftID",
			SchemaName: "gift_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (g *PaymentsGetStarGiftAuctionAcquiredGiftsRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode payments.getStarGiftAuctionAcquiredGifts#6ba2cbec as nil")
	}
	b.PutID(PaymentsGetStarGiftAuctionAcquiredGiftsRequestTypeID)
	return g.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (g *PaymentsGetStarGiftAuctionAcquiredGiftsRequest) EncodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode payments.getStarGiftAuctionAcquiredGifts#6ba2cbec as nil")
	}
	b.PutLong(g.GiftID)
	return nil
}

// Decode implements bin.Decoder.
func (g *PaymentsGetStarGiftAuctionAcquiredGiftsRequest) Decode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode payments.getStarGiftAuctionAcquiredGifts#6ba2cbec to nil")
	}
	if err := b.ConsumeID(PaymentsGetStarGiftAuctionAcquiredGiftsRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode payments.getStarGiftAuctionAcquiredGifts#6ba2cbec: %w", err)
	}
	return g.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (g *PaymentsGetStarGiftAuctionAcquiredGiftsRequest) DecodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode payments.getStarGiftAuctionAcquiredGifts#6ba2cbec to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode payments.getStarGiftAuctionAcquiredGifts#6ba2cbec: field gift_id: %w", err)
		}
		g.GiftID = value
	}
	return nil
}

// GetGiftID returns value of GiftID field.
func (g *PaymentsGetStarGiftAuctionAcquiredGiftsRequest) GetGiftID() (value int64) {
	if g == nil {
		return
	}
	return g.GiftID
}

// PaymentsGetStarGiftAuctionAcquiredGifts invokes method payments.getStarGiftAuctionAcquiredGifts#6ba2cbec returning error if any.
//
// See https://core.telegram.org/method/payments.getStarGiftAuctionAcquiredGifts for reference.
func (c *Client) PaymentsGetStarGiftAuctionAcquiredGifts(ctx context.Context, giftid int64) (*PaymentsStarGiftAuctionAcquiredGifts, error) {
	var result PaymentsStarGiftAuctionAcquiredGifts

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