Easy-to-use API for Diograph API. Read, write and connect diories without manual REST requests. Build your Diograph app without a hassle.
npm install diograph-store
import { DiographStore } from "diograph-store"
DiographStore.setAuthToken("my-own-token")
DiographStore.getAllDiories().then(res => {
console.log(res)
})
Retrieve diory from Diograph API.
Current diory interface:
id: string;
name: string;
url: string;
type: string;
background: string;
date: string;
geo: {
type: string,
latitude: string,
longitude: string,
geoRadius: string
};
connectedDiories = Array<Diory>;
Returns Promise<Diory> if diory exists.
Returns Promise<null> if not found.
Retrieve all diories with given type from Diograph API. Returns all diories with any type if type is not given.
Returns Promise<Array<Diory>>.
* optional parameter
Create a new diory.
Object given as a parameter could look like this:
{
"name": "My first diory",
"address": "http://dioryme.github.io",
"diory-type": "webpage",
"background": null,
"date": "05/01/2017"
}
Returns Promise<Diory>
Creates a new diory and connects it to another diory.
Object given as a parameter is the same as in “DiographStore.createDiory()”.
Returns Promise<ConnectionObject>.
{
"connection": <Connection>,
"fromDiory": <Diory>,
"toDiory": <Diory>
}
Creates a new diory and connects it to another diory from both sides.
Object given as a parameter is the same as in “DiographStore.createDiory()”.
Returns Promise<ConnectionObject>.
{
"connection": <Connection>,
("reversedConnection": <Connection>,) <= not yet implemented
"fromDiory": <Diory>,
"toDiory": <Diory>
}
Connects two diories.
Returns Promise<ConnectionObject>.
{
"connection": <Connection>,
"fromDiory": <Diory>,
"toDiory": <Diory>
}
Updates the attributes of the diory.
Object given as a parameter is the same as in “DiographStore.createDiory()”.
Returns Promise<Diory>
Deletes a diory.
Returns Promise<void>.
=== Nothing under this line have been implemented yet ===
Connects two diories from both sides.
Returns Promise<ConnectionObject>.
{
"connection": <Connection>,
"reversedConnection": <Connection>,
"fromDiory": <Diory>,
"toDiory": <Diory>
}
Gets the connection between two diories.
Current connection interface:
{
position: {
width: "20%",
top: "60%",
height: "20%",
left: "220%"
},
from-diory-id: 1,
to-diory-id: 914
}
Returns Promise<Connection> if connection exists.
Returns Promise<null> if connection not found.
Updates the connection between two diories.
Returns Promise<Connection>.
Deletes connection between two diories.
Returns Promise<void>.
Deletes connection of two diories from both sides. If connection is only from one side, it deletes
Returns Promise<void>.