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

// InvokeWithBusinessConnectionRequest represents TL type `invokeWithBusinessConnection#dd289f8e`.
// Invoke a method using a Telegram Business Bot connection, see here » for more info,
// including a list of the methods that can be wrapped in this constructor¹.
// Make sure to always send queries wrapped in a invokeWithBusinessConnection to the
// datacenter ID, specified in the dc_id field of the botBusinessConnection¹ that is
// being used.
//
// Links:
//  1. https://core.telegram.org/api/bots/connected-business-bots
//  2. https://core.telegram.org/constructor/botBusinessConnection
//
// See https://core.telegram.org/constructor/invokeWithBusinessConnection for reference.
type InvokeWithBusinessConnectionRequest struct {
	// Business connection ID.
	ConnectionID string
	// The actual query.
	Query bin.Object
}

// InvokeWithBusinessConnectionRequestTypeID is TL type id of InvokeWithBusinessConnectionRequest.
const InvokeWithBusinessConnectionRequestTypeID = 0xdd289f8e

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

func ( *InvokeWithBusinessConnectionRequest) () bool {
	if  == nil {
		return true
	}
	if !(.ConnectionID == "") {
		return false
	}
	if !(.Query == nil) {
		return false
	}

	return true
}

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

// FillFrom fills InvokeWithBusinessConnectionRequest from given interface.
func ( *InvokeWithBusinessConnectionRequest) ( interface {
	() ( string)
	() ( bin.Object)
}) {
	.ConnectionID = .()
	.Query = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InvokeWithBusinessConnectionRequest) () tdp.Type {
	 := tdp.Type{
		Name: "invokeWithBusinessConnection",
		ID:   InvokeWithBusinessConnectionRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ConnectionID",
			SchemaName: "connection_id",
		},
		{
			Name:       "Query",
			SchemaName: "query",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InvokeWithBusinessConnectionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode invokeWithBusinessConnection#dd289f8e as nil")
	}
	.PutID(InvokeWithBusinessConnectionRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InvokeWithBusinessConnectionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode invokeWithBusinessConnection#dd289f8e as nil")
	}
	.PutString(.ConnectionID)
	if  := .Query.Encode();  != nil {
		return fmt.Errorf("unable to encode invokeWithBusinessConnection#dd289f8e: field query: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InvokeWithBusinessConnectionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode invokeWithBusinessConnection#dd289f8e to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode invokeWithBusinessConnection#dd289f8e: field connection_id: %w", )
		}
		.ConnectionID = 
	}
	{
		if  := .Query.Decode();  != nil {
			return fmt.Errorf("unable to decode invokeWithBusinessConnection#dd289f8e: field query: %w", )
		}
	}
	return nil
}

// GetConnectionID returns value of ConnectionID field.
func ( *InvokeWithBusinessConnectionRequest) () ( string) {
	if  == nil {
		return
	}
	return .ConnectionID
}

// GetQuery returns value of Query field.
func ( *InvokeWithBusinessConnectionRequest) () ( bin.Object) {
	if  == nil {
		return
	}
	return .Query
}