// Code generated by ent, DO NOT EDIT.

package ent

import (
	"fmt"
	"strings"
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect/sql"
	"github.com/google/uuid"
	"github.com/lightsparkdev/spark/so/ent/pendingsendtransfer"
	"github.com/lightsparkdev/spark/so/ent/schema/schematype"
)

// PendingSendTransfer is the model entity for the PendingSendTransfer schema.
type PendingSendTransfer struct {
	config `json:"-"`
	// ID of the ent.
	ID uuid.UUID `json:"id,omitempty"`
	// CreateTime holds the value of the "create_time" field.
	CreateTime time.Time `json:"create_time,omitempty"`
	// UpdateTime holds the value of the "update_time" field.
	UpdateTime time.Time `json:"update_time,omitempty"`
	// TransferID holds the value of the "transfer_id" field.
	TransferID uuid.UUID `json:"transfer_id,omitempty"`
	// Status holds the value of the "status" field.
	Status       schematype.PendingSendTransferStatus `json:"status,omitempty"`
	selectValues sql.SelectValues
}

// scanValues returns the types for scanning values from sql.Rows.
func (*PendingSendTransfer) scanValues(columns []string) ([]any, error) {
	values := make([]any, len(columns))
	for i := range columns {
		switch columns[i] {
		case pendingsendtransfer.FieldStatus:
			values[i] = new(sql.NullString)
		case pendingsendtransfer.FieldCreateTime, pendingsendtransfer.FieldUpdateTime:
			values[i] = new(sql.NullTime)
		case pendingsendtransfer.FieldID, pendingsendtransfer.FieldTransferID:
			values[i] = new(uuid.UUID)
		default:
			values[i] = new(sql.UnknownType)
		}
	}
	return values, nil
}

// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the PendingSendTransfer fields.
func (pst *PendingSendTransfer) assignValues(columns []string, values []any) error {
	if m, n := len(values), len(columns); m < n {
		return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
	}
	for i := range columns {
		switch columns[i] {
		case pendingsendtransfer.FieldID:
			if value, ok := values[i].(*uuid.UUID); !ok {
				return fmt.Errorf("unexpected type %T for field id", values[i])
			} else if value != nil {
				pst.ID = *value
			}
		case pendingsendtransfer.FieldCreateTime:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field create_time", values[i])
			} else if value.Valid {
				pst.CreateTime = value.Time
			}
		case pendingsendtransfer.FieldUpdateTime:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field update_time", values[i])
			} else if value.Valid {
				pst.UpdateTime = value.Time
			}
		case pendingsendtransfer.FieldTransferID:
			if value, ok := values[i].(*uuid.UUID); !ok {
				return fmt.Errorf("unexpected type %T for field transfer_id", values[i])
			} else if value != nil {
				pst.TransferID = *value
			}
		case pendingsendtransfer.FieldStatus:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field status", values[i])
			} else if value.Valid {
				pst.Status = schematype.PendingSendTransferStatus(value.String)
			}
		default:
			pst.selectValues.Set(columns[i], values[i])
		}
	}
	return nil
}

// Value returns the ent.Value that was dynamically selected and assigned to the PendingSendTransfer.
// This includes values selected through modifiers, order, etc.
func (pst *PendingSendTransfer) Value(name string) (ent.Value, error) {
	return pst.selectValues.Get(name)
}

// Update returns a builder for updating this PendingSendTransfer.
// Note that you need to call PendingSendTransfer.Unwrap() before calling this method if this PendingSendTransfer
// was returned from a transaction, and the transaction was committed or rolled back.
func (pst *PendingSendTransfer) Update() *PendingSendTransferUpdateOne {
	return NewPendingSendTransferClient(pst.config).UpdateOne(pst)
}

// Unwrap unwraps the PendingSendTransfer entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (pst *PendingSendTransfer) Unwrap() *PendingSendTransfer {
	_tx, ok := pst.config.driver.(*txDriver)
	if !ok {
		panic("ent: PendingSendTransfer is not a transactional entity")
	}
	pst.config.driver = _tx.drv
	return pst
}

// String implements the fmt.Stringer.
func (pst *PendingSendTransfer) String() string {
	var builder strings.Builder
	builder.WriteString("PendingSendTransfer(")
	builder.WriteString(fmt.Sprintf("id=%v, ", pst.ID))
	builder.WriteString("create_time=")
	builder.WriteString(pst.CreateTime.Format(time.ANSIC))
	builder.WriteString(", ")
	builder.WriteString("update_time=")
	builder.WriteString(pst.UpdateTime.Format(time.ANSIC))
	builder.WriteString(", ")
	builder.WriteString("transfer_id=")
	builder.WriteString(fmt.Sprintf("%v", pst.TransferID))
	builder.WriteString(", ")
	builder.WriteString("status=")
	builder.WriteString(fmt.Sprintf("%v", pst.Status))
	builder.WriteByte(')')
	return builder.String()
}

// PendingSendTransfers is a parsable slice of PendingSendTransfer.
type PendingSendTransfers []*PendingSendTransfer
