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

// PostAddress represents TL type `postAddress#1e8caaeb`.
// Shipping address
//
// See https://core.telegram.org/constructor/postAddress for reference.
type PostAddress struct {
	// First line for the address
	StreetLine1 string
	// Second line for the address
	StreetLine2 string
	// City
	City string
	// State, if applicable (empty otherwise)
	State string
	// ISO 3166-1 alpha-2 country code
	CountryISO2 string
	// Address post code
	PostCode string
}

// PostAddressTypeID is TL type id of PostAddress.
const PostAddressTypeID = 0x1e8caaeb

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

func ( *PostAddress) () bool {
	if  == nil {
		return true
	}
	if !(.StreetLine1 == "") {
		return false
	}
	if !(.StreetLine2 == "") {
		return false
	}
	if !(.City == "") {
		return false
	}
	if !(.State == "") {
		return false
	}
	if !(.CountryISO2 == "") {
		return false
	}
	if !(.PostCode == "") {
		return false
	}

	return true
}

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

// FillFrom fills PostAddress from given interface.
func ( *PostAddress) ( interface {
	() ( string)
	() ( string)
	() ( string)
	() ( string)
	() ( string)
	() ( string)
}) {
	.StreetLine1 = .()
	.StreetLine2 = .()
	.City = .()
	.State = .()
	.CountryISO2 = .()
	.PostCode = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PostAddress) () tdp.Type {
	 := tdp.Type{
		Name: "postAddress",
		ID:   PostAddressTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "StreetLine1",
			SchemaName: "street_line1",
		},
		{
			Name:       "StreetLine2",
			SchemaName: "street_line2",
		},
		{
			Name:       "City",
			SchemaName: "city",
		},
		{
			Name:       "State",
			SchemaName: "state",
		},
		{
			Name:       "CountryISO2",
			SchemaName: "country_iso2",
		},
		{
			Name:       "PostCode",
			SchemaName: "post_code",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PostAddress) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode postAddress#1e8caaeb as nil")
	}
	.PutID(PostAddressTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PostAddress) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode postAddress#1e8caaeb as nil")
	}
	.PutString(.StreetLine1)
	.PutString(.StreetLine2)
	.PutString(.City)
	.PutString(.State)
	.PutString(.CountryISO2)
	.PutString(.PostCode)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PostAddress) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode postAddress#1e8caaeb to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode postAddress#1e8caaeb: field street_line1: %w", )
		}
		.StreetLine1 = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode postAddress#1e8caaeb: field street_line2: %w", )
		}
		.StreetLine2 = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode postAddress#1e8caaeb: field city: %w", )
		}
		.City = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode postAddress#1e8caaeb: field state: %w", )
		}
		.State = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode postAddress#1e8caaeb: field country_iso2: %w", )
		}
		.CountryISO2 = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode postAddress#1e8caaeb: field post_code: %w", )
		}
		.PostCode = 
	}
	return nil
}

// GetStreetLine1 returns value of StreetLine1 field.
func ( *PostAddress) () ( string) {
	if  == nil {
		return
	}
	return .StreetLine1
}

// GetStreetLine2 returns value of StreetLine2 field.
func ( *PostAddress) () ( string) {
	if  == nil {
		return
	}
	return .StreetLine2
}

// GetCity returns value of City field.
func ( *PostAddress) () ( string) {
	if  == nil {
		return
	}
	return .City
}

// GetState returns value of State field.
func ( *PostAddress) () ( string) {
	if  == nil {
		return
	}
	return .State
}

// GetCountryISO2 returns value of CountryISO2 field.
func ( *PostAddress) () ( string) {
	if  == nil {
		return
	}
	return .CountryISO2
}

// GetPostCode returns value of PostCode field.
func ( *PostAddress) () ( string) {
	if  == nil {
		return
	}
	return .PostCode
}