{"id":37518142,"url":"https://github.com/ricado-group/js-api-client","last_synced_at":"2026-04-01T18:47:30.274Z","repository":{"id":37954308,"uuid":"304170285","full_name":"ricado-group/js-api-client","owner":"ricado-group","description":"A JavaScript Client for the RICADO Gen 4 API","archived":false,"fork":false,"pushed_at":"2026-03-15T10:16:40.000Z","size":28190,"stargazers_count":0,"open_issues_count":17,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-15T23:11:11.652Z","etag":null,"topics":["api","client","gen4"],"latest_commit_sha":null,"homepage":"https://ricado-group.github.io/js-api-client/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ricado-group.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-10-15T00:44:37.000Z","updated_at":"2026-03-15T10:15:46.000Z","dependencies_parsed_at":"2024-01-17T12:39:43.818Z","dependency_job_id":"9827ea22-ea50-4221-9eec-b01e08ba8911","html_url":"https://github.com/ricado-group/js-api-client","commit_stats":{"total_commits":272,"total_committers":5,"mean_commits":54.4,"dds":"0.49264705882352944","last_synced_commit":"f2ca4e16c748bc1875d285719dce1c58d4440e74"},"previous_names":[],"tags_count":112,"template":false,"template_full_name":null,"purl":"pkg:github/ricado-group/js-api-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricado-group%2Fjs-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricado-group%2Fjs-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricado-group%2Fjs-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricado-group%2Fjs-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ricado-group","download_url":"https://codeload.github.com/ricado-group/js-api-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricado-group%2Fjs-api-client/sbom","scorecard":{"id":774804,"data":{"date":"2025-08-11","repo":{"name":"github.com/ricado-group/js-api-client","commit":"02476c4014e7332a7d79fdb6023f6e7c676a2dbe"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:17","Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:16","Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Warn: no topLevel permission defined: .github/workflows/gh-pages.yml:1","Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/ricado-group/js-api-client/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/ricado-group/js-api-client/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/ricado-group/js-api-client/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gh-pages.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/ricado-group/js-api-client/gh-pages.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gh-pages.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/ricado-group/js-api-client/gh-pages.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/gh-pages.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/ricado-group/js-api-client/gh-pages.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/ricado-group/js-api-client/main.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/ricado-group/js-api-client/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/ricado-group/js-api-client/main.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/ricado-group/js-api-client/main.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:64: update your workflow using https://app.stepsecurity.io/secureworkflow/ricado-group/js-api-client/main.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/ricado-group/js-api-client/main.yml/master?enable=pin","Info:   0 out of   7 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   5 third-party GitHubAction dependencies pinned","Info:   2 out of   2 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact 2.6.1 not signed: https://api.github.com/repos/ricado-group/js-api-client/releases/208551934","Warn: release artifact 2.6.0 not signed: https://api.github.com/repos/ricado-group/js-api-client/releases/206051825","Warn: release artifact 2.5.18 not signed: https://api.github.com/repos/ricado-group/js-api-client/releases/198480818","Warn: release artifact 2.5.16 not signed: https://api.github.com/repos/ricado-group/js-api-client/releases/155556889","Warn: release artifact 2.5.15 not signed: https://api.github.com/repos/ricado-group/js-api-client/releases/154268337","Warn: release artifact 2.6.1 does not have provenance: https://api.github.com/repos/ricado-group/js-api-client/releases/208551934","Warn: release artifact 2.6.0 does not have provenance: https://api.github.com/repos/ricado-group/js-api-client/releases/206051825","Warn: release artifact 2.5.18 does not have provenance: https://api.github.com/repos/ricado-group/js-api-client/releases/198480818","Warn: release artifact 2.5.16 does not have provenance: https://api.github.com/repos/ricado-group/js-api-client/releases/155556889","Warn: release artifact 2.5.15 does not have provenance: https://api.github.com/repos/ricado-group/js-api-client/releases/154268337"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/main.yml:16"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":7,"reason":"SAST tool detected but not run on all commits","details":["Info: SAST configuration detected: CodeQL","Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"30 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-6fx8-h7jm-663j","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-qm95-pgcg-qqfq","Warn: Project is vulnerable to: GHSA-cqmj-92xf-r6r9","Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq","Warn: Project is vulnerable to: GHSA-mxhp-79qh-mcx6","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j","Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T03:15:36.736Z","repository_id":37954308,"created_at":"2025-08-23T03:15:36.736Z","updated_at":"2025-08-23T03:15:36.736Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","client","gen4"],"created_at":"2026-01-16T08:09:57.679Z","updated_at":"2026-04-01T18:47:30.252Z","avatar_url":"https://github.com/ricado-group.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm (scoped)](https://img.shields.io/npm/v/@ricado/api-client?color=green)](https://www.npmjs.com/package/@ricado/api-client)\n\n# RICADO Gen 4 API JS Client\n\nRICADO Gen 4 API client for NodeJS and Browsers\n\n- Written in modern JavaScript. Tested for NodeJS 16+ and Browsers\n- Includes Typings for Typescript\n- Complete support for the RICADO Gen 4 API - [OpenAPI Documentation](https://ricado-group.github.io/php-rest-api-docs)\n- Perfect symmetry: JS method signatures match the Web API Docs\n- All methods return a `Promise`\n- The Authentication Token is automatically handled on all methods\n\n**NOTE:** All examples written in this README use the NodeJS (ES5) Specification.\n\n## Documentation\n\nDocumentation for the latest Stable Release can be found here: [ricado-group.github.io/js-api-client](https://ricado-group.github.io/js-api-client/)\n\n## Install\n\n```\nnpm install @ricado/api-client\n```\n\nThe `src` folder contains ESNext code.\n\nThe `dist` folder contains ES6 transpiled code and is the default export for this module.\n\n## Usage\n\n`@ricado/api-client` mirrors the published API Docs. All interaction is through stateless functions in Controllers.\n\n```javascript\nconst api = require('@ricado/api-client');\n\napi.initialize();\n\napi.userAccountLogin('user@ricado.co.nz', 'abcd1234')\n.then(jwt =\u003e console.log(jwt))\n.catch(error =\u003e console.log(error));\n\napi.Controllers.UserAccountController.getCurrent()\n.then(userAccount =\u003e console.log(\"Logged in as `\" + userAccount.firstName + \" \" + userAccount.lastName))\n.catch(error =\u003e console.log(error));\n```\n\nUsing `async/await` in Node 8.x or newer:\n\n```javascript\nconst api = require('@ricado/api-client');\n\n;(async function() {\n    var userAccount = await api.Controllers.UserAccountController.getCurrent();\n\n    console.log(\"Hello! I'm \" + userAccount.firstName);\n})();\n```\n\n**NOTE:** A `Promise` will only resolve if there was no issue that needs dealing with. See `Error Handling` below for examples.\n\n#### Importing and Initializing\n\nYour first step will be to import the API Client module and Initialize the API before any use.\n\n```javascript\nconst api = require('@ricado/api-client');\n\napi.initialize();\n```\n\nThe `api.initialize()` method can also support an existing JSON Web Token. This is useful if you are persisting the JSON Web Token in your app and would like to skip the Login (Generate a new JWT) process.\n\n```javascript\nconst api = require('@ricado/api-client');\n\nlet jwt = myFunctionThatGetsTheJWT();\n\napi.initialize(jwt);\n```\n\n#### Performing a Login\n\nYou'll need to Login (Generate a new JWT) before you can make any API Calls (except for /ping of course!)\n\nTo Login a User Account:\n\n```javascript\nlet email = 'name@ricado.co.nz';\nlet password = 'abcd1234';\n\napi.userAccountLogin(email, password)\n.then((jwt) =\u003e {\n    console.log(\"Signed In!\");\n    // NOTE: You may wish to persist this jwt somewhere in your app for future use!\n})\n.catch((error) =\u003e {\n    console.log(\"Failed to Sign In!\");\n    console.log(error);\n});\n```\n\nTo Login an API Account:\n\n```javascript\nlet key = 'myapikey';\nlet secret = 'myapisecret';\n\napi.apiAccountLogin(key, secret)\n.then((jwt) =\u003e {\n    console.log(\"Ready to go!\");\n    // NOTE: You may wish to persist this jwt somewhere in your app for future use!\n})\n.catch((error) =\u003e {\n    console.log(\"Failed to Sign In!\");\n    console.log(error);\n});\n```\n\n#### Performing a Logout\n\nIf you wish to Logout (Destroy existing JWT) there's one simple method to call.\n\n**NOTE:** Calling this method will Destroy the Token on the API Servers and will clear the locally stored JWT (`api.JWT`)\n\n```javascript\napi.logout()\n.then(result =\u003e console.log(\"Done!\"))\n.catch(error =\u003e console.log(error));\n```\n\n#### Locking and Unlocking the JSON Web Token\n\nThe API makes use of a concept called \"Token Locking\" to reduce the risk of a JSON Web Token being copied and used by another party. The API will (at it's own discretion) automatically `Lock` the JSON Web Token after a period of inactivity. It is then required to `Unlock` the JSON Web Token before any API calls can be successfully resumed. If you make an API call without first unlocking the token, an `UnauthorizedError` will be thrown with a message about the Token being Locked.\n\n**NOTE:** These methods can only be used on Tokens for a `User Account`. Tokens for an `API Account` will never be locked.\n\nIf the User has a Pin Code set, unlock using that Pin Code\n\n```javascript\nlet pinCode = 12345;\n\napi.pinCodeUnlock(pinCode)\n.then(result =\u003e console.log(\"Unlocked!\")) // Remember when the return type is `Promise\u003cboolean\u003e` it will always be `true`!\n.catch(error =\u003e console.log(error));\n```\n\nIf the User doesn't have a Pin Code set, unlock using a Password\n\n```javascript\nlet password = \"abcd1234\";\n\napi.passwordUnlock(password)\n.then(result =\u003e console.log(\"Unlocked!\"))\n.catch(error =\u003e console.log(error));\n```\n\nLock is called without any parameters\n\n```javascript\napi.lock()\n.then(result =\u003e console.log(\"Locked!\"))\n.catch(error =\u003e console.log(error));\n```\n\n#### Retrieving a Single Model\n\nA Single Model can be retrieved by calling the stateless `getOne(id)` function on a Controller. The Single Model is passed back in the `Promise.then` method.\n\n```javascript\nlet siteId = 1;\n\napi.Controllers.SiteController.getOne(siteId)\n.then(site =\u003e console.log(\"Got My Site: \" + site.name))\n.catch(error =\u003e console.log(error));\n```\n\n### Updating a Single Model\n\nModels can be updated by calling the stateless `update(id, properties)` function on a Controller. When you Update a Single Model, the Updated version of that same Model is passed back in the `Promise.then` method.\n\n```javascript\nlet siteId = 1;\n\napi.Controllers.SiteController.update(siteId, {name: \"My New Site Name\"})\n.then(site =\u003e console.log(\"The Name is now: \" + site.name))\n.catch(error =\u003e console.log(error));\n```\n\n### Deleting a Single Model\n\nModels can be deleted by calling the stateless `delete(id)` function on a Controller. When you Delete a Single Model, the `Promise.then` method will be called if successful, otherwise the `Promise.catch` method will be called with the appropriate `Error`.\n\n```javascript\nlet siteId = 1;\n\napi.Controllers.SiteController.delete(siteId)\n.then(result =\u003e console.log(\"Deleted!\"))\n.catch(error =\u003e console.log(error));\n```\n\n### Retrieving a Collection of Models\n\nA Collection of Models (all) can be retrieved by calling the stateless `getAll()` function on a Controller. The Model Collection is passed back in the `Promise.then` method.\n\n```javascript\napi.Controllers.SiteController.getAll()\n.then((sites) =\u003e {\n    sites.forEach((site) =\u003e {\n        console.log(\"Got another Site: \" + site.name);\n    });\n})\n.catch(error =\u003e console.log(error));\n```\n\n### Creating a new Models Object\n\nA new Model Object can be created by calling the stateless `create(json)` function on a Controller. The newly created Model Object is passed back in the `Promise.then` method.\n\n```javascript\napi.Controllers.SiteController.create({name: \"My Site Name\", companyId: \"xyz-xyz-xyz\"})\n.then(site =\u003e console.log(\"Got my new Site ID: \" + site.id))\n.catch(error =\u003e console.log(error));\n```\n\n**NOTE:** Refer to the API Documentation for the structures required to create each type of Model.\n\n## Error Handling\n\nThis API Client provides additional Error Classes that extend the built-in `Error` type. All Errors will at minimum define `Error.message`. You can also make use of `Error.stack` in Node and on most modern browsers.\n\nErrors:\n\n- `BadRequestError` Used for Response Code 400\n- `UnauthorizedError` Used for Response Code 401\n- `ForbiddenError` Used for Response Code 403\n- `NotFoundError` Used for Response Code 404\n- `NotAllowedError` Used for Response Code 405\n- `ServerError` Used for Response Code 500\n- `NetworkError` Wraps up Errors thrown by `fetch`\n\n`Promise` Example:\n\n```javascript\napi.Controllers.UserAccountController.deleteCurrent()\n.then(result =\u003e result ? console.log(\"Success!\") : console.log(\"Uh-oh!\"))\n.catch((error) =\u003e {\n    // This Error should be one of the Above Errors or a generic `Error` type.\n    console.log(\"Error Message: \" + error.message);\n    console.log(\"Error Stack: \" + error.stack);\n});\n```\n\n`async/await` Example:\n\n```javascript\nasync function deleteApiAccount(id) {\n    try\n    {\n        var result = await api.Controllers.ApiAccountController.delete(id);\n\n        result ? console.log(\"Success!\") : console.log(\"Uh-oh!\");\n    }\n    catch (error)\n    {\n        // This Error should be one of the Above Errors or a generic `Error` type.\n        console.log(\"Error Message: \" + error.message);\n        console.log(\"Error Stack: \" + error.stack);\n    }\n}\n```\n\nExample: Retrieving a Collection of Users\n\n```javascript\napi.Controllers.UserAccountController.getAll()\n.then((users) =\u003e {\n    // The `users` variable will always be set and will at minimum be an empty Array `[]`. There isn't a need to check that users is defined and that is is in-fact an Array.\n    users.forEach(user =\u003e console.log(\"Got \" + user.firstName + \" \" + user.lastName));\n})\n.catch((error) =\u003e {\n    /**\n     * `.catch(error)` will always be called if something went wrong\n     * \n     * - A network error occured\n     * - You might not be logged in or have a locked token\n     * - The server had an *issue*\n     */\n    console.log(error);\n});\n```\n\nExample: Attempting to Retrieve a User that doesn't exist\n\n```javascript\napi.Controllers.UserAccountController.getOne('an-id-that-does-not-exist')\n.then((user) =\u003e {\n    // You'll never make it to here as the User does not exist. If the user did exist however, you can always be confident that the `user` variable will be set and will at bare minimum be a `UserAccountModel` object.\n    console.log(\"His name is \" + user.firstName + \" \" + user.lastName);\n})\n.catch((error) =\u003e {\n    /**\n     * In this example, apart from something like a `NetworkError` we would expect to see a `NotFoundError` to be passed back.\n     */\n    console.log(error);\n});\n```\n\nExample: Attempting to Delete a User that doesn't exist\n\n```javascript\napi.Controllers.UserAccountController.delete('an-id-that-does-not-exist')\n.then((result) =\u003e {\n    // You'll never make it to here as the User does not exist. If the user did exist however, you can always be confident that the `result` variable will be set and will always be `true` meaning `result === true` will always be the case!\n})\n.catch((error) =\u003e {\n    /**\n     * In this example, apart from something like a `NetworkError` we would expect to see a `NotFoundError` to be passed back.\n     */\n    console.log(error);\n});\n```\n\n## Testing\n\nFor Node:\n\n```\nnpm test\n```\n\nFor Browsers:\n\n**Yet to be supported!!**\n\n## Contributing\n\nCurrently this code-base is mostly generated from the PHP API and then hand-edited as required. In the future, we hope this process of generation will happen automatically with the use of a local `npm` script!\n\nIn the mean-time, if you wish to contribute, please either create a new branch (if you have permission) or fork this repository and submit a pull request.\n\n## TODO\n\n- Support generating this README.md from a Template so we can inject some code examples and types automatically!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricado-group%2Fjs-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fricado-group%2Fjs-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricado-group%2Fjs-api-client/lists"}