// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

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

// PaymentsCheckGiftCodeRequest represents TL type `payments.checkGiftCode#8e51b4c1`.
// Obtain information about a Telegram Premium giftcode »¹
//
// Links:
//  1. https://core.telegram.org/api/giveaways
//
// See https://core.telegram.org/method/payments.checkGiftCode for reference.
type PaymentsCheckGiftCodeRequest struct {
	// The giftcode to check
	Slug string
}

// PaymentsCheckGiftCodeRequestTypeID is TL type id of PaymentsCheckGiftCodeRequest.
const PaymentsCheckGiftCodeRequestTypeID = 0x8e51b4c1

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

func ( *PaymentsCheckGiftCodeRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Slug == "") {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsCheckGiftCodeRequest from given interface.
func ( *PaymentsCheckGiftCodeRequest) ( interface {
	() ( string)
}) {
	.Slug = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsCheckGiftCodeRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.checkGiftCode",
		ID:   PaymentsCheckGiftCodeRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Slug",
			SchemaName: "slug",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsCheckGiftCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.checkGiftCode#8e51b4c1 as nil")
	}
	.PutID(PaymentsCheckGiftCodeRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsCheckGiftCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.checkGiftCode#8e51b4c1 as nil")
	}
	.PutString(.Slug)
	return nil
}

// Decode implements bin.Decoder.
func ( *PaymentsCheckGiftCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.checkGiftCode#8e51b4c1 to nil")
	}
	if  := .ConsumeID(PaymentsCheckGiftCodeRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode payments.checkGiftCode#8e51b4c1: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsCheckGiftCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.checkGiftCode#8e51b4c1 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.checkGiftCode#8e51b4c1: field slug: %w", )
		}
		.Slug = 
	}
	return nil
}

// GetSlug returns value of Slug field.
func ( *PaymentsCheckGiftCodeRequest) () ( string) {
	if  == nil {
		return
	}
	return .Slug
}

// PaymentsCheckGiftCode invokes method payments.checkGiftCode#8e51b4c1 returning error if any.
// Obtain information about a Telegram Premium giftcode »¹
//
// Links:
//  1. https://core.telegram.org/api/giveaways
//
// Possible errors:
//
//	400 GIFT_SLUG_INVALID: The specified slug is invalid.
//
// See https://core.telegram.org/method/payments.checkGiftCode for reference.
func ( *Client) ( context.Context,  string) (*PaymentsCheckedGiftCode, error) {
	var  PaymentsCheckedGiftCode

	 := &PaymentsCheckGiftCodeRequest{
		Slug: ,
	}
	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return &, nil
}