package domain

import "time"

type CreateSnapshotsCmdPayload struct {
	serverKey       string
	versionCode     string
	versionTimezone string
	date            time.Time
}

const createSnapshotsCmdPayloadModelName = "CreateSnapshotsCmdPayload"

func NewCreateSnapshotsCmdPayload(
	serverKey string,
	versionCode string,
	versionTimezone string,
	date time.Time,
) (CreateSnapshotsCmdPayload, error) {
	if serverKey == "" {
		return CreateSnapshotsCmdPayload{}, ValidationError{
			Model: createSnapshotsCmdPayloadModelName,
			Field: "serverKey",
			Err:   ErrRequired,
		}
	}

	if versionCode == "" {
		return CreateSnapshotsCmdPayload{}, ValidationError{
			Model: createSnapshotsCmdPayloadModelName,
			Field: "versionCode",
			Err:   ErrRequired,
		}
	}

	if versionTimezone == "" {
		return CreateSnapshotsCmdPayload{}, ValidationError{
			Model: createSnapshotsCmdPayloadModelName,
			Field: "versionTimezone",
			Err:   ErrRequired,
		}
	}

	return CreateSnapshotsCmdPayload{
		serverKey:       serverKey,
		versionCode:     versionCode,
		versionTimezone: versionTimezone,
		date:            date,
	}, nil
}

func (p CreateSnapshotsCmdPayload) ServerKey() string {
	return p.serverKey
}

func (p CreateSnapshotsCmdPayload) VersionCode() string {
	return p.versionCode
}

func (p CreateSnapshotsCmdPayload) VersionTimezone() string {
	return p.versionTimezone
}

func (p CreateSnapshotsCmdPayload) Date() time.Time {
	return p.date
}

type SnapshotsCreatedEventPayload struct {
	serverKey   string
	versionCode string
}

const snapshotsCreatedEventPayloadModelName = "SnapshotsCreatedEventPayload"

func NewSnapshotsCreatedEventPayload(serverKey string, versionCode string) (SnapshotsCreatedEventPayload, error) {
	if serverKey == "" {
		return SnapshotsCreatedEventPayload{}, ValidationError{
			Model: snapshotsCreatedEventPayloadModelName,
			Field: "serverKey",
			Err:   ErrRequired,
		}
	}

	if versionCode == "" {
		return SnapshotsCreatedEventPayload{}, ValidationError{
			Model: snapshotsCreatedEventPayloadModelName,
			Field: "versionCode",
			Err:   ErrRequired,
		}
	}

	return SnapshotsCreatedEventPayload{serverKey: serverKey, versionCode: versionCode}, nil
}

func (p SnapshotsCreatedEventPayload) ServerKey() string {
	return p.serverKey
}

func (p SnapshotsCreatedEventPayload) VersionCode() string {
	return p.versionCode
}
