// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"time"
	"wechat-api/ent/whatsappchannel"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)

// WhatsappChannelCreate is the builder for creating a WhatsappChannel entity.
type WhatsappChannelCreate struct {
	config
	mutation *WhatsappChannelMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetCreatedAt sets the "created_at" field.
func (wcc *WhatsappChannelCreate) SetCreatedAt(t time.Time) *WhatsappChannelCreate {
	wcc.mutation.SetCreatedAt(t)
	return wcc
}

// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (wcc *WhatsappChannelCreate) SetNillableCreatedAt(t *time.Time) *WhatsappChannelCreate {
	if t != nil {
		wcc.SetCreatedAt(*t)
	}
	return wcc
}

// SetUpdatedAt sets the "updated_at" field.
func (wcc *WhatsappChannelCreate) SetUpdatedAt(t time.Time) *WhatsappChannelCreate {
	wcc.mutation.SetUpdatedAt(t)
	return wcc
}

// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (wcc *WhatsappChannelCreate) SetNillableUpdatedAt(t *time.Time) *WhatsappChannelCreate {
	if t != nil {
		wcc.SetUpdatedAt(*t)
	}
	return wcc
}

// SetStatus sets the "status" field.
func (wcc *WhatsappChannelCreate) SetStatus(u uint8) *WhatsappChannelCreate {
	wcc.mutation.SetStatus(u)
	return wcc
}

// SetNillableStatus sets the "status" field if the given value is not nil.
func (wcc *WhatsappChannelCreate) SetNillableStatus(u *uint8) *WhatsappChannelCreate {
	if u != nil {
		wcc.SetStatus(*u)
	}
	return wcc
}

// SetDeletedAt sets the "deleted_at" field.
func (wcc *WhatsappChannelCreate) SetDeletedAt(t time.Time) *WhatsappChannelCreate {
	wcc.mutation.SetDeletedAt(t)
	return wcc
}

// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (wcc *WhatsappChannelCreate) SetNillableDeletedAt(t *time.Time) *WhatsappChannelCreate {
	if t != nil {
		wcc.SetDeletedAt(*t)
	}
	return wcc
}

// SetAk sets the "ak" field.
func (wcc *WhatsappChannelCreate) SetAk(s string) *WhatsappChannelCreate {
	wcc.mutation.SetAk(s)
	return wcc
}

// SetNillableAk sets the "ak" field if the given value is not nil.
func (wcc *WhatsappChannelCreate) SetNillableAk(s *string) *WhatsappChannelCreate {
	if s != nil {
		wcc.SetAk(*s)
	}
	return wcc
}

// SetSk sets the "sk" field.
func (wcc *WhatsappChannelCreate) SetSk(s string) *WhatsappChannelCreate {
	wcc.mutation.SetSk(s)
	return wcc
}

// SetNillableSk sets the "sk" field if the given value is not nil.
func (wcc *WhatsappChannelCreate) SetNillableSk(s *string) *WhatsappChannelCreate {
	if s != nil {
		wcc.SetSk(*s)
	}
	return wcc
}

// SetWaID sets the "wa_id" field.
func (wcc *WhatsappChannelCreate) SetWaID(s string) *WhatsappChannelCreate {
	wcc.mutation.SetWaID(s)
	return wcc
}

// SetNillableWaID sets the "wa_id" field if the given value is not nil.
func (wcc *WhatsappChannelCreate) SetNillableWaID(s *string) *WhatsappChannelCreate {
	if s != nil {
		wcc.SetWaID(*s)
	}
	return wcc
}

// SetWaName sets the "wa_name" field.
func (wcc *WhatsappChannelCreate) SetWaName(s string) *WhatsappChannelCreate {
	wcc.mutation.SetWaName(s)
	return wcc
}

// SetNillableWaName sets the "wa_name" field if the given value is not nil.
func (wcc *WhatsappChannelCreate) SetNillableWaName(s *string) *WhatsappChannelCreate {
	if s != nil {
		wcc.SetWaName(*s)
	}
	return wcc
}

// SetWabaID sets the "waba_id" field.
func (wcc *WhatsappChannelCreate) SetWabaID(u uint64) *WhatsappChannelCreate {
	wcc.mutation.SetWabaID(u)
	return wcc
}

// SetNillableWabaID sets the "waba_id" field if the given value is not nil.
func (wcc *WhatsappChannelCreate) SetNillableWabaID(u *uint64) *WhatsappChannelCreate {
	if u != nil {
		wcc.SetWabaID(*u)
	}
	return wcc
}

// SetBusinessID sets the "business_id" field.
func (wcc *WhatsappChannelCreate) SetBusinessID(u uint64) *WhatsappChannelCreate {
	wcc.mutation.SetBusinessID(u)
	return wcc
}

// SetNillableBusinessID sets the "business_id" field if the given value is not nil.
func (wcc *WhatsappChannelCreate) SetNillableBusinessID(u *uint64) *WhatsappChannelCreate {
	if u != nil {
		wcc.SetBusinessID(*u)
	}
	return wcc
}

