tobytech-client v1.0.0
tobytech-client
Overview
Tobytech provides a tool to easly manage the data on your website. The data can be accessed using our rest api or in dashboard. To use this package you need to register an account at Tobytech.no.
The services we provide:
- Blog - Create and manage posts. Newsletters are available to setup.
- Booking - Easily create and manage your bookings. We will handle everthing on the backend, including emails.
- Contact form - Integrate
Installation
Install the tobytech-client NPM module
npm install tobytech-client
or
yarn add tobytech-client
Configure
Create a new file with the name tobytech.js, and paste the following code inside.
const tobytechApp = {
clientId: [clientid],
projectId: [projectid],
domain: [domain]
}
module.exports = tobytechApp;
The brackets should not be included.
Example
The example below uses the getBookedDates function from the booking service. Every call will be asynchronous with a object response.
const {getBookedDates} = require("tobytech-client/lib/booking");
const tobytechApp = require("./tobytechApp");
async function getDates() {
// This will be your api call
const res = await getBookedDates(tobytechApp,"5","3");
// The result {status: (boolean), data: (object/array)}
if (res["status"]) {
console.log("Success")
console.log(res["data"])
} else {
// If status is false the 'msg' parameter will be the error message
console.log(res["msg"])
}
}
getDates();
Blog
getPosts
parameters(tobytechApp: Object, blogId: String)
Respons:
{
"status": true, //(boolean),
"data": [], //(array), Only if status is true
"msg": "message" //(String), Only if status is false. This is the error message
}
Example respons:
//Success
{
"status": true,
"data": [[ 81, "How to act on the promise", 415, "2022-07-15 22:38:34" ],...]
}
The data parameter is an array of arrays, where the indexes are:
- 0: post id
- 1: post title
- 2: number of views
- 3: creation date
//Failed
{
"status": false,
"msg": "missing parameters"
}
getPost
parameters(tobytechApp: Object, blogId: String, postId: String)
Respons:
{
"status": true, //(boolean),
"data": [], //(array), Only if status is true
"msg": "message" //(String), Only if status is false. This is the error message
}
Example respons:
//Success
{
"status": true,
"data": [ "How to act on the promise", "https://image.url.png", "<p><strong>The beginning is the only way</strong></p> ...", 415, "2022-07-15 22:38:34" ]
}
The data parameter is an array of arrays, where the indexes are:
- 0: post title
- 1: post image url
- 2: post content html
- 3: number of views
- 4: creation date
//Failed
{
"status": false,
"msg": "missing parameters"
}
Booking
addNewBooking
parameters (tobytechApp: Object, collectionId: String, optionId: String, bookingStart: String(YYYY-MM-DD), bookingEnd: String(YYYY-MM-DD), booking_customer_id: String)
Respons:
{
"status": true, //(boolean)
"msg": "message" //(String)
}
Example respons:
//Success
{
"status": true,
"data": "Booking created"
}
//Failed
{
"status": false,
"msg": "Date already in use"
}
getBookedDates
parameters (tobytechApp: Object, collectionId: String, optionId: String)
Respons:
{
"status": true, //(boolean),
"data": [], //(array), Only if status is true
"msg": "message" //(String), Only if status is false. This is the error message
}
Example respons:
//Success
{
"status": true,
"data": ["2022-08-24", "2022-08-25","2022-08-26","2022-09-07","2022-09-08","2022-09-09",...]
}
//Failed
{
"status": false,
"msg": "collection not found"
}
Contact form
in progress...
3 years ago