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

// PaymentsApplyGiftCodeRequest represents TL type `payments.applyGiftCode#f6e26854`.
// Apply a Telegram Premium giftcode »¹
//
// Links:
//  1. https://core.telegram.org/api/giveaways
//
// See https://core.telegram.org/method/payments.applyGiftCode for reference.
type PaymentsApplyGiftCodeRequest struct {
	// The code to apply
	Slug string
}

// PaymentsApplyGiftCodeRequestTypeID is TL type id of PaymentsApplyGiftCodeRequest.
const PaymentsApplyGiftCodeRequestTypeID = 0xf6e26854

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *PaymentsApplyGiftCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.applyGiftCode#f6e26854 as nil")
	}
	.PutID(PaymentsApplyGiftCodeRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

// PaymentsApplyGiftCode invokes method payments.applyGiftCode#f6e26854 returning error if any.
// Apply a Telegram Premium giftcode »¹
//
// Links:
//  1. https://core.telegram.org/api/giveaways
//
// Possible errors:
//
//	406 GIFTCODE_NOT_ALLOWED:
//
// See https://core.telegram.org/method/payments.applyGiftCode for reference.
func ( *Client) ( context.Context,  string) (UpdatesClass, error) {
	var  UpdatesBox

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