package models

import "fmt"

type Application struct {
	Name   string `json:"name"`
	Number string `json:"-"`
}

func NewApplication(
	name string,
	opts ...ApplicationOpt,
) *Application {
	application := &Application{
		Name: name,
	}
	for _, opt := range opts {
		opt(application)
	}
	return application
}

type ApplicationOpt func(application *Application) error

func WithApplicationNumber(number int) ApplicationOpt {
	return func(application *Application) error {
		application.SetNumber(number)
		return nil
	}
}

func (a *Application) SetNumber(number int) {
	a.Number = fmt.Sprintf("%d", number)
}
