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

// PaymentsLaunchPrepaidGiveawayRequest represents TL type `payments.launchPrepaidGiveaway#5ff58f20`.
// Launch a prepaid giveaway »¹.
//
// Links:
//  1. https://core.telegram.org/api/giveaways
//
// See https://core.telegram.org/method/payments.launchPrepaidGiveaway for reference.
type PaymentsLaunchPrepaidGiveawayRequest struct {
	// The peer where to launch the giveaway.
	Peer InputPeerClass
	// The prepaid giveaway ID.
	GiveawayID int64
	// Giveway parameters
	Purpose InputStorePaymentPurposeClass
}

// PaymentsLaunchPrepaidGiveawayRequestTypeID is TL type id of PaymentsLaunchPrepaidGiveawayRequest.
const PaymentsLaunchPrepaidGiveawayRequestTypeID = 0x5ff58f20

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

func ( *PaymentsLaunchPrepaidGiveawayRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.GiveawayID == 0) {
		return false
	}
	if !(.Purpose == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsLaunchPrepaidGiveawayRequest from given interface.
func ( *PaymentsLaunchPrepaidGiveawayRequest) ( interface {
	() ( InputPeerClass)
	() ( int64)
	() ( InputStorePaymentPurposeClass)
}) {
	.Peer = .()
	.GiveawayID = .()
	.Purpose = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsLaunchPrepaidGiveawayRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.launchPrepaidGiveaway",
		ID:   PaymentsLaunchPrepaidGiveawayRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "GiveawayID",
			SchemaName: "giveaway_id",
		},
		{
			Name:       "Purpose",
			SchemaName: "purpose",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsLaunchPrepaidGiveawayRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.launchPrepaidGiveaway#5ff58f20 as nil")
	}
	.PutID(PaymentsLaunchPrepaidGiveawayRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsLaunchPrepaidGiveawayRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.launchPrepaidGiveaway#5ff58f20 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode payments.launchPrepaidGiveaway#5ff58f20: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.launchPrepaidGiveaway#5ff58f20: field peer: %w", )
	}
	.PutLong(.GiveawayID)
	if .Purpose == nil {
		return fmt.Errorf("unable to encode payments.launchPrepaidGiveaway#5ff58f20: field purpose is nil")
	}
	if  := .Purpose.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.launchPrepaidGiveaway#5ff58f20: field purpose: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsLaunchPrepaidGiveawayRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.launchPrepaidGiveaway#5ff58f20 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode payments.launchPrepaidGiveaway#5ff58f20: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode payments.launchPrepaidGiveaway#5ff58f20: field giveaway_id: %w", )
		}
		.GiveawayID = 
	}
	{
		,  := DecodeInputStorePaymentPurpose()
		if  != nil {
			return fmt.Errorf("unable to decode payments.launchPrepaidGiveaway#5ff58f20: field purpose: %w", )
		}
		.Purpose = 
	}
	return nil
}

// GetPeer returns value of Peer field.
func ( *PaymentsLaunchPrepaidGiveawayRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetGiveawayID returns value of GiveawayID field.
func ( *PaymentsLaunchPrepaidGiveawayRequest) () ( int64) {
	if  == nil {
		return
	}
	return .GiveawayID
}

// GetPurpose returns value of Purpose field.
func ( *PaymentsLaunchPrepaidGiveawayRequest) () ( InputStorePaymentPurposeClass) {
	if  == nil {
		return
	}
	return .Purpose
}

// PaymentsLaunchPrepaidGiveaway invokes method payments.launchPrepaidGiveaway#5ff58f20 returning error if any.
// Launch a prepaid giveaway »¹.
//
// Links:
//  1. https://core.telegram.org/api/giveaways
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/payments.launchPrepaidGiveaway for reference.
func ( *Client) ( context.Context,  *PaymentsLaunchPrepaidGiveawayRequest) (UpdatesClass, error) {
	var  UpdatesBox

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