diff --git a/src/MarcSync/MarcSyncv1.0.lua b/src/MarcSync/MarcSyncv1.0.lua index bbecde5..4fa246a 100644 --- a/src/MarcSync/MarcSyncv1.0.lua +++ b/src/MarcSync/MarcSyncv1.0.lua @@ -52,7 +52,7 @@ return { self._checkInstallation = function() if not self then error("Please Setup MarcSync before using MarcSync.") end if not self._accessToken then error("[MarcSync] Please set a Token before using MarcSync.") end - if not HttpService.HttpEnabled then error("Please Enable HTTPService in order to use MarcSync.") end + if not game:GetService("HttpService").HttpEnabled then error("Please Enable HTTPService in order to use MarcSync.") end end self = setmetatable(self, { diff --git a/src/MarcSync/Objects/Collection.lua b/src/MarcSync/Objects/Collection.lua index 73c0d79..435d7b7 100644 --- a/src/MarcSync/Objects/Collection.lua +++ b/src/MarcSync/Objects/Collection.lua @@ -1,13 +1,11 @@ local Utils = require(script.Parent.Parent.Utils) local Entry = require(script.Parent.Entry) -local types = { - EntryData = require(script.Parent.Parent.Types.EntryData).getType() -} +local Types = require(script.Parent.Parent.Types) local Collection = {} -Collection.createEntry = function(self:typeof(Collection), data:typeof(types.EntryData)):typeof(Entry.new()) +Collection.createEntry = function(self:typeof(Collection), data:Types.EntryData):typeof(Entry.new()) if not self._collectionName then error("[MarcSync: Collection] Invalid Object created or trying to access an destroied object.") end local result = Utils.makeHTTPRequest("entry", "POST", "https://api.marcsync.dev/v0/entries/"..self._collectionName, {["data"]=data}, self._accessToken); @@ -21,7 +19,7 @@ Collection.createEntry = function(self:typeof(Collection), data:typeof(types.Ent return result end -Collection.updateEntries = function(self:typeof(Collection), filters:typeof(types.EntryData), data:typeof(types.EntryData)):number +Collection.updateEntries = function(self:typeof(Collection), filters:Types.EntryData, data:Types.EntryData):number if not self._collectionName then error("[MarcSync: Collection] Invalid Object created or trying to access an destroied object.") end local result = Utils.makeHTTPRequest("entry", "PUT", "https://api.marcsync.dev/v0/entries/"..self._collectionName, {["filters"]=filters,["data"]=data}, self._accessToken); if not result["success"] then error(result["errorMessage"]) end @@ -29,7 +27,7 @@ Collection.updateEntries = function(self:typeof(Collection), filters:typeof(type return result["modifiedEntries"] end -Collection.getEntries = function(self:typeof(Collection), filters:typeof(types.EntryData)):{[number]:typeof(Entry.new())} +Collection.getEntries = function(self:typeof(Collection), filters:Types.EntryData):{[number]:typeof(Entry.new())} if not self._collectionName then error("[MarcSync: Collection] Invalid Object created or trying to access an destroied object.") end if not filters then filters = {} end local result = Utils.makeHTTPRequest("entry", "DELETE", "https://api.marcsync.dev/v0/entries/"..self._collectionName.."?isQuery=true", {["filters"]=filters}, self._accessToken); @@ -46,7 +44,7 @@ Collection.getEntries = function(self:typeof(Collection), filters:typeof(types.E return result end -Collection.deleteEntries = function(self:typeof(Collection), filters:typeof(types.EntryData)):number +Collection.deleteEntries = function(self:typeof(Collection), filters:Types.EntryData):number if not self._collectionName then error("[MarcSync: Collection] Invalid Object created or trying to access an destroied object.") end local result = Utils.makeHTTPRequest("DELETE", "https://api.marcsync.dev/v0/entries/"..self._collectionName, {["filters"]=filters}, self._accessToken); if not result["success"] then error(result["errorMessage"]) end diff --git a/src/MarcSync/Objects/Entry.lua b/src/MarcSync/Objects/Entry.lua index d28907e..1bc4e5d 100644 --- a/src/MarcSync/Objects/Entry.lua +++ b/src/MarcSync/Objects/Entry.lua @@ -1,8 +1,6 @@ local Utils = require(script.Parent.Parent.Utils) -local types = { - EntryData = require(script.Parent.Parent.Types.EntryData).getType() -} +local Types = require(script.Parent.Parent.Types) local Entry = {} @@ -11,11 +9,11 @@ Entry.getValue = function(self:typeof(Entry), key:string):any return self._entryData[key] end -Entry.getValues = function(self:typeof(Entry)):typeof(types.EntryData) +Entry.getValues = function(self:typeof(Entry)):Types.EntryData return self._entryData end -Entry.updateValues = function(self:typeof(Entry), data:typeof(types.EntryData)):number +Entry.updateValues = function(self:typeof(Entry), data:Types.EntryData):number local result = Utils.makeHTTPRequest("entry", "PUT", "https://api.marcsync.dev/v0/entries/"..self._tableId, {["filters"]={["_id"]=self._objectId},["data"]=data}, self._accessToken); if result["success"] and result["modifiedEntries"] and result["modifiedEntries"] > 0 then @@ -39,7 +37,7 @@ Entry.delete = function(self:typeof(Entry)) end return { - new = function(tableId:string, entryData:typeof(types.EntryData), accessToken:string):typeof(Entry) + new = function(tableId:string, entryData:Types.EntryData, accessToken:string):typeof(Entry) if not tableId or not entryData or not entryData["_id"] or not accessToken then error("[MarcSync: Entry] Tried creating invalid Entry Object.") end local self = {} self._tableId = tableId diff --git a/src/MarcSync/Types.lua b/src/MarcSync/Types.lua new file mode 100644 index 0000000..835be36 --- /dev/null +++ b/src/MarcSync/Types.lua @@ -0,0 +1,7 @@ +local types = {} + +export type EntryData = { + [string]: any +} + +return types \ No newline at end of file diff --git a/src/MarcSync/Types/EntryData.lua b/src/MarcSync/Types/EntryData.lua deleted file mode 100644 index c9f8aa1..0000000 --- a/src/MarcSync/Types/EntryData.lua +++ /dev/null @@ -1,9 +0,0 @@ -type EntryData = { - [string]: any -} - -return { - getType = function(): EntryData - return {} - end, -} \ No newline at end of file