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

// SMSJobsStatus represents TL type `smsjobs.status#2aee9191`.
// Status
//
// See https://core.telegram.org/constructor/smsjobs.status for reference.
type SMSJobsStatus struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Allow international numbers
	AllowInternational bool
	// Recently sent
	RecentSent int
	// Since
	RecentSince int
	// Remaining
	RecentRemains int
	// Total sent
	TotalSent int
	// Total since
	TotalSince int
	// Last gift deep link
	//
	// Use SetLastGiftSlug and GetLastGiftSlug helpers.
	LastGiftSlug string
	// Terms of service URL
	TermsURL string
}

// SMSJobsStatusTypeID is TL type id of SMSJobsStatus.
const SMSJobsStatusTypeID = 0x2aee9191

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

func ( *SMSJobsStatus) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.AllowInternational == false) {
		return false
	}
	if !(.RecentSent == 0) {
		return false
	}
	if !(.RecentSince == 0) {
		return false
	}
	if !(.RecentRemains == 0) {
		return false
	}
	if !(.TotalSent == 0) {
		return false
	}
	if !(.TotalSince == 0) {
		return false
	}
	if !(.LastGiftSlug == "") {
		return false
	}
	if !(.TermsURL == "") {
		return false
	}

	return true
}

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

// FillFrom fills SMSJobsStatus from given interface.
func ( *SMSJobsStatus) ( interface {
	() ( bool)
	() ( int)
	() ( int)
	() ( int)
	() ( int)
	() ( int)
	() ( string,  bool)
	() ( string)
}) {
	.AllowInternational = .()
	.RecentSent = .()
	.RecentSince = .()
	.RecentRemains = .()
	.TotalSent = .()
	.TotalSince = .()
	if ,  := .();  {
		.LastGiftSlug = 
	}

	.TermsURL = .()
}

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

// TypeName returns name of type in TL schema.
func (*SMSJobsStatus) () string {
	return "smsjobs.status"
}

// TypeInfo returns info about TL type.
func ( *SMSJobsStatus) () tdp.Type {
	 := tdp.Type{
		Name: "smsjobs.status",
		ID:   SMSJobsStatusTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "AllowInternational",
			SchemaName: "allow_international",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "RecentSent",
			SchemaName: "recent_sent",
		},
		{
			Name:       "RecentSince",
			SchemaName: "recent_since",
		},
		{
			Name:       "RecentRemains",
			SchemaName: "recent_remains",
		},
		{
			Name:       "TotalSent",
			SchemaName: "total_sent",
		},
		{
			Name:       "TotalSince",
			SchemaName: "total_since",
		},
		{
			Name:       "LastGiftSlug",
			SchemaName: "last_gift_slug",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "TermsURL",
			SchemaName: "terms_url",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *SMSJobsStatus) () {
	if !(.AllowInternational == false) {
		.Flags.Set(0)
	}
	if !(.LastGiftSlug == "") {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *SMSJobsStatus) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode smsjobs.status#2aee9191 as nil")
	}
	.PutID(SMSJobsStatusTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *SMSJobsStatus) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode smsjobs.status#2aee9191 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode smsjobs.status#2aee9191: field flags: %w", )
	}
	.PutInt(.RecentSent)
	.PutInt(.RecentSince)
	.PutInt(.RecentRemains)
	.PutInt(.TotalSent)
	.PutInt(.TotalSince)
	if .Flags.Has(1) {
		.PutString(.LastGiftSlug)
	}
	.PutString(.TermsURL)
	return nil
}

// Decode implements bin.Decoder.
func ( *SMSJobsStatus) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode smsjobs.status#2aee9191 to nil")
	}
	if  := .ConsumeID(SMSJobsStatusTypeID);  != nil {
		return fmt.Errorf("unable to decode smsjobs.status#2aee9191: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *SMSJobsStatus) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode smsjobs.status#2aee9191 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode smsjobs.status#2aee9191: field flags: %w", )
		}
	}
	.AllowInternational = .Flags.Has(0)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode smsjobs.status#2aee9191: field recent_sent: %w", )
		}
		.RecentSent = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode smsjobs.status#2aee9191: field recent_since: %w", )
		}
		.RecentSince = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode smsjobs.status#2aee9191: field recent_remains: %w", )
		}
		.RecentRemains = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode smsjobs.status#2aee9191: field total_sent: %w", )
		}
		.TotalSent = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode smsjobs.status#2aee9191: field total_since: %w", )
		}
		.TotalSince = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode smsjobs.status#2aee9191: field last_gift_slug: %w", )
		}
		.LastGiftSlug = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode smsjobs.status#2aee9191: field terms_url: %w", )
		}
		.TermsURL = 
	}
	return nil
}

// SetAllowInternational sets value of AllowInternational conditional field.
func ( *SMSJobsStatus) ( bool) {
	if  {
		.Flags.Set(0)
		.AllowInternational = true
	} else {
		.Flags.Unset(0)
		.AllowInternational = false
	}
}

// GetAllowInternational returns value of AllowInternational conditional field.
func ( *SMSJobsStatus) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetRecentSent returns value of RecentSent field.
func ( *SMSJobsStatus) () ( int) {
	if  == nil {
		return
	}
	return .RecentSent
}

// GetRecentSince returns value of RecentSince field.
func ( *SMSJobsStatus) () ( int) {
	if  == nil {
		return
	}
	return .RecentSince
}

// GetRecentRemains returns value of RecentRemains field.
func ( *SMSJobsStatus) () ( int) {
	if  == nil {
		return
	}
	return .RecentRemains
}

// GetTotalSent returns value of TotalSent field.
func ( *SMSJobsStatus) () ( int) {
	if  == nil {
		return
	}
	return .TotalSent
}

// GetTotalSince returns value of TotalSince field.
func ( *SMSJobsStatus) () ( int) {
	if  == nil {
		return
	}
	return .TotalSince
}

// SetLastGiftSlug sets value of LastGiftSlug conditional field.
func ( *SMSJobsStatus) ( string) {
	.Flags.Set(1)
	.LastGiftSlug = 
}

// GetLastGiftSlug returns value of LastGiftSlug conditional field and
// boolean which is true if field was set.
func ( *SMSJobsStatus) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .LastGiftSlug, true
}

// GetTermsURL returns value of TermsURL field.
func ( *SMSJobsStatus) () ( string) {
	if  == nil {
		return
	}
	return .TermsURL
}