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

// RestrictionReason represents TL type `restrictionReason#d072acb4`.
// Restriction reason.
// Contains the reason why access to a certain object must be restricted. Clients are
// supposed to deny access to the channel if the platform field is equal to all or to the
// current platform (ios, android, wp, etc.). Platforms can be concatenated (ios-android,
// ios-wp), unknown platforms are to be ignored. The text is the error message that
// should be shown to the user.
//
// See https://core.telegram.org/constructor/restrictionReason for reference.
type RestrictionReason struct {
	// Platform identifier (ios, android, wp, all, etc.), can be concatenated with a dash as
	// separator (android-ios, ios-wp, etc)
	Platform string
	// Restriction reason (porno, terms, etc.)
	Reason string
	// Error message to be shown to the user
	Text string
}

// RestrictionReasonTypeID is TL type id of RestrictionReason.
const RestrictionReasonTypeID = 0xd072acb4

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

func ( *RestrictionReason) () bool {
	if  == nil {
		return true
	}
	if !(.Platform == "") {
		return false
	}
	if !(.Reason == "") {
		return false
	}
	if !(.Text == "") {
		return false
	}

	return true
}

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

// FillFrom fills RestrictionReason from given interface.
func ( *RestrictionReason) ( interface {
	() ( string)
	() ( string)
	() ( string)
}) {
	.Platform = .()
	.Reason = .()
	.Text = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *RestrictionReason) () tdp.Type {
	 := tdp.Type{
		Name: "restrictionReason",
		ID:   RestrictionReasonTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Platform",
			SchemaName: "platform",
		},
		{
			Name:       "Reason",
			SchemaName: "reason",
		},
		{
			Name:       "Text",
			SchemaName: "text",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *RestrictionReason) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode restrictionReason#d072acb4 as nil")
	}
	.PutID(RestrictionReasonTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *RestrictionReason) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode restrictionReason#d072acb4 as nil")
	}
	.PutString(.Platform)
	.PutString(.Reason)
	.PutString(.Text)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *RestrictionReason) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode restrictionReason#d072acb4 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode restrictionReason#d072acb4: field platform: %w", )
		}
		.Platform = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode restrictionReason#d072acb4: field reason: %w", )
		}
		.Reason = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode restrictionReason#d072acb4: field text: %w", )
		}
		.Text = 
	}
	return nil
}

// GetPlatform returns value of Platform field.
func ( *RestrictionReason) () ( string) {
	if  == nil {
		return
	}
	return .Platform
}

// GetReason returns value of Reason field.
func ( *RestrictionReason) () ( string) {
	if  == nil {
		return
	}
	return .Reason
}

// GetText returns value of Text field.
func ( *RestrictionReason) () ( string) {
	if  == nil {
		return
	}
	return .Text
}