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

// GetPremiumGiftPaymentOptionsRequest represents TL type `getPremiumGiftPaymentOptions#e35eae5c`.
type GetPremiumGiftPaymentOptionsRequest struct {
}

// GetPremiumGiftPaymentOptionsRequestTypeID is TL type id of GetPremiumGiftPaymentOptionsRequest.
const GetPremiumGiftPaymentOptionsRequestTypeID = 0xe35eae5c

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

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

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*GetPremiumGiftPaymentOptionsRequest) TypeName() string {
	return "getPremiumGiftPaymentOptions"
}

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

// Encode implements bin.Encoder.
func (g *GetPremiumGiftPaymentOptionsRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getPremiumGiftPaymentOptions#e35eae5c as nil")
	}
	b.PutID(GetPremiumGiftPaymentOptionsRequestTypeID)
	return g.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (g *GetPremiumGiftPaymentOptionsRequest) EncodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getPremiumGiftPaymentOptions#e35eae5c as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (g *GetPremiumGiftPaymentOptionsRequest) Decode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode getPremiumGiftPaymentOptions#e35eae5c to nil")
	}
	if err := b.ConsumeID(GetPremiumGiftPaymentOptionsRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode getPremiumGiftPaymentOptions#e35eae5c: %w", err)
	}
	return g.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (g *GetPremiumGiftPaymentOptionsRequest) DecodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode getPremiumGiftPaymentOptions#e35eae5c to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (g *GetPremiumGiftPaymentOptionsRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
	if g == nil {
		return fmt.Errorf("can't encode getPremiumGiftPaymentOptions#e35eae5c as nil")
	}
	b.ObjStart()
	b.PutID("getPremiumGiftPaymentOptions")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (g *GetPremiumGiftPaymentOptionsRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
	if g == nil {
		return fmt.Errorf("can't decode getPremiumGiftPaymentOptions#e35eae5c to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("getPremiumGiftPaymentOptions"); err != nil {
				return fmt.Errorf("unable to decode getPremiumGiftPaymentOptions#e35eae5c: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetPremiumGiftPaymentOptions invokes method getPremiumGiftPaymentOptions#e35eae5c returning error if any.
func (c *Client) GetPremiumGiftPaymentOptions(ctx context.Context) (*PremiumGiftPaymentOptions, error) {
	var result PremiumGiftPaymentOptions

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