package domain import ( "errors" "net/url" ) type SyncServersCmdPayload struct { versionCode string url *url.URL } func NewSyncServersCmdPayload(versionCode string, u *url.URL) (SyncServersCmdPayload, error) { if versionCode == "" { return SyncServersCmdPayload{}, errors.New("version code can't be blank") } if u == nil { return SyncServersCmdPayload{}, errors.New("url can't be nil") } return SyncServersCmdPayload{versionCode: versionCode, url: u}, nil } func NewSyncServersCmdPayloadWithStringURL(versionCode string, rawURL string) (SyncServersCmdPayload, error) { u, err := parseURL(rawURL) if err != nil { return SyncServersCmdPayload{}, err } return NewSyncServersCmdPayload(versionCode, u) } func (p SyncServersCmdPayload) VersionCode() string { return p.versionCode } func (p SyncServersCmdPayload) URL() *url.URL { return p.url }