// SetOrganizationID sets the "organization_id" field.
func (wcc *WhatsappChannelCreate) SetOrganizationID(u uint64) *WhatsappChannelCreate {
	wcc.mutation.SetOrganizationID(u)
	return wcc
}

// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
func (wcc *WhatsappChannelCreate) SetNillableOrganizationID(u *uint64) *WhatsappChannelCreate {
	if u != nil {
		wcc.SetOrganizationID(*u)
	}
	return wcc
}

// SetVerifyAccount sets the "verify_account" field.
func (wcc *WhatsappChannelCreate) SetVerifyAccount(s string) *WhatsappChannelCreate {
	wcc.mutation.SetVerifyAccount(s)
	return wcc
}

// SetNillableVerifyAccount sets the "verify_account" field if the given value is not nil.
func (wcc *WhatsappChannelCreate) SetNillableVerifyAccount(s *string) *WhatsappChannelCreate {
	if s != nil {
		wcc.SetVerifyAccount(*s)
	}
	return wcc
}

// SetID sets the "id" field.
func (wcc *WhatsappChannelCreate) SetID(u uint64) *WhatsappChannelCreate {
	wcc.mutation.SetID(u)
	return wcc
}

// Mutation returns the WhatsappChannelMutation object of the builder.
func (wcc *WhatsappChannelCreate) Mutation() *WhatsappChannelMutation {
	return wcc.mutation
}

// Save creates the WhatsappChannel in the database.
func (wcc *WhatsappChannelCreate) Save(ctx context.Context) (*WhatsappChannel, error) {
	if err := wcc.defaults(); err != nil {
		return nil, err
	}
	return withHooks(ctx, wcc.sqlSave, wcc.mutation, wcc.hooks)
}

// SaveX calls Save and panics if Save returns an error.
func (wcc *WhatsappChannelCreate) SaveX(ctx context.Context) *WhatsappChannel {
	v, err := wcc.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (wcc *WhatsappChannelCreate) Exec(ctx context.Context) error {
	_, err := wcc.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (wcc *WhatsappChannelCreate) ExecX(ctx context.Context) {
	if err := wcc.Exec(ctx); err != nil {
		panic(err)
	}
}

// defaults sets the default values of the builder before save.
func (wcc *WhatsappChannelCreate) defaults() error {
	if _, ok := wcc.mutation.CreatedAt(); !ok {
		if whatsappchannel.DefaultCreatedAt == nil {
			return fmt.Errorf("ent: uninitialized whatsappchannel.DefaultCreatedAt (forgotten import ent/runtime?)")
		}
		v := whatsappchannel.DefaultCreatedAt()
		wcc.mutation.SetCreatedAt(v)
	}
	if _, ok := wcc.mutation.UpdatedAt(); !ok {
		if whatsappchannel.DefaultUpdatedAt == nil {
			return fmt.Errorf("ent: uninitialized whatsappchannel.DefaultUpdatedAt (forgotten import ent/runtime?)")
		}
		v := whatsappchannel.DefaultUpdatedAt()
		wcc.mutation.SetUpdatedAt(v)
	}
	if _, ok := wcc.mutation.Status(); !ok {
		v := whatsappchannel.DefaultStatus
		wcc.mutation.SetStatus(v)
	}
	if _, ok := wcc.mutation.Ak(); !ok {
		v := whatsappchannel.DefaultAk
		wcc.mutation.SetAk(v)
	}
	if _, ok := wcc.mutation.Sk(); !ok {
		v := whatsappchannel.DefaultSk
		wcc.mutation.SetSk(v)
	}
	if _, ok := wcc.mutation.WaID(); !ok {
		v := whatsappchannel.DefaultWaID
		wcc.mutation.SetWaID(v)
	}
	if _, ok := wcc.mutation.WaName(); !ok {
		v := whatsappchannel.DefaultWaName
		wcc.mutation.SetWaName(v)
	}
	if _, ok := wcc.mutation.WabaID(); !ok {
		v := whatsappchannel.DefaultWabaID
		wcc.mutation.SetWabaID(v)
	}
	if _, ok := wcc.mutation.BusinessID(); !ok {
		v := whatsappchannel.DefaultBusinessID
		wcc.mutation.SetBusinessID(v)
	}
	if _, ok := wcc.mutation.OrganizationID(); !ok {
		v := whatsappchannel.DefaultOrganizationID
		wcc.mutation.SetOrganizationID(v)
	}
	if _, ok := wcc.mutation.VerifyAccount(); !ok {
		v := whatsappchannel.DefaultVerifyAccount
		wcc.mutation.SetVerifyAccount(v)
	}
	return nil
}

// check runs all checks and user-defined validators on the builder.
func (wcc *WhatsappChannelCreate) check() error {
	if _, ok := wcc.mutation.CreatedAt(); !ok {
		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "WhatsappChannel.created_at"`)}
	}
	if _, ok := wcc.mutation.UpdatedAt(); !ok {
		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "WhatsappChannel.updated_at"`)}
	}
	if _, ok := wcc.mutation.Sk(); !ok {
		return &ValidationError{Name: "sk", err: errors.New(`ent: missing required field "WhatsappChannel.sk"`)}
	}
	if _, ok := wcc.mutation.WabaID(); !ok {
		return &ValidationError{Name: "waba_id", err: errors.New(`ent: missing required field "WhatsappChannel.waba_id"`)}
	}
	if _, ok := wcc.mutation.BusinessID(); !ok {
		return &ValidationError{Name: "business_id", err: errors.New(`ent: missing required field "WhatsappChannel.business_id"`)}
	}
	if _, ok := wcc.mutation.VerifyAccount(); !ok {
		return &ValidationError{Name: "verify_account", err: errors.New(`ent: missing required field "WhatsappChannel.verify_account"`)}
	}
	return nil
}

