temporarily add SAPI
This commit is contained in:
parent
19f49e4a9d
commit
5622037719
9 changed files with 452 additions and 1 deletions
61
SimplyAPI/examples/groups.js
Normal file
61
SimplyAPI/examples/groups.js
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
const config = require('./config.json')
|
||||
const SAPI = require('./SimplyAPI.js')
|
||||
const SimplyAPI = new SAPI(config)
|
||||
|
||||
let group = {
|
||||
parent: "root",
|
||||
color: "",
|
||||
private: true,
|
||||
preventTrusted: false,
|
||||
name: "123",
|
||||
desc: "test group",
|
||||
emoji: "",
|
||||
members: []
|
||||
}
|
||||
|
||||
main = async () => {
|
||||
getGroups()
|
||||
findGroup("123")
|
||||
createTestGroup(group)
|
||||
deleteTestGroup("123")
|
||||
}
|
||||
|
||||
getGroups = async () => {
|
||||
SimplyAPI.getGroups()
|
||||
.then((response) => {
|
||||
console.log(response.data)
|
||||
})
|
||||
.catch(err => console.error(err))
|
||||
}
|
||||
|
||||
findGroup = async (what) => {
|
||||
SimplyAPI.findGroup(what, (group) => {
|
||||
if (group) {
|
||||
console.log(group)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
createTestGroup = async (data) => {
|
||||
SimplyAPI.createGroup(data)
|
||||
.then((response) => {
|
||||
console.log(response.data)
|
||||
})
|
||||
.catch(err => console.error(err))
|
||||
}
|
||||
|
||||
deleteTestGroup = async (what) => {
|
||||
await SimplyAPI.findGroup(what, async (group) => {
|
||||
if (group) {
|
||||
await SimplyAPI.deleteGroup(group.id)
|
||||
.then(async (res) => {
|
||||
if (res.status == 200) {
|
||||
console.log(`group deleted: ${group.content.name}.`,)
|
||||
}
|
||||
})
|
||||
.catch(err => console.error(err))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
main()
|
||||
58
SimplyAPI/examples/members.js
Normal file
58
SimplyAPI/examples/members.js
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
const config = require('./config.json')
|
||||
const SAPI = require('./lib/SimplyAPI.js')
|
||||
const SimplyAPI = new SAPI(config)
|
||||
|
||||
let member = {
|
||||
name: "Test",
|
||||
desc: "a test member",
|
||||
pronouns: "It/Its",
|
||||
pkId: "",
|
||||
color: "",
|
||||
avatarUuid: "",
|
||||
avatarUrl: "",
|
||||
private: false,
|
||||
preventTrusted: false,
|
||||
preventFrontNotifs: false,
|
||||
info: {
|
||||
"Age": "19",
|
||||
"Likes": "bread"
|
||||
}
|
||||
}
|
||||
|
||||
main = async () => {
|
||||
findMember("Test")
|
||||
createTestMember(member)
|
||||
deleteTestMember("Test")
|
||||
}
|
||||
|
||||
findMember = async (who) => {
|
||||
SimplyAPI.findMemberCallback(who, (member) => {
|
||||
if (member) {
|
||||
console.log(member)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
createTestMember = async (data) => {
|
||||
SimplyAPI.createMember(data)
|
||||
.then((response) => {
|
||||
console.log(response.data)
|
||||
})
|
||||
.catch(err => console.error(err))
|
||||
}
|
||||
|
||||
deleteTestMember = async (who) => {
|
||||
await SimplyAPI.findMember(who, async (member) => {
|
||||
if (member) {
|
||||
await SimplyAPI.deleteMember(member.id)
|
||||
.then((res) => {
|
||||
if (res.status == 200) {
|
||||
console.log(`member deleted: ${res.data.content.name}.`)
|
||||
}
|
||||
})
|
||||
.catch(err => console.error(err))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
main()
|
||||
26
SimplyAPI/examples/other.js
Normal file
26
SimplyAPI/examples/other.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
const config = require('./config.json')
|
||||
const SAPI = require('./SimplyAPI.js')
|
||||
const SimplyAPI = new SAPI(config)
|
||||
|
||||
main = async () => {
|
||||
getSystem()
|
||||
getCurrentFronters()
|
||||
}
|
||||
|
||||
getSystem = async () => {
|
||||
SimplyAPI.getSystem()
|
||||
.then((response) => {
|
||||
console.log(response.data)
|
||||
})
|
||||
.catch(err => console.error(err))
|
||||
}
|
||||
|
||||
getCurrentFronters = async () => {
|
||||
SimplyAPI.getFronters()
|
||||
.then((response) => {
|
||||
console.log(response)
|
||||
})
|
||||
.catch(err => console.error(err))
|
||||
}
|
||||
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue