OASIS API
This package is for client applications to connect and work with the OASIS API
Various oasis-api functions and services can be accessed with this API such as Authentication, Karma, Avatars.
Each function call you make returns a promise of an object which is in this form:
{error: boolean, data: object}
.
object values
error: true when response from api fails
data: response gotten from server.
Getting started
To get started with this package run
npm install oasis-api
This installs the package to your project.
To use it in the Application, it can be imported by
import oasis from "oasis-api"
Auth
The Auth class handles the authentication of the oasis-api. It can be imported by:
import { Auth } from "oasis-api"
Login
To login use this code:
import { Auth } from "oasis-api";
const oasisAuth = new Auth();
oasisAuth.login({
username: "email@test.com",
password: "testpass",
}).then((res)=>{
if(res.error){
}
else
}).catch((err)=>{
console.log(err)
})
Signup
For signup, use this code snippet:
import { Auth } from "oasis-api";
const oasisAuth = new Auth();
const data = await OasisAuth.signup({
firstName: "test",
lastName: "test",
email: "test@email.com",
password: "test",
confirmPassword: "test",
acceptTerms: true,
avatarType: "User",
title: "Mr",
});
Logout
This logs a user out and revokes his token
import { Auth } from "oasis-api";
const oasisAuth = new Auth();
const data = await OasisAuth.logout();
Forgot password
import { Auth } from "oasis-api";
const oasisAuth = new Auth();
const data = await OasisAuth.forgotPassword({ email: "test@test.com" });
Get user
This function is used when trying to get a currently logged in user.
Code snippet:
import { Auth } from "oasis-api";
const oasisAuth = new Auth();
const data = await OasisAuth.getUser();
Avatar
This class manages a user's avatar from adding Karma, deleting and updating avatar, etc,
import { Avatar } from "oasis-api"
get
This function gets an avatar when its ID is provided
import { Avatar } from "oasis-api";
const avatar = new Avatar();
const res = await avatar.get();
Get All
This function returns all registered avatars
import { Avatar } from "oasis-api";
const avatar = new Avatar();
const res = await avatar.getAll();
update
This updates the avatar with the given ID. User must be logged in & authenticated for this method to work.
avatar.update(data, id).then(()=>{
}).catch((err)=>{
})
the parameter data should be of this shape
"title": "string",
"firstName": "string",
"lastName": "string",
"avatarType": "string",
"email": "user@example.com",
"password": "string",
"confirmPassword": "string"
}
delete
This updates the avatar with the given ID. User must be logged in & authenticated for this method to work.
avatar.delete(id).then(()=>{
}).catch((err)=>{
})
addKarma
Adds karma to avatar. User must be logged in & authenticated for this method to work.
avatar.addKarma(id, data).then(()=>{
}).catch((err)=>{
})
params
id: Avatar id
data schema
"karmaType": "string",
"karmaSourceType": "string",
"karamSourceTitle": "string",
"karmaSourceDesc": "string"
}
removeKarma
Removes karma to avatar. User must be logged in & authenticated for this method to work.
avatar.removeKarma(id, data).then(()=>{
}).catch((err)=>{
})
params
id: Avatar id
data schema
"karmaType": "string",
"karmaSourceType": "string",
"karamSourceTitle": "string",
"karmaSourceDesc": "string"
}
Data
loadHolon
Load's a holon data object for the given id.
const data = new oasis.Data()
data.loadHolon(id).then(()=>{
}).catch((err)=>{
})
params
id: Holon id
loadAllHolons
Load's all holon data object for the given id.
const data = new oasis.Data()
data.loadAllHolons().then(()=>{
}).catch((err)=>{
})
saveHolon
saves holon data object.
const data = new oasis.Data()
data.saveHolon(data).then(()=>{
}).catch((err)=>{
})
deleteHolon
deletes a holon data object for the given id.
const data = new oasis.Data()
data.deleteHolon(id).then(()=>{
}).catch((err)=>{
})
params
id: Holon id
Karma
getKarmaForAvatar
gets karma value of an avatar
const karma = new oasis.Karma()
karma.getKarmaForAvatar(id).then(()=>{
}).catch((err)=>{
})
params
id: Avatar id
removeKarmaForAvatar
removes karma value of an avatar
const karma = new oasis.Karma()
karma.getKarmaForAvatar(id, data).then(()=>{
}).catch((err)=>{
})
params
id: Avatar id
data schema:
const data={
karmaType: string,
karmaSourceType: string,
karamSourceTitle: string,
karmaSourceDesc: string,
}
getKarmaAkashicRecordsForAvatar
oasis.Karma.getKarmaAkashicRecordsForAvatar(id)
params
id: Avatar id
Holochain
getHolochainAgentIdForAvatar
oasis.Holochain.getHolochainAgentIdForAvatar(id)
params
id: holochain id
getHolochainAgentPrivateKeyForAvatar
oasis.Holochain.getHolochainAgentPrivateKeyForAvatar(id)
params
id: avatar id
getAvatarIdForHolochainAgentId
oasis.Holochain.getAvatarIdForHolochainAgentId(id)
params
id: agent id
getHoloFuelBalanceForAgentId
oasis.Holochain.getHoloFuelBalanceForAgentId(id)
params
id: agent id
getHoloFuelBalanceForAvatar
oasis.Holochain.getHoloFuelBalanceForAvatar(id)
params
id: avatar id
getHoloFuelBalanceForAvatar
oasis.Holochain.getHoloFuelBalanceForAvatar(data)
params
data schema: {agentId: string, avatarId: string}
NFT
createPurchase
oasis.NFT.createPurchase(data)
params
data schema
nftProvider: number,
solanaExchange: {
fromAccount: {
publicKey: string,
},
toAccount: {
publicKey: string,
},
memoText: string,
amount: number,
mintAccount: {
publicKey: string,
},
},
cargoExchange: {
saleId: string,
},
}
getOlandPrice
oasis.NFT.createPurchase(count, couponCode)
purchaseOLAND
oasis.NFT.purchaseOLAND(data)
params
data schema
{
olandId: "",
avatarId: "",
avatarUsername: "",
tiles: "",
walletAddress: "",
cargoSaleId: "",
}
Solona
mint
oasis.Solana.mint(data)
exchange
oasis.Solana.exchange(data)
params
data schema
{
fromAccount: {
publicKey: "",
},
toAccount: {
publicKey: "",
},
memoText: "",
amount: 0,
mintAccount: {
publicKey: "",
},
}