package domain

import (
	"net/url"
)

type SyncEnnoblementsCmdPayload struct {
	serverKey   string
	serverURL   *url.URL
	versionCode string
}

const syncEnnoblementsCmdPayloadModelName = "SyncEnnoblementsCmdPayload"

func NewSyncEnnoblementsCmdPayload(
	serverKey string,
	serverURL *url.URL,
	versionCode string,
) (SyncEnnoblementsCmdPayload, error) {
	if serverKey == "" {
		return SyncEnnoblementsCmdPayload{}, ValidationError{
			Model: syncEnnoblementsCmdPayloadModelName,
			Field: "serverKey",
			Err:   ErrRequired,
		}
	}

	if serverURL == nil {
		return SyncEnnoblementsCmdPayload{}, ValidationError{
			Model: syncEnnoblementsCmdPayloadModelName,
			Field: "serverURL",
			Err:   ErrNil,
		}
	}

	if versionCode == "" {
		return SyncEnnoblementsCmdPayload{}, ValidationError{
			Model: syncEnnoblementsCmdPayloadModelName,
			Field: "versionCode",
			Err:   ErrRequired,
		}
	}

	return SyncEnnoblementsCmdPayload{
		serverKey:   serverKey,
		serverURL:   serverURL,
		versionCode: versionCode,
	}, nil
}

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

func (p SyncEnnoblementsCmdPayload) ServerURL() *url.URL {
	return p.serverURL
}

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

type EnnoblementsSyncedEventPayload struct {
	serverKey   string
	serverURL   *url.URL
	versionCode string
}

const ennoblementsSyncedEventPayloadModelName = "EnnoblementsSyncedEventPayload"

func NewEnnoblementsSyncedEventPayload(
	serverKey string,
	serverURL *url.URL,
	versionCode string,
) (EnnoblementsSyncedEventPayload, error) {
	if serverKey == "" {
		return EnnoblementsSyncedEventPayload{}, ValidationError{
			Model: ennoblementsSyncedEventPayloadModelName,
			Field: "serverKey",
			Err:   ErrRequired,
		}
	}

	if serverURL == nil {
		return EnnoblementsSyncedEventPayload{}, ValidationError{
			Model: ennoblementsSyncedEventPayloadModelName,
			Field: "serverURL",
			Err:   ErrNil,
		}
	}

	if versionCode == "" {
		return EnnoblementsSyncedEventPayload{}, ValidationError{
			Model: ennoblementsSyncedEventPayloadModelName,
			Field: "versionCode",
			Err:   ErrRequired,
		}
	}

	return EnnoblementsSyncedEventPayload{
		serverKey:   serverKey,
		serverURL:   serverURL,
		versionCode: versionCode,
	}, nil
}

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

func (p EnnoblementsSyncedEventPayload) ServerURL() *url.URL {
	return p.serverURL
}

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