func (wcc *WhatsappChannelCreate) sqlSave(ctx context.Context) (*WhatsappChannel, error) {
	if err := wcc.check(); err != nil {
		return nil, err
	}
	_node, _spec := wcc.createSpec()
	if err := sqlgraph.CreateNode(ctx, wcc.driver, _spec); err != nil {
		if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	if _spec.ID.Value != _node.ID {
		id := _spec.ID.Value.(int64)
		_node.ID = uint64(id)
	}
	wcc.mutation.id = &_node.ID
	wcc.mutation.done = true
	return _node, nil
}

func (wcc *WhatsappChannelCreate) createSpec() (*WhatsappChannel, *sqlgraph.CreateSpec) {
	var (
		_node = &WhatsappChannel{config: wcc.config}
		_spec = sqlgraph.NewCreateSpec(whatsappchannel.Table, sqlgraph.NewFieldSpec(whatsappchannel.FieldID, field.TypeUint64))
	)
	_spec.OnConflict = wcc.conflict
	if id, ok := wcc.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = id
	}
	if value, ok := wcc.mutation.CreatedAt(); ok {
		_spec.SetField(whatsappchannel.FieldCreatedAt, field.TypeTime, value)
		_node.CreatedAt = value
	}
	if value, ok := wcc.mutation.UpdatedAt(); ok {
		_spec.SetField(whatsappchannel.FieldUpdatedAt, field.TypeTime, value)
		_node.UpdatedAt = value
	}
	if value, ok := wcc.mutation.Status(); ok {
		_spec.SetField(whatsappchannel.FieldStatus, field.TypeUint8, value)
		_node.Status = value
	}
	if value, ok := wcc.mutation.DeletedAt(); ok {
		_spec.SetField(whatsappchannel.FieldDeletedAt, field.TypeTime, value)
		_node.DeletedAt = value
	}
	if value, ok := wcc.mutation.Ak(); ok {
		_spec.SetField(whatsappchannel.FieldAk, field.TypeString, value)
		_node.Ak = value
	}
	if value, ok := wcc.mutation.Sk(); ok {
		_spec.SetField(whatsappchannel.FieldSk, field.TypeString, value)
		_node.Sk = value
	}
	if value, ok := wcc.mutation.WaID(); ok {
		_spec.SetField(whatsappchannel.FieldWaID, field.TypeString, value)
		_node.WaID = value
	}
	if value, ok := wcc.mutation.WaName(); ok {
		_spec.SetField(whatsappchannel.FieldWaName, field.TypeString, value)
		_node.WaName = value
	}
	if value, ok := wcc.mutation.WabaID(); ok {
		_spec.SetField(whatsappchannel.FieldWabaID, field.TypeUint64, value)
		_node.WabaID = value
	}
	if value, ok := wcc.mutation.BusinessID(); ok {
		_spec.SetField(whatsappchannel.FieldBusinessID, field.TypeUint64, value)
		_node.BusinessID = value
	}
	if value, ok := wcc.mutation.OrganizationID(); ok {
		_spec.SetField(whatsappchannel.FieldOrganizationID, field.TypeUint64, value)
		_node.OrganizationID = value
	}
	if value, ok := wcc.mutation.VerifyAccount(); ok {
		_spec.SetField(whatsappchannel.FieldVerifyAccount, field.TypeString, value)
		_node.VerifyAccount = value
	}
	return _node, _spec
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.WhatsappChannel.Create().
//		SetCreatedAt(v).
//		OnConflict(
//			// Update the row with the new values
//			// the was proposed for insertion.
//			sql.ResolveWithNewValues(),
//		).
//		// Override some of the fields with custom
//		// update values.
//		Update(func(u *ent.WhatsappChannelUpsert) {
//			SetCreatedAt(v+v).
//		}).
//		Exec(ctx)
func (wcc *WhatsappChannelCreate) OnConflict(opts ...sql.ConflictOption) *WhatsappChannelUpsertOne {
	wcc.conflict = opts
	return &WhatsappChannelUpsertOne{
		create: wcc,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.WhatsappChannel.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (wcc *WhatsappChannelCreate) OnConflictColumns(columns ...string) *WhatsappChannelUpsertOne {
	wcc.conflict = append(wcc.conflict, sql.ConflictColumns(columns...))
	return &WhatsappChannelUpsertOne{
		create: wcc,
	}
}

type (
	// WhatsappChannelUpsertOne is the builder for "upsert"-ing
	//  one WhatsappChannel node.
	WhatsappChannelUpsertOne struct {
		create *WhatsappChannelCreate
	}

	// WhatsappChannelUpsert is the "OnConflict" setter.
	WhatsappChannelUpsert struct {
		*sql.UpdateSet
	}
)

// SetUpdatedAt sets the "updated_at" field.
func (u *WhatsappChannelUpsert) SetUpdatedAt(v time.Time) *WhatsappChannelUpsert {
	u.Set(whatsappchannel.FieldUpdatedAt, v)
	return u
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *WhatsappChannelUpsert) UpdateUpdatedAt() *WhatsappChannelUpsert {
	u.SetExcluded(whatsappchannel.FieldUpdatedAt)
	return u
}

// SetStatus sets the "status" field.
func (u *WhatsappChannelUpsert) SetStatus(v uint8) *WhatsappChannelUpsert {
	u.Set(whatsappchannel.FieldStatus, v)
	return u
}

// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *WhatsappChannelUpsert) UpdateStatus() *WhatsappChannelUpsert {
	u.SetExcluded(whatsappchannel.FieldStatus)
	return u
}

// AddStatus adds v to the "status" field.
func (u *WhatsappChannelUpsert) AddStatus(v uint8) *WhatsappChannelUpsert {
	u.Add(whatsappchannel.FieldStatus, v)
	return u
}

// ClearStatus clears the value of the "status" field.
func (u *WhatsappChannelUpsert) ClearStatus() *WhatsappChannelUpsert {
	u.SetNull(whatsappchannel.FieldStatus)
	return u
}

// SetDeletedAt sets the "deleted_at" field.
func (u *WhatsappChannelUpsert) SetDeletedAt(v time.Time) *WhatsappChannelUpsert {
	u.Set(whatsappchannel.FieldDeletedAt, v)
	return u
}

// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *WhatsappChannelUpsert) UpdateDeletedAt() *WhatsappChannelUpsert {
	u.SetExcluded(whatsappchannel.FieldDeletedAt)
	return u
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *WhatsappChannelUpsert) ClearDeletedAt() *WhatsappChannelUpsert {
	u.SetNull(whatsappchannel.FieldDeletedAt)
	return u
}

// SetAk sets the "ak" field.
func (u *WhatsappChannelUpsert) SetAk(v string) *WhatsappChannelUpsert {
	u.Set(whatsappchannel.FieldAk, v)
	return u
}

// UpdateAk sets the "ak" field to the value that was provided on create.
func (u *WhatsappChannelUpsert) UpdateAk() *WhatsappChannelUpsert {
	u.SetExcluded(whatsappchannel.FieldAk)
	return u
}

// ClearAk clears the value of the "ak" field.
func (u *WhatsappChannelUpsert) ClearAk() *WhatsappChannelUpsert {
	u.SetNull(whatsappchannel.FieldAk)
	return u
}

// SetSk sets the "sk" field.
func (u *WhatsappChannelUpsert) SetSk(v string) *WhatsappChannelUpsert {
	u.Set(whatsappchannel.FieldSk, v)
	return u
}

// UpdateSk sets the "sk" field to the value that was provided on create.
func (u *WhatsappChannelUpsert) UpdateSk() *WhatsappChannelUpsert {
	u.SetExcluded(whatsappchannel.FieldSk)
	return u
}

// SetWaID sets the "wa_id" field.
func (u *WhatsappChannelUpsert) SetWaID(v string) *WhatsappChannelUpsert {
	u.Set(whatsappchannel.FieldWaID, v)
	return u
}

// UpdateWaID sets the "wa_id" field to the value that was provided on create.
func (u *WhatsappChannelUpsert) UpdateWaID() *WhatsappChannelUpsert {
	u.SetExcluded(whatsappchannel.FieldWaID)
	return u
}

// ClearWaID clears the value of the "wa_id" field.
func (u *WhatsappChannelUpsert) ClearWaID() *WhatsappChannelUpsert {
	u.SetNull(whatsappchannel.FieldWaID)
	return u
}

// SetWaName sets the "wa_name" field.
func (u *WhatsappChannelUpsert) SetWaName(v string) *WhatsappChannelUpsert {
	u.Set(whatsappchannel.FieldWaName, v)
	return u
}

// UpdateWaName sets the "wa_name" field to the value that was provided on create.
func (u *WhatsappChannelUpsert) UpdateWaName() *WhatsappChannelUpsert {
	u.SetExcluded(whatsappchannel.FieldWaName)
	return u
}

// ClearWaName clears the value of the "wa_name" field.
func (u *WhatsappChannelUpsert) ClearWaName() *WhatsappChannelUpsert {
	u.SetNull(whatsappchannel.FieldWaName)
	return u
}

// SetWabaID sets the "waba_id" field.
func (u *WhatsappChannelUpsert) SetWabaID(v uint64) *WhatsappChannelUpsert {
	u.Set(whatsappchannel.FieldWabaID, v)
	return u
}

// UpdateWabaID sets the "waba_id" field to the value that was provided on create.
func (u *WhatsappChannelUpsert) UpdateWabaID() *WhatsappChannelUpsert {
	u.SetExcluded(whatsappchannel.FieldWabaID)
	return u
}

// AddWabaID adds v to the "waba_id" field.
func (u *WhatsappChannelUpsert) AddWabaID(v uint64) *WhatsappChannelUpsert {
	u.Add(whatsappchannel.FieldWabaID, v)
	return u
}

// SetBusinessID sets the "business_id" field.
func (u *WhatsappChannelUpsert) SetBusinessID(v uint64) *WhatsappChannelUpsert {
	u.Set(whatsappchannel.FieldBusinessID, v)
	return u
}

// UpdateBusinessID sets the "business_id" field to the value that was provided on create.
func (u *WhatsappChannelUpsert) UpdateBusinessID() *WhatsappChannelUpsert {
	u.SetExcluded(whatsappchannel.FieldBusinessID)
	return u
}

// AddBusinessID adds v to the "business_id" field.
func (u *WhatsappChannelUpsert) AddBusinessID(v uint64) *WhatsappChannelUpsert {
	u.Add(whatsappchannel.FieldBusinessID, v)
	return u
}

// SetOrganizationID sets the "organization_id" field.
func (u *WhatsappChannelUpsert) SetOrganizationID(v uint64) *WhatsappChannelUpsert {
	u.Set(whatsappchannel.FieldOrganizationID, v)
	return u
}

// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
func (u *WhatsappChannelUpsert) UpdateOrganizationID() *WhatsappChannelUpsert {
	u.SetExcluded(whatsappchannel.FieldOrganizationID)
	return u
}

// AddOrganizationID adds v to the "organization_id" field.
func (u *WhatsappChannelUpsert) AddOrganizationID(v uint64) *WhatsappChannelUpsert {
	u.Add(whatsappchannel.FieldOrganizationID, v)
	return u
}

// ClearOrganizationID clears the value of the "organization_id" field.
func (u *WhatsappChannelUpsert) ClearOrganizationID() *WhatsappChannelUpsert {
	u.SetNull(whatsappchannel.FieldOrganizationID)
	return u
}

// SetVerifyAccount sets the "verify_account" field.
func (u *WhatsappChannelUpsert) SetVerifyAccount(v string) *WhatsappChannelUpsert {
	u.Set(whatsappchannel.FieldVerifyAccount, v)
	return u
}

// UpdateVerifyAccount sets the "verify_account" field to the value that was provided on create.
func (u *WhatsappChannelUpsert) UpdateVerifyAccount() *WhatsappChannelUpsert {
	u.SetExcluded(whatsappchannel.FieldVerifyAccount)
	return u
}

// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
// Using this option is equivalent to using:
//
//	client.WhatsappChannel.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(whatsappchannel.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *WhatsappChannelUpsertOne) UpdateNewValues() *WhatsappChannelUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		if _, exists := u.create.mutation.ID(); exists {
			s.SetIgnore(whatsappchannel.FieldID)
		}
		if _, exists := u.create.mutation.CreatedAt(); exists {
			s.SetIgnore(whatsappchannel.FieldCreatedAt)
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.WhatsappChannel.Create().
//	    OnConflict(sql.ResolveWithIgnore()).
//	    Exec(ctx)
func (u *WhatsappChannelUpsertOne) Ignore() *WhatsappChannelUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
	return u
}

// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *WhatsappChannelUpsertOne) DoNothing() *WhatsappChannelUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the WhatsappChannelCreate.OnConflict
// documentation for more info.
func (u *WhatsappChannelUpsertOne) Update(set func(*WhatsappChannelUpsert)) *WhatsappChannelUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&WhatsappChannelUpsert{UpdateSet: update})
	}))
	return u
}

// SetUpdatedAt sets the "updated_at" field.
func (u *WhatsappChannelUpsertOne) SetUpdatedAt(v time.Time) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetUpdatedAt(v)
	})
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *WhatsappChannelUpsertOne) UpdateUpdatedAt() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateUpdatedAt()
	})
}

// SetStatus sets the "status" field.
func (u *WhatsappChannelUpsertOne) SetStatus(v uint8) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetStatus(v)
	})
}

// AddStatus adds v to the "status" field.
func (u *WhatsappChannelUpsertOne) AddStatus(v uint8) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.AddStatus(v)
	})
}

// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *WhatsappChannelUpsertOne) UpdateStatus() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateStatus()
	})
}

// ClearStatus clears the value of the "status" field.
func (u *WhatsappChannelUpsertOne) ClearStatus() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.ClearStatus()
	})
}

// SetDeletedAt sets the "deleted_at" field.
func (u *WhatsappChannelUpsertOne) SetDeletedAt(v time.Time) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetDeletedAt(v)
	})
}

// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *WhatsappChannelUpsertOne) UpdateDeletedAt() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateDeletedAt()
	})
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *WhatsappChannelUpsertOne) ClearDeletedAt() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.ClearDeletedAt()
	})
}

// SetAk sets the "ak" field.
func (u *WhatsappChannelUpsertOne) SetAk(v string) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetAk(v)
	})
}

// UpdateAk sets the "ak" field to the value that was provided on create.
func (u *WhatsappChannelUpsertOne) UpdateAk() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateAk()
	})
}

// ClearAk clears the value of the "ak" field.
func (u *WhatsappChannelUpsertOne) ClearAk() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.ClearAk()
	})
}

// SetSk sets the "sk" field.
func (u *WhatsappChannelUpsertOne) SetSk(v string) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetSk(v)
	})
}

// UpdateSk sets the "sk" field to the value that was provided on create.
func (u *WhatsappChannelUpsertOne) UpdateSk() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateSk()
	})
}

// SetWaID sets the "wa_id" field.
func (u *WhatsappChannelUpsertOne) SetWaID(v string) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetWaID(v)
	})
}

// UpdateWaID sets the "wa_id" field to the value that was provided on create.
func (u *WhatsappChannelUpsertOne) UpdateWaID() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateWaID()
	})
}

