|
|
@ -11,24 +11,21 @@ export const CONTENT_TYPE_FORM = "x-www-form-urlencoded";
|
|
|
|
//** API URLS **//
|
|
|
|
//** API URLS **//
|
|
|
|
export const API_GET_PAGES = "/api/v1/page/published";
|
|
|
|
export const API_GET_PAGES = "/api/v1/page/published";
|
|
|
|
export const API_GET_FEATURED = "/api/v1/page/featured";
|
|
|
|
export const API_GET_FEATURED = "/api/v1/page/featured";
|
|
|
|
export const API_GET_MENU = "/api/v1/page/menu";
|
|
|
|
|
|
|
|
export const API_GET_PAGE = "/api/v1/page/single";
|
|
|
|
export const API_GET_PAGE = "/api/v1/page/single";
|
|
|
|
|
|
|
|
export const API_GET_MENU = "/api/v1/page/menu";
|
|
|
|
export const API_GET_TAGS = "/api/v1/page/tags";
|
|
|
|
export const API_GET_TAGS = "/api/v1/page/tags";
|
|
|
|
|
|
|
|
|
|
|
|
//** API TASKS **//
|
|
|
|
//** API TASKS **//
|
|
|
|
export const TASK_GET_CONTENT = "retrieveContent";
|
|
|
|
export const TASK_GET_CONTENT = "retrieveContent";
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* FipamoContentAPI
|
|
|
|
* Fipamo Content API
|
|
|
|
|
|
|
|
* class for retrieving page data from install
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export default class FipamoAPI {
|
|
|
|
export default class FipamoAPI {
|
|
|
|
//--------------------------
|
|
|
|
|
|
|
|
// constructor
|
|
|
|
|
|
|
|
//--------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* @constructor
|
|
|
|
* @param {string} baseURL - url of site
|
|
|
|
* @param {string} baseURL - url of site; uses local when empty
|
|
|
|
* @param {string} key - user api key
|
|
|
|
* @param {string} key - user api key
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
constructor(baseURL = null, key = null) {
|
|
|
|
constructor(baseURL = null, key = null) {
|
|
|
@ -41,32 +38,29 @@ export default class FipamoAPI {
|
|
|
|
// methods
|
|
|
|
// methods
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
|
|
|
|
|
|
|
|
getPages(key) {
|
|
|
|
/**
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
* Method for retrieving page data
|
|
|
|
this._request(
|
|
|
|
* @param {string} type - type of pages being retrieved; defaults to published
|
|
|
|
this.baseURL
|
|
|
|
*/
|
|
|
|
? this.baseURL + API_GET_PAGES + "?key=" + key
|
|
|
|
pages(type = null) {
|
|
|
|
: API_GET_PAGES,
|
|
|
|
//set url based on request type
|
|
|
|
TASK_GET_CONTENT,
|
|
|
|
let requestURL = "";
|
|
|
|
REQUEST_TYPE_GET
|
|
|
|
switch (type) {
|
|
|
|
)
|
|
|
|
default:
|
|
|
|
.then((result) => {
|
|
|
|
case "published":
|
|
|
|
resolve(result);
|
|
|
|
requestURL = API_GET_PAGES + "?key=" + this.key;
|
|
|
|
})
|
|
|
|
break;
|
|
|
|
.catch((err) => {
|
|
|
|
case "featured":
|
|
|
|
reject(err);
|
|
|
|
requestURL = API_GET_FEATURED + "?key=" + this.key;
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
});
|
|
|
|
case "menu":
|
|
|
|
}
|
|
|
|
requestURL = API_GET_MENU + "?key=" + this.key;
|
|
|
|
|
|
|
|
break;
|
|
|
|
getFeatured(key) {
|
|
|
|
}
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
this._request(
|
|
|
|
this._request(
|
|
|
|
this.baseURL
|
|
|
|
this.baseURL ? this.baseURL + requestURL : requestURL,
|
|
|
|
? this.baseURL + API_GET_FEATURED + "?key=" + key
|
|
|
|
TASK_GET_CONTENT
|
|
|
|
: API_GET_FEATURED,
|
|
|
|
|
|
|
|
TASK_GET_CONTENT,
|
|
|
|
|
|
|
|
REQUEST_TYPE_GET
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.then((result) => {
|
|
|
|
.then((result) => {
|
|
|
|
resolve(result);
|
|
|
|
resolve(result);
|
|
|
@ -76,13 +70,16 @@ export default class FipamoAPI {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
getMenu(key) {
|
|
|
|
* Method for retrieving single page
|
|
|
|
|
|
|
|
* @param {string} id - uuid of desired page
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
page(id) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
this._request(
|
|
|
|
this._request(
|
|
|
|
this.baseURL
|
|
|
|
this.baseURL
|
|
|
|
? this.baseURL + API_GET_MENU + "?key=" + key
|
|
|
|
? this.baseURL + API_GET_PAGE + "/" + id + "?key=" + this.key
|
|
|
|
: API_GET_MENU,
|
|
|
|
: API_GET_PAGE + "/" + id + "?key=" + this.key,
|
|
|
|
TASK_GET_CONTENT,
|
|
|
|
TASK_GET_CONTENT,
|
|
|
|
REQUEST_TYPE_GET
|
|
|
|
REQUEST_TYPE_GET
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -95,12 +92,15 @@ export default class FipamoAPI {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getTags(key) {
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Method for retrieving all tags used by pages
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
tags() {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
this._request(
|
|
|
|
this._request(
|
|
|
|
this.baseURL
|
|
|
|
this.baseURL
|
|
|
|
? this.baseURL + API_GET_TAGS + "?key=" + key
|
|
|
|
? this.baseURL + API_GET_TAGS + "?key=" + this.key
|
|
|
|
: API_GET_TAGS,
|
|
|
|
: API_GET_TAGS + "?key=" + this.key,
|
|
|
|
TASK_GET_CONTENT,
|
|
|
|
TASK_GET_CONTENT,
|
|
|
|
REQUEST_TYPE_GET
|
|
|
|
REQUEST_TYPE_GET
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -113,24 +113,6 @@ export default class FipamoAPI {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getPage(id, key) {
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
|
|
this._request(
|
|
|
|
|
|
|
|
//API_GET_PAGE + "/" + id + "?key=" + key,
|
|
|
|
|
|
|
|
this.baseURL
|
|
|
|
|
|
|
|
? this.baseURL + API_GET_PAGE + "/" + id + "?key=" + key
|
|
|
|
|
|
|
|
: API_GET_PAGE,
|
|
|
|
|
|
|
|
TASK_GET_CONTENT,
|
|
|
|
|
|
|
|
REQUEST_TYPE_GET
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.then((result) => {
|
|
|
|
|
|
|
|
resolve(result);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
|
|
|
reject(err);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
// private
|
|
|
|
// private
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
@ -162,12 +144,6 @@ export default class FipamoAPI {
|
|
|
|
"Content-type",
|
|
|
|
"Content-type",
|
|
|
|
"application/" + contentType
|
|
|
|
"application/" + contentType
|
|
|
|
);
|
|
|
|
);
|
|
|
|
/**
|
|
|
|
|
|
|
|
request.setRequestHeader(
|
|
|
|
|
|
|
|
"Access-Control-Allow-Origin",
|
|
|
|
|
|
|
|
self.baseURL
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
request.send(JSON.stringify(requestData));
|
|
|
|
request.send(JSON.stringify(requestData));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case CONTENT_TYPE_FORM:
|
|
|
|
case CONTENT_TYPE_FORM:
|
|
|
|