UNPKG

@zohodesk/haas-api-creator

Version:

This is used to call server side api call as js api call in client side - hc -api javascript es6

179 lines (109 loc) 3.2 kB
# helpcenter_poc ## Release Pkg Description - @zohodesk/haas-api-creator ###1.0.117 js_api_creator pkg updated ###1.0.116 js_api_creator pkg updated ###1.0.115 helpcenter setup jwt and sms api are added ###1.0.114 community/customview related api are added ###1.0.113 kb related api are added ###1.0.111 and 1.0.112 sms setup related api are added ###1.0.103 packages upgraded js-api-creator 1.0.21 ### 1.0.20 packages upgraded js-api-creator and react-cli in package.json. ### 1.0.88 community api and desk global search api added ### 1.0.87 Temp attachment api added. 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. #haas-api-creator ##How to install ```javascript npm i portal-api-creator ``` ###Define : ```javascript 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 ```javascript 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() ``` ```javascript 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 ```javascript 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. ```javascript 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"] }, ] } ```