package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type PostAddress struct {
StreetLine1 string
StreetLine2 string
City string
State string
CountryISO2 string
PostCode string
}
const PostAddressTypeID = 0x1e8caaeb
var (
_ bin .Encoder = &PostAddress {}
_ bin .Decoder = &PostAddress {}
_ bin .BareEncoder = &PostAddress {}
_ bin .BareDecoder = &PostAddress {}
)
func (p *PostAddress ) Zero () bool {
if p == nil {
return true
}
if !(p .StreetLine1 == "" ) {
return false
}
if !(p .StreetLine2 == "" ) {
return false
}
if !(p .City == "" ) {
return false
}
if !(p .State == "" ) {
return false
}
if !(p .CountryISO2 == "" ) {
return false
}
if !(p .PostCode == "" ) {
return false
}
return true
}
func (p *PostAddress ) String () string {
if p == nil {
return "PostAddress(nil)"
}
type Alias PostAddress
return fmt .Sprintf ("PostAddress%+v" , Alias (*p ))
}
func (p *PostAddress ) FillFrom (from interface {
GetStreetLine1 () (value string )
GetStreetLine2 () (value string )
GetCity () (value string )
GetState () (value string )
GetCountryISO2 () (value string )
GetPostCode () (value string )
}) {
p .StreetLine1 = from .GetStreetLine1 ()
p .StreetLine2 = from .GetStreetLine2 ()
p .City = from .GetCity ()
p .State = from .GetState ()
p .CountryISO2 = from .GetCountryISO2 ()
p .PostCode = from .GetPostCode ()
}
func (*PostAddress ) TypeID () uint32 {
return PostAddressTypeID
}
func (*PostAddress ) TypeName () string {
return "postAddress"
}
func (p *PostAddress ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "postAddress" ,
ID : PostAddressTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .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 typ
}
func (p *PostAddress ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode postAddress#1e8caaeb as nil" )
}
b .PutID (PostAddressTypeID )
return p .EncodeBare (b )
}
func (p *PostAddress ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode postAddress#1e8caaeb as nil" )
}
b .PutString (p .StreetLine1 )
b .PutString (p .StreetLine2 )
b .PutString (p .City )
b .PutString (p .State )
b .PutString (p .CountryISO2 )
b .PutString (p .PostCode )
return nil
}
func (p *PostAddress ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode postAddress#1e8caaeb to nil" )
}
if err := b .ConsumeID (PostAddressTypeID ); err != nil {
return fmt .Errorf ("unable to decode postAddress#1e8caaeb: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PostAddress ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode postAddress#1e8caaeb to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode postAddress#1e8caaeb: field street_line1: %w" , err )
}
p .StreetLine1 = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode postAddress#1e8caaeb: field street_line2: %w" , err )
}
p .StreetLine2 = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode postAddress#1e8caaeb: field city: %w" , err )
}
p .City = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode postAddress#1e8caaeb: field state: %w" , err )
}
p .State = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode postAddress#1e8caaeb: field country_iso2: %w" , err )
}
p .CountryISO2 = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode postAddress#1e8caaeb: field post_code: %w" , err )
}
p .PostCode = value
}
return nil
}
func (p *PostAddress ) GetStreetLine1 () (value string ) {
if p == nil {
return
}
return p .StreetLine1
}
func (p *PostAddress ) GetStreetLine2 () (value string ) {
if p == nil {
return
}
return p .StreetLine2
}
func (p *PostAddress ) GetCity () (value string ) {
if p == nil {
return
}
return p .City
}
func (p *PostAddress ) GetState () (value string ) {
if p == nil {
return
}
return p .State
}
func (p *PostAddress ) GetCountryISO2 () (value string ) {
if p == nil {
return
}
return p .CountryISO2
}
func (p *PostAddress ) GetPostCode () (value string ) {
if p == nil {
return
}
return p .PostCode
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .