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

// JSONObjectValue represents TL type `jsonObjectValue#c0de1bd9`.
// JSON key: value pair
//
// See https://core.telegram.org/constructor/jsonObjectValue for reference.
type JSONObjectValue struct {
	// Key
	Key string
	// Value
	Value JSONValueClass
}

// JSONObjectValueTypeID is TL type id of JSONObjectValue.
const JSONObjectValueTypeID = 0xc0de1bd9

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

func ( *JSONObjectValue) () bool {
	if  == nil {
		return true
	}
	if !(.Key == "") {
		return false
	}
	if !(.Value == nil) {
		return false
	}

	return true
}

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

// FillFrom fills JSONObjectValue from given interface.
func ( *JSONObjectValue) ( interface {
	() ( string)
	() ( JSONValueClass)
}) {
	.Key = .()
	.Value = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *JSONObjectValue) () tdp.Type {
	 := tdp.Type{
		Name: "jsonObjectValue",
		ID:   JSONObjectValueTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Key",
			SchemaName: "key",
		},
		{
			Name:       "Value",
			SchemaName: "value",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *JSONObjectValue) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode jsonObjectValue#c0de1bd9 as nil")
	}
	.PutID(JSONObjectValueTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *JSONObjectValue) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode jsonObjectValue#c0de1bd9 as nil")
	}
	.PutString(.Key)
	if .Value == nil {
		return fmt.Errorf("unable to encode jsonObjectValue#c0de1bd9: field value is nil")
	}
	if  := .Value.Encode();  != nil {
		return fmt.Errorf("unable to encode jsonObjectValue#c0de1bd9: field value: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *JSONObjectValue) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode jsonObjectValue#c0de1bd9 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode jsonObjectValue#c0de1bd9: field key: %w", )
		}
		.Key = 
	}
	{
		,  := DecodeJSONValue()
		if  != nil {
			return fmt.Errorf("unable to decode jsonObjectValue#c0de1bd9: field value: %w", )
		}
		.Value = 
	}
	return nil
}

// GetKey returns value of Key field.
func ( *JSONObjectValue) () ( string) {
	if  == nil {
		return
	}
	return .Key
}

// GetValue returns value of Value field.
func ( *JSONObjectValue) () ( JSONValueClass) {
	if  == nil {
		return
	}
	return .Value
}