1.0.28 • Published 3 years ago

metrics-api-wrapper v1.0.28

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

Discovery app - Metrics API Wrapper

A wrapper library for the Discovery app metrics backend

How to use this wrapper

Install the wrapper by running

npm install metrics-api-wrapper

Create an instance of the wrapper as seen below:

const metricsApiWrapper = require('metrics-api-wrapper')
const apiWrapperClient = metricsApiWrapper.createInstance({BACKEND_API_URL: 'https://yourbackenduri'})

where the config vaiable BACKEND_API_URL is set to the url of the backend. You can then invoke the wrapper as follows:

const clients = await apiWrapperClient.getClients(params) // params contains query params as a json object
await apiWrapperClient.createClient(client) // client is a json object contained request payload
const clientFile = await apiWrapperClient.downloadClients(params) // params contains query params as a json object

Documentation for wrapper methods

All URIs are relative to BACKEND_API_URL configuration variable.

Ever getXXX endpoint takes the query params in json object form as a parameter. So getClients(a: "string", b: 2) will call GET /clients?a=string&b=2. If you need to include a Date as a param, use the JS date class: getClients(from: new Date()). The function will then return as a Promise the response payload value. Handling this promise is done at the caller's end.

Every downloadXXX endpoint returns a file Buffer, which can then be turned into whatever file format is desired (https://nodejs.org/en/knowledge/advanced/buffers/how-to-use-buffers/), for example to convert to utf-8 string we can use Buffer.toString('utf-8'). It also takes query params as a function parameter in json form as with the getXXX functions.

Every createXXX endpoint takes the request payload body (in JSON) as a param.

Client wrapper methods

MethodHTTP requestDescription
getClients(requestQueryParams)GET /clientsGet all Clients
createClient(requestPayload)POST /clientsCreate a Client
downloadClients(requestQueryParams)GET /clients/fileDownload Client file

Drawer wrapper methods

MethodHTTP requestDescription
getDrawers(requestQueryParams)GET /drawersGet all Drawers
createDrawer(requestPayload)POST /drawersCreate a Drawer
downloadDrawers(requestQueryParams)GET /drawers/fileDownload Drawers file

Plan wrapper methods

MethodHTTP requestDescription
getPlans(requestQueryParams)GET /plansGet all Plans
createPlan(requestPayload)POST /plansCreate a Plan
downloadPlans(requestQueryParams)GET /plans/fileDownload Plans file

Session wrapper methods

MethodHTTP requestDescription
getSessions(requestQueryParams)GET /sessionsGet all Sessions
createSession(requestPayload)POST /sessionsCreate a Session
downloadSessions(requestQueryParams)GET /sessions/fileDownload Sessions file

Tooltip wrapper methods

MethodHTTP requestDescription
getTooltips(requestQueryParams)GET /tooltipsGet all Tooltips
createTooltip(requestPayload)POST /tooltipsCreate a Tooltip
downloadTooltips(requestQueryParams)GET /tooltips/fileDownload Tooltips file

AssetAllocationCard wrapper methods

MethodHTTP requestDescription
getAssetAllocationCards(requestQueryParams)GET /asset-allocation-cardsGet all AssetAllocationCards
createAssetAllocationCard(requestPayload)POST /asset-allocation-cardsCreate a AssetAllocationCard
downloadAssetAllocationCards(requestQueryParams)GET /asset-allocation-cards/fileDownload AssetAllocationCards file

CardLoading wrapper methods

MethodHTTP requestDescription
getCardLoadings(requestQueryParams)GET /card-loadingsGet all CardLoadings
createCardLoading(requestPayload)POST /card-loadingsCreate a CardLoading
downloadCardLoadings(requestQueryParams)GET /card-loadings/fileDownload CardLoadings file

DddCalcPlanWorthNnn wrapper methods

MethodHTTP requestDescription
getDddCalcPlanWorthNnns(requestQueryParams)GET /ddd-calc-plan-worth-nnnsGet all DddCalcPlanWorthNnns
createDddCalcPlanWorthNnn(requestPayload)POST /ddd-calc-plan-worth-nnnsCreate a DddCalcPlanWorthNnn
downloadDddCalcPlanWorthNnns(requestQueryParams)GET /ddd-calc-plan-worth-nnns/fileDownload DddCalcPlanWorthNnns file

DddLink wrapper methods

MethodHTTP requestDescription
getDddLinks(requestQueryParams)GET /ddd-linksGet all DddLinks
createDddLink(requestPayload)POST /ddd-linksCreate a DddLink
downloadDddLinks(requestQueryParams)GET /ddd-links/fileDownload DddLinks file

FeeAdvisoryServicesCardIteration wrapper methods

MethodHTTP requestDescription
getFeeAdvisoryServicesCardIterations(requestQueryParams)GET /fee-advisory-services-card-iterationsGet all FeeAdvisoryServicesCardIterations
createFeeAdvisoryServicesCardIteration(requestPayload)POST /fee-advisory-services-card-iterationsCreate a FeeAdvisoryServicesCardIteration
downloadFeeAdvisoryServicesCardIterations(requestQueryParams)GET /fee-advisory-services-card-iterations/fileDownload FeeAdvisoryServicesCardIterations file

PageLoading wrapper methods

MethodHTTP requestDescription
getPageLoadings(requestQueryParams)GET /page-loadingsGet all PageLoadings
createPageLoading(requestPayload)POST /page-loadingsCreate a PageLoading
downloadPageLoadings(requestQueryParams)GET /page-loadings/fileDownload PageLoadings file

PdfReport wrapper methods

MethodHTTP requestDescription
getPdfReports(requestQueryParams)GET /pdf-reportsGet all PdfReports
createPdfReport(requestPayload)POST /pdf-reportsCreate a PdfReport
downloadPdfReports(requestQueryParams)GET /pdf-reports/fileDownload PdfReports file

ProspectConvertSingleCreatePlanLink wrapper methods

MethodHTTP requestDescription
getProspectConvertSingleCreatePlanLinks(requestQueryParams)GET /prospect-convert-single-create-plan-linksGet all ProspectConvertSingleCreatePlanLinks
createProspectConvertSingleCreatePlanLink(requestPayload)POST /prospect-convert-single-create-plan-linksCreate a ProspectConvertSingleCreatePlanLink
downloadProspectConvertSingleCreatePlanLinks(requestQueryParams)GET /prospect-convert-single-create-plan-links/fileDownload ProspectConvertSingleCreatePlanLinks file

ScenarioCard wrapper methods

MethodHTTP requestDescription
getScenarioCards(requestQueryParams)GET /scenario-cardsGet all ScenarioCards
createScenarioCard(requestPayload)POST /scenario-cardsCreate a ScenarioCard
downloadScenarioCards(requestQueryParams)GET /scenario-cards/fileDownload ScenarioCards file

Linting

The wrapper uses typescript-eslint.

To lint the code, run the following command:

npm run lint

To autofix lint errors, run the following command:

npm run lint:fix

Publishing to npm

To publish the package to npm, first run

npm login

to login with your npm account (if you don't have one, create one) Optional: create a new version of the package with npm version patch. This is only needed if you've made changes and need to create a new version of the package. Then run

npm publish

to publish the package to npm.

Please note that the name metrics-api-wrapper may not be available. Simply change the name of the package to something else which is available and desirable. Note that you will import the package with this name when using the library.

1.0.28

3 years ago

1.0.26

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago