--[[----------------------------------------------------------------------------

WFCatSpaceTestUtils.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2022 Adobe

All Rights Reserved.
NOTICE: All information contained herein is, and remains
the property of Adobe and its suppliers, if any. The intellectual
and technical concepts contained herein are proprietary to Adobe
and its suppliers and are protected by all applicable intellectual
property laws, including trade secret and copyright laws.
Dissemination of this information or reproduction of this material
is strictly forbidden unless prior written permission is obtained
from Adobe.


----------------------------------------------------------------------------]]--

	-- WF.core.os
local KSDate = require 'KSDate'

	-- WF.core.utils
local KSIdGenerator = require 'KSIdGenerator'

--============================================================================--

local WFCatSpaceTestUtils = {}

--------------------------------------------------------------------------------
--[[!
 	\brief Create a comment document

 	\param commentId ( Optional String ) optional comment ID for document.
 	\param optArgs ( Optional Table ) Optional document modifiers:
 		assetId ( String ): sets the value for the asset ID.
 		authorId ( String ): sets the value for author ID
        commentRevId ( String ): sets the value for _newRevId.
        createdDate ( String ): sets the value for created date.
        spaceId ( String ): sets the value for _spaceId.
 		
 	\return (table) With comment document fields.
 --]]

function WFCatSpaceTestUtils.createComment( commentId, optArgs )
	
	local assetId = optArgs.assetId or KSIdGenerator.uuidInLowercaseHex()
	local authorId = optArgs.authorId or KSIdGenerator.uuidInLowercaseHex()
	local commentRevId = optArgs.commentRevId or KSIdGenerator.uuidInLowercaseHex()
	local createdDate = optArgs.createdDate or KSDate.timeInIso8601Format( nil, false )
	local spaceId = optArgs.spaceId or KSIdGenerator.uuidInLowercaseHex()
	commentId = commentId or KSIdGenerator.uuidInLowercaseHex()
	
	local commentDoc = {
			_id = commentId,
			_newRevId = commentRevId,
			type = 'comment',
			subtype = 'user',
			_spaceId = spaceId,
			asset = { id = assetId },
			body = 'foo',
			_localOnly = {
				created = createdDate,
				author = {
					id = authorId,
					full_name = "John Smith",
					first_name = "John",
					last_name = "Smith",
				},
			},
		}
	
	return commentDoc
	
end

--------------------------------------------------------------------------------
--[[!
 	\brief Create a favorite document

 	\param favoriteId ( Optional String ) optional favorite ID for document.
 	\param optArgs ( Optional Table ) Optional document modifiers:
 		assetId ( String ): sets the value for the asset ID.
 		authorId ( String ): sets the value for author ID
        createdDate ( String ): sets the value for created date.
		spaceId ( String ): sets the value for space ID.
 		
 	\return (table) With favorite document.
 --]]

function WFCatSpaceTestUtils.createFavorite( favoriteId, optArgs )
	
	local assetId = optArgs.assetId or KSIdGenerator.uuidInLowercaseHex()
	local authorId = optArgs.authorId or KSIdGenerator.uuidInLowercaseHex()
	local createdDate = optArgs.createdDate or KSDate.timeInIso8601Format( nil, false )
	local spaceId = optArgs.spaceId or KSIdGenerator.uuidInLowercaseHex()
	favoriteId = favoriteId or KSIdGenerator.uuidInLowercaseHex()
	
	local favoriteDoc = {
			_id = favoriteId,
			type = 'favorite',
			subtype = 'user',
			asset = { 
				id = assetId 
			},
			body = 'foo',
			_localOnly = {
				created = createdDate,
				author = {
					id = authorId,
					full_name = "John Smith",
					first_name = "John",
					last_name = "Smith",
				},
			},
			space = {
				id = spaceId 
			},
		}
	
	return favoriteDoc

end

--------------------------------------------------------------------------------
--[[!
 	\brief Create a space_album document

 	\param spaceAlbumId ( Optional String ) optional space albumId ID for document.
 	\param optArgs ( Optional Table ) Optional document modifiers:
		albumId ( String ): sets the value for the album ID.
		spaceId ( String ): sets the value for _spaceId.
        userCreatedDate ( String ): sets the value for when the user created date.
		userUpdatedDate ( String ): sets the value for when the user updated date.
 		
 	\return (table) With space album document.
 --]]
 
function WFCatSpaceTestUtils.createSpaceAlbumDocument( spaceAlbumId, optArgs )

	local albumId = optArgs.albumId or KSIdGenerator.uuidInLowercaseHex()
	local spaceId = optArgs.spaceId or KSIdGenerator.uuidInLowercaseHex()
	local userCreatedDate = optArgs.userCreatedDate or KSDate.timeInIso8601Format( nil, false )
	local userUpdatedDate = optArgs.userUpdatedDate or KSDate.timeInIso8601Format( nil, false )
	spaceAlbumId = spaceAlbumId or KSIdGenerator.uuidInLowercaseHex()
	
	local spaceAlbumDoc = {
				_id = spaceAlbumId,
				type = 'space_album',
				space = {
					id = spaceId
				},
				album = {
					id = albumId
				},
				userCreated = userCreatedDate,
				userUpdated = userUpdatedDate,
			}
	
	return spaceAlbumDoc

end

--------------------------------------------------------------------------------
--[[!
 	\brief Create a space document

 	\param spaceId ( Optional String ) optional space albumId ID for document.
 	\param optArgs ( Optional Table ) Optional document modifiers:
		commentsDisabledStatus ( Boolean ): Sets wether users can add comments.
 		docSubtype ( String ): sets the value for document suubtype. Supported 
								subtypes are 'shared', 'gallery', or ' review'.
		downloadStatus ( Boolean ): Sets if users can download resources from this space.
		favoritesDisabledStatus ( Boolean ): Indicates if users can favorite asset.
		locationStatus ( Boolean ): Sets if asset location information is shown.
		metadataStatus ( Boolean ): Indicates if asset metadata is shown for this space.
		privateStatus ( Boolean ): Indicates whether this space is publicly accessible.
		
	Note: if no modifiers are given boolean variables default to false.
 	\return (table) With space document.
 --]]
 
function WFCatSpaceTestUtils.createSpaceDocument( spaceId, optArgs )
	
	local commentsDisabledStatus = optArgs.commentsDisabledStatus or false
	local docSubtype = optArgs.docSubtype or "shared"
	local downloadStatus = optArgs.downloadStatus or false
	local favoritesDisabledStatus = optArgs.favoritesDisabledStatus or false
	local locationStatus = optArgs.locationStatus or false
	local metadataStatus = optArgs.metadataStatus or false
	local privateStatus = optArgs.privateStatus or false
	spaceId = spaceId or KSIdGenerator.uuidInLowercaseHex()
	
	local spaceAlbumDoc = {
			_id = spaceId,
			type = 'space',
			comments_disabled = commentsDisabledStatus,
			favorites_disabled = favoritesDisabledStatus,
			subtype = docSubtype,
			download = downloadStatus,
			private = privateStatus,
			location = locationStatus,
			metadata = metadataStatus,
		}
	
	return spaceAlbumDoc

end
--------------------------------------------------------------------------------

return WFCatSpaceTestUtils
