--[[
	Api.Classes
	Api.Enums
	Api.GetProperties(className)
	Api.IsEnum(valueType)
--]]


	-- Services
	local HttpService = game:GetService("HttpService")
	local ServerStorage = game:GetService("ServerStorage")
	local ReplicatedStorage = game:GetService("ReplicatedStorage")

	-- Functions
	local apiDump = HttpService:JSONDecode(jsonToParse)

	local Classes = {}
	local Enums = {}

	local function sortAlphabetic(t, property)
		table.sort(t,
			function(x,y) return x[property] < y[property]
		end)
	end

	local function isEnum(name)
		return Enums[name] ~= nil
	end

	local function getProperties(className)
		local class = Classes[className]
		local properties = {}

		if not class then return properties end
		
		while class do
			for _,member in pairs(class.Members) do
				if member.MemberType == "Property" then
					table.insert(properties, member)
				end
			end
			class = Classes[class.Superclass]
		end

		sortAlphabetic(properties, "Name")

		return properties
	end
	
	for i, class in ipairs(apiDump.Classes) do
		Classes[class.Name] = class
	end
	for _, enum in ipairs(apiDump.Enums) do
		Enums[enum.Name] = enum
	end

	return {
		Classes = Classes;
		Enums = Enums;
		GetProperties = getProperties;
		IsEnum = isEnum;
	}
end