// ClearWaID clears the value of the "wa_id" field.
func (u *WhatsappChannelUpsertOne) ClearWaID() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.ClearWaID()
	})
}

// SetWaName sets the "wa_name" field.
func (u *WhatsappChannelUpsertOne) SetWaName(v string) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetWaName(v)
	})
}

// UpdateWaName sets the "wa_name" field to the value that was provided on create.
func (u *WhatsappChannelUpsertOne) UpdateWaName() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateWaName()
	})
}

// ClearWaName clears the value of the "wa_name" field.
func (u *WhatsappChannelUpsertOne) ClearWaName() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.ClearWaName()
	})
}

// SetWabaID sets the "waba_id" field.
func (u *WhatsappChannelUpsertOne) SetWabaID(v uint64) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetWabaID(v)
	})
}

// AddWabaID adds v to the "waba_id" field.
func (u *WhatsappChannelUpsertOne) AddWabaID(v uint64) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.AddWabaID(v)
	})
}

// UpdateWabaID sets the "waba_id" field to the value that was provided on create.
func (u *WhatsappChannelUpsertOne) UpdateWabaID() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateWabaID()
	})
}

// SetBusinessID sets the "business_id" field.
func (u *WhatsappChannelUpsertOne) SetBusinessID(v uint64) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetBusinessID(v)
	})
}

// AddBusinessID adds v to the "business_id" field.
func (u *WhatsappChannelUpsertOne) AddBusinessID(v uint64) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.AddBusinessID(v)
	})
}

// UpdateBusinessID sets the "business_id" field to the value that was provided on create.
func (u *WhatsappChannelUpsertOne) UpdateBusinessID() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateBusinessID()
	})
}

// SetOrganizationID sets the "organization_id" field.
func (u *WhatsappChannelUpsertOne) SetOrganizationID(v uint64) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetOrganizationID(v)
	})
}

// AddOrganizationID adds v to the "organization_id" field.
func (u *WhatsappChannelUpsertOne) AddOrganizationID(v uint64) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.AddOrganizationID(v)
	})
}

// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
func (u *WhatsappChannelUpsertOne) UpdateOrganizationID() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateOrganizationID()
	})
}

// ClearOrganizationID clears the value of the "organization_id" field.
func (u *WhatsappChannelUpsertOne) ClearOrganizationID() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.ClearOrganizationID()
	})
}

// SetVerifyAccount sets the "verify_account" field.
func (u *WhatsappChannelUpsertOne) SetVerifyAccount(v string) *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetVerifyAccount(v)
	})
}

// UpdateVerifyAccount sets the "verify_account" field to the value that was provided on create.
func (u *WhatsappChannelUpsertOne) UpdateVerifyAccount() *WhatsappChannelUpsertOne {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateVerifyAccount()
	})
}

// Exec executes the query.
func (u *WhatsappChannelUpsertOne) Exec(ctx context.Context) error {
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for WhatsappChannelCreate.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *WhatsappChannelUpsertOne) ExecX(ctx context.Context) {
	if err := u.create.Exec(ctx); err != nil {
		panic(err)
	}
}

// Exec executes the UPSERT query and returns the inserted/updated ID.
func (u *WhatsappChannelUpsertOne) ID(ctx context.Context) (id uint64, err error) {
	node, err := u.create.Save(ctx)
	if err != nil {
		return id, err
	}
	return node.ID, nil
}

