Comparing version 0.0.3 to 0.1.0
@@ -45,3 +45,3 @@ import axios from "axios"; | ||
.then((res) => { | ||
if (res.data.isError) { | ||
if (res.data.isError > 0) { | ||
return { error: true, data: res.data }; | ||
@@ -52,3 +52,3 @@ } | ||
.catch((err) => { | ||
return { error: true, data: err }; | ||
return { error: true, data: { error: err.response.data, message: err.response.data.title } }; | ||
}); | ||
@@ -59,3 +59,3 @@ } | ||
data = { | ||
email, | ||
username, | ||
password, | ||
@@ -79,10 +79,8 @@ } | ||
} | ||
const sto = JSON.stringify(res.data.result.avatar); | ||
console.log(res.data) | ||
const sto = JSON.stringify(res.data.result); | ||
localStorage.setItem("user", sto); | ||
localStorage.setItem("login", data); | ||
console.log(sto); | ||
this.token = { | ||
jwtToken: res.data.result.avatar.jwtToken, | ||
refreshToken: res.data.result.avatar.refreshToken, | ||
}; | ||
return { error: false, data: res.data }; | ||
@@ -131,3 +129,5 @@ }) | ||
headers: { | ||
Authorization: `Bearer ${this.token.jwtToken}`, | ||
"Content-Type": "application/json", | ||
Cookie: `refreshToken=${this.token.refresh}`, | ||
}, | ||
@@ -139,4 +139,4 @@ data: data, | ||
.then((response) => { | ||
if (response.data.isError) { | ||
return { error: true, data: response.data }; | ||
if (res.data.isError) { | ||
return { error: true, data: res.data }; | ||
} | ||
@@ -143,0 +143,0 @@ return { error: false, data: response.data }; |
@@ -5,5 +5,2 @@ import Auth from "./auth/auth.js"; | ||
import NFT from "./nft/nft.js"; | ||
import EOSIO from "./EOSIO/eosio.js"; | ||
import Data from "./data/data.js"; | ||
import Solana from "./solana/solana.js"; | ||
@@ -15,5 +12,2 @@ export default { | ||
NFT, | ||
EOSIO, | ||
Data, | ||
Solana, | ||
}; |
{ | ||
"name": "oasis-api", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "A JavaScript proxy for the Oasis API. To be used only in the browser.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
333
README.md
# 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. | ||
- [OASIS API](#oasis-api) | ||
@@ -16,2 +24,29 @@ - [Getting started](#getting-started) | ||
- [Get All](#get-all) | ||
- [update](#update) | ||
- [delete](#delete) | ||
- [addKarma](#addkarma) | ||
- [removeKarma](#removekarma) | ||
- [Data](#data) | ||
- [loadHolon](#loadholon) | ||
- [loadAllHolons](#loadallholons) | ||
- [saveHolon](#saveholon) | ||
- [deleteHolon](#deleteholon) | ||
- [Karma](#karma) | ||
- [getKarmaForAvatar](#getkarmaforavatar) | ||
- [removeKarmaForAvatar](#removekarmaforavatar) | ||
- [getKarmaAkashicRecordsForAvatar](#getkarmaakashicrecordsforavatar) | ||
- [Holochain](#holochain) | ||
- [getHolochainAgentIdForAvatar](#getholochainagentidforavatar) | ||
- [getHolochainAgentPrivateKeyForAvatar](#getholochainagentprivatekeyforavatar) | ||
- [getAvatarIdForHolochainAgentId](#getavataridforholochainagentid) | ||
- [getHoloFuelBalanceForAgentId](#getholofuelbalanceforagentid) | ||
- [getHoloFuelBalanceForAvatar](#getholofuelbalanceforavatar) | ||
- [getHoloFuelBalanceForAvatar](#getholofuelbalanceforavatar-1) | ||
- [NFT](#nft) | ||
- [createPurchase](#createpurchase) | ||
- [getOlandPrice](#getolandprice) | ||
- [purchaseOLAND](#purchaseoland) | ||
- [Solona](#solona) | ||
- [mint](#mint) | ||
- [exchange](#exchange) | ||
@@ -44,6 +79,13 @@ ## Getting started | ||
const user = await oasisAuth.login({ | ||
email: "email@test.com", | ||
oasisAuth.login({ | ||
username: "email@test.com", | ||
password: "testpass", | ||
}); | ||
}).then((res)=>{ | ||
if(res.error){ | ||
// Error | ||
} | ||
else // No error | ||
}).catch((err)=>{ | ||
console.log(err) | ||
}) | ||
``` | ||
@@ -112,6 +154,4 @@ | ||
```js | ||
import { Avatar } from "oasis-api"; | ||
const avatar = new Avatar(); | ||
import { Avatar } from "oasis-api" | ||
``` | ||
### get | ||
@@ -138,1 +178,282 @@ | ||
``` | ||
### update | ||
This updates the avatar with the given ID. User must be logged in & authenticated for this method to work. | ||
```js | ||
avatar.update(data, id).then(()=>{ | ||
//pass | ||
}).catch((err)=>{ | ||
// pass | ||
}) | ||
``` | ||
the parameter **data** should be of this shape | ||
```js{ | ||
"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. | ||
```js | ||
avatar.delete(id).then(()=>{ | ||
//pass | ||
}).catch((err)=>{ | ||
// pass | ||
}) | ||
``` | ||
### addKarma | ||
Adds karma to avatar. User must be logged in & authenticated for this method to work. | ||
```js | ||
avatar.addKarma(id, data).then(()=>{ | ||
//pass | ||
}).catch((err)=>{ | ||
// pass | ||
}) | ||
``` | ||
**params** | ||
*id*: Avatar id | ||
*data schema* | ||
```js{ | ||
"karmaType": "string", | ||
"karmaSourceType": "string", | ||
"karamSourceTitle": "string", | ||
"karmaSourceDesc": "string" | ||
} | ||
``` | ||
### removeKarma | ||
Removes karma to avatar. User must be logged in & authenticated for this method to work. | ||
```js | ||
avatar.removeKarma(id, data).then(()=>{ | ||
//pass | ||
}).catch((err)=>{ | ||
// pass | ||
}) | ||
``` | ||
**params** | ||
*id*: Avatar id | ||
*data schema* | ||
```js{ | ||
"karmaType": "string", | ||
"karmaSourceType": "string", | ||
"karamSourceTitle": "string", | ||
"karmaSourceDesc": "string" | ||
} | ||
``` | ||
## Data | ||
### loadHolon | ||
Load's a holon data object for the given id. | ||
```js | ||
const data = new oasis.Data() | ||
data.loadHolon(id).then(()=>{ | ||
//pass | ||
}).catch((err)=>{ | ||
// pass | ||
}) | ||
``` | ||
**params** | ||
*id*: Holon id | ||
### loadAllHolons | ||
Load's all holon data object for the given id. | ||
```js | ||
const data = new oasis.Data() | ||
data.loadAllHolons().then(()=>{ | ||
//pass | ||
}).catch((err)=>{ | ||
// pass | ||
}) | ||
``` | ||
### saveHolon | ||
saves holon data object. | ||
```js | ||
const data = new oasis.Data() | ||
data.saveHolon(data).then(()=>{ | ||
//pass | ||
}).catch((err)=>{ | ||
// pass | ||
}) | ||
``` | ||
### deleteHolon | ||
deletes a holon data object for the given id. | ||
```js | ||
const data = new oasis.Data() | ||
data.deleteHolon(id).then(()=>{ | ||
//pass | ||
}).catch((err)=>{ | ||
// pass | ||
}) | ||
``` | ||
**params** | ||
*id*: Holon id | ||
## Karma | ||
### getKarmaForAvatar | ||
gets karma value of an avatar | ||
```js | ||
const karma = new oasis.Karma() | ||
karma.getKarmaForAvatar(id).then(()=>{ | ||
//pass | ||
}).catch((err)=>{ | ||
// pass | ||
}) | ||
``` | ||
**params** | ||
*id*: Avatar id | ||
### removeKarmaForAvatar | ||
removes karma value of an avatar | ||
```js | ||
const karma = new oasis.Karma() | ||
karma.getKarmaForAvatar(id, data).then(()=>{ | ||
//pass | ||
}).catch((err)=>{ | ||
// pass | ||
}) | ||
``` | ||
**params** | ||
*id*: Avatar id | ||
*data schema*: | ||
```js | ||
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: "", | ||
}, | ||
} | ||
``` |
@@ -0,1 +1,2 @@ | ||
import axios from "axios"; | ||
import Avatar from "../avatar/avatar"; | ||
@@ -8,3 +9,3 @@ | ||
async Mint(data) { | ||
async mint(data) { | ||
data = JSON.stringify(data); | ||
@@ -11,0 +12,0 @@ this.token = await this.avatar.callLogin(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34235
455
849