metrics-api-wrapper v1.0.28
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
Method | HTTP request | Description |
---|---|---|
getClients(requestQueryParams) | GET /clients | Get all Clients |
createClient(requestPayload) | POST /clients | Create a Client |
downloadClients(requestQueryParams) | GET /clients/file | Download Client file |
Drawer wrapper methods
Method | HTTP request | Description |
---|---|---|
getDrawers(requestQueryParams) | GET /drawers | Get all Drawers |
createDrawer(requestPayload) | POST /drawers | Create a Drawer |
downloadDrawers(requestQueryParams) | GET /drawers/file | Download Drawers file |
Plan wrapper methods
Method | HTTP request | Description |
---|---|---|
getPlans(requestQueryParams) | GET /plans | Get all Plans |
createPlan(requestPayload) | POST /plans | Create a Plan |
downloadPlans(requestQueryParams) | GET /plans/file | Download Plans file |
Session wrapper methods
Method | HTTP request | Description |
---|---|---|
getSessions(requestQueryParams) | GET /sessions | Get all Sessions |
createSession(requestPayload) | POST /sessions | Create a Session |
downloadSessions(requestQueryParams) | GET /sessions/file | Download Sessions file |
Tooltip wrapper methods
Method | HTTP request | Description |
---|---|---|
getTooltips(requestQueryParams) | GET /tooltips | Get all Tooltips |
createTooltip(requestPayload) | POST /tooltips | Create a Tooltip |
downloadTooltips(requestQueryParams) | GET /tooltips/file | Download Tooltips file |
AssetAllocationCard wrapper methods
Method | HTTP request | Description |
---|---|---|
getAssetAllocationCards(requestQueryParams) | GET /asset-allocation-cards | Get all AssetAllocationCards |
createAssetAllocationCard(requestPayload) | POST /asset-allocation-cards | Create a AssetAllocationCard |
downloadAssetAllocationCards(requestQueryParams) | GET /asset-allocation-cards/file | Download AssetAllocationCards file |
CardLoading wrapper methods
Method | HTTP request | Description |
---|---|---|
getCardLoadings(requestQueryParams) | GET /card-loadings | Get all CardLoadings |
createCardLoading(requestPayload) | POST /card-loadings | Create a CardLoading |
downloadCardLoadings(requestQueryParams) | GET /card-loadings/file | Download CardLoadings file |
DddCalcPlanWorthNnn wrapper methods
Method | HTTP request | Description |
---|---|---|
getDddCalcPlanWorthNnns(requestQueryParams) | GET /ddd-calc-plan-worth-nnns | Get all DddCalcPlanWorthNnns |
createDddCalcPlanWorthNnn(requestPayload) | POST /ddd-calc-plan-worth-nnns | Create a DddCalcPlanWorthNnn |
downloadDddCalcPlanWorthNnns(requestQueryParams) | GET /ddd-calc-plan-worth-nnns/file | Download DddCalcPlanWorthNnns file |
DddLink wrapper methods
Method | HTTP request | Description |
---|---|---|
getDddLinks(requestQueryParams) | GET /ddd-links | Get all DddLinks |
createDddLink(requestPayload) | POST /ddd-links | Create a DddLink |
downloadDddLinks(requestQueryParams) | GET /ddd-links/file | Download DddLinks file |
FeeAdvisoryServicesCardIteration wrapper methods
Method | HTTP request | Description |
---|---|---|
getFeeAdvisoryServicesCardIterations(requestQueryParams) | GET /fee-advisory-services-card-iterations | Get all FeeAdvisoryServicesCardIterations |
createFeeAdvisoryServicesCardIteration(requestPayload) | POST /fee-advisory-services-card-iterations | Create a FeeAdvisoryServicesCardIteration |
downloadFeeAdvisoryServicesCardIterations(requestQueryParams) | GET /fee-advisory-services-card-iterations/file | Download FeeAdvisoryServicesCardIterations file |
PageLoading wrapper methods
Method | HTTP request | Description |
---|---|---|
getPageLoadings(requestQueryParams) | GET /page-loadings | Get all PageLoadings |
createPageLoading(requestPayload) | POST /page-loadings | Create a PageLoading |
downloadPageLoadings(requestQueryParams) | GET /page-loadings/file | Download PageLoadings file |
PdfReport wrapper methods
Method | HTTP request | Description |
---|---|---|
getPdfReports(requestQueryParams) | GET /pdf-reports | Get all PdfReports |
createPdfReport(requestPayload) | POST /pdf-reports | Create a PdfReport |
downloadPdfReports(requestQueryParams) | GET /pdf-reports/file | Download PdfReports file |
ProspectConvertSingleCreatePlanLink wrapper methods
Method | HTTP request | Description |
---|---|---|
getProspectConvertSingleCreatePlanLinks(requestQueryParams) | GET /prospect-convert-single-create-plan-links | Get all ProspectConvertSingleCreatePlanLinks |
createProspectConvertSingleCreatePlanLink(requestPayload) | POST /prospect-convert-single-create-plan-links | Create a ProspectConvertSingleCreatePlanLink |
downloadProspectConvertSingleCreatePlanLinks(requestQueryParams) | GET /prospect-convert-single-create-plan-links/file | Download ProspectConvertSingleCreatePlanLinks file |
ScenarioCard wrapper methods
Method | HTTP request | Description |
---|---|---|
getScenarioCards(requestQueryParams) | GET /scenario-cards | Get all ScenarioCards |
createScenarioCard(requestPayload) | POST /scenario-cards | Create a ScenarioCard |
downloadScenarioCards(requestQueryParams) | GET /scenario-cards/file | Download 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.