// IDX is like ID, but panics if an error occurs.
func (u *WhatsappChannelUpsertOne) IDX(ctx context.Context) uint64 {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

// WhatsappChannelCreateBulk is the builder for creating many WhatsappChannel entities in bulk.
type WhatsappChannelCreateBulk struct {
	config
	err      error
	builders []*WhatsappChannelCreate
	conflict []sql.ConflictOption
}

// Save creates the WhatsappChannel entities in the database.
func (wccb *WhatsappChannelCreateBulk) Save(ctx context.Context) ([]*WhatsappChannel, error) {
	if wccb.err != nil {
		return nil, wccb.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(wccb.builders))
	nodes := make([]*WhatsappChannel, len(wccb.builders))
	mutators := make([]Mutator, len(wccb.builders))
	for i := range wccb.builders {
		func(i int, root context.Context) {
			builder := wccb.builders[i]
			builder.defaults()
			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
				mutation, ok := m.(*WhatsappChannelMutation)
				if !ok {
					return nil, fmt.Errorf("unexpected mutation type %T", m)
				}
				if err := builder.check(); err != nil {
					return nil, err
				}
				builder.mutation = mutation
				var err error
				nodes[i], specs[i] = builder.createSpec()
				if i < len(mutators)-1 {
					_, err = mutators[i+1].Mutate(root, wccb.builders[i+1].mutation)
				} else {
					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
					spec.OnConflict = wccb.conflict
					// Invoke the actual operation on the latest mutation in the chain.
					if err = sqlgraph.BatchCreate(ctx, wccb.driver, spec); err != nil {
						if sqlgraph.IsConstraintError(err) {
							err = &ConstraintError{msg: err.Error(), wrap: err}
						}
					}
				}
				if err != nil {
					return nil, err
				}
				mutation.id = &nodes[i].ID
				if specs[i].ID.Value != nil && nodes[i].ID == 0 {
					id := specs[i].ID.Value.(int64)
					nodes[i].ID = uint64(id)
				}
				mutation.done = true
				return nodes[i], nil
			})
			for i := len(builder.hooks) - 1; i >= 0; i-- {
				mut = builder.hooks[i](mut)
			}
			mutators[i] = mut
		}(i, ctx)
	}
	if len(mutators) > 0 {
		if _, err := mutators[0].Mutate(ctx, wccb.builders[0].mutation); err != nil {
			return nil, err
		}
	}
	return nodes, nil
}

// SaveX is like Save, but panics if an error occurs.
func (wccb *WhatsappChannelCreateBulk) SaveX(ctx context.Context) []*WhatsappChannel {
	v, err := wccb.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (wccb *WhatsappChannelCreateBulk) Exec(ctx context.Context) error {
	_, err := wccb.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (wccb *WhatsappChannelCreateBulk) ExecX(ctx context.Context) {
	if err := wccb.Exec(ctx); err != nil {
		panic(err)
	}
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.WhatsappChannel.CreateBulk(builders...).
//		OnConflict(
//			// Update the row with the new values
//			// the was proposed for insertion.
//			sql.ResolveWithNewValues(),
//		).
//		// Override some of the fields with custom
//		// update values.
//		Update(func(u *ent.WhatsappChannelUpsert) {
//			SetCreatedAt(v+v).
//		}).
//		Exec(ctx)
func (wccb *WhatsappChannelCreateBulk) OnConflict(opts ...sql.ConflictOption) *WhatsappChannelUpsertBulk {
	wccb.conflict = opts
	return &WhatsappChannelUpsertBulk{
		create: wccb,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.WhatsappChannel.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (wccb *WhatsappChannelCreateBulk) OnConflictColumns(columns ...string) *WhatsappChannelUpsertBulk {
	wccb.conflict = append(wccb.conflict, sql.ConflictColumns(columns...))
	return &WhatsappChannelUpsertBulk{
		create: wccb,
	}
}

// WhatsappChannelUpsertBulk is the builder for "upsert"-ing
// a bulk of WhatsappChannel nodes.
type WhatsappChannelUpsertBulk struct {
	create *WhatsappChannelCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.WhatsappChannel.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(whatsappchannel.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *WhatsappChannelUpsertBulk) UpdateNewValues() *WhatsappChannelUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		for _, b := range u.create.builders {
			if _, exists := b.mutation.ID(); exists {
				s.SetIgnore(whatsappchannel.FieldID)
			}
			if _, exists := b.mutation.CreatedAt(); exists {
				s.SetIgnore(whatsappchannel.FieldCreatedAt)
			}
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.WhatsappChannel.Create().
//		OnConflict(sql.ResolveWithIgnore()).
//		Exec(ctx)
func (u *WhatsappChannelUpsertBulk) Ignore() *WhatsappChannelUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
	return u
}

// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *WhatsappChannelUpsertBulk) DoNothing() *WhatsappChannelUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the WhatsappChannelCreateBulk.OnConflict
// documentation for more info.
func (u *WhatsappChannelUpsertBulk) Update(set func(*WhatsappChannelUpsert)) *WhatsappChannelUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&WhatsappChannelUpsert{UpdateSet: update})
	}))
	return u
}

// SetUpdatedAt sets the "updated_at" field.
func (u *WhatsappChannelUpsertBulk) SetUpdatedAt(v time.Time) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetUpdatedAt(v)
	})
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *WhatsappChannelUpsertBulk) UpdateUpdatedAt() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateUpdatedAt()
	})
}

// SetStatus sets the "status" field.
func (u *WhatsappChannelUpsertBulk) SetStatus(v uint8) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetStatus(v)
	})
}

// AddStatus adds v to the "status" field.
func (u *WhatsappChannelUpsertBulk) AddStatus(v uint8) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.AddStatus(v)
	})
}

// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *WhatsappChannelUpsertBulk) UpdateStatus() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateStatus()
	})
}

