@zohodesk/portal-api-creator
v1.0.30
Published
This is used to call server side api call as js api call in client side - portal-api javascript es6
Downloads
203
Maintainers
Readme
helpcenter_poc
Add your changes and check if it is fine.
$> jsapps/app
$> npm install
$> npm run build
If run build is successfully done. next steps --->
Once changes are ready publish the version. make version changes in package.json
$> npm publish --access public
All completed commit your code.
npm publish --access public
#portal-api-creator
##How to install
npm i portal-api-creator
###Define :
createPortalAPI(modules==>{ <name> : 'api list' },
(m)=>"https://myspace.com/space/v1/" , ===> prefix will be added for all urls + dynamic changable
(m)=>globalParameters, ===> params will be added for all urls + dynamic changable
(m)=>headers ===> header will be added for all urls + dynamic changable
)
##How to use in your code - example
import createPortalAPI, { kb , community } from 'portal-api-creator';
const portalAPIS = createPortalAPI({ kb, community}, (m)=>{
return 'https://myspace.com/api/v1/'
} , (m)=>{
return { appId : "dsdlfo39o3ksjkskso90939o33i38i383i" }
} , (m)=>{
return {
hash : "sdflsflsdkfsdkfiwelelqweoqwelqweqkewpelqweqkenqw8j33jj3bnbbdsfhfhdshfshdf"
}
});
portalAPIS.kb.articles()
portalAPIS.community.topics()
import creatorPortalAPI, { kb } from 'portal-api-creator';
global.portalAPI = creatorPortalAPI({ kb },()=>{
return "https://my.allows.com/v1/api/"
},()=>{
return {
"appPortalId" : "4659fc50aa0a07b8cd88c9af18ee0eb36cf32c3dda4b4401afb6719abeecaa48"
}
});
global.portalAPI.kb.articles();
##How to use dynamic/custom modules code - example
import APIBuilder from 'portal-api-creator';
const builder = APIBuilder((m)=>{
return 'https://myspace.com/api/v1/'
} , (m)=>{
return { appId : "dsdlfo39o3ksjkskso90939o33i38i383i" }
} , (m)=>{
return {
hash : "sdflsflsdkfsdkfiwelelqweoqwelqweqkewpelqweqkenqw8j33jj3bnbbdsfhfhdshfshdf"
}
});
let module1 = builder.create({ <module1> : <module1 apis> });
let module2 = builder.create({ <module2> : <module2 apis> });
let module3 = builder.create({ <module3> : <module3 apis> });
module3.books()
module2.people()
##Next Works - inside the pattern changes js-api-creator soon.
entity : {
name : "communityTopics",
type : ["get","update","delete","create"],
entity : {
name : "attachments",
type : ["get","delete","create"],
actions : [
{ name : "content", type : ["get"] }
]
},
actions : [
{ name : "like" , type : ["update"] },
{ name : "dislike" , type : ["update"] },
]
}