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

// PaymentsResolveStarGiftOfferRequest represents TL type `payments.resolveStarGiftOffer#e9ce781c`.
// Accept or decline a previously received collectible gift purchase offer »¹, see here
// »² for the full flow.
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gift-purchase-offers
//  2. https://core.telegram.org/api/gifts#collectible-gift-purchase-offers
//
// See https://core.telegram.org/method/payments.resolveStarGiftOffer for reference.
type PaymentsResolveStarGiftOfferRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, declines the offer; otherwise, accepts it.
	Decline bool
	// Identifier of the messageActionStarGiftPurchaseOffer¹ service message describing the
	// offer to act upon.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/messageActionStarGiftPurchaseOffer
	OfferMsgID int
}

// PaymentsResolveStarGiftOfferRequestTypeID is TL type id of PaymentsResolveStarGiftOfferRequest.
const PaymentsResolveStarGiftOfferRequestTypeID = 0xe9ce781c

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

func ( *PaymentsResolveStarGiftOfferRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Decline == false) {
		return false
	}
	if !(.OfferMsgID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsResolveStarGiftOfferRequest from given interface.
func ( *PaymentsResolveStarGiftOfferRequest) ( interface {
	() ( bool)
	() ( int)
}) {
	.Decline = .()
	.OfferMsgID = .()
}

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

// TypeName returns name of type in TL schema.
func (*PaymentsResolveStarGiftOfferRequest) () string {
	return "payments.resolveStarGiftOffer"
}

// TypeInfo returns info about TL type.
func ( *PaymentsResolveStarGiftOfferRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.resolveStarGiftOffer",
		ID:   PaymentsResolveStarGiftOfferRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Decline",
			SchemaName: "decline",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "OfferMsgID",
			SchemaName: "offer_msg_id",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsResolveStarGiftOfferRequest) () {
	if !(.Decline == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsResolveStarGiftOfferRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.resolveStarGiftOffer#e9ce781c as nil")
	}
	.PutID(PaymentsResolveStarGiftOfferRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsResolveStarGiftOfferRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.resolveStarGiftOffer#e9ce781c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.resolveStarGiftOffer#e9ce781c: field flags: %w", )
	}
	.PutInt(.OfferMsgID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsResolveStarGiftOfferRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.resolveStarGiftOffer#e9ce781c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.resolveStarGiftOffer#e9ce781c: field flags: %w", )
		}
	}
	.Decline = .Flags.Has(0)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode payments.resolveStarGiftOffer#e9ce781c: field offer_msg_id: %w", )
		}
		.OfferMsgID = 
	}
	return nil
}

// SetDecline sets value of Decline conditional field.
func ( *PaymentsResolveStarGiftOfferRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Decline = true
	} else {
		.Flags.Unset(0)
		.Decline = false
	}
}

// GetDecline returns value of Decline conditional field.
func ( *PaymentsResolveStarGiftOfferRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetOfferMsgID returns value of OfferMsgID field.
func ( *PaymentsResolveStarGiftOfferRequest) () ( int) {
	if  == nil {
		return
	}
	return .OfferMsgID
}

// PaymentsResolveStarGiftOffer invokes method payments.resolveStarGiftOffer#e9ce781c returning error if any.
// Accept or decline a previously received collectible gift purchase offer »¹, see here
// »² for the full flow.
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gift-purchase-offers
//  2. https://core.telegram.org/api/gifts#collectible-gift-purchase-offers
//
// Possible errors:
//
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//
// See https://core.telegram.org/method/payments.resolveStarGiftOffer for reference.
func ( *Client) ( context.Context,  *PaymentsResolveStarGiftOfferRequest) (UpdatesClass, error) {
	var  UpdatesBox

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return .Updates, nil
}