// ClearStatus clears the value of the "status" field.
func (u *WhatsappChannelUpsertBulk) ClearStatus() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.ClearStatus()
	})
}

// SetDeletedAt sets the "deleted_at" field.
func (u *WhatsappChannelUpsertBulk) SetDeletedAt(v time.Time) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetDeletedAt(v)
	})
}

// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *WhatsappChannelUpsertBulk) UpdateDeletedAt() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateDeletedAt()
	})
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *WhatsappChannelUpsertBulk) ClearDeletedAt() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.ClearDeletedAt()
	})
}

// SetAk sets the "ak" field.
func (u *WhatsappChannelUpsertBulk) SetAk(v string) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetAk(v)
	})
}

// UpdateAk sets the "ak" field to the value that was provided on create.
func (u *WhatsappChannelUpsertBulk) UpdateAk() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateAk()
	})
}

// ClearAk clears the value of the "ak" field.
func (u *WhatsappChannelUpsertBulk) ClearAk() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.ClearAk()
	})
}

// SetSk sets the "sk" field.
func (u *WhatsappChannelUpsertBulk) SetSk(v string) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetSk(v)
	})
}

// UpdateSk sets the "sk" field to the value that was provided on create.
func (u *WhatsappChannelUpsertBulk) UpdateSk() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateSk()
	})
}

// SetWaID sets the "wa_id" field.
func (u *WhatsappChannelUpsertBulk) SetWaID(v string) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetWaID(v)
	})
}

// UpdateWaID sets the "wa_id" field to the value that was provided on create.
func (u *WhatsappChannelUpsertBulk) UpdateWaID() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateWaID()
	})
}

// ClearWaID clears the value of the "wa_id" field.
func (u *WhatsappChannelUpsertBulk) ClearWaID() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.ClearWaID()
	})
}

// SetWaName sets the "wa_name" field.
func (u *WhatsappChannelUpsertBulk) SetWaName(v string) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetWaName(v)
	})
}

// UpdateWaName sets the "wa_name" field to the value that was provided on create.
func (u *WhatsappChannelUpsertBulk) UpdateWaName() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateWaName()
	})
}

// ClearWaName clears the value of the "wa_name" field.
func (u *WhatsappChannelUpsertBulk) ClearWaName() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.ClearWaName()
	})
}

// SetWabaID sets the "waba_id" field.
func (u *WhatsappChannelUpsertBulk) SetWabaID(v uint64) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetWabaID(v)
	})
}

// AddWabaID adds v to the "waba_id" field.
func (u *WhatsappChannelUpsertBulk) AddWabaID(v uint64) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.AddWabaID(v)
	})
}

// UpdateWabaID sets the "waba_id" field to the value that was provided on create.
func (u *WhatsappChannelUpsertBulk) UpdateWabaID() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateWabaID()
	})
}

// SetBusinessID sets the "business_id" field.
func (u *WhatsappChannelUpsertBulk) SetBusinessID(v uint64) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetBusinessID(v)
	})
}

// AddBusinessID adds v to the "business_id" field.
func (u *WhatsappChannelUpsertBulk) AddBusinessID(v uint64) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.AddBusinessID(v)
	})
}

// UpdateBusinessID sets the "business_id" field to the value that was provided on create.
func (u *WhatsappChannelUpsertBulk) UpdateBusinessID() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateBusinessID()
	})
}

// SetOrganizationID sets the "organization_id" field.
func (u *WhatsappChannelUpsertBulk) SetOrganizationID(v uint64) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetOrganizationID(v)
	})
}

// AddOrganizationID adds v to the "organization_id" field.
func (u *WhatsappChannelUpsertBulk) AddOrganizationID(v uint64) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.AddOrganizationID(v)
	})
}

// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
func (u *WhatsappChannelUpsertBulk) UpdateOrganizationID() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateOrganizationID()
	})
}

// ClearOrganizationID clears the value of the "organization_id" field.
func (u *WhatsappChannelUpsertBulk) ClearOrganizationID() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.ClearOrganizationID()
	})
}

// SetVerifyAccount sets the "verify_account" field.
func (u *WhatsappChannelUpsertBulk) SetVerifyAccount(v string) *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.SetVerifyAccount(v)
	})
}

// UpdateVerifyAccount sets the "verify_account" field to the value that was provided on create.
func (u *WhatsappChannelUpsertBulk) UpdateVerifyAccount() *WhatsappChannelUpsertBulk {
	return u.Update(func(s *WhatsappChannelUpsert) {
		s.UpdateVerifyAccount()
	})
}

// Exec executes the query.
func (u *WhatsappChannelUpsertBulk) Exec(ctx context.Context) error {
	if u.create.err != nil {
		return u.create.err
	}
	for i, b := range u.create.builders {
		if len(b.conflict) != 0 {
			return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the WhatsappChannelCreateBulk instead", i)
		}
	}
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for WhatsappChannelCreateBulk.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *WhatsappChannelUpsertBulk) ExecX(ctx context.Context) {
	if err := u.create.Exec(ctx); err != nil {
		panic(err)
	}
}
