Author SHA1 Message Date
IBims2CooleTim be4e83588b Update FilterData.lua 2023-12-21 21:42:19 +01:00
IBims2CooleTim 06304f1aee Changes:
- Changed Endpoints to v1
2023-12-16 04:33:06 +01:00
6 changed files with 32 additions and 33 deletions

No files matched your search

-21
View File
@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2023 Marcel Lorbeer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
BIN
View File
Binary file not shown.
@@ -52,8 +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
--print(HttpService.HttpEnabled)
--if not HttpService.HttpEnabled then error("Please Enable HTTPService in order to use MarcSync.") end
if not HttpService.HttpEnabled then error("Please Enable HTTPService in order to use MarcSync.") end
end
self = setmetatable(self, {
@@ -62,4 +61,4 @@ return {
return self
end
}
}
+17 -7
View File
@@ -2,7 +2,8 @@ local Utils = require(script.Parent.Parent.Utils)
local Entry = require(script.Parent.Entry)
local types = {
EntryData = require(script.Parent.Parent.Types.EntryData).getType()
EntryData = require(script.Parent.Parent.Types.EntryData).getType(),
FilterData = require(script.Parent.Parent.Types.FilterData).getType()
}
local Collection = {}
@@ -21,18 +22,24 @@ 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:typeof(types.FilterData), data:typeof(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 filters then filters = {} end
if not filters._startsWith then filters._startsWith = {} end
if not filters._ignoreCases then filters._ignoreCases = {} end
local result = Utils.makeHTTPRequest("entry", "PUT", "https://api.marcsync.dev/v1/entries/"..self._collectionName, {["filters"]=filters,["data"]=data}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
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:typeof(types.FilterData), limit: number):{[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);
if not filters._startsWith then filters._startsWith = {} end
if not filters._ignoreCases then filters._ignoreCases = {} end
if not limit then limit = 0 end
local result = Utils.makeHTTPRequest("entry", "PATCH", "https://api.marcsync.dev/v1/entries/"..self._collectionName.."?methodOverwrite=GET", {["filters"]=filters, ["limit"] = limit}, self._accessToken);
if result["success"] and result["entries"] then
local _result = {}
for index,entry in pairs(result["entries"]) do
@@ -46,9 +53,12 @@ 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:typeof(types.FilterData)):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 filters then filters = {} end
if not filters._startsWith then filters._startsWith = {} end
if not filters._ignoreCases then filters._ignoreCases = {} end
local result = Utils.makeHTTPRequest("entry", "DELETE", "https://api.marcsync.dev/v1/entries/"..self._collectionName, {["filters"]=filters}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
return result["deletedEntries"]
+2 -2
View File
@@ -16,7 +16,7 @@ Entry.getValues = function(self:typeof(Entry)):typeof(types.EntryData)
end
Entry.updateValues = function(self:typeof(Entry), data:typeof(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);
local result = Utils.makeHTTPRequest("entry", "PUT", "https://api.marcsync.dev/v1/entries/"..self._tableId, {["filters"]={["_id"]=self._objectId},["data"]=data}, self._accessToken);
if result["success"] and result["modifiedEntries"] and result["modifiedEntries"] > 0 then
for i,v in pairs(data) do
@@ -31,7 +31,7 @@ end
Entry.delete = function(self:typeof(Entry))
if typeof(self) ~= "table" then error("Please use : instead of .") end
local result = Utils.makeHTTPRequest("entry", "DELETE", "https://api.marcsync.dev/v0/entries/"..self._tableId, {["filters"]={["_id"]=self._objectId}}, self._accessToken);
local result = Utils.makeHTTPRequest("entry", "DELETE", "https://api.marcsync.dev/v1/entries/"..self._tableId, {["filters"]={["_id"]=self._objectId}}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
self = nil
+11
View File
@@ -0,0 +1,11 @@
type FilterData = {
["_startsWith"]: {string},
["_ignoreCases"]: {string},
[string]: any
}
return {
getType = function(): FilterData
return {}
end,
}