downloader/api/internal/core/entities/download.go

27 lines
487 B
Go
Raw Normal View History

2021-12-21 02:18:11 +01:00
package entities
import (
"downloader/pkg/common/uuid"
"errors"
)
type Download struct {
ID string `json:"id"`
Status string `json:"status"`
Link string `json:"link"`
}
2021-12-21 23:05:00 +01:00
func NewDownload(link string) func(uuidGen uuid.Gen) (*Download, error) {
2021-12-21 02:18:11 +01:00
return func(uuidGen uuid.Gen) (*Download, error) {
2021-12-21 23:05:00 +01:00
if link == "" {
2021-12-21 02:18:11 +01:00
return nil, errors.New("A field was not valid")
}
return &Download{
ID: uuidGen.Create(),
Status: "scheduled",
Link: link,
}, nil
}
}