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

// MessagesSetBotShippingResultsRequest represents TL type `messages.setBotShippingResults#e5f672fa`.
// If you sent an invoice requesting a shipping address and the parameter is_flexible was
// specified, the bot will receive an updateBotShippingQuery¹ update. Use this method to
// reply to shipping queries.
//
// Links:
//  1. https://core.telegram.org/constructor/updateBotShippingQuery
//
// See https://core.telegram.org/method/messages.setBotShippingResults for reference.
type MessagesSetBotShippingResultsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Unique identifier for the query to be answered
	QueryID int64
	// Error message in human readable form that explains why it is impossible to complete
	// the order (e.g. "Sorry, delivery to your desired address is unavailable"). Telegram
	// will display this message to the user.
	//
	// Use SetError and GetError helpers.
	Error string
	// A vector of available shipping options.
	//
	// Use SetShippingOptions and GetShippingOptions helpers.
	ShippingOptions []ShippingOption
}

// MessagesSetBotShippingResultsRequestTypeID is TL type id of MessagesSetBotShippingResultsRequest.
const MessagesSetBotShippingResultsRequestTypeID = 0xe5f672fa

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

func ( *MessagesSetBotShippingResultsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.QueryID == 0) {
		return false
	}
	if !(.Error == "") {
		return false
	}
	if !(.ShippingOptions == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSetBotShippingResultsRequest from given interface.
func ( *MessagesSetBotShippingResultsRequest) ( interface {
	() ( int64)
	() ( string,  bool)
	() ( []ShippingOption,  bool)
}) {
	.QueryID = .()
	if ,  := .();  {
		.Error = 
	}

	if ,  := .();  {
		.ShippingOptions = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*MessagesSetBotShippingResultsRequest) () string {
	return "messages.setBotShippingResults"
}

// TypeInfo returns info about TL type.
func ( *MessagesSetBotShippingResultsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.setBotShippingResults",
		ID:   MessagesSetBotShippingResultsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "QueryID",
			SchemaName: "query_id",
		},
		{
			Name:       "Error",
			SchemaName: "error",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ShippingOptions",
			SchemaName: "shipping_options",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesSetBotShippingResultsRequest) () {
	if !(.Error == "") {
		.Flags.Set(0)
	}
	if !(.ShippingOptions == nil) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesSetBotShippingResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setBotShippingResults#e5f672fa as nil")
	}
	.PutID(MessagesSetBotShippingResultsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSetBotShippingResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setBotShippingResults#e5f672fa as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setBotShippingResults#e5f672fa: field flags: %w", )
	}
	.PutLong(.QueryID)
	if .Flags.Has(0) {
		.PutString(.Error)
	}
	if .Flags.Has(1) {
		.PutVectorHeader(len(.ShippingOptions))
		for ,  := range .ShippingOptions {
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode messages.setBotShippingResults#e5f672fa: field shipping_options element with index %d: %w", , )
			}
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSetBotShippingResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setBotShippingResults#e5f672fa to nil")
	}
	if  := .ConsumeID(MessagesSetBotShippingResultsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.setBotShippingResults#e5f672fa: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSetBotShippingResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setBotShippingResults#e5f672fa to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.setBotShippingResults#e5f672fa: field flags: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setBotShippingResults#e5f672fa: field query_id: %w", )
		}
		.QueryID = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setBotShippingResults#e5f672fa: field error: %w", )
		}
		.Error = 
	}
	if .Flags.Has(1) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setBotShippingResults#e5f672fa: field shipping_options: %w", )
		}

		if  > 0 {
			.ShippingOptions = make([]ShippingOption, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  ShippingOption
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode messages.setBotShippingResults#e5f672fa: field shipping_options: %w", )
			}
			.ShippingOptions = append(.ShippingOptions, )
		}
	}
	return nil
}

// GetQueryID returns value of QueryID field.
func ( *MessagesSetBotShippingResultsRequest) () ( int64) {
	if  == nil {
		return
	}
	return .QueryID
}

// SetError sets value of Error conditional field.
func ( *MessagesSetBotShippingResultsRequest) ( string) {
	.Flags.Set(0)
	.Error = 
}

// GetError returns value of Error conditional field and
// boolean which is true if field was set.
func ( *MessagesSetBotShippingResultsRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Error, true
}

// SetShippingOptions sets value of ShippingOptions conditional field.
func ( *MessagesSetBotShippingResultsRequest) ( []ShippingOption) {
	.Flags.Set(1)
	.ShippingOptions = 
}

// GetShippingOptions returns value of ShippingOptions conditional field and
// boolean which is true if field was set.
func ( *MessagesSetBotShippingResultsRequest) () ( []ShippingOption,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .ShippingOptions, true
}

// MessagesSetBotShippingResults invokes method messages.setBotShippingResults#e5f672fa returning error if any.
// If you sent an invoice requesting a shipping address and the parameter is_flexible was
// specified, the bot will receive an updateBotShippingQuery¹ update. Use this method to
// reply to shipping queries.
//
// Links:
//  1. https://core.telegram.org/constructor/updateBotShippingQuery
//
// Possible errors:
//
//	400 QUERY_ID_INVALID: The query ID is invalid.
//
// See https://core.telegram.org/method/messages.setBotShippingResults for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesSetBotShippingResultsRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}