├── .eslintrc.json ├── .github └── workflows │ └── node.js.yml ├── .gitignore ├── LICENSE ├── README.md ├── docs ├── live │ ├── APIError.html │ ├── APIError.js.html │ ├── AlertsHelper.html │ ├── ConversationsHelper.html │ ├── DownloadsHelper.html │ ├── Error.html │ ├── Error.js.html │ ├── Http.html │ ├── Http.js.html │ ├── LicensesHelper.html │ ├── MembersHelper.html │ ├── ProfilePostsHelper.html │ ├── PurchasesHelper.html │ ├── ResourcesHelper.html │ ├── ReviewsHelper.html │ ├── SortOptions.html │ ├── SortOptions.js.html │ ├── ThreadsHelper.html │ ├── Token.html │ ├── Token.js.html │ ├── TokenType.html │ ├── TokenType.js.html │ ├── UpdatesHelper.html │ ├── VersionsHelper.html │ ├── Wrapper.html │ ├── Wrapper.js.html │ ├── fonts │ │ ├── OpenSans-Bold-webfont.eot │ │ ├── OpenSans-Bold-webfont.svg │ │ ├── OpenSans-Bold-webfont.woff │ │ ├── OpenSans-BoldItalic-webfont.eot │ │ ├── OpenSans-BoldItalic-webfont.svg │ │ ├── OpenSans-BoldItalic-webfont.woff │ │ ├── OpenSans-Italic-webfont.eot │ │ ├── OpenSans-Italic-webfont.svg │ │ ├── OpenSans-Italic-webfont.woff │ │ ├── OpenSans-Light-webfont.eot │ │ ├── OpenSans-Light-webfont.svg │ │ ├── OpenSans-Light-webfont.woff │ │ ├── OpenSans-LightItalic-webfont.eot │ │ ├── OpenSans-LightItalic-webfont.svg │ │ ├── OpenSans-LightItalic-webfont.woff │ │ ├── OpenSans-Regular-webfont.eot │ │ ├── OpenSans-Regular-webfont.svg │ │ └── OpenSans-Regular-webfont.woff │ ├── global.html │ ├── helpers_AlertsHelper.js.html │ ├── helpers_ConversationsHelper.js.html │ ├── helpers_ThreadsHelper.js.html │ ├── helpers_members_MembersHelper.js.html │ ├── helpers_members_ProfilePostsHelper.js.html │ ├── helpers_resources_DownloadsHelper.js.html │ ├── helpers_resources_LicensesHelper.js.html │ ├── helpers_resources_PurchasesHelper.js.html │ ├── helpers_resources_ResourcesHelper.js.html │ ├── helpers_resources_ReviewsHelper.js.html │ ├── helpers_resources_UpdatesHelper.js.html │ ├── helpers_resources_VersionsHelper.js.html │ ├── index.html │ ├── scripts │ │ ├── linenumber.js │ │ └── prettify │ │ │ ├── Apache-License-2.0.txt │ │ │ ├── lang-css.js │ │ │ └── prettify.js │ └── styles │ │ ├── jsdoc-default.css │ │ ├── prettify-jsdoc.css │ │ └── prettify-tomorrow.css └── staged │ ├── APIError.html │ ├── APIError.js.html │ ├── AlertsHelper.html │ ├── ConversationsHelper.html │ ├── DownloadsHelper.html │ ├── Error.html │ ├── Error.js.html │ ├── Http.html │ ├── Http.js.html │ ├── LicensesHelper.html │ ├── MembersHelper.html │ ├── ProfilePostsHelper.html │ ├── PurchasesHelper.html │ ├── ResourcesHelper.html │ ├── ReviewsHelper.html │ ├── SortOptions.html │ ├── SortOptions.js.html │ ├── ThreadsHelper.html │ ├── Token.html │ ├── Token.js.html │ ├── TokenType.html │ ├── TokenType.js.html │ ├── UpdatesHelper.html │ ├── VersionsHelper.html │ ├── Wrapper.html │ ├── Wrapper.js.html │ ├── fonts │ ├── OpenSans-Bold-webfont.eot │ ├── OpenSans-Bold-webfont.svg │ ├── OpenSans-Bold-webfont.woff │ ├── OpenSans-BoldItalic-webfont.eot │ ├── OpenSans-BoldItalic-webfont.svg │ ├── OpenSans-BoldItalic-webfont.woff │ ├── OpenSans-Italic-webfont.eot │ ├── OpenSans-Italic-webfont.svg │ ├── OpenSans-Italic-webfont.woff │ ├── OpenSans-Light-webfont.eot │ ├── OpenSans-Light-webfont.svg │ ├── OpenSans-Light-webfont.woff │ ├── OpenSans-LightItalic-webfont.eot │ ├── OpenSans-LightItalic-webfont.svg │ ├── OpenSans-LightItalic-webfont.woff │ ├── OpenSans-Regular-webfont.eot │ ├── OpenSans-Regular-webfont.svg │ └── OpenSans-Regular-webfont.woff │ ├── global.html │ ├── helpers_AlertsHelper.js.html │ ├── helpers_ConversationsHelper.js.html │ ├── helpers_ThreadsHelper.js.html │ ├── helpers_members_MembersHelper.js.html │ ├── helpers_members_ProfilePostsHelper.js.html │ ├── helpers_resources_DownloadsHelper.js.html │ ├── helpers_resources_LicensesHelper.js.html │ ├── helpers_resources_PurchasesHelper.js.html │ ├── helpers_resources_ResourcesHelper.js.html │ ├── helpers_resources_ReviewsHelper.js.html │ ├── helpers_resources_UpdatesHelper.js.html │ ├── helpers_resources_VersionsHelper.js.html │ ├── index.html │ ├── scripts │ ├── linenumber.js │ └── prettify │ │ ├── Apache-License-2.0.txt │ │ ├── lang-css.js │ │ └── prettify.js │ └── styles │ ├── jsdoc-default.css │ ├── prettify-jsdoc.css │ └── prettify-tomorrow.css ├── examples ├── conversation-verification.js ├── delete-all-versions.js ├── discord-identity-bot │ ├── index.js │ ├── package-lock.json │ └── package.json ├── download-verification.js ├── export-purchases-csv.js ├── license-check.js ├── lookup-user.js ├── pm-on-purchase.js └── version-check.js ├── package-lock.json ├── package.json ├── src ├── APIError.js ├── Http.js ├── SortOptions.js ├── Throttler.js ├── Token.js ├── TokenType.js ├── Wrapper.js ├── helpers │ ├── AlertsHelper.js │ ├── ConversationsHelper.js │ ├── ThreadsHelper.js │ ├── members │ │ ├── MembersHelper.js │ │ └── ProfilePostsHelper.js │ └── resources │ │ ├── DownloadsHelper.js │ │ ├── LicensesHelper.js │ │ ├── PurchasesHelper.js │ │ ├── ResourcesHelper.js │ │ ├── ReviewsHelper.js │ │ ├── UpdatesHelper.js │ │ └── VersionsHelper.js └── index.js ├── tests ├── base.js ├── sort_options.js └── test.js ├── tsconfig.json └── types ├── APIError.d.ts ├── APIError.d.ts.map ├── Error.d.ts ├── Error.d.ts.map ├── Http.d.ts ├── Http.d.ts.map ├── SortOptions.d.ts ├── SortOptions.d.ts.map ├── Throttler.d.ts ├── Throttler.d.ts.map ├── Token.d.ts ├── Token.d.ts.map ├── TokenType.d.ts ├── TokenType.d.ts.map ├── Wrapper.d.ts ├── Wrapper.d.ts.map ├── helpers ├── AlertsHelper.d.ts ├── AlertsHelper.d.ts.map ├── ConversationsHelper.d.ts ├── ConversationsHelper.d.ts.map ├── ThreadsHelper.d.ts ├── ThreadsHelper.d.ts.map ├── members │ ├── MembersHelper.d.ts │ ├── MembersHelper.d.ts.map │ ├── ProfilePostsHelper.d.ts │ └── ProfilePostsHelper.d.ts.map └── resources │ ├── DownloadsHelper.d.ts │ ├── DownloadsHelper.d.ts.map │ ├── LicensesHelper.d.ts │ ├── LicensesHelper.d.ts.map │ ├── PurchasesHelper.d.ts │ ├── PurchasesHelper.d.ts.map │ ├── ResourcesHelper.d.ts │ ├── ResourcesHelper.d.ts.map │ ├── ReviewsHelper.d.ts │ ├── ReviewsHelper.d.ts.map │ ├── UpdatesHelper.d.ts │ ├── UpdatesHelper.d.ts.map │ ├── VersionsHelper.d.ts │ └── VersionsHelper.d.ts.map ├── index.d.ts └── index.d.ts.map /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true, 4 | "commonjs": true, 5 | "es2021": true 6 | }, 7 | "extends": "eslint:recommended", 8 | "parserOptions": { 9 | "ecmaVersion": 13 10 | }, 11 | "rules": { 12 | "max-len": [ 13 | "error", 14 | {"code": 120} 15 | ], 16 | "camelcase": [ 17 | "error" 18 | ], 19 | "indent": [ 20 | "error", 21 | 4 22 | ], 23 | "linebreak-style": [ 24 | "error", 25 | "unix" 26 | ], 27 | "quotes": [ 28 | "error", 29 | "double" 30 | ], 31 | "semi": [ 32 | "error", 33 | "always" 34 | ], 35 | "no-unused-vars": 0 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | pull_request: 10 | branches: [ main ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | node-version: [12.x, 14.x, 16.x] 20 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 21 | 22 | steps: 23 | - uses: actions/checkout@v2 24 | - name: Use Node.js ${{ matrix.node-version }} 25 | uses: actions/setup-node@v2 26 | with: 27 | node-version: ${{ matrix.node-version }} 28 | cache: 'npm' 29 | - run: npm ci 30 | - run: npm run build --if-present 31 | - run: npm test 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 BuiltByBit (Mick Capital Pty. Ltd.) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BuiltByBit's Official Node.js API Wrapper 2 | 3 | [![npm](https://img.shields.io/npm/v/@builtbybit/api-wrapper)](https://www.npmjs.com/package/@builtbybit/api-wrapper) 4 | [![npm type definitions](https://img.shields.io/npm/types/@builtbybit/api-wrapper)](https://github.com/BuiltByBit/js-api-wrapper/tree/main/types) 5 | [![npm](https://img.shields.io/npm/dt/@builtbybit/api-wrapper)](https://www.npmjs.com/package/@builtbybit/api-wrapper) 6 | [![npm version](https://img.shields.io/badge/docs-passing-brightgreen)](https://builtbybit.github.io/js-api-wrapper/live/) 7 | [![NPM](https://img.shields.io/npm/l/@builtbybit/api-wrapper)](https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 8 | 9 | An official asynchronous Node.js wrapper for BuiltByBit's [Ultimate API](https://builtbybit.com/wiki/ultimate-api/). 10 | 11 | - A Promise-based design built upon [`axios`](https://www.npmjs.com/package/axios). 12 | - Stalls requests when a dynamic rate limiting error is encountered. 13 | - Full coverage of the Ultimate API. 14 | - A comprehensive set of relevant usage examples. 15 | - Automatically generated TypeScript declarations. 16 | - Automatically generated and hosted [documentation](https://builtbybit.github.io/js-api-wrapper/live/). 17 | 18 | ## Installation & Basic Usage 19 | 20 | Install via `npm`: 21 | 22 | ``` 23 | npm i @builtbybit/api-wrapper 24 | ``` 25 | 26 | Initialise wrapper and fetch information about yourself via Promise's .then() notation: 27 | 28 | ```JS 29 | const { Wrapper, Token, TokenType } = require("@builtbybit/api-wrapper"); 30 | 31 | let token = new Token(TokenType.PRIVATE, "Find @ https://builtbybit.com/account/api"); 32 | let wrapper = new Wrapper(); 33 | 34 | // We catch any Promise rejections ourselves. 35 | wrapper.init(token).then(wrapper.members().self().then(self => { 36 | console.log(self); 37 | })).catch(error => { 38 | console.log("ERROR: " + error); 39 | }); 40 | ``` 41 | 42 | Initialise wrapper and fetch information about yourself via async/await: 43 | 44 | ```JS 45 | const { Wrapper, Token, TokenType } = require("@builtbybit/api-wrapper"); 46 | 47 | let token = new Token(TokenType.PRIVATE, "Find @ https://builtbybit.com/account/api"); 48 | let wrapper = new Wrapper(); 49 | ... 50 | 51 | // Let the caller catch any Promise rejections. Else, use a try-catch block. 52 | await wrapper.init(token); 53 | console.log(await wrapper.members().self()); 54 | ``` 55 | 56 | An comprehensive set of [examples](https://github.com/BuiltByBit/js-api-wrapper/tree/main/examples) can be found under the `/examples` directory. 57 | 58 | ## Contributions 59 | 60 | We welcome contributions in the form of bug fixes or otherwise. All pull requests will be reviewed and changes may be requested before merging. Though, please seek advice regarding the introduction of additional features via an issue before working on them - we may have reasons not to introduce the given feature, or may want to introduce it via a different approach. 61 | 62 | Whilst no contribution guidelines exist currently, please ensure you: 63 | - Develop with readability in mind. 64 | - Comment appropriately where non-obvious approaches or invariants are being enforced. 65 | - Include documentation comments where appropriate. 66 | - Never regenerate live documentation - this is done upon each version release. 67 | - Regenerate staged documentation via `npm run doc-staged`. 68 | - Regenerate type declarations via `npm run type` if modifying class/function signatures. 69 | - Use `npm run lint` and correct any linting errors within your final commit. 70 | 71 | ## Issues & Support 72 | 73 | The [issues tracker](https://github.com/BuiltByBit/js-api-wrapper/issues) for this repository should only be used to report bugs or issues with this official Node.js wrapper. 74 | 75 | For bugs or issues related to the Ultimate API itself, please open a [support ticket](https://builtbybit.com/tickets/new) or create a [bug report](https://builtbybit.com/suggestions/create-thread) on our platform. 76 | -------------------------------------------------------------------------------- /docs/live/APIError.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: APIError.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: APIError.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
31 | 
32 | /** A type which represents a parsed error from the API, or an internal wrapper error. */
33 | class APIError extends Error {
34 |     #code;
35 |     #message;
36 | 
37 |     constructor(json) {
38 |         super(`${json.code} - ${json.message}`);
39 | 
40 |         this.#code = json.code;
41 |         this.#message = json.message;
42 |     }
43 | 
44 |     /** Returns the machine-readable code of the error.
45 |      * 
46 |      * @type {string} The machine-readable error code.
47 |      */
48 |     get code() {
49 |         return this.#code;
50 |     }
51 | 
52 |     /** Returns the human-readable message of the error.
53 |      * 
54 |      * @type {string} The human-readable error message.
55 |      */
56 |     get message() {
57 |         return this.#message;
58 |     }
59 | 
60 |     /** Constructs a new Error which originated within the wrapper.
61 |      * 
62 |      * @param {string} message The internal error message.
63 |      * @returns {APIError} The newly-constructed error.
64 |      */
65 |     static internal(message) {
66 |         return new APIError({code: "InternalWrapperError", message});
67 |     }
68 | }
69 | 
70 | exports.APIError = APIError;
71 |
72 |
73 | 74 | 75 | 76 | 77 |
78 | 79 | 82 | 83 |
84 | 85 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /docs/live/Error.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: Error.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: Error.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
31 | 
32 | /** A type which represents a parsed error from the API, or an internal wrapper error. */
33 | class Error {
34 |     #code;
35 |     #message;
36 | 
37 |     constructor(json) {
38 |         this.#code = json.code;
39 |         this.#message = json.message;
40 |     }
41 | 
42 |     /** Returns a string representation of this error including both the machine and human-readable parts.
43 |      * 
44 |      * @returns {string} A string representation of this error.
45 |      */
46 |     toString() {
47 |         return `${this.#code}: ${this.#message}`;
48 |     }
49 | 
50 |     /** Returns the machine-readable code of the error.
51 |      * 
52 |      * @returns {string} The machine-readable error code.
53 |      */
54 |     code() {
55 |         return this.#code;
56 |     }
57 | 
58 |     /** Returns the human-readable message of the error.
59 |      * 
60 |      * @returns {string} The human-readable error message.
61 |      */
62 |     message() {
63 |         return this.#message;
64 |     }
65 | 
66 |     /** Constructs a new Error which originated within the wrapper.
67 |      * 
68 |      * @param {string} message The internal error message.
69 |      * @returns {Error} The newly-constructed error.
70 |      */
71 |     static internal(message) {
72 |         return new Error({code: "InternalWrapperError", message});
73 |     }
74 | }
75 | 
76 | exports.Error = Error;
77 |
78 |
79 | 80 | 81 | 82 | 83 |
84 | 85 | 88 | 89 |
90 | 91 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /docs/live/SortOptions.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: SortOptions.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: SortOptions.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
31 | 
32 | /** A type representing the sorting options available for listing-style endpoints. */
33 | class SortOptions {
34 |     sort;
35 |     order;
36 |     page;
37 | 
38 |     /** Convets this SortOptions instance into a query string.
39 |      * 
40 |      * @returns {string} The query-string representation.
41 |      */
42 |     toQueryString() {
43 |         let asArray = [];
44 | 
45 |         if (this.sort) {
46 |             asArray.push(`sort=${this.sort}`);
47 |         }
48 |         if (this.order) {
49 |             asArray.push(`order=${this.order}`);
50 |         }
51 |         if (this.page) {
52 |             asArray.push(`page=${this.page}`);
53 |         }
54 |         
55 |         return "?" + asArray.join("&");
56 |     }
57 | 
58 |     /** Returns whether or not any sort options have been set.
59 |      * 
60 |      * @returns {boolean} Whether or not any sort options have been set.
61 |      */
62 |     isSet() {
63 |         return this.sort || this.order || this.page;
64 |     }
65 | }
66 | 
67 | exports.SortOptions = SortOptions;
68 |
69 |
70 | 71 | 72 | 73 | 74 |
75 | 76 | 79 | 80 |
81 | 82 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/live/Token.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: Token.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: Token.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
31 | 
32 | const { TokenType } = require("./TokenType");
33 | 
34 | /** A type representing an API authentication token. */
35 | class Token {
36 |     #type;
37 |     #value;
38 | 
39 |     /** Constructs a new token from its constituents.
40 |      * 
41 |      * @param {TokenType} type The type of this token.
42 |      * @param {string} value The value of this token.
43 |      */
44 |     constructor(type, value) {
45 |         this.#type = type;
46 |         this.#value = value;
47 |     }
48 | 
49 |     /** Constructs an object containing the header representation of this token.
50 |      * 
51 |      * @returns An object with a single attribute, 'Authorization'.
52 |      */
53 |     asHeader() {
54 |         return {Authorization: `${this.#type.headerName()} ${this.#value}`};
55 |     }
56 | }
57 | 
58 | exports.Token = Token;
59 |
60 |
61 | 62 | 63 | 64 | 65 |
66 | 67 | 70 | 71 |
72 | 73 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /docs/live/TokenType.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Class: TokenType 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Class: TokenType

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

TokenType()

32 | 33 |
A type representing the different token types.
34 | 35 | 36 |
37 | 38 |
39 |
40 | 41 | 42 | 43 | 44 |

Constructor

45 | 46 | 47 | 48 |

new TokenType()

49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 |
Source:
95 |
98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 |
106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 |
149 | 150 |
151 | 152 | 153 | 154 | 155 |
156 | 157 | 160 | 161 |
162 | 163 | 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /docs/live/TokenType.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: TokenType.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: TokenType.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
31 | 
32 | /** A type representing the different token types. */
33 | class TokenType {
34 |     static PRIVATE = new TokenType("Private");
35 |     static SHARED = new TokenType("Shared");
36 | 
37 |     #headerName;
38 | 
39 |     constructor(headerName) {
40 |         this.#headerName = headerName;
41 |     }
42 | 
43 |     headerName() {
44 |         return this.#headerName;
45 |     }
46 | }
47 | 
48 | exports.TokenType = TokenType;
49 |
50 |
51 | 52 | 53 | 54 | 55 |
56 | 57 | 60 | 61 |
62 | 63 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /docs/live/fonts/OpenSans-Bold-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/live/fonts/OpenSans-Bold-webfont.eot -------------------------------------------------------------------------------- /docs/live/fonts/OpenSans-Bold-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/live/fonts/OpenSans-Bold-webfont.woff -------------------------------------------------------------------------------- /docs/live/fonts/OpenSans-BoldItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/live/fonts/OpenSans-BoldItalic-webfont.eot -------------------------------------------------------------------------------- /docs/live/fonts/OpenSans-BoldItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/live/fonts/OpenSans-BoldItalic-webfont.woff -------------------------------------------------------------------------------- /docs/live/fonts/OpenSans-Italic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/live/fonts/OpenSans-Italic-webfont.eot -------------------------------------------------------------------------------- /docs/live/fonts/OpenSans-Italic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/live/fonts/OpenSans-Italic-webfont.woff -------------------------------------------------------------------------------- /docs/live/fonts/OpenSans-Light-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/live/fonts/OpenSans-Light-webfont.eot -------------------------------------------------------------------------------- /docs/live/fonts/OpenSans-Light-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/live/fonts/OpenSans-Light-webfont.woff -------------------------------------------------------------------------------- /docs/live/fonts/OpenSans-LightItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/live/fonts/OpenSans-LightItalic-webfont.eot -------------------------------------------------------------------------------- /docs/live/fonts/OpenSans-LightItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/live/fonts/OpenSans-LightItalic-webfont.woff -------------------------------------------------------------------------------- /docs/live/fonts/OpenSans-Regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/live/fonts/OpenSans-Regular-webfont.eot -------------------------------------------------------------------------------- /docs/live/fonts/OpenSans-Regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/live/fonts/OpenSans-Regular-webfont.woff -------------------------------------------------------------------------------- /docs/live/helpers_AlertsHelper.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: helpers/AlertsHelper.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: helpers/AlertsHelper.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
 30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
 31 | 
 32 | const { SortOptions } = require("../SortOptions");
 33 | 
 34 | /**
 35 |  * @typedef {object} Alert
 36 |  * @property {number} caused_member_id
 37 |  * @property {string} content_type
 38 |  * @property {number} content_id
 39 |  * @property {string} alert_type
 40 |  * @property {number} alert_date
 41 |  */
 42 | 
 43 | /** A helper type for alert-related API endpoints. */
 44 | class AlertsHelper {
 45 |     #wrapper;
 46 | 
 47 |     constructor(wrapper) {
 48 |         this.#wrapper = wrapper;
 49 |     }
 50 | 
 51 |     /** List a single page of unread alerts.
 52 |      * 
 53 |      * @param {SortOptions | undefined} sort An optional set of sort options.
 54 |      * @return {Array<Alert>} An array of raw data objects.
 55 |      */
 56 |     async list(sort) {
 57 |         return await this.#wrapper.http().get("/alerts", sort);
 58 |     }
 59 | 
 60 |     /** List all pages of unread alerts.
 61 |      * 
 62 |      * @param {SortOptions | undefined} sort An optional set of sort options.
 63 |      * @return {Array<Alert>} An array of raw data objects.
 64 |      */
 65 |     async listAll(sort) {
 66 |         return await this.#wrapper.http().listUntil("/alerts", () => true, sort);
 67 |     }
 68 | 
 69 |     /** List multiple pages of unread alerts until a condition is no longer met.
 70 |      * 
 71 |      * @param {function(Alert):boolean} shouldContinue A function which determines if further pages are requested.
 72 |      * @param {SortOptions | undefined} sort An optional set of sort options.
 73 |      * 
 74 |      * @return {Array<Alert>} An array of raw data objects.
 75 |      */
 76 |     async listUntil(shouldContinue, sort) {
 77 |         return await this.#wrapper.http().listUntil("/alerts", shouldContinue, sort);
 78 |     }
 79 | 
 80 |     /** Mark unread alerts as read. */
 81 |     async markAsRead() {
 82 |         return await this.#wrapper.http().patch("/alerts", { read: true });
 83 |     }
 84 | }
 85 | 
 86 | exports.AlertsHelper = AlertsHelper;
87 |
88 |
89 | 90 | 91 | 92 | 93 |
94 | 95 | 98 | 99 |
100 | 101 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /docs/live/helpers_resources_PurchasesHelper.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: helpers/resources/PurchasesHelper.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: helpers/resources/PurchasesHelper.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
 30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
 31 | 
 32 | const { SortOptions } = require("../../SortOptions");
 33 | 
 34 | /**
 35 |  * @typedef {object} Purchase
 36 |  * @property {number} purchase_id
 37 |  * @property {number} purchaser_id
 38 |  * @property {number} license_id
 39 |  * @property {boolean} renewal
 40 |  * @property {string} status
 41 |  * @property {number} price
 42 |  * @property {string} currency
 43 |  * @property {number} purchase_date
 44 |  * @property {number} validation_date
 45 |  */
 46 | 
 47 | /** A helper type for resource purchase-related API endpoints. */
 48 | class PurchasesHelper {
 49 |     #wrapper;
 50 |     
 51 |     constructor(wrapper) {
 52 |         this.#wrapper = wrapper;
 53 |     }
 54 |     
 55 |     /** List a page of purchases for a given resource.
 56 |      * 
 57 |      * @param {number} resourceId The identifier of the resource.
 58 |      * @param {SortOptions | undefined} sort An optional set of sort options.
 59 |      * 
 60 |      * @return {Array<Purchase>} An array of raw data objects.
 61 |      */
 62 |     async list(resourceId, sort) {
 63 |         return await this.#wrapper.http().get(`/resources/${resourceId}/purchases`, sort);
 64 |     }
 65 |     
 66 |     /** List all pages of purchases for a given resource.
 67 |      * 
 68 |      * @param {number} resourceId The identifier of the resource.
 69 |      * @param {SortOptions | undefined} sort An optional set of sort options.
 70 |      * 
 71 |      * @return {Array<Purchase>} An array of raw data objects.
 72 |      */
 73 |     async listAll(resourceId, sort) {
 74 |         return await this.#wrapper.http().listUntil(`/resources/${resourceId}/purchases`, () => true, sort);
 75 |     }
 76 | 
 77 |     /** List multiple pages of purchases for a given resource until a condition is no longer met.
 78 |      * 
 79 |      * @param {number} resourceId The identifier of the resource.
 80 |      * @param {function(Purchase):boolean} shouldContinue A function which determines if further pages are requested.
 81 |      * @param {SortOptions | undefined} sort An optional set of sort options.
 82 |      * 
 83 |      * @return {Array<Purchase>} An array of raw data objects.
 84 |      */
 85 |     async listUntil(resourceId, shouldContinue, sort) {
 86 |         return await this.#wrapper.http().listUntil(`/resources/${resourceId}/purchases`, shouldContinue, sort);
 87 |     }
 88 |     
 89 |     /** Fetch a purchase for a given resource.
 90 |      * 
 91 |      * @param {number} resourceId The identifier of the resource.
 92 |      * @param {number} purchaseId The identifier of the purchase.
 93 |      * 
 94 |      * @return {Purchase} A raw data object.
 95 |      */
 96 |     async fetch(resourceId, purchaseId) {
 97 |         return await this.#wrapper.http().get(`/resources/${resourceId}/purchases/${purchaseId}`);
 98 |     }
 99 | }
100 | 
101 | exports.PurchasesHelper = PurchasesHelper;
102 |
103 |
104 | 105 | 106 | 107 | 108 |
109 | 110 | 113 | 114 |
115 | 116 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /docs/live/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Home 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Home

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |

30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
51 | 52 | 55 | 56 |
57 | 58 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /docs/live/scripts/linenumber.js: -------------------------------------------------------------------------------- 1 | /*global document */ 2 | (() => { 3 | const source = document.getElementsByClassName('prettyprint source linenums'); 4 | let i = 0; 5 | let lineNumber = 0; 6 | let lineId; 7 | let lines; 8 | let totalLines; 9 | let anchorHash; 10 | 11 | if (source && source[0]) { 12 | anchorHash = document.location.hash.substring(1); 13 | lines = source[0].getElementsByTagName('li'); 14 | totalLines = lines.length; 15 | 16 | for (; i < totalLines; i++) { 17 | lineNumber++; 18 | lineId = `line${lineNumber}`; 19 | lines[i].id = lineId; 20 | if (lineId === anchorHash) { 21 | lines[i].className += ' selected'; 22 | } 23 | } 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /docs/live/scripts/prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", 2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); 3 | -------------------------------------------------------------------------------- /docs/live/styles/prettify-jsdoc.css: -------------------------------------------------------------------------------- 1 | /* JSDoc prettify.js theme */ 2 | 3 | /* plain text */ 4 | .pln { 5 | color: #000000; 6 | font-weight: normal; 7 | font-style: normal; 8 | } 9 | 10 | /* string content */ 11 | .str { 12 | color: #006400; 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | 17 | /* a keyword */ 18 | .kwd { 19 | color: #000000; 20 | font-weight: bold; 21 | font-style: normal; 22 | } 23 | 24 | /* a comment */ 25 | .com { 26 | font-weight: normal; 27 | font-style: italic; 28 | } 29 | 30 | /* a type name */ 31 | .typ { 32 | color: #000000; 33 | font-weight: normal; 34 | font-style: normal; 35 | } 36 | 37 | /* a literal value */ 38 | .lit { 39 | color: #006400; 40 | font-weight: normal; 41 | font-style: normal; 42 | } 43 | 44 | /* punctuation */ 45 | .pun { 46 | color: #000000; 47 | font-weight: bold; 48 | font-style: normal; 49 | } 50 | 51 | /* lisp open bracket */ 52 | .opn { 53 | color: #000000; 54 | font-weight: bold; 55 | font-style: normal; 56 | } 57 | 58 | /* lisp close bracket */ 59 | .clo { 60 | color: #000000; 61 | font-weight: bold; 62 | font-style: normal; 63 | } 64 | 65 | /* a markup tag name */ 66 | .tag { 67 | color: #006400; 68 | font-weight: normal; 69 | font-style: normal; 70 | } 71 | 72 | /* a markup attribute name */ 73 | .atn { 74 | color: #006400; 75 | font-weight: normal; 76 | font-style: normal; 77 | } 78 | 79 | /* a markup attribute value */ 80 | .atv { 81 | color: #006400; 82 | font-weight: normal; 83 | font-style: normal; 84 | } 85 | 86 | /* a declaration */ 87 | .dec { 88 | color: #000000; 89 | font-weight: bold; 90 | font-style: normal; 91 | } 92 | 93 | /* a variable name */ 94 | .var { 95 | color: #000000; 96 | font-weight: normal; 97 | font-style: normal; 98 | } 99 | 100 | /* a function name */ 101 | .fun { 102 | color: #000000; 103 | font-weight: bold; 104 | font-style: normal; 105 | } 106 | 107 | /* Specify class=linenums on a pre to get line numbering */ 108 | ol.linenums { 109 | margin-top: 0; 110 | margin-bottom: 0; 111 | } 112 | -------------------------------------------------------------------------------- /docs/live/styles/prettify-tomorrow.css: -------------------------------------------------------------------------------- 1 | /* Tomorrow Theme */ 2 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */ 3 | /* Pretty printing styles. Used with prettify.js. */ 4 | /* SPAN elements with the classes below are added by prettyprint. */ 5 | /* plain text */ 6 | .pln { 7 | color: #4d4d4c; } 8 | 9 | @media screen { 10 | /* string content */ 11 | .str { 12 | color: #718c00; } 13 | 14 | /* a keyword */ 15 | .kwd { 16 | color: #8959a8; } 17 | 18 | /* a comment */ 19 | .com { 20 | color: #8e908c; } 21 | 22 | /* a type name */ 23 | .typ { 24 | color: #4271ae; } 25 | 26 | /* a literal value */ 27 | .lit { 28 | color: #f5871f; } 29 | 30 | /* punctuation */ 31 | .pun { 32 | color: #4d4d4c; } 33 | 34 | /* lisp open bracket */ 35 | .opn { 36 | color: #4d4d4c; } 37 | 38 | /* lisp close bracket */ 39 | .clo { 40 | color: #4d4d4c; } 41 | 42 | /* a markup tag name */ 43 | .tag { 44 | color: #c82829; } 45 | 46 | /* a markup attribute name */ 47 | .atn { 48 | color: #f5871f; } 49 | 50 | /* a markup attribute value */ 51 | .atv { 52 | color: #3e999f; } 53 | 54 | /* a declaration */ 55 | .dec { 56 | color: #f5871f; } 57 | 58 | /* a variable name */ 59 | .var { 60 | color: #c82829; } 61 | 62 | /* a function name */ 63 | .fun { 64 | color: #4271ae; } } 65 | /* Use higher contrast and text-weight for printable form. */ 66 | @media print, projection { 67 | .str { 68 | color: #060; } 69 | 70 | .kwd { 71 | color: #006; 72 | font-weight: bold; } 73 | 74 | .com { 75 | color: #600; 76 | font-style: italic; } 77 | 78 | .typ { 79 | color: #404; 80 | font-weight: bold; } 81 | 82 | .lit { 83 | color: #044; } 84 | 85 | .pun, .opn, .clo { 86 | color: #440; } 87 | 88 | .tag { 89 | color: #006; 90 | font-weight: bold; } 91 | 92 | .atn { 93 | color: #404; } 94 | 95 | .atv { 96 | color: #060; } } 97 | /* Style */ 98 | /* 99 | pre.prettyprint { 100 | background: white; 101 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 102 | font-size: 12px; 103 | line-height: 1.5; 104 | border: 1px solid #ccc; 105 | padding: 10px; } 106 | */ 107 | 108 | /* Specify class=linenums on a pre to get line numbering */ 109 | ol.linenums { 110 | margin-top: 0; 111 | margin-bottom: 0; } 112 | 113 | /* IE indents via margin-left */ 114 | li.L0, 115 | li.L1, 116 | li.L2, 117 | li.L3, 118 | li.L4, 119 | li.L5, 120 | li.L6, 121 | li.L7, 122 | li.L8, 123 | li.L9 { 124 | /* */ } 125 | 126 | /* Alternate shading for lines */ 127 | li.L1, 128 | li.L3, 129 | li.L5, 130 | li.L7, 131 | li.L9 { 132 | /* */ } 133 | -------------------------------------------------------------------------------- /docs/staged/APIError.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: APIError.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: APIError.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
31 | 
32 | /** A type which represents a parsed error from the API, or an internal wrapper error. */
33 | class APIError extends Error {
34 |     #code;
35 |     #message;
36 | 
37 |     constructor(json) {
38 |         super(`${json.code} - ${json.message}`);
39 | 
40 |         this.#code = json.code;
41 |         this.#message = json.message;
42 |     }
43 | 
44 |     /** Returns the machine-readable code of the error.
45 |      * 
46 |      * @type {string} The machine-readable error code.
47 |      */
48 |     get code() {
49 |         return this.#code;
50 |     }
51 | 
52 |     /** Returns the human-readable message of the error.
53 |      * 
54 |      * @type {string} The human-readable error message.
55 |      */
56 |     get message() {
57 |         return this.#message;
58 |     }
59 | 
60 |     /** Constructs a new Error which originated within the wrapper.
61 |      * 
62 |      * @param {string} message The internal error message.
63 |      * @returns {APIError} The newly-constructed error.
64 |      */
65 |     static internal(message) {
66 |         return new APIError({code: "InternalWrapperError", message});
67 |     }
68 | }
69 | 
70 | exports.APIError = APIError;
71 |
72 |
73 | 74 | 75 | 76 | 77 |
78 | 79 | 82 | 83 |
84 | 85 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /docs/staged/Error.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: Error.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: Error.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
31 | 
32 | /** A type which represents a parsed error from the API, or an internal wrapper error. */
33 | class Error {
34 |     #code;
35 |     #message;
36 | 
37 |     constructor(json) {
38 |         this.#code = json.code;
39 |         this.#message = json.message;
40 |     }
41 | 
42 |     /** Returns a string representation of this error including both the machine and human-readable parts.
43 |      * 
44 |      * @returns {string} A string representation of this error.
45 |      */
46 |     toString() {
47 |         return `${this.#code}: ${this.#message}`;
48 |     }
49 | 
50 |     /** Returns the machine-readable code of the error.
51 |      * 
52 |      * @returns {string} The machine-readable error code.
53 |      */
54 |     code() {
55 |         return this.#code;
56 |     }
57 | 
58 |     /** Returns the human-readable message of the error.
59 |      * 
60 |      * @returns {string} The human-readable error message.
61 |      */
62 |     message() {
63 |         return this.#message;
64 |     }
65 | 
66 |     /** Constructs a new Error which originated within the wrapper.
67 |      * 
68 |      * @param {string} message The internal error message.
69 |      * @returns {Error} The newly-constructed error.
70 |      */
71 |     static internal(message) {
72 |         return new Error({code: "InternalWrapperError", message});
73 |     }
74 | }
75 | 
76 | exports.Error = Error;
77 |
78 |
79 | 80 | 81 | 82 | 83 |
84 | 85 | 88 | 89 |
90 | 91 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /docs/staged/SortOptions.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: SortOptions.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: SortOptions.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
31 | 
32 | /** A type representing the sorting options available for listing-style endpoints. */
33 | class SortOptions {
34 |     sort;
35 |     order;
36 |     page;
37 | 
38 |     /** Convets this SortOptions instance into a query string.
39 |      * 
40 |      * @returns {string} The query-string representation.
41 |      */
42 |     toQueryString() {
43 |         let asArray = [];
44 | 
45 |         if (this.sort) {
46 |             asArray.push(`sort=${this.sort}`);
47 |         }
48 |         if (this.order) {
49 |             asArray.push(`order=${this.order}`);
50 |         }
51 |         if (this.page) {
52 |             asArray.push(`page=${this.page}`);
53 |         }
54 |         
55 |         return "?" + asArray.join("&");
56 |     }
57 | 
58 |     /** Returns whether or not any sort options have been set.
59 |      * 
60 |      * @returns {boolean} Whether or not any sort options have been set.
61 |      */
62 |     isSet() {
63 |         return this.sort || this.order || this.page;
64 |     }
65 | }
66 | 
67 | exports.SortOptions = SortOptions;
68 |
69 |
70 | 71 | 72 | 73 | 74 |
75 | 76 | 79 | 80 |
81 | 82 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/staged/Token.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: Token.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: Token.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
31 | 
32 | const { TokenType } = require("./TokenType");
33 | 
34 | /** A type representing an API authentication token. */
35 | class Token {
36 |     #type;
37 |     #value;
38 | 
39 |     /** Constructs a new token from its constituents.
40 |      * 
41 |      * @param {TokenType} type The type of this token.
42 |      * @param {string} value The value of this token.
43 |      */
44 |     constructor(type, value) {
45 |         this.#type = type;
46 |         this.#value = value;
47 |     }
48 | 
49 |     /** Constructs an object containing the header representation of this token.
50 |      * 
51 |      * @returns An object with a single attribute, 'Authorization'.
52 |      */
53 |     asHeader() {
54 |         return {Authorization: `${this.#type.headerName()} ${this.#value}`};
55 |     }
56 | }
57 | 
58 | exports.Token = Token;
59 |
60 |
61 | 62 | 63 | 64 | 65 |
66 | 67 | 70 | 71 |
72 | 73 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /docs/staged/TokenType.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Class: TokenType 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Class: TokenType

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

TokenType()

32 | 33 |
A type representing the different token types.
34 | 35 | 36 |
37 | 38 |
39 |
40 | 41 | 42 | 43 | 44 |

Constructor

45 | 46 | 47 | 48 |

new TokenType()

49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 |
Source:
95 |
98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 |
106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 |
149 | 150 |
151 | 152 | 153 | 154 | 155 |
156 | 157 | 160 | 161 |
162 | 163 | 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /docs/staged/TokenType.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: TokenType.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: TokenType.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
31 | 
32 | /** A type representing the different token types. */
33 | class TokenType {
34 |     static PRIVATE = new TokenType("Private");
35 |     static SHARED = new TokenType("Shared");
36 | 
37 |     #headerName;
38 | 
39 |     constructor(headerName) {
40 |         this.#headerName = headerName;
41 |     }
42 | 
43 |     headerName() {
44 |         return this.#headerName;
45 |     }
46 | }
47 | 
48 | exports.TokenType = TokenType;
49 |
50 |
51 | 52 | 53 | 54 | 55 |
56 | 57 | 60 | 61 |
62 | 63 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /docs/staged/fonts/OpenSans-Bold-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/staged/fonts/OpenSans-Bold-webfont.eot -------------------------------------------------------------------------------- /docs/staged/fonts/OpenSans-Bold-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/staged/fonts/OpenSans-Bold-webfont.woff -------------------------------------------------------------------------------- /docs/staged/fonts/OpenSans-BoldItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/staged/fonts/OpenSans-BoldItalic-webfont.eot -------------------------------------------------------------------------------- /docs/staged/fonts/OpenSans-BoldItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/staged/fonts/OpenSans-BoldItalic-webfont.woff -------------------------------------------------------------------------------- /docs/staged/fonts/OpenSans-Italic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/staged/fonts/OpenSans-Italic-webfont.eot -------------------------------------------------------------------------------- /docs/staged/fonts/OpenSans-Italic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/staged/fonts/OpenSans-Italic-webfont.woff -------------------------------------------------------------------------------- /docs/staged/fonts/OpenSans-Light-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/staged/fonts/OpenSans-Light-webfont.eot -------------------------------------------------------------------------------- /docs/staged/fonts/OpenSans-Light-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/staged/fonts/OpenSans-Light-webfont.woff -------------------------------------------------------------------------------- /docs/staged/fonts/OpenSans-LightItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/staged/fonts/OpenSans-LightItalic-webfont.eot -------------------------------------------------------------------------------- /docs/staged/fonts/OpenSans-LightItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/staged/fonts/OpenSans-LightItalic-webfont.woff -------------------------------------------------------------------------------- /docs/staged/fonts/OpenSans-Regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/staged/fonts/OpenSans-Regular-webfont.eot -------------------------------------------------------------------------------- /docs/staged/fonts/OpenSans-Regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BuiltByBit/js-api-wrapper/d7fa7283794314142772a25042da3f52f11d6fd4/docs/staged/fonts/OpenSans-Regular-webfont.woff -------------------------------------------------------------------------------- /docs/staged/helpers_AlertsHelper.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: helpers/AlertsHelper.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: helpers/AlertsHelper.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
 30 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
 31 | 
 32 | const { SortOptions } = require("../SortOptions");
 33 | 
 34 | /**
 35 |  * @typedef {object} Alert
 36 |  * @property {number} caused_member_id
 37 |  * @property {string} content_type
 38 |  * @property {number} content_id
 39 |  * @property {string} alert_type
 40 |  * @property {number} alert_date
 41 |  */
 42 | 
 43 | /** A helper type for alert-related API endpoints. */
 44 | class AlertsHelper {
 45 |     #wrapper;
 46 | 
 47 |     constructor(wrapper) {
 48 |         this.#wrapper = wrapper;
 49 |     }
 50 | 
 51 |     /** List a single page of unread alerts.
 52 |      * 
 53 |      * @param {SortOptions | undefined} sort An optional set of sort options.
 54 |      * @return {Array<Alert>} An array of raw data objects.
 55 |      */
 56 |     async list(sort) {
 57 |         return await this.#wrapper.http().get("/alerts", sort);
 58 |     }
 59 | 
 60 |     /** List all pages of unread alerts.
 61 |      * 
 62 |      * @param {SortOptions | undefined} sort An optional set of sort options.
 63 |      * @return {Array<Alert>} An array of raw data objects.
 64 |      */
 65 |     async listAll(sort) {
 66 |         return await this.#wrapper.http().listUntil("/alerts", () => true, sort);
 67 |     }
 68 | 
 69 |     /** List multiple pages of unread alerts until a condition is no longer met.
 70 |      * 
 71 |      * @param {function(Alert):boolean} shouldContinue A function which determines if further pages are requested.
 72 |      * @param {SortOptions | undefined} sort An optional set of sort options.
 73 |      * 
 74 |      * @return {Array<Alert>} An array of raw data objects.
 75 |      */
 76 |     async listUntil(shouldContinue, sort) {
 77 |         return await this.#wrapper.http().listUntil("/alerts", shouldContinue, sort);
 78 |     }
 79 | 
 80 |     /** Mark unread alerts as read. */
 81 |     async markAsRead() {
 82 |         return await this.#wrapper.http().patch("/alerts", { read: true });
 83 |     }
 84 | }
 85 | 
 86 | exports.AlertsHelper = AlertsHelper;
87 |
88 |
89 | 90 | 91 | 92 | 93 |
94 | 95 | 98 | 99 |
100 | 101 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /docs/staged/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Home 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Home

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |

30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
51 | 52 | 55 | 56 |
57 | 58 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /docs/staged/scripts/linenumber.js: -------------------------------------------------------------------------------- 1 | /*global document */ 2 | (() => { 3 | const source = document.getElementsByClassName('prettyprint source linenums'); 4 | let i = 0; 5 | let lineNumber = 0; 6 | let lineId; 7 | let lines; 8 | let totalLines; 9 | let anchorHash; 10 | 11 | if (source && source[0]) { 12 | anchorHash = document.location.hash.substring(1); 13 | lines = source[0].getElementsByTagName('li'); 14 | totalLines = lines.length; 15 | 16 | for (; i < totalLines; i++) { 17 | lineNumber++; 18 | lineId = `line${lineNumber}`; 19 | lines[i].id = lineId; 20 | if (lineId === anchorHash) { 21 | lines[i].className += ' selected'; 22 | } 23 | } 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /docs/staged/scripts/prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", 2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); 3 | -------------------------------------------------------------------------------- /docs/staged/styles/prettify-jsdoc.css: -------------------------------------------------------------------------------- 1 | /* JSDoc prettify.js theme */ 2 | 3 | /* plain text */ 4 | .pln { 5 | color: #000000; 6 | font-weight: normal; 7 | font-style: normal; 8 | } 9 | 10 | /* string content */ 11 | .str { 12 | color: #006400; 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | 17 | /* a keyword */ 18 | .kwd { 19 | color: #000000; 20 | font-weight: bold; 21 | font-style: normal; 22 | } 23 | 24 | /* a comment */ 25 | .com { 26 | font-weight: normal; 27 | font-style: italic; 28 | } 29 | 30 | /* a type name */ 31 | .typ { 32 | color: #000000; 33 | font-weight: normal; 34 | font-style: normal; 35 | } 36 | 37 | /* a literal value */ 38 | .lit { 39 | color: #006400; 40 | font-weight: normal; 41 | font-style: normal; 42 | } 43 | 44 | /* punctuation */ 45 | .pun { 46 | color: #000000; 47 | font-weight: bold; 48 | font-style: normal; 49 | } 50 | 51 | /* lisp open bracket */ 52 | .opn { 53 | color: #000000; 54 | font-weight: bold; 55 | font-style: normal; 56 | } 57 | 58 | /* lisp close bracket */ 59 | .clo { 60 | color: #000000; 61 | font-weight: bold; 62 | font-style: normal; 63 | } 64 | 65 | /* a markup tag name */ 66 | .tag { 67 | color: #006400; 68 | font-weight: normal; 69 | font-style: normal; 70 | } 71 | 72 | /* a markup attribute name */ 73 | .atn { 74 | color: #006400; 75 | font-weight: normal; 76 | font-style: normal; 77 | } 78 | 79 | /* a markup attribute value */ 80 | .atv { 81 | color: #006400; 82 | font-weight: normal; 83 | font-style: normal; 84 | } 85 | 86 | /* a declaration */ 87 | .dec { 88 | color: #000000; 89 | font-weight: bold; 90 | font-style: normal; 91 | } 92 | 93 | /* a variable name */ 94 | .var { 95 | color: #000000; 96 | font-weight: normal; 97 | font-style: normal; 98 | } 99 | 100 | /* a function name */ 101 | .fun { 102 | color: #000000; 103 | font-weight: bold; 104 | font-style: normal; 105 | } 106 | 107 | /* Specify class=linenums on a pre to get line numbering */ 108 | ol.linenums { 109 | margin-top: 0; 110 | margin-bottom: 0; 111 | } 112 | -------------------------------------------------------------------------------- /docs/staged/styles/prettify-tomorrow.css: -------------------------------------------------------------------------------- 1 | /* Tomorrow Theme */ 2 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */ 3 | /* Pretty printing styles. Used with prettify.js. */ 4 | /* SPAN elements with the classes below are added by prettyprint. */ 5 | /* plain text */ 6 | .pln { 7 | color: #4d4d4c; } 8 | 9 | @media screen { 10 | /* string content */ 11 | .str { 12 | color: #718c00; } 13 | 14 | /* a keyword */ 15 | .kwd { 16 | color: #8959a8; } 17 | 18 | /* a comment */ 19 | .com { 20 | color: #8e908c; } 21 | 22 | /* a type name */ 23 | .typ { 24 | color: #4271ae; } 25 | 26 | /* a literal value */ 27 | .lit { 28 | color: #f5871f; } 29 | 30 | /* punctuation */ 31 | .pun { 32 | color: #4d4d4c; } 33 | 34 | /* lisp open bracket */ 35 | .opn { 36 | color: #4d4d4c; } 37 | 38 | /* lisp close bracket */ 39 | .clo { 40 | color: #4d4d4c; } 41 | 42 | /* a markup tag name */ 43 | .tag { 44 | color: #c82829; } 45 | 46 | /* a markup attribute name */ 47 | .atn { 48 | color: #f5871f; } 49 | 50 | /* a markup attribute value */ 51 | .atv { 52 | color: #3e999f; } 53 | 54 | /* a declaration */ 55 | .dec { 56 | color: #f5871f; } 57 | 58 | /* a variable name */ 59 | .var { 60 | color: #c82829; } 61 | 62 | /* a function name */ 63 | .fun { 64 | color: #4271ae; } } 65 | /* Use higher contrast and text-weight for printable form. */ 66 | @media print, projection { 67 | .str { 68 | color: #060; } 69 | 70 | .kwd { 71 | color: #006; 72 | font-weight: bold; } 73 | 74 | .com { 75 | color: #600; 76 | font-style: italic; } 77 | 78 | .typ { 79 | color: #404; 80 | font-weight: bold; } 81 | 82 | .lit { 83 | color: #044; } 84 | 85 | .pun, .opn, .clo { 86 | color: #440; } 87 | 88 | .tag { 89 | color: #006; 90 | font-weight: bold; } 91 | 92 | .atn { 93 | color: #404; } 94 | 95 | .atv { 96 | color: #060; } } 97 | /* Style */ 98 | /* 99 | pre.prettyprint { 100 | background: white; 101 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 102 | font-size: 12px; 103 | line-height: 1.5; 104 | border: 1px solid #ccc; 105 | padding: 10px; } 106 | */ 107 | 108 | /* Specify class=linenums on a pre to get line numbering */ 109 | ol.linenums { 110 | margin-top: 0; 111 | margin-bottom: 0; } 112 | 113 | /* IE indents via margin-left */ 114 | li.L0, 115 | li.L1, 116 | li.L2, 117 | li.L3, 118 | li.L4, 119 | li.L5, 120 | li.L6, 121 | li.L7, 122 | li.L8, 123 | li.L9 { 124 | /* */ } 125 | 126 | /* Alternate shading for lines */ 127 | li.L1, 128 | li.L3, 129 | li.L5, 130 | li.L7, 131 | li.L9 { 132 | /* */ } 133 | -------------------------------------------------------------------------------- /examples/conversation-verification.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { Wrapper, Token, TokenType } = require("@builtbybit/api-wrapper"); 5 | const readline = require("readline"); 6 | 7 | const rl = readline.createInterface({ 8 | input: process.stdin, 9 | output: process.stdout 10 | }); 11 | 12 | let token = new Token(TokenType.PRIVATE, "Find @ https://builtbybit.com/account/api"); 13 | let wrapper = new Wrapper(); 14 | 15 | 16 | async function main() { 17 | await wrapper.init(token); 18 | 19 | let title = "Verification"; 20 | let message = "This message verifies that I am speaking with you."; 21 | 22 | rl.question("What is the ID of the user you'd like to start a conversation with?", (userId) => { 23 | let conversation = wrapper.conversations().start(title, message, new Array(userId)); 24 | console.info("Conversation " + conversation + " created for verification"); 25 | }); 26 | 27 | } 28 | 29 | main().catch(error => console.error("ERROR: " + error)); -------------------------------------------------------------------------------- /examples/delete-all-versions.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { Wrapper, Token, TokenType } = require("@builtbybit/api-wrapper"); 5 | 6 | let token = new Token(TokenType.PRIVATE, "Find @ https://builtbybit.com/account/api"); 7 | let wrapper = new Wrapper(); 8 | 9 | let resourceId = 0; 10 | 11 | async function main() { 12 | await wrapper.init(token); 13 | 14 | let versions = await wrapper.resources().versions().listAll(resourceId); 15 | 16 | // The current version cannot be deleted so we remove it from the returned list of versions. 17 | versions.shift(); 18 | 19 | for (const index in versions) { 20 | let versionId = versions[index]["version_id"]; 21 | 22 | await wrapper.resources().versions().delete(resourceId, versionId); 23 | console.log("Successfully deleted version with id: " + versionId); 24 | } 25 | } 26 | 27 | main().catch(error => console.error("ERROR: " + error)); 28 | -------------------------------------------------------------------------------- /examples/discord-identity-bot/index.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { Wrapper, Token, TokenType, Error } = require("@builtbybit/api-wrapper"); 5 | const { Client, Intents } = require('discord.js'); 6 | 7 | const bbbToken = new Token(TokenType.PRIVATE, "Find @ https://builtbybit.com/account/api"); 8 | const botToken = "Find @ https://discord.com/developers/applications"; 9 | 10 | const GUILD_ID = "0"; 11 | const ROLE_ID = "0"; 12 | const CHANNEL_ID = "0"; 13 | 14 | let guild = undefined; 15 | let channel = undefined; 16 | let role = undefined; 17 | 18 | const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); 19 | const wrapper = new Wrapper(); 20 | 21 | async function main() { 22 | await client.login(botToken); 23 | await wrapper.init(bbbToken); 24 | 25 | guild = await client.guilds.fetch(GUILD_ID); 26 | channel = await client.channels.fetch(CHANNEL_ID); 27 | role = await guild.roles.fetch(ROLE_ID); 28 | 29 | client.on("guildMemberAdd", join); 30 | } 31 | 32 | async function join(user) { 33 | if (user.guild.id !== guild.id) return; 34 | 35 | let member; 36 | try { 37 | member = await wrapper.members().fetchByDiscord(Number(user.user.id)); 38 | } catch (error) { 39 | if (error instanceof Error && error.code() === "MemberNotFound") { 40 | await channel.send(`[BuiltByBit] No member found for ${user}.`); 41 | } 42 | 43 | throw error; 44 | } 45 | 46 | let member_url = `https://wbuiltbybit.com/members/${member.member_id}/`; 47 | await channel.send(`[BuiltByBit] A member was found for ${user}: '${member.username}' (${member_url}).`); 48 | 49 | await user.roles.add(role); 50 | } 51 | 52 | main().catch(error => console.error("ERROR: " + error)); -------------------------------------------------------------------------------- /examples/discord-identity-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discord-identity-bot", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "discord.js": "^13.6.0", 13 | "@builtbybit/api-wrapper": "^1.1.4" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/download-verification.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2025 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { Wrapper, Token, TokenType } = require("@builtbybit/api-wrapper"); 5 | const readline = require("readline"); 6 | const { table } = require("table"); 7 | 8 | const rl = readline.createInterface({ 9 | input: process.stdin, 10 | output: process.stdout 11 | }); 12 | 13 | const config = { 14 | header: { 15 | alignment: "center", 16 | content: "BuiltByBit Download Verification" 17 | } 18 | }; 19 | 20 | let token = new Token(TokenType.PRIVATE, "Find @ https://builtbybit.com/account/api"); 21 | let wrapper = new Wrapper(); 22 | 23 | async function main() { 24 | await wrapper.init(token); 25 | 26 | let ownedResources = await wrapper.resources().listOwnedAll().catch(e => { console.error(e); }); 27 | let resourceIds = [["Resource Title", "Resource ID"]]; 28 | for (const resource of ownedResources) { 29 | resourceIds.push([resource.title, resource.resource_id]); 30 | } 31 | const ownedConfig = { 32 | header: { 33 | alignment: "center", 34 | content: "BuiltByBit Download Verification\nOwned Resources" 35 | } 36 | }; 37 | console.log(table(resourceIds, ownedConfig)); 38 | 39 | rl.question("Lookup by (u)sername or by (r)esource id? ", async (answer) =>{ 40 | let downloadDetails; 41 | let user; 42 | let downloads = []; 43 | switch (answer.toLowerCase()) { 44 | case "u": 45 | try { 46 | rl.question("What is the username of the user you'd like to lookup? ", async (username) => { 47 | user = await wrapper.members().fetchByUsername(username).catch(e => { console.error(e); }); 48 | console.log("Fetching..."); 49 | downloads.push(["Resource Title", "Resource ID", "Download Date"]); 50 | for (const resource of ownedResources) { 51 | // eslint-disable-next-line max-len 52 | downloadDetails = await wrapper.resources().downloads().listByMemberAll(resource.resource_id, user.member_id).catch(e => { console.error(e); }); 53 | for (const download of downloadDetails) { 54 | // eslint-disable-next-line max-len 55 | downloads.push([resource.title, resource.resource_id, new Date(download.download_date * 1000).toLocaleString()]); 56 | } 57 | } 58 | console.log(table(downloads, config)); 59 | rl.close(); 60 | }); 61 | } catch (e) { 62 | console.error(e); 63 | rl.close(); 64 | } 65 | break; 66 | case "r": 67 | try { 68 | rl.question("What is the resource id of the resource you'd like to lookup? ", async (resourceId) => { 69 | // eslint-disable-next-line max-len 70 | downloadDetails = await wrapper.resources().downloads().listAll(resourceId).catch(e => { console.error(e); }); 71 | downloads.push(["Username", "Member ID", "Download Date"]); 72 | console.log("Fetching..."); 73 | for (const download of downloadDetails) { 74 | user = await wrapper.members().fetch(download.downloader_id).catch(e => { console.error(e); }); 75 | // eslint-disable-next-line max-len 76 | downloads.push([user.username, user.member_id, new Date(download.download_date * 1000).toLocaleString()]); 77 | } 78 | console.log(table(downloads, config)); 79 | rl.close(); 80 | }); 81 | } catch (e) { 82 | console.error(e); 83 | rl.close(); 84 | } 85 | break; 86 | default: 87 | console.error("Invalid input. Please try again."); 88 | rl.close(); 89 | break; 90 | } 91 | }); 92 | } 93 | 94 | main().catch(error => console.error("ERROR: " + error)); -------------------------------------------------------------------------------- /examples/export-purchases-csv.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { Wrapper, Token, TokenType } = require("@builtbybit/api-wrapper"); 5 | const fs = require("fs"); 6 | 7 | let token = new Token(TokenType.PRIVATE, "Find @ https://builtbybit.com/account/api"); 8 | let wrapper = new Wrapper(); 9 | 10 | async function main() { 11 | await wrapper.init(token); 12 | 13 | let ownedResources = await wrapper.resources().listOwnedAll(); 14 | let fileData = "Resource ID,Purchase ID,Member ID,Renewal,Price,Currency,Date\n"; 15 | 16 | for (const rIndex in ownedResources) { 17 | let resourceId = ownedResources[rIndex]["resource_id"]; 18 | let purchases = await wrapper.resources().purchases().listAll(resourceId); 19 | 20 | for (const pIndex in purchases) { 21 | let purchaseId = purchases[pIndex]["purchase_id"]; 22 | let memberId = purchases[pIndex]["purchaser_id"]; 23 | let renewal = purchases[pIndex]["renewal"]; 24 | let price = purchases[pIndex]["price"]; 25 | let currency = purchases[pIndex]["currency"]; 26 | let date = purchases[pIndex]["purchase_date"]; 27 | 28 | fileData += `${resourceId},${purchaseId},${memberId},${renewal},${price},${currency},${date}\n`; 29 | } 30 | 31 | console.log(`Fetched all purchases for ${resourceId}.`); 32 | } 33 | 34 | await fs.promises.writeFile("./purchases.csv", fileData); 35 | console.log("Done!"); 36 | } 37 | 38 | main().catch(error => console.error("ERROR: " + error)); 39 | -------------------------------------------------------------------------------- /examples/license-check.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { Wrapper, Token, TokenType } = require("@builtbybit/api-wrapper"); 5 | 6 | let token = new Token(TokenType.SHARED, "Find @ https://builtbybit.com/account/api"); 7 | let wrapper = new Wrapper(); 8 | 9 | // Injected placeholders. 10 | let resourceId = Number("%%__RESOURCE__%%"); 11 | let memberId = Number("%%__USER__%%"); 12 | let nonce = Number("%%__NONCE__%%"); 13 | let timestamp = Number("%%__TIMESTAMP__%%"); 14 | 15 | async function main() { 16 | await wrapper.init(token); 17 | 18 | let license = await wrapper.resources().licenses().fetchMember(resourceId, memberId, nonce, timestamp); 19 | let currentTimestamp = Math.floor(new Date().getTime() / 1000); 20 | 21 | if (license.permanent && !license.active) { 22 | throw "A license has been found but it isn't currently active."; 23 | } 24 | 25 | if (!license.permanent && (license["start_date"] > currentTimestamp || license["end_date"] < currentTimestamp)) { 26 | throw "A license has been found but it has since expired."; 27 | } 28 | 29 | console.log("Active license found, returning from function without throwing an error."); 30 | } 31 | 32 | main().catch(error => console.error("ERROR: " + error)); 33 | -------------------------------------------------------------------------------- /examples/lookup-user.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { Wrapper, Token, TokenType } = require("@builtbybit/api-wrapper"); 5 | const readline = require("readline"); 6 | 7 | const rl = readline.createInterface({ 8 | input: process.stdin, 9 | output: process.stdout 10 | }); 11 | 12 | let token = new Token(TokenType.PRIVATE, "Find @ https://builtbybit.com/account/api"); 13 | let wrapper = new Wrapper(); 14 | 15 | async function main() { 16 | await wrapper.init(token); 17 | 18 | rl.question("Lookup by (u)sername or by (i)d? ", (answer) => { 19 | let userObj; 20 | switch (answer.toLowerCase()) { 21 | case "u": 22 | try { 23 | rl.question("What is the username of the user you'd like to lookup? ", async (username) => { 24 | userObj = await wrapper.members().fetchByUsername(username).catch(e => { console.error(e); }); 25 | let memberId = userObj.member_id; 26 | let joinDate = userObj.join_date; 27 | let lastActivityDate = userObj.last_activity_date; 28 | let banned = userObj.banned; 29 | let suspended = userObj.suspended; 30 | let restricted = userObj.restricted; 31 | let disabled = userObj.disabled; 32 | let postCount = userObj.post_count; 33 | // eslint-disable-next-line max-len 34 | let message = `${username}'s Statistics:\nMember Id: ${memberId}\nJoin Date: ${new Date(joinDate * 1000)}\nLast Activity: ${new Date(lastActivityDate * 1000)}\nBanned: ${banned}\nSuspended: ${suspended}\nRestricted: ${restricted}\nDisabled: ${disabled}\nPost Count: ${postCount}`; 35 | console.log(message); 36 | rl.close(); 37 | }); 38 | } catch (error) { 39 | console.log("Error: " + error); 40 | } 41 | break; 42 | case "i": 43 | try { 44 | rl.question("What is the ID of the user you'd like to lookup? ", async (userId) => { 45 | let userObj = await wrapper.members().fetch(userId).catch(e => { console.log(e); }); 46 | let username = userObj.username; 47 | let joinDate = userObj.join_date; 48 | let lastActivityDate = userObj.last_activity_date; 49 | let banned = userObj.banned; 50 | let suspended = userObj.suspended; 51 | let restricted = userObj.restricted; 52 | let disabled = userObj.disabled; 53 | let postCount = userObj.post_count; 54 | 55 | // eslint-disable-next-line max-len 56 | let message = `${userId}'s Statistics:\nUsername: ${username}\nJoin Date: ${new Date(joinDate * 1000)}\nLast Activity: ${new Date(lastActivityDate * 1000)}\nBanned: ${banned}\nSuspended: ${suspended}\nRestricted: ${restricted}\nDisabled: ${disabled}\nPost Count: ${postCount}`; 57 | 58 | console.log(message); 59 | rl.close(); 60 | }); 61 | } catch (error) { 62 | console.log("ERROR: " + error); 63 | } 64 | break; 65 | default: 66 | console.log("Invalid Answer"); 67 | } 68 | }); 69 | } 70 | 71 | main().catch(error => console.error("ERROR: " + error)); -------------------------------------------------------------------------------- /examples/pm-on-purchase.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { Wrapper, Token, TokenType } = require("@builtbybit/api-wrapper"); 5 | 6 | let token = new Token(TokenType.PRIVATE, "Find @ https://builtbybit.com/account/api"); 7 | let wrapper = new Wrapper(); 8 | 9 | // We're only listening for a specific resource in this example, but this could be expanded to cover multiple. 10 | let resourceId = 0; 11 | 12 | // We're only keeping a store of the last purchase ID in memory for this example, but it's likely you'd want to 13 | // read/write this to a secondary data store (ie. a file or database). 14 | let lastPurchaseId = 0; 15 | 16 | let pmTitle = "Your recent purchase!"; 17 | let pmMessage = `Hi there, 18 | 19 | Thank you for your recent purchase of my resource. 20 | 21 | If you need any assistance, don't hesitate to contact me. 22 | 23 | Thanks, 24 | - Author`; 25 | 26 | async function main() { 27 | await wrapper.init(token); 28 | 29 | // Poll once every hour. 30 | task(); 31 | setInterval(task, 60 * 60 * 1000); 32 | } 33 | 34 | async function task() { 35 | let purchases = await wrapper.resources().purchases().listUntil(resourceId, (purchase) => { 36 | return purchase["purchase_id"] > lastPurchaseId; 37 | }); 38 | 39 | if (purchases.length > 0) { 40 | lastPurchaseId = purchases[0]["purchase_id"]; 41 | 42 | for (const index in purchases) { 43 | await onPurchase(purchases[index]); 44 | } 45 | } 46 | } 47 | 48 | async function onPurchase(purchase) { 49 | await wrapper.conversations().create(pmTitle, pmMessage, purchase["purchaser_id"]); 50 | console.log(`A PM has been sent to user ${purchase["purchaser_id"]}.`); 51 | } 52 | 53 | main().catch(error => console.error("ERROR: " + error)); 54 | -------------------------------------------------------------------------------- /examples/version-check.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { Wrapper, Token, TokenType } = require("@builtbybit/api-wrapper"); 5 | 6 | let token = new Token(TokenType.SHARED, "Find @ https://builtbybit.com/account/api"); 7 | let wrapper = new Wrapper(); 8 | 9 | // Injected placeholders. 10 | let resourceId = "%%__RESOURCE__%%"; 11 | let versionId = "%%__VERSION__%%"; 12 | 13 | async function main() { 14 | await wrapper.init(token); 15 | 16 | let latest = await wrapper.resources().versions().latest(resourceId); 17 | 18 | if (Number(versionId) === latest["version_id"]) { 19 | console.log("Up to date."); 20 | } else { 21 | console.log(`A new version exists. https://builtbybit.com/resources/${resourceId}/`); 22 | } 23 | } 24 | 25 | main().catch(error => console.error("ERROR: " + error)); 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@builtbybit/api-wrapper", 3 | "version": "1.1.10", 4 | "description": "An official asynchronous Node.js wrapper for BuiltByBit's Ultimate API.", 5 | "keywords": [ 6 | "builtbybit", 7 | "api wrapper", 8 | "asynchronous" 9 | ], 10 | "main": "./src/index.js", 11 | "types": "./types/index.d.ts", 12 | "scripts": { 13 | "doc-live": "jsdoc -r ./src/ -d ./docs/live/", 14 | "doc-staged": "jsdoc -r ./src/ -d ./docs/staged/", 15 | "lint": "npx eslint --fix ./src/", 16 | "type": "npx tsc", 17 | "test": "node ./tests/test.js && npx eslint ./src/" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/BuiltByBit/js-api-wrapper.git" 22 | }, 23 | "author": "BuiltByBit (Mick Capital Pty. Ltd.)", 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/BuiltByBit/js-api-wrapper/issues" 27 | }, 28 | "homepage": "https://builtbybit.com/wiki/ultimate-api/", 29 | "dependencies": { 30 | "axios": "^0.21.1" 31 | }, 32 | "devDependencies": { 33 | "eslint": "^8.6.0", 34 | "jsdoc": "^4.0.2", 35 | "typescript": "^4.5.5" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/APIError.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | /** A type which represents a parsed error from the API, or an internal wrapper error. */ 5 | class APIError extends Error { 6 | #code; 7 | #message; 8 | 9 | constructor(json) { 10 | super(`${json.code} - ${json.message}`); 11 | 12 | this.#code = json.code; 13 | this.#message = json.message; 14 | } 15 | 16 | /** Returns the machine-readable code of the error. 17 | * 18 | * @type {string} The machine-readable error code. 19 | */ 20 | get code() { 21 | return this.#code; 22 | } 23 | 24 | /** Returns the human-readable message of the error. 25 | * 26 | * @type {string} The human-readable error message. 27 | */ 28 | get message() { 29 | return this.#message; 30 | } 31 | 32 | /** Constructs a new Error which originated within the wrapper. 33 | * 34 | * @param {string} message The internal error message. 35 | * @returns {APIError} The newly-constructed error. 36 | */ 37 | static internal(message) { 38 | return new APIError({code: "InternalWrapperError", message}); 39 | } 40 | } 41 | 42 | exports.APIError = APIError; -------------------------------------------------------------------------------- /src/SortOptions.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | /** A type representing the sorting options available for listing-style endpoints. */ 5 | class SortOptions { 6 | sort; 7 | order; 8 | page; 9 | 10 | /** Convets this SortOptions instance into a query string. 11 | * 12 | * @returns {string} The query-string representation. 13 | */ 14 | toQueryString() { 15 | let asArray = []; 16 | 17 | if (this.sort) { 18 | asArray.push(`sort=${this.sort}`); 19 | } 20 | if (this.order) { 21 | asArray.push(`order=${this.order}`); 22 | } 23 | if (this.page) { 24 | asArray.push(`page=${this.page}`); 25 | } 26 | 27 | return "?" + asArray.join("&"); 28 | } 29 | 30 | /** Returns whether or not any sort options have been set. 31 | * 32 | * @returns {boolean} Whether or not any sort options have been set. 33 | */ 34 | isSet() { 35 | return this.sort || this.order || this.page; 36 | } 37 | } 38 | 39 | exports.SortOptions = SortOptions; -------------------------------------------------------------------------------- /src/Throttler.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | class Throttler { 5 | #readLastRetry; 6 | #readLastRequest; 7 | 8 | #writeLastRetry; 9 | #writeLastRequest; 10 | 11 | constructor() { 12 | this.#readLastRetry = 0; 13 | this.#readLastRequest = Date.now(); 14 | 15 | this.#writeLastRetry = 0; 16 | this.#writeLastRequest = Date.now(); 17 | } 18 | 19 | setRead(retry) { 20 | this.#readLastRetry = retry; 21 | this.#readLastRequest = Date.now(); 22 | } 23 | 24 | setWrite(retry) { 25 | this.#writeLastRetry = retry; 26 | this.#writeLastRequest = Date.now(); 27 | } 28 | 29 | resetRead() { 30 | this.#readLastRetry = 0; 31 | this.#readLastRequest = Date.now(); 32 | } 33 | 34 | resetWrite() { 35 | this.#writeLastRetry = 0; 36 | this.#writeLastRequest = Date.now(); 37 | } 38 | 39 | async stallIfRequired(write) { 40 | let stall = true; 41 | 42 | while (stall) { 43 | let time = Date.now(); 44 | 45 | // As rate limits for WRITE operations are applied independently of those applied to READ operations, we 46 | // first determine if we're in a WRITE operation, and if we are, attempt to stall if required. 47 | // `stall_for_helper` will return true if a stall was required (and it completed the stall), or false if 48 | // no stall was required. 49 | if (write && (await this.#stallForHelper(this.#writeLastRetry, this.#writeLastRequest, time))) { 50 | continue; 51 | } else if (write) { 52 | stall = false; 53 | continue; 54 | } 55 | 56 | // If we haven't started a new iteration of this loop yet, we must be in a READ operation. 57 | if (await this.#stallForHelper(this.#readLastRetry, this.#readLastRequest, time)) { 58 | continue; 59 | } else { 60 | stall = false; 61 | } 62 | } 63 | } 64 | 65 | // A helper function for `stall_if_required` which computes over a generic set of rate limiting parameters. 66 | async #stallForHelper(lastRetry, lastRequest, time) { 67 | // If we've previously hit a rate limit, no other request has been completed with a non-429 response since, and 68 | // we're still within the Retry-After delay period, we should stall this request. The exact amount of time we 69 | // stall for derives from the amount of time that has passed since the last request, minus the Retry-After 70 | // value. 71 | if (lastRetry > 0 && time - lastRequest < lastRetry) { 72 | let stallFor = lastRetry - (time - lastRequest); 73 | await new Promise((resolve) => setTimeout(resolve, stallFor)); 74 | 75 | return true; 76 | } else { 77 | return false; 78 | } 79 | } 80 | } 81 | 82 | exports.Throttler = Throttler; -------------------------------------------------------------------------------- /src/Token.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { TokenType } = require("./TokenType"); 5 | 6 | /** A type representing an API authentication token. */ 7 | class Token { 8 | #type; 9 | #value; 10 | 11 | /** Constructs a new token from its constituents. 12 | * 13 | * @param {TokenType} type The type of this token. 14 | * @param {string} value The value of this token. 15 | */ 16 | constructor(type, value) { 17 | this.#type = type; 18 | this.#value = value; 19 | } 20 | 21 | /** Constructs an object containing the header representation of this token. 22 | * 23 | * @returns An object with a single attribute, 'Authorization'. 24 | */ 25 | asHeader() { 26 | return {Authorization: `${this.#type.headerName()} ${this.#value}`}; 27 | } 28 | } 29 | 30 | exports.Token = Token; -------------------------------------------------------------------------------- /src/TokenType.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | /** A type representing the different token types. */ 5 | class TokenType { 6 | static PRIVATE = new TokenType("Private"); 7 | static SHARED = new TokenType("Shared"); 8 | 9 | #headerName; 10 | 11 | constructor(headerName) { 12 | this.#headerName = headerName; 13 | } 14 | 15 | headerName() { 16 | return this.#headerName; 17 | } 18 | } 19 | 20 | exports.TokenType = TokenType; -------------------------------------------------------------------------------- /src/Wrapper.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const axios = require("axios"); 5 | 6 | const { Token } = require("./Token"); 7 | const { Http } = require("./Http.js"); 8 | const { APIError } = require("./APIError.js"); 9 | const { Throttler } = require("./Throttler.js"); 10 | 11 | const { AlertsHelper } = require("./helpers/AlertsHelper.js"); 12 | const { ConversationsHelper } = require("./helpers/ConversationsHelper.js"); 13 | const { ThreadsHelper } = require("./helpers/ThreadsHelper.js"); 14 | const { MembersHelper } = require("./helpers/members/MembersHelper.js"); 15 | const { ResourcesHelper } = require("./helpers/resources/ResourcesHelper.js"); 16 | 17 | /** The primary wrapping type for interactions with BuiltByBit's API. */ 18 | class Wrapper { 19 | /** The base API URL and version which will be prepended to non-absolute paths by axios. */ 20 | static #BASE_URL = "https://api.builtbybit.com/v1"; 21 | 22 | #http; 23 | 24 | /** Initialise this wrapper with a provided API token. 25 | * 26 | *

27 | * 28 | * By default, initialisation of this wrapper will execute a health check which we expect to always succeed under 29 | * nominal conditions. If the request does fail, we expect subsequent requests to other endpoints to also fail. In 30 | * this situation, we conclude that an initialisation failure has occured. We reject the returned Promise and pass 31 | * back the error to the caller. 32 | * 33 | * @param {Token} token The constructed API token. 34 | * @param {boolean} health Whether or not to execute a health check during initialisation. 35 | */ 36 | async init(token, health = true) { 37 | let client = axios.create({baseURL: Wrapper.#BASE_URL, headers: token.asHeader()}); 38 | this.#http = new Http(client, new Throttler()); 39 | 40 | if (health) await this.health(); 41 | } 42 | 43 | /** Schedule an empty request which we expect to always succeed under nominal conditions. */ 44 | async health() { 45 | if (await this.#http.get("/health") !== "ok") { 46 | throw APIError.internal("The health response contained unexpected data."); 47 | } 48 | } 49 | 50 | /** Schedule an empty request and measure how long the API took to respond. 51 | * 52 | *

53 | * 54 | * This duration may not be representative of the raw request latency due to the fact that requests may be stalled 55 | * locally within this wrapper to ensure compliance with rate limiting rules. Whilst this is a trade-off, it can 56 | * be argued that the returned duration will be more representative of the true latencies experienced. 57 | * 58 | * @return {number} The response time in milliseconds. 59 | */ 60 | async ping() { 61 | let start = Date.now(); 62 | await this.health(); 63 | return Date.now() - start; 64 | } 65 | 66 | /** Access alert-related helper functions. 67 | * 68 | * @return {AlertsHelper} A newly-constructed alert helper instance. 69 | */ 70 | alerts() { 71 | return new AlertsHelper(this); 72 | } 73 | 74 | /** Access conversation-related helper functions. 75 | * 76 | * @return {ConversationsHelper} A newly-constructed conversation helper instance. 77 | */ 78 | conversations() { 79 | return new ConversationsHelper(this); 80 | } 81 | 82 | /** Access thread-related helper functions. 83 | * 84 | * @return {ThreadsHelper} A newly-constructed thread helper instance. 85 | */ 86 | threads() { 87 | return new ThreadsHelper(this); 88 | } 89 | 90 | /** Access member-related helper functions. 91 | * 92 | * @return {MembersHelper} A newly-constructed member helper instance. 93 | */ 94 | members() { 95 | return new MembersHelper(this); 96 | } 97 | 98 | /** Access resource-related helper functions. 99 | * 100 | * @return {ResourcesHelper} A newly-constructed resource helper instance. 101 | */ 102 | resources() { 103 | return new ResourcesHelper(this); 104 | } 105 | 106 | /** Access the inner Http instance which can be used to make raw requests. 107 | * 108 | * @returns {Http} The current Http instance in use by this wrapper. 109 | */ 110 | http() { 111 | return this.#http; 112 | } 113 | } 114 | 115 | exports.Wrapper = Wrapper; -------------------------------------------------------------------------------- /src/helpers/AlertsHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { SortOptions } = require("../SortOptions"); 5 | 6 | /** 7 | * @typedef {object} Alert 8 | * @property {number} caused_member_id 9 | * @property {string} content_type 10 | * @property {number} content_id 11 | * @property {string} alert_type 12 | * @property {number} alert_date 13 | */ 14 | 15 | /** A helper type for alert-related API endpoints. */ 16 | class AlertsHelper { 17 | #wrapper; 18 | 19 | constructor(wrapper) { 20 | this.#wrapper = wrapper; 21 | } 22 | 23 | /** List a single page of unread alerts. 24 | * 25 | * @param {SortOptions | undefined} sort An optional set of sort options. 26 | * @return {Array} An array of raw data objects. 27 | */ 28 | async list(sort) { 29 | return await this.#wrapper.http().get("/alerts", sort); 30 | } 31 | 32 | /** List all pages of unread alerts. 33 | * 34 | * @param {SortOptions | undefined} sort An optional set of sort options. 35 | * @return {Array} An array of raw data objects. 36 | */ 37 | async listAll(sort) { 38 | return await this.#wrapper.http().listUntil("/alerts", () => true, sort); 39 | } 40 | 41 | /** List multiple pages of unread alerts until a condition is no longer met. 42 | * 43 | * @param {function(Alert):boolean} shouldContinue A function which determines if further pages are requested. 44 | * @param {SortOptions | undefined} sort An optional set of sort options. 45 | * 46 | * @return {Array} An array of raw data objects. 47 | */ 48 | async listUntil(shouldContinue, sort) { 49 | return await this.#wrapper.http().listUntil("/alerts", shouldContinue, sort); 50 | } 51 | 52 | /** Mark unread alerts as read. */ 53 | async markAsRead() { 54 | return await this.#wrapper.http().patch("/alerts", { read: true }); 55 | } 56 | } 57 | 58 | exports.AlertsHelper = AlertsHelper; -------------------------------------------------------------------------------- /src/helpers/ConversationsHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { SortOptions } = require("../SortOptions"); 5 | 6 | /** 7 | * @typedef {object} Conversation 8 | * @property {number} conversation_id 9 | * @property {string} title 10 | * @property {number} creation_date 11 | * @property {number} creator_id 12 | * @property {number} last_message_date 13 | * @property {number} last_read_date 14 | * @property {boolean} open 15 | * @property {number} reply_count 16 | * @property {Array} recipient_ids 17 | */ 18 | 19 | /** 20 | * @typedef {object} Reply 21 | * @property {number} message_id 22 | * @property {number} message_date 23 | * @property {number} author_id 24 | * @property {string} message 25 | */ 26 | 27 | /** A helper type for conversation-related API endpoints. */ 28 | class ConversationsHelper { 29 | #wrapper; 30 | 31 | constructor(wrapper) { 32 | this.#wrapper = wrapper; 33 | } 34 | 35 | /** List a page of unread conversations. 36 | * 37 | * @param {SortOptions | undefined} sort An optional set of sort options. 38 | * @return {Array} An array of raw data objects. 39 | */ 40 | async list(sort) { 41 | return await this.#wrapper.http().get("/conversations", sort); 42 | } 43 | 44 | /** List all pages of unread conversations. 45 | * 46 | * @param {SortOptions | undefined} sort An optional set of sort options. 47 | * @return {Array} An array of raw data objects. 48 | */ 49 | async listAll(sort) { 50 | return await this.#wrapper.http().listUntil("/conversations", () => true, sort); 51 | } 52 | 53 | /** List multiple pages of unread conversations until a condition is no longer met. 54 | * 55 | * @param {function(Conversation):boolean} shouldContinue A function which determines if further pages are 56 | * requested. 57 | * @param {SortOptions | undefined} sort An optional set of sort options. 58 | * 59 | * @return {Array} An array of raw data objects. 60 | */ 61 | async listUntil(shouldContinue, sort) { 62 | return await this.#wrapper.http().listUntil("/conversations", shouldContinue, sort); 63 | } 64 | 65 | /** Start a new conversation. 66 | * 67 | * @param {string} title The title of the conversation. 68 | * @param {string} message The content of the first message in the conversation. 69 | * @param {Array} recipientIds An array of recipient identifiers. 70 | * 71 | * @return {number} The newly-created conversation identifier. 72 | */ 73 | async start(title, message, recipientIds) { 74 | let body = {title, message, "recipient_ids": recipientIds}; 75 | return await this.#wrapper.http().post("/conversations", body); 76 | } 77 | 78 | /** List a page of replies to an unread conversation. 79 | * 80 | * @param {number} conversationId The identifier of the unread conversation. 81 | * @param {SortOptions | undefined} sort An optional set of sort options. 82 | * 83 | * @return {Array} An array of raw data objects. 84 | */ 85 | async listReplies(conversationId, sort) { 86 | return await this.#wrapper.http().get(`/conversations/${conversationId}/replies`, sort); 87 | } 88 | 89 | /** List all pages of replies to an unread conversation. 90 | * 91 | * @param {number} conversationId The identifier of the unread conversation. 92 | * @param {SortOptions | undefined} sort An optional set of sort options. 93 | * 94 | * @return {Array} An array of raw data objects. 95 | */ 96 | async listRepliesAll(conversationId, sort) { 97 | return await this.#wrapper.http().listUntil(`/conversations/${conversationId}/replies`, () => true, sort); 98 | } 99 | 100 | /** List multiple pages of replies to an unread conversation until a condition is no longer met. 101 | * 102 | * @param {number} conversationId The identifier of the unread conversation. 103 | * @param {function(Reply):boolean} shouldContinue A function which determines if further pages are requested. 104 | * @param {SortOptions | undefined} sort An optional set of sort options. 105 | * 106 | * @return {Array} An array of raw data objects. 107 | */ 108 | async listRepliesUntil(conversationId, shouldContinue, sort) { 109 | return await this.#wrapper.http().listUntil(`/conversations/${conversationId}/replies`, shouldContinue, sort); 110 | } 111 | 112 | /** Reply to an unread conversation 113 | * 114 | * @param {number} conversationId The identifier of the unread conversation. 115 | * @param {string} message The content of the new reply. 116 | * 117 | * @return {number} The identifier of the newly-created conversation message. 118 | */ 119 | async reply(conversationId, message) { 120 | return await this.#wrapper.http().post(`/conversations/${conversationId}/replies`, {message}); 121 | } 122 | } 123 | 124 | exports.ConversationsHelper = ConversationsHelper; 125 | -------------------------------------------------------------------------------- /src/helpers/ThreadsHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { SortOptions } = require("../SortOptions"); 5 | 6 | /** 7 | * @typedef {object} BasicThread 8 | * @property {number} thread_id 9 | * @property {string} title 10 | * @property {number} reply_count 11 | * @property {number} view_count 12 | * @property {number} creation_date 13 | * @property {number} last_message_date 14 | */ 15 | 16 | /** 17 | * @typedef {object} Thread 18 | * @property {number} thread_id 19 | * @property {string} forum_name 20 | * @property {string} title 21 | * @property {number} reply_count 22 | * @property {number} view_count 23 | * @property {number} post_date 24 | * @property {string} thread_type 25 | * @property {boolean} thread_open 26 | * @property {number} last_post_date 27 | */ 28 | 29 | /** 30 | * @typedef {object} Reply 31 | * @property {number} reply_id 32 | * @property {number} author_id 33 | * @property {number} post_date 34 | * @property {string} message 35 | */ 36 | 37 | /** A helper type for thread-related API endpoints. */ 38 | class ThreadsHelper { 39 | #wrapper; 40 | 41 | constructor(wrapper) { 42 | this.#wrapper = wrapper; 43 | } 44 | 45 | /** List a page of threads you own or collaborate on. 46 | * 47 | * @param {SortOptions | undefined} sort An optional set of sort options. 48 | * @return {Array} An array of raw data objects. 49 | */ 50 | async list(sort) { 51 | return await this.#wrapper.http().get("/threads", sort); 52 | } 53 | 54 | /** List all pages of threads you own or collaborate on. 55 | * 56 | * @param {SortOptions | undefined} sort An optional set of sort options. 57 | * @return {Array} An array of raw data objects. 58 | */ 59 | async listAll(sort) { 60 | return await this.#wrapper.http().listUntil("/threads", () => true, sort); 61 | } 62 | 63 | /** List multiple pages of threads you own or collaborate on until a condition is no longer met. 64 | * 65 | * @param {function(BasicThread):boolean} shouldContinue A function which determines if further pages are requested. 66 | * @param {SortOptions | undefined} sort An optional set of sort options. 67 | * 68 | * @return {Array} An array of raw data objects. 69 | */ 70 | async listUntil(shouldContinue, sort) { 71 | return await this.#wrapper.http().listUntil("/threads", shouldContinue, sort); 72 | } 73 | 74 | /** Fetch information about a thread you own or collaborate on. 75 | * 76 | * @param {number} threadId The identifier of the thread. 77 | * @return {Thread} A raw data object. 78 | */ 79 | async fetch(threadId) { 80 | return await this.#wrapper.http().get(`/threads/${threadId}`); 81 | } 82 | 83 | /** List a page of replies for a thread you own or collaborate on. 84 | * 85 | * @param {number} threadId The identifier of the thread. 86 | * @param {SortOptions | undefined} sort An optional set of sort options. 87 | * 88 | * @return {Array} An array of raw data objects. 89 | */ 90 | async listReplies(threadId, sort) { 91 | return await this.#wrapper.http().get(`/threads/${threadId}/replies`, sort); 92 | } 93 | 94 | /** List all pages of replies for a thread you own or collaborate on. 95 | * 96 | * @param {number} threadId The identifier of the thread. 97 | * @param {SortOptions | undefined} sort An optional set of sort options. 98 | * 99 | * @return {Array} An array of raw data objects. 100 | */ 101 | async listRepliesAll(threadId, sort) { 102 | return await this.#wrapper.http().listUntil(`/threads/${threadId}/replies`, () => true, sort); 103 | } 104 | 105 | /** List multiple pages of replies for a thread you own or collaborate on until a condition is no longer met. 106 | * 107 | * @param {number} threadId The identifier of the thread. 108 | * @param {function(Reply):boolean} shouldContinue A function which determines if further pages are requested. 109 | * @param {SortOptions | undefined} sort An optional set of sort options. 110 | * 111 | * @return {Array} An array of raw data objects. 112 | */ 113 | async listRepliesUntil(threadId, shouldContinue, sort) { 114 | return await this.#wrapper.http().listUntil(`/threads/${threadId}/replies`, shouldContinue, sort); 115 | } 116 | 117 | /** Reply to a thread you own or collaborate on. 118 | * 119 | * @param {number} threadId The identifier of the thread. 120 | * @param {string} message The content of the new reply. 121 | * 122 | * @return {number} The identifier of the newly-created post. 123 | */ 124 | async reply(threadId, message) { 125 | return await this.#wrapper.http().post(`/threads/${threadId}/replies`, { message }); 126 | } 127 | } 128 | 129 | exports.ThreadsHelper = ThreadsHelper; -------------------------------------------------------------------------------- /src/helpers/members/MembersHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { ProfilePostsHelper } = require("./ProfilePostsHelper.js"); 5 | 6 | /** 7 | * @typedef {object} Member 8 | * @property {number} member_id 9 | * @property {string} username 10 | * @property {number} join_date 11 | * @property {number} [last_activity_date] 12 | * @property {boolean} banned 13 | * @property {boolean} suspended 14 | * @property {boolean} restricted 15 | * @property {boolean} disabled 16 | * @property {boolean} premium 17 | * @property {boolean} supreme 18 | * @property {boolean} ultimate 19 | * @property {number} [discord_id] 20 | * @property {string} avatar_url 21 | * @property {number} post_count 22 | * @property {number} resource_count 23 | * @property {number} purchase_count 24 | * @property {number} feedback_positive 25 | * @property {number} feedback_neutral 26 | * @property {number} feedback_negative 27 | */ 28 | 29 | /** 30 | * @typedef {object} Ban 31 | * @property {number} member_id 32 | * @property {number} banned_by_id 33 | * @property {number} ban_date 34 | * @property {string} reason 35 | */ 36 | 37 | /** A helper type for member-related API endpoints. */ 38 | class MembersHelper { 39 | #wrapper; 40 | 41 | constructor(wrapper) { 42 | this.#wrapper = wrapper; 43 | } 44 | 45 | /** Fetch information about yourself. 46 | * 47 | * @return {Member} A raw data object. 48 | */ 49 | async self() { 50 | return await this.#wrapper.http().get("/members/self"); 51 | } 52 | 53 | /** Modify information about yourself. 54 | * 55 | * @param {string} aboutMe The 'about me' field content, or undefined. 56 | * @param {string} customTitle The 'custom title' field content, or undefined. 57 | * @param {string} signature The 'signature' field content, or undefined. 58 | */ 59 | async modifySelf(aboutMe, customTitle, signature) { 60 | let body = {"about_me": aboutMe, "custom_title": customTitle, signature}; 61 | return await this.#wrapper.http().patch("/members/self", body); 62 | } 63 | 64 | /** Fetch information about a member. 65 | * 66 | * @param {number} memberId The identifier of the member. 67 | * @return {Member} A raw data object. 68 | */ 69 | async fetch(memberId) { 70 | return await this.#wrapper.http().get(`/members/${memberId}`); 71 | } 72 | 73 | /** Fetch information about a member by username. 74 | * 75 | * @param {string} username The username of the member. 76 | * @return {Member} A raw data object. 77 | */ 78 | async fetchByUsername(username) { 79 | return await this.#wrapper.http().get(`/members/usernames/${username}`); 80 | } 81 | 82 | /** Fetch information about a member by Discord identifier. 83 | * 84 | * @param {string} discordId The identifier of the Discord account. 85 | * @return {Member} A raw data object. 86 | */ 87 | async fetchByDiscord(discordId) { 88 | return await this.#wrapper.http().get(`/members/discords/${discordId}`); 89 | } 90 | 91 | /** Fetch a list of recently issued bans. 92 | * 93 | * @return {Array} An array of raw data objects. 94 | */ 95 | async bans() { 96 | return await this.#wrapper.http().get("/members/bans"); 97 | } 98 | 99 | /** Access profile post-related helper functions. 100 | * 101 | * @return {ProfilePostsHelper} A newly-constructed profile post helper instance. 102 | */ 103 | profilePosts() { 104 | return new ProfilePostsHelper(this.#wrapper); 105 | } 106 | } 107 | 108 | exports.MembersHelper = MembersHelper; -------------------------------------------------------------------------------- /src/helpers/members/ProfilePostsHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { SortOptions } = require("../../SortOptions"); 5 | 6 | /** 7 | * @typedef {object} ProfilePost 8 | * @property {number} profile_post_id 9 | * @property {number} author_id 10 | * @property {number} post_date 11 | * @property {string} message 12 | * @property {number} comment_count 13 | */ 14 | 15 | /** A helper type for profile post-related API endpoints. */ 16 | class ProfilePostsHelper { 17 | #wrapper; 18 | 19 | constructor(wrapper) { 20 | this.#wrapper = wrapper; 21 | } 22 | 23 | /** List a page of profile posts on your profile. 24 | * 25 | * @param {SortOptions | undefined} sort An optional set of sort options. 26 | * @return {Array} An array of raw data objects. 27 | */ 28 | async list(sort) { 29 | return await this.#wrapper.http().get("/members/self/profile-posts", sort); 30 | } 31 | 32 | /** List all pages of profile posts on your profile. 33 | * 34 | * @param {SortOptions | undefined} sort An optional set of sort options. 35 | * @return {Array} An array of raw data objects. 36 | */ 37 | async listAll(sort) { 38 | return await this.#wrapper.http().listUntil("/members/self/profile-posts", () => true, sort); 39 | } 40 | 41 | /** List multiple pages of profile posts on your profile until a condition is no longer met. 42 | * 43 | * @param {function(ProfilePost):boolean} shouldContinue A function which determines if further pages are requested. 44 | * @param {SortOptions | undefined} sort An optional set of sort options. 45 | * @return {Array} An array of raw data objects. 46 | */ 47 | async listUntil(shouldContinue, sort) { 48 | return await this.#wrapper.http().listUntil("/members/self/profile-posts", shouldContinue, sort); 49 | } 50 | 51 | /** Fetch information about a profile post on your profile. 52 | * 53 | * @param {number} profilePostId The identifier of the profile post to fetch. 54 | * @return {ProfilePost} A raw data object. 55 | */ 56 | async fetch(profilePostId) { 57 | return await this.#wrapper.http().get(`/members/self/profile-posts/${profilePostId}`); 58 | } 59 | 60 | /** Create a new profile post on your profile. 61 | * 62 | * @param {string} message The content of the message to modify to. 63 | * @return {number} The identifer of the newly-created profile post. 64 | */ 65 | async create(message) { 66 | return await this.#wrapper.http().post("/members/self/profile-posts", { message }); 67 | } 68 | 69 | /** Modify a profile post on your profile that you've authored. 70 | * 71 | * @param {number} profilePostId The identifier of the profile post to modify. 72 | * @param {string} message The content of the message to modify to. 73 | */ 74 | async modify(profilePostId, message) { 75 | return await this.#wrapper.http().patch(`/members/self/profile-posts/${profilePostId}`, { message }); 76 | } 77 | 78 | /** Delete a profile post on your profile that you've authored. 79 | * 80 | * @param {number} profilePostId The identifier of the profile post to delete. 81 | */ 82 | async delete(profilePostId) { 83 | return await this.#wrapper.http().delete(`/members/self/profile-posts/${profilePostId}`); 84 | } 85 | } 86 | 87 | exports.ProfilePostsHelper = ProfilePostsHelper; -------------------------------------------------------------------------------- /src/helpers/resources/LicensesHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { SortOptions } = require("../../SortOptions"); 5 | 6 | /** 7 | * @typedef {object} License 8 | * @property {number} license_id 9 | * @property {number} purchaser_id 10 | * @property {boolean} validated 11 | * @property {boolean} permanent 12 | * @property {boolean} active 13 | * @property {number} start_date 14 | * @property {number} end_date 15 | * @property {number} previous_end_date 16 | */ 17 | 18 | /** A helper type for resource license-related API endpoints. */ 19 | class LicensesHelper { 20 | #wrapper; 21 | 22 | constructor(wrapper) { 23 | this.#wrapper = wrapper; 24 | } 25 | 26 | /** List a page of licenses for a given resource. 27 | * 28 | * @param {number} resourceId The identifier of the resource. 29 | * @param {SortOptions | undefined} sort An optional set of sort options. 30 | * 31 | * @return {Array} An array of raw data objects. 32 | */ 33 | async list(resourceId, sort) { 34 | return await this.#wrapper.http().get(`/resources/${resourceId}/licenses`, sort); 35 | } 36 | 37 | /** List all pages of licenses for a given resource. 38 | * 39 | * @param {number} resourceId The identifier of the resource. 40 | * @param {SortOptions | undefined} sort An optional set of sort options. 41 | * 42 | * @return {Array} An array of raw data objects. 43 | */ 44 | async listAll(resourceId, sort) { 45 | return await this.#wrapper.http().listUntil(`/resources/${resourceId}/licenses`, () => true, sort); 46 | } 47 | 48 | /** List multiple pages of licenses for a given resource until a condition is no longer met. 49 | * 50 | * @param {number} resourceId The identifier of the resource. 51 | * @param {function(License):boolean} shouldContinue A function which determines if further pages are requested. 52 | * @param {SortOptions | undefined} sort An optional set of sort options. 53 | * 54 | * @return {Array} An array of raw data objects. 55 | */ 56 | async listUntil(resourceId, shouldContinue, sort) { 57 | return await this.#wrapper.http().listUntil(`/resources/${resourceId}/licenses`, shouldContinue, sort); 58 | } 59 | 60 | /** Fetch a license for a given resource. 61 | * 62 | * @param {number} resourceId The identifier of the resource. 63 | * @param {number} licenseId The identifier of the license. 64 | * 65 | * @return {License} A raw data object. 66 | */ 67 | async fetch(resourceId, licenseId) { 68 | return await this.#wrapper.http().get(`/resources/${resourceId}/licenses/${licenseId}`); 69 | } 70 | 71 | /** Fetch a member's license for a given resource. 72 | * 73 | * @param {number} resourceId The identifier of the resource. 74 | * @param {number} memberId The identifier of the member. 75 | * @param {number | undefined} nonce The download's NONCE value, or undefined if using a Private token. 76 | * @param {number | undefined} timestamp The download's UNIX timestamp, or undefined if using a Private token. 77 | * 78 | * @return {License} A raw data object. 79 | */ 80 | async fetchMember(resourceId, memberId, nonce, timestamp) { 81 | let endpoint = `/resources/${resourceId}/licenses/members/${memberId}`; 82 | if (nonce && timestamp) endpoint += `?nonce=${nonce}×tamp=${timestamp}`; 83 | 84 | return await this.#wrapper.http().get(endpoint); 85 | } 86 | 87 | /** Modify a permanent license (and convert to permanent if currently temporary). 88 | * 89 | * @param {number} resourceId The identifier of the resource. 90 | * @param {number} licenseId The identifier of the license. 91 | * @param {boolean} active Whether or not the license should be active. 92 | */ 93 | async modifyPermanent(resourceId, licenseId, active) { 94 | let body = {permanent: true, active}; 95 | return await this.#wrapper.http().patch(`/resources/${resourceId}/licenses/${licenseId}`, body); 96 | } 97 | 98 | /** Modify a temporary license (and convert to temporary if currently permanent). 99 | * 100 | * @param {number} resourceId The identifier of the resource. 101 | * @param {number} licenseId The identifier of the license. 102 | * @param {number} startDate The UNIX timestamp of when the license should start. 103 | * @param {number} endDate The UNIX timestamp of when the license should end. 104 | */ 105 | async modifyTemporary(resourceId, licenseId, startDate, endDate) { 106 | let body = {permanent: false, "start_date": startDate, "end_date": endDate}; 107 | return await this.#wrapper.http().patch(`/resources/${resourceId}/licenses/${licenseId}`, body); 108 | } 109 | } 110 | 111 | exports.LicensesHelper = LicensesHelper; -------------------------------------------------------------------------------- /src/helpers/resources/PurchasesHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { SortOptions } = require("../../SortOptions"); 5 | 6 | /** 7 | * @typedef {object} Purchase 8 | * @property {number} purchase_id 9 | * @property {number} purchaser_id 10 | * @property {number} license_id 11 | * @property {boolean} renewal 12 | * @property {string} status 13 | * @property {number} price 14 | * @property {string} currency 15 | * @property {number} purchase_date 16 | * @property {number} validation_date 17 | */ 18 | 19 | /** A helper type for resource purchase-related API endpoints. */ 20 | class PurchasesHelper { 21 | #wrapper; 22 | 23 | constructor(wrapper) { 24 | this.#wrapper = wrapper; 25 | } 26 | 27 | /** List a page of purchases for a given resource. 28 | * 29 | * @param {number} resourceId The identifier of the resource. 30 | * @param {SortOptions | undefined} sort An optional set of sort options. 31 | * 32 | * @return {Array} An array of raw data objects. 33 | */ 34 | async list(resourceId, sort) { 35 | return await this.#wrapper.http().get(`/resources/${resourceId}/purchases`, sort); 36 | } 37 | 38 | /** List all pages of purchases for a given resource. 39 | * 40 | * @param {number} resourceId The identifier of the resource. 41 | * @param {SortOptions | undefined} sort An optional set of sort options. 42 | * 43 | * @return {Array} An array of raw data objects. 44 | */ 45 | async listAll(resourceId, sort) { 46 | return await this.#wrapper.http().listUntil(`/resources/${resourceId}/purchases`, () => true, sort); 47 | } 48 | 49 | /** List multiple pages of purchases for a given resource until a condition is no longer met. 50 | * 51 | * @param {number} resourceId The identifier of the resource. 52 | * @param {function(Purchase):boolean} shouldContinue A function which determines if further pages are requested. 53 | * @param {SortOptions | undefined} sort An optional set of sort options. 54 | * 55 | * @return {Array} An array of raw data objects. 56 | */ 57 | async listUntil(resourceId, shouldContinue, sort) { 58 | return await this.#wrapper.http().listUntil(`/resources/${resourceId}/purchases`, shouldContinue, sort); 59 | } 60 | 61 | /** Fetch a purchase for a given resource. 62 | * 63 | * @param {number} resourceId The identifier of the resource. 64 | * @param {number} purchaseId The identifier of the purchase. 65 | * 66 | * @return {Purchase} A raw data object. 67 | */ 68 | async fetch(resourceId, purchaseId) { 69 | return await this.#wrapper.http().get(`/resources/${resourceId}/purchases/${purchaseId}`); 70 | } 71 | } 72 | 73 | exports.PurchasesHelper = PurchasesHelper; -------------------------------------------------------------------------------- /src/helpers/resources/ReviewsHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { SortOptions } = require("../../SortOptions"); 5 | 6 | /** 7 | * @typedef {object} Review 8 | * @property {number} review_id 9 | * @property {number} reviewer_id 10 | * @property {number} review_date 11 | * @property {number} rating 12 | * @property {string} message 13 | * @property {string} response 14 | */ 15 | 16 | /** A helper type for resource review-related API endpoints. */ 17 | class ReviewsHelper { 18 | #wrapper; 19 | 20 | constructor(wrapper) { 21 | this.#wrapper = wrapper; 22 | } 23 | 24 | /** List a page of reviews for a given resource. 25 | * 26 | * @param {number} resourceId The identifier of the resource. 27 | * @param {SortOptions | undefined} sort An optional set of sort options. 28 | * 29 | * @return {Array} An array of raw data objects. 30 | */ 31 | async list(resourceId, sort) { 32 | return await this.#wrapper.http().get(`/resources/${resourceId}/reviews`, sort); 33 | } 34 | 35 | /** List all pages of reviews for a given resource. 36 | * 37 | * @param {number} resourceId The identifier of the resource. 38 | * @param {SortOptions | undefined} sort An optional set of sort options. 39 | * 40 | * @return {Array} An array of raw data objects. 41 | */ 42 | async listAll(resourceId, sort) { 43 | return await this.#wrapper.http().listUntil(`/resources/${resourceId}/reviews`, () => true, sort); 44 | } 45 | 46 | /** List multiple pages of reviews for a given resource until a condition is no longer met. 47 | * 48 | * @param {number} resourceId The identifier of the resource. 49 | * @param {function(Review):boolean} shouldContinue A function which determines if further pages are requested. 50 | * @param {SortOptions | undefined} sort An optional set of sort options. 51 | * 52 | * @return {Array} An array of raw data objects. 53 | */ 54 | async listUntil(resourceId, shouldContinue, sort) { 55 | return await this.#wrapper.http().listUntil(`/resources/${resourceId}/reviews`, shouldContinue, sort); 56 | } 57 | 58 | /** Fetch a resource review by a member for a given resource. 59 | * 60 | * @param {number} resourceId The identifier of the resource. 61 | * @param {number} memberId The identifier of the member. 62 | * 63 | * @return {Review} A raw data object. 64 | */ 65 | async fetch(resourceId, memberId) { 66 | return await this.#wrapper.http().get(`/resources/${resourceId}/reviews/members/${memberId}`); 67 | } 68 | 69 | /** Respond to a review for a given resource. 70 | * 71 | * @param {number} resourceId The identifier of the resource. 72 | * @param {number} reviewId The identifier of the review. 73 | * @param {string} response The content of the author response. 74 | */ 75 | async respond(resourceId, reviewId, response) { 76 | return await this.#wrapper.http().patch(`/resources/${resourceId}/reviews/${reviewId}`, {response}); 77 | } 78 | } 79 | 80 | exports.ReviewsHelper = ReviewsHelper; -------------------------------------------------------------------------------- /src/helpers/resources/UpdatesHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { SortOptions } = require("../../SortOptions"); 5 | 6 | /** 7 | * @typedef {object} Update 8 | * @property {number} update_id 9 | * @property {string} title 10 | * @property {string} message 11 | * @property {number} update_date 12 | */ 13 | 14 | /** A helper type for resource update-related API endpoints. */ 15 | class UpdatesHelper { 16 | #wrapper; 17 | 18 | constructor(wrapper) { 19 | this.#wrapper = wrapper; 20 | } 21 | 22 | /** List a page of updates for a given resource. 23 | * 24 | * @param {number} resourceId The identifier of the resource. 25 | * @param {SortOptions | undefined} sort An optional set of sort options. 26 | * 27 | * @return {Array} An array of raw data objects. 28 | */ 29 | async list(resourceId, sort) { 30 | return await this.#wrapper.http().get(`/resources/${resourceId}/updates`, sort); 31 | } 32 | 33 | /** List all pages of updates for a given resource. 34 | * 35 | * @param {number} resourceId The identifier of the resource. 36 | * @param {SortOptions | undefined} sort An optional set of sort options. 37 | * 38 | * @return {Array} An array of raw data objects. 39 | */ 40 | async listAll(resourceId, sort) { 41 | return await this.#wrapper.http().listUntil(`/resources/${resourceId}/updates`, () => true, sort); 42 | } 43 | 44 | /** List multiple pages of updates for a given resource until a condition is no longer met. 45 | * 46 | * @param {number} resourceId The identifier of the resource. 47 | * @param {function(Update):boolean} shouldContinue A function which determines if further pages are requested. 48 | * @param {SortOptions | undefined} sort An optional set of sort options. 49 | * 50 | * @return {Array} An array of raw data objects. 51 | */ 52 | async listUntil(resourceId, shouldContinue, sort) { 53 | return await this.#wrapper.http().listUntil(`/resources/${resourceId}/updates`, shouldContinue, sort); 54 | } 55 | 56 | /** Fetch the latest update for a given resource. 57 | * 58 | * @param {number} resourceId The identifier of the resource. 59 | * 60 | * @return {Update} A raw data object. 61 | */ 62 | async latest(resourceId) { 63 | return await this.#wrapper.http().get(`/resources/${resourceId}/updates/latest`); 64 | } 65 | 66 | /** Fetch an update for a given resource. 67 | * 68 | * @param {number} resourceId The identifier of the resource. 69 | * @param {number} updateId The identifier of the update. 70 | * 71 | * @return {Update} A raw data object. 72 | */ 73 | async fetch(resourceId, updateId) { 74 | return await this.#wrapper.http().get(`/resources/${resourceId}/updates/${updateId}`); 75 | } 76 | 77 | /** Delete an update for a given resource. 78 | * 79 | * @param {number} resourceId The identifier of the resource. 80 | * @param {number} updateId The identifier of the update. 81 | */ 82 | async delete(resourceId, updateId) { 83 | return await this.#wrapper.http().delete(`/resources/${resourceId}/updates/${updateId}`); 84 | } 85 | } 86 | 87 | exports.UpdatesHelper = UpdatesHelper; -------------------------------------------------------------------------------- /src/helpers/resources/VersionsHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const { SortOptions } = require("../../SortOptions"); 5 | 6 | /** 7 | * @typedef {object} Version 8 | * @property {number} version_id 9 | * @property {number} update_id 10 | * @property {string} name 11 | * @property {number} release_date 12 | * @property {number} download_count 13 | */ 14 | 15 | /** A helper type for resource version-related API endpoints. */ 16 | class VersionsHelper { 17 | #wrapper; 18 | 19 | constructor(wrapper) { 20 | this.#wrapper = wrapper; 21 | } 22 | 23 | /** List a page of versions for a given resource. 24 | * 25 | * @param {number} resourceId The identifier of the resource. 26 | * @param {SortOptions | undefined} sort An optional set of sort options. 27 | * 28 | * @return {Array} An array of raw data objects. 29 | */ 30 | async list(resourceId, sort) { 31 | return await this.#wrapper.http().get(`/resources/${resourceId}/versions`, sort); 32 | } 33 | 34 | /** List all pages of versions for a given resource. 35 | * 36 | * @param {number} resourceId The identifier of the resource. 37 | * @param {SortOptions | undefined} sort An optional set of sort options. 38 | * 39 | * @return {Array} An array of raw data objects. 40 | */ 41 | async listAll(resourceId, sort) { 42 | return await this.#wrapper.http().listUntil(`/resources/${resourceId}/versions`, () => true, sort); 43 | } 44 | 45 | /** List multiple pages of versions for a given resource until a condition is no longer met. 46 | * 47 | * @param {number} resourceId The identifier of the resource. 48 | * @param {function(Version):boolean} shouldContinue A function which determines if further pages are requested. 49 | * @param {SortOptions | undefined} sort An optional set of sort options. 50 | * 51 | * @return {Array} An array of raw data objects. 52 | */ 53 | async listUntil(resourceId, shouldContinue, sort) { 54 | return await this.#wrapper.http().listUntil(`/resources/${resourceId}/versions`, shouldContinue, sort); 55 | } 56 | 57 | /** Fetch the latest version for a given resource. 58 | * 59 | * @param {number} resourceId The identifier of the resource. 60 | * 61 | * @return {Version} A raw data object. 62 | */ 63 | async latest(resourceId) { 64 | return await this.#wrapper.http().get(`/resources/${resourceId}/versions/latest`); 65 | } 66 | 67 | /** Fetch a version for a given resource. 68 | * 69 | * @param {number} resourceId The identifier of the resource. 70 | * @param {number} versionId The identifier of the version. 71 | * 72 | * @return {Version} A raw data object. 73 | */ 74 | async fetch(resourceId, versionId) { 75 | return await this.#wrapper.http().get(`/resources/${resourceId}/versions/${versionId}`); 76 | } 77 | 78 | /** Delete a version for a given resource. 79 | * 80 | * @param {number} resourceId The identifier of the resource. 81 | * @param {number} versionId The identifier of the version. 82 | */ 83 | async delete(resourceId, versionId) { 84 | return await this.#wrapper.http().delete(`/resources/${resourceId}/versions/${versionId}`); 85 | } 86 | } 87 | 88 | exports.VersionsHelper = VersionsHelper; -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | exports.Token = require("./Token.js").Token; 5 | exports.TokenType = require("./TokenType.js").TokenType; 6 | exports.SortOptions = require("./SortOptions.js").SortOptions; 7 | exports.Http = require("./Http.js").Http; 8 | exports.APIError = require("./APIError.js").APIError; 9 | exports.Wrapper = require("./Wrapper.js").Wrapper; 10 | 11 | exports.AlertsHelper = require("./helpers/AlertsHelper.js").AlertsHelper; 12 | exports.ConversationsHelper = require("./helpers/ConversationsHelper.js").ConversationsHelper; 13 | exports.ThreadsHelper = require("./helpers/ThreadsHelper.js").ThreadsHelper; 14 | 15 | exports.MembersHelper = require("./helpers/members/MembersHelper.js").MembersHelper; 16 | exports.ProfilePostsHelper = require("./helpers/members/ProfilePostsHelper.js").ProfilePostsHelper; 17 | 18 | exports.ResourcesHelper = require("./helpers/resources/ResourcesHelper.js").ResourcesHelper; 19 | exports.DownloadsHelper = require("./helpers/resources/DownloadsHelper.js").DownloadsHelper; 20 | exports.LicensesHelper = require("./helpers/resources/LicensesHelper.js").LicensesHelper; 21 | exports.PurchasesHelper = require("./helpers/resources/PurchasesHelper.js").PurchasesHelper; 22 | exports.ReviewsHelper = require("./helpers/resources/ReviewsHelper.js").ReviewsHelper; 23 | exports.UpdatesHelper = require("./helpers/resources/UpdatesHelper.js").UpdatesHelper; 24 | exports.VersionsHelper = require("./helpers/resources/VersionsHelper.js").VersionsHelper; -------------------------------------------------------------------------------- /tests/base.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | -------------------------------------------------------------------------------- /tests/sort_options.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | const assert = require("assert"); 5 | const { SortOptions } = require("../src/SortOptions.js"); 6 | 7 | function single_sort() { 8 | let options = new SortOptions(); 9 | options.sort = "purchases"; 10 | assert.strictEqual(options.toQueryString(), "?sort=purchases"); 11 | } 12 | 13 | function single_order() { 14 | let options = new SortOptions(); 15 | options.order = "asc"; 16 | assert.strictEqual(options.toQueryString(), "?order=asc"); 17 | } 18 | 19 | function single_page() { 20 | let options = new SortOptions(); 21 | options.page = 5; 22 | assert.strictEqual(options.toQueryString(), "?page=5"); 23 | } 24 | 25 | single_sort(); 26 | single_order(); 27 | single_page(); -------------------------------------------------------------------------------- /tests/test.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.) 2 | // MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE) 3 | 4 | require("./base.js"); 5 | require("./sort_options.js"); -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src/**/*"], 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "declaration": true, 6 | "emitDeclarationOnly": true, 7 | "outDir": "types", 8 | "declarationMap": true 9 | } 10 | } -------------------------------------------------------------------------------- /types/APIError.d.ts: -------------------------------------------------------------------------------- 1 | /** A type which represents a parsed error from the API, or an internal wrapper error. */ 2 | export class APIError extends Error { 3 | /** Constructs a new Error which originated within the wrapper. 4 | * 5 | * @param {string} message The internal error message. 6 | * @returns {APIError} The newly-constructed error. 7 | */ 8 | static internal(message: string): APIError; 9 | constructor(json: any); 10 | /** Returns the machine-readable code of the error. 11 | * 12 | * @type {string} The machine-readable error code. 13 | */ 14 | get code(): string; 15 | /** Returns the human-readable message of the error. 16 | * 17 | * @type {string} The human-readable error message. 18 | */ 19 | get message(): string; 20 | #private; 21 | } 22 | //# sourceMappingURL=APIError.d.ts.map -------------------------------------------------------------------------------- /types/APIError.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"APIError.d.ts","sourceRoot":"","sources":["../src/APIError.js"],"names":[],"mappings":"AAGA,yFAAyF;AACzF;IA2BI;;;;OAIG;IACH,yBAHW,MAAM,GACJ,QAAQ,CAIpB;IA9BD,uBAKC;IAED;;;OAGG;IACH,mBAEC;IAED;;;OAGG;IACH,sBAEC;;CAUJ"} -------------------------------------------------------------------------------- /types/Error.d.ts: -------------------------------------------------------------------------------- 1 | /** A type which represents a parsed error from the API, or an internal wrapper error. */ 2 | export class Error { 3 | /** Constructs a new Error which originated within the wrapper. 4 | * 5 | * @param {string} message The internal error message. 6 | * @returns {Error} The newly-constructed error. 7 | */ 8 | static internal(message: string): Error; 9 | constructor(json: any); 10 | /** Returns a string representation of this error including both the machine and human-readable parts. 11 | * 12 | * @returns {string} A string representation of this error. 13 | */ 14 | toString(): string; 15 | /** Returns the machine-readable code of the error. 16 | * 17 | * @returns {string} The machine-readable error code. 18 | */ 19 | code(): string; 20 | /** Returns the human-readable message of the error. 21 | * 22 | * @returns {string} The human-readable error message. 23 | */ 24 | message(): string; 25 | #private; 26 | } 27 | //# sourceMappingURL=Error.d.ts.map -------------------------------------------------------------------------------- /types/Error.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../src/Error.js"],"names":[],"mappings":"AAGA,yFAAyF;AACzF;IAiCI;;;;OAIG;IACH,yBAHW,MAAM,GACJ,KAAK,CAIjB;IApCD,uBAGC;IAED;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,WAFa,MAAM,CAIlB;;CAUJ"} -------------------------------------------------------------------------------- /types/Http.d.ts: -------------------------------------------------------------------------------- 1 | /** A type that handles raw HTTP requests to the API. */ 2 | export class Http { 3 | /** The maximum number of objects returned by a list endpoint for a single request. */ 4 | static "__#2@#PER_PAGE": number; 5 | /** The content type used for WRITE operations with bodies (ie. POST/PATCH). */ 6 | static "__#2@#WRITE_HEADERS": { 7 | headers: { 8 | "Content-Type": string; 9 | }; 10 | }; 11 | constructor(client: any, throtter: any); 12 | /** Schedules a GET request for a specific endpoint. 13 | * 14 | * @param {string} endpoint The path of the endpoint (incl. any path parameters). 15 | * @param {SortOptions | undefined} sort The optional set of sort options. 16 | * 17 | * @return {*} The response data on success. 18 | */ 19 | get(endpoint: string, sort?: SortOptions | undefined): any; 20 | /** Schedules a POST request for a specific endpoint. 21 | * 22 | * @param {string} endpoint The path of the endpoint (incl. any path parameters). 23 | * @param {object} body The request body options. 24 | * 25 | * @return {number} The response data on success (ie. a content identifier). 26 | */ 27 | post(endpoint: string, body: object): number; 28 | /** Schedules a PATCH request for a specific endpoint. 29 | * 30 | * @param {string} endpoint The path of the endpoint (incl. any path parameters). 31 | * @param {object} body The request body options. 32 | */ 33 | patch(endpoint: string, body: object): any; 34 | /** Schedules a DELETE request for a specific endpoint. 35 | * 36 | * @param {string} endpoint The path of the endpoint (incl. any path parameters). 37 | */ 38 | delete(endpoint: string): any; 39 | /** A raw function returning a compiled list of objects from all available pages or until we decide to stop. 40 | * 41 | *

42 | * 43 | * 'shouldContinue' expects a function with a single parameter and should return a boolean representing if we 44 | * should continue to add the current (and future) objects to the final list (and thus, if we should continue 45 | * to make requests). This function is called for every single object as a parameter within each request's 46 | * returned list. 47 | * 48 | *

49 | * 50 | * This function continuously makes requests to a specific endpoint with a set of sort options, and increments the 51 | * sort option page count after each request. 52 | * 53 | * @param {string} endpoint The path of the endpoint (incl. any path parameters). 54 | * @param {function(object):boolean} shouldContinue A function which determines if further pages are requested. 55 | * @param {SortOptions | undefined} sort An optional set of sort options. 56 | * 57 | * @return {Array} An array of raw objects. 58 | */ 59 | listUntil(endpoint: string, shouldContinue: (arg0: object) => boolean, sort?: SortOptions | undefined): Array; 60 | #private; 61 | } 62 | import { SortOptions } from "./SortOptions.js"; 63 | //# sourceMappingURL=Http.d.ts.map -------------------------------------------------------------------------------- /types/Http.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Http.d.ts","sourceRoot":"","sources":["../src/Http.js"],"names":[],"mappings":"AAMA,wDAAwD;AACxD;IACI,sFAAsF;IACtF,gCAAsB;IAEtB,+EAA+E;IAC/E;;;;MAAwE;IAKxE,wCAGC;IAED;;;;;;OAMG;IACH,cALW,MAAM,SACN,WAAW,GAAG,SAAS,OAgBjC;IAED;;;;;;OAMG;IACH,eALW,MAAM,QACN,MAAM,GAEL,MAAM,CAajB;IAED;;;;OAIG;IACH,gBAHW,MAAM,QACN,MAAM,OAahB;IAED;;;OAGG;IACH,iBAFW,MAAM,OAahB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,oBANW,MAAM,yBACG,MAAM,KAAE,OAAO,SACxB,WAAW,GAAG,SAAS,GAEtB,MAAM,MAAM,CAAC,CAyBxB;;CA2BJ"} -------------------------------------------------------------------------------- /types/SortOptions.d.ts: -------------------------------------------------------------------------------- 1 | /** A type representing the sorting options available for listing-style endpoints. */ 2 | export class SortOptions { 3 | sort: any; 4 | order: any; 5 | page: any; 6 | /** Convets this SortOptions instance into a query string. 7 | * 8 | * @returns {string} The query-string representation. 9 | */ 10 | toQueryString(): string; 11 | /** Returns whether or not any sort options have been set. 12 | * 13 | * @returns {boolean} Whether or not any sort options have been set. 14 | */ 15 | isSet(): boolean; 16 | } 17 | //# sourceMappingURL=SortOptions.d.ts.map -------------------------------------------------------------------------------- /types/SortOptions.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"SortOptions.d.ts","sourceRoot":"","sources":["../src/SortOptions.js"],"names":[],"mappings":"AAGA,qFAAqF;AACrF;IACI,UAAK;IACL,WAAM;IACN,UAAK;IAEL;;;OAGG;IACH,iBAFa,MAAM,CAgBlB;IAED;;;OAGG;IACH,SAFa,OAAO,CAInB;CACJ"} -------------------------------------------------------------------------------- /types/Throttler.d.ts: -------------------------------------------------------------------------------- 1 | export class Throttler { 2 | setRead(retry: any): void; 3 | setWrite(retry: any): void; 4 | resetRead(): void; 5 | resetWrite(): void; 6 | stallIfRequired(write: any): Promise; 7 | #private; 8 | } 9 | //# sourceMappingURL=Throttler.d.ts.map -------------------------------------------------------------------------------- /types/Throttler.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Throttler.d.ts","sourceRoot":"","sources":["../src/Throttler.js"],"names":[],"mappings":"AAGA;IAeI,0BAGC;IAED,2BAGC;IAED,kBAGC;IAED,mBAGC;IAED,2CAwBC;;CAiBJ"} -------------------------------------------------------------------------------- /types/Token.d.ts: -------------------------------------------------------------------------------- 1 | /** A type representing an API authentication token. */ 2 | export class Token { 3 | /** Constructs a new token from its constituents. 4 | * 5 | * @param {TokenType} type The type of this token. 6 | * @param {string} value The value of this token. 7 | */ 8 | constructor(type: TokenType, value: string); 9 | /** Constructs an object containing the header representation of this token. 10 | * 11 | * @returns An object with a single attribute, 'Authorization'. 12 | */ 13 | asHeader(): { 14 | Authorization: string; 15 | }; 16 | #private; 17 | } 18 | import { TokenType } from "./TokenType"; 19 | //# sourceMappingURL=Token.d.ts.map -------------------------------------------------------------------------------- /types/Token.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Token.d.ts","sourceRoot":"","sources":["../src/Token.js"],"names":[],"mappings":"AAKA,uDAAuD;AACvD;IAII;;;;OAIG;IACH,kBAHW,SAAS,SACT,MAAM,EAKhB;IAED;;;OAGG;IACH;;MAEC;;CACJ"} -------------------------------------------------------------------------------- /types/TokenType.d.ts: -------------------------------------------------------------------------------- 1 | /** A type representing the different token types. */ 2 | export class TokenType { 3 | static PRIVATE: TokenType; 4 | static SHARED: TokenType; 5 | constructor(headerName: any); 6 | headerName(): any; 7 | #private; 8 | } 9 | //# sourceMappingURL=TokenType.d.ts.map -------------------------------------------------------------------------------- /types/TokenType.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"TokenType.d.ts","sourceRoot":"","sources":["../src/TokenType.js"],"names":[],"mappings":"AAGA,qDAAqD;AACrD;IACI,0BAA0C;IAC1C,yBAAwC;IAIxC,6BAEC;IAED,kBAEC;;CACJ"} -------------------------------------------------------------------------------- /types/Wrapper.d.ts: -------------------------------------------------------------------------------- 1 | /** The primary wrapping type for interactions with BuiltByBit's API. */ 2 | export class Wrapper { 3 | /** The base API URL and version which will be prepended to non-absolute paths by axios. */ 4 | static "__#18@#BASE_URL": string; 5 | /** Initialise this wrapper with a provided API token. 6 | * 7 | *

8 | * 9 | * By default, initialisation of this wrapper will execute a health check which we expect to always succeed under 10 | * nominal conditions. If the request does fail, we expect subsequent requests to other endpoints to also fail. In 11 | * this situation, we conclude that an initialisation failure has occured. We reject the returned Promise and pass 12 | * back the error to the caller. 13 | * 14 | * @param {Token} token The constructed API token. 15 | * @param {boolean} health Whether or not to execute a health check during initialisation. 16 | */ 17 | init(token: Token, health?: boolean): Promise; 18 | /** Schedule an empty request which we expect to always succeed under nominal conditions. */ 19 | health(): Promise; 20 | /** Schedule an empty request and measure how long the API took to respond. 21 | * 22 | *

23 | * 24 | * This duration may not be representative of the raw request latency due to the fact that requests may be stalled 25 | * locally within this wrapper to ensure compliance with rate limiting rules. Whilst this is a trade-off, it can 26 | * be argued that the returned duration will be more representative of the true latencies experienced. 27 | * 28 | * @return {number} The response time in milliseconds. 29 | */ 30 | ping(): number; 31 | /** Access alert-related helper functions. 32 | * 33 | * @return {AlertsHelper} A newly-constructed alert helper instance. 34 | */ 35 | alerts(): AlertsHelper; 36 | /** Access conversation-related helper functions. 37 | * 38 | * @return {ConversationsHelper} A newly-constructed conversation helper instance. 39 | */ 40 | conversations(): ConversationsHelper; 41 | /** Access thread-related helper functions. 42 | * 43 | * @return {ThreadsHelper} A newly-constructed thread helper instance. 44 | */ 45 | threads(): ThreadsHelper; 46 | /** Access member-related helper functions. 47 | * 48 | * @return {MembersHelper} A newly-constructed member helper instance. 49 | */ 50 | members(): MembersHelper; 51 | /** Access resource-related helper functions. 52 | * 53 | * @return {ResourcesHelper} A newly-constructed resource helper instance. 54 | */ 55 | resources(): ResourcesHelper; 56 | /** Access the inner Http instance which can be used to make raw requests. 57 | * 58 | * @returns {Http} The current Http instance in use by this wrapper. 59 | */ 60 | http(): Http; 61 | #private; 62 | } 63 | import { Token } from "./Token"; 64 | import { AlertsHelper } from "./helpers/AlertsHelper.js"; 65 | import { ConversationsHelper } from "./helpers/ConversationsHelper.js"; 66 | import { ThreadsHelper } from "./helpers/ThreadsHelper.js"; 67 | import { MembersHelper } from "./helpers/members/MembersHelper.js"; 68 | import { ResourcesHelper } from "./helpers/resources/ResourcesHelper.js"; 69 | import { Http } from "./Http.js"; 70 | //# sourceMappingURL=Wrapper.d.ts.map -------------------------------------------------------------------------------- /types/Wrapper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Wrapper.d.ts","sourceRoot":"","sources":["../src/Wrapper.js"],"names":[],"mappings":"AAgBA,wEAAwE;AACxE;IACI,2FAA2F;IAC3F,iCAAmD;IAInD;;;;;;;;;;;OAWG;IACH,YAHW,KAAK,WACL,OAAO,iBAOjB;IAED,4FAA4F;IAC5F,wBAIC;IAED;;;;;;;;;OASG;IACH,QAFY,MAAM,CAMjB;IAED;;;OAGG;IACH,UAFY,YAAY,CAIvB;IAED;;;OAGG;IACH,iBAFY,mBAAmB,CAI9B;IAED;;;OAGG;IACH,WAFY,aAAa,CAIxB;IAED;;;OAGG;IACH,WAFY,aAAa,CAIxB;IAED;;;OAGG;IACH,aAFY,eAAe,CAI1B;IAED;;;OAGG;IACH,QAFa,IAAI,CAIhB;;CACJ"} -------------------------------------------------------------------------------- /types/helpers/AlertsHelper.d.ts: -------------------------------------------------------------------------------- 1 | export type Alert = { 2 | caused_member_id: number; 3 | content_type: string; 4 | content_id: number; 5 | alert_type: string; 6 | alert_date: number; 7 | }; 8 | /** 9 | * @typedef {object} Alert 10 | * @property {number} caused_member_id 11 | * @property {string} content_type 12 | * @property {number} content_id 13 | * @property {string} alert_type 14 | * @property {number} alert_date 15 | */ 16 | /** A helper type for alert-related API endpoints. */ 17 | export class AlertsHelper { 18 | constructor(wrapper: any); 19 | /** List a single page of unread alerts. 20 | * 21 | * @param {SortOptions | undefined} sort An optional set of sort options. 22 | * @return {Array} An array of raw data objects. 23 | */ 24 | list(sort: SortOptions | undefined): Array; 25 | /** List all pages of unread alerts. 26 | * 27 | * @param {SortOptions | undefined} sort An optional set of sort options. 28 | * @return {Array} An array of raw data objects. 29 | */ 30 | listAll(sort: SortOptions | undefined): Array; 31 | /** List multiple pages of unread alerts until a condition is no longer met. 32 | * 33 | * @param {function(Alert):boolean} shouldContinue A function which determines if further pages are requested. 34 | * @param {SortOptions | undefined} sort An optional set of sort options. 35 | * 36 | * @return {Array} An array of raw data objects. 37 | */ 38 | listUntil(shouldContinue: (arg0: Alert) => boolean, sort: SortOptions | undefined): Array; 39 | /** Mark unread alerts as read. */ 40 | markAsRead(): Promise; 41 | #private; 42 | } 43 | import { SortOptions } from "../SortOptions"; 44 | //# sourceMappingURL=AlertsHelper.d.ts.map -------------------------------------------------------------------------------- /types/helpers/AlertsHelper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"AlertsHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/AlertsHelper.js"],"names":[],"mappings":";sBAOc,MAAM;kBACN,MAAM;gBACN,MAAM;gBACN,MAAM;gBACN,MAAM;;AANpB;;;;;;;GAOG;AAEH,qDAAqD;AACrD;IAGI,0BAEC;IAED;;;;OAIG;IACH,WAHW,WAAW,GAAG,SAAS,GACtB,MAAM,KAAK,CAAC,CAIvB;IAED;;;;OAIG;IACH,cAHW,WAAW,GAAG,SAAS,GACtB,MAAM,KAAK,CAAC,CAIvB;IAED;;;;;;OAMG;IACH,iCALoB,KAAK,KAAE,OAAO,QACvB,WAAW,GAAG,SAAS,GAEtB,MAAM,KAAK,CAAC,CAIvB;IAED,kCAAkC;IAClC,2BAEC;;CACJ"} -------------------------------------------------------------------------------- /types/helpers/ConversationsHelper.d.ts: -------------------------------------------------------------------------------- 1 | export type Conversation = { 2 | conversation_id: number; 3 | title: string; 4 | creation_date: number; 5 | creator_id: number; 6 | last_message_date: number; 7 | last_read_date: number; 8 | open: boolean; 9 | reply_count: number; 10 | recipient_ids: Array; 11 | }; 12 | export type Reply = { 13 | message_id: number; 14 | message_date: number; 15 | author_id: number; 16 | message: string; 17 | }; 18 | /** 19 | * @typedef {object} Conversation 20 | * @property {number} conversation_id 21 | * @property {string} title 22 | * @property {number} creation_date 23 | * @property {number} creator_id 24 | * @property {number} last_message_date 25 | * @property {number} last_read_date 26 | * @property {boolean} open 27 | * @property {number} reply_count 28 | * @property {Array} recipient_ids 29 | */ 30 | /** 31 | * @typedef {object} Reply 32 | * @property {number} message_id 33 | * @property {number} message_date 34 | * @property {number} author_id 35 | * @property {string} message 36 | */ 37 | /** A helper type for conversation-related API endpoints. */ 38 | export class ConversationsHelper { 39 | constructor(wrapper: any); 40 | /** List a page of unread conversations. 41 | * 42 | * @param {SortOptions | undefined} sort An optional set of sort options. 43 | * @return {Array} An array of raw data objects. 44 | */ 45 | list(sort: SortOptions | undefined): Array; 46 | /** List all pages of unread conversations. 47 | * 48 | * @param {SortOptions | undefined} sort An optional set of sort options. 49 | * @return {Array} An array of raw data objects. 50 | */ 51 | listAll(sort: SortOptions | undefined): Array; 52 | /** List multiple pages of unread conversations until a condition is no longer met. 53 | * 54 | * @param {function(Conversation):boolean} shouldContinue A function which determines if further pages are 55 | * requested. 56 | * @param {SortOptions | undefined} sort An optional set of sort options. 57 | * 58 | * @return {Array} An array of raw data objects. 59 | */ 60 | listUntil(shouldContinue: (arg0: Conversation) => boolean, sort: SortOptions | undefined): Array; 61 | /** Start a new conversation. 62 | * 63 | * @param {string} title The title of the conversation. 64 | * @param {string} message The content of the first message in the conversation. 65 | * @param {Array} recipientIds An array of recipient identifiers. 66 | * 67 | * @return {number} The newly-created conversation identifier. 68 | */ 69 | start(title: string, message: string, recipientIds: Array): number; 70 | /** List a page of replies to an unread conversation. 71 | * 72 | * @param {number} conversationId The identifier of the unread conversation. 73 | * @param {SortOptions | undefined} sort An optional set of sort options. 74 | * 75 | * @return {Array} An array of raw data objects. 76 | */ 77 | listReplies(conversationId: number, sort: SortOptions | undefined): Array; 78 | /** List all pages of replies to an unread conversation. 79 | * 80 | * @param {number} conversationId The identifier of the unread conversation. 81 | * @param {SortOptions | undefined} sort An optional set of sort options. 82 | * 83 | * @return {Array} An array of raw data objects. 84 | */ 85 | listRepliesAll(conversationId: number, sort: SortOptions | undefined): Array; 86 | /** List multiple pages of replies to an unread conversation until a condition is no longer met. 87 | * 88 | * @param {number} conversationId The identifier of the unread conversation. 89 | * @param {function(Reply):boolean} shouldContinue A function which determines if further pages are requested. 90 | * @param {SortOptions | undefined} sort An optional set of sort options. 91 | * 92 | * @return {Array} An array of raw data objects. 93 | */ 94 | listRepliesUntil(conversationId: number, shouldContinue: (arg0: Reply) => boolean, sort: SortOptions | undefined): Array; 95 | /** Reply to an unread conversation 96 | * 97 | * @param {number} conversationId The identifier of the unread conversation. 98 | * @param {string} message The content of the new reply. 99 | * 100 | * @return {number} The identifier of the newly-created conversation message. 101 | */ 102 | reply(conversationId: number, message: string): number; 103 | #private; 104 | } 105 | import { SortOptions } from "../SortOptions"; 106 | //# sourceMappingURL=ConversationsHelper.d.ts.map -------------------------------------------------------------------------------- /types/helpers/ConversationsHelper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ConversationsHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/ConversationsHelper.js"],"names":[],"mappings":";qBAOc,MAAM;WACN,MAAM;mBACN,MAAM;gBACN,MAAM;uBACN,MAAM;oBACN,MAAM;UACN,OAAO;iBACP,MAAM;mBACN,MAAM,MAAM,CAAC;;;gBAKb,MAAM;kBACN,MAAM;eACN,MAAM;aACN,MAAM;;AAlBpB;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AAEH,4DAA4D;AAC5D;IAGI,0BAEC;IAED;;;;OAIG;IACH,WAHW,WAAW,GAAG,SAAS,GACtB,MAAM,YAAY,CAAC,CAI9B;IAED;;;;OAIG;IACH,cAHW,WAAW,GAAG,SAAS,GACtB,MAAM,YAAY,CAAC,CAI9B;IAED;;;;;;;OAOG;IACH,iCANoB,YAAY,KAAE,OAAO,QAE9B,WAAW,GAAG,SAAS,GAEtB,MAAM,YAAY,CAAC,CAI9B;IAED;;;;;;;OAOG;IACH,aANW,MAAM,WACN,MAAM,gBACN,MAAM,MAAM,CAAC,GAEZ,MAAM,CAKjB;IAED;;;;;;OAMG;IACH,4BALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,KAAK,CAAC,CAIvB;IAED;;;;;;OAMG;IACH,+BALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,KAAK,CAAC,CAIvB;IAED;;;;;;;OAOG;IACH,iCANW,MAAM,yBACG,KAAK,KAAE,OAAO,QACvB,WAAW,GAAG,SAAS,GAEtB,MAAM,KAAK,CAAC,CAIvB;IAED;;;;;;OAMG;IACH,sBALW,MAAM,WACN,MAAM,GAEL,MAAM,CAIjB;;CACJ"} -------------------------------------------------------------------------------- /types/helpers/ThreadsHelper.d.ts: -------------------------------------------------------------------------------- 1 | export type BasicThread = { 2 | thread_id: number; 3 | title: string; 4 | reply_count: number; 5 | view_count: number; 6 | creation_date: number; 7 | last_message_date: number; 8 | }; 9 | export type Thread = { 10 | thread_id: number; 11 | forum_name: string; 12 | title: string; 13 | reply_count: number; 14 | view_count: number; 15 | post_date: number; 16 | thread_type: string; 17 | thread_open: boolean; 18 | last_post_date: number; 19 | }; 20 | export type Reply = { 21 | reply_id: number; 22 | author_id: number; 23 | post_date: number; 24 | message: string; 25 | }; 26 | /** 27 | * @typedef {object} BasicThread 28 | * @property {number} thread_id 29 | * @property {string} title 30 | * @property {number} reply_count 31 | * @property {number} view_count 32 | * @property {number} creation_date 33 | * @property {number} last_message_date 34 | */ 35 | /** 36 | * @typedef {object} Thread 37 | * @property {number} thread_id 38 | * @property {string} forum_name 39 | * @property {string} title 40 | * @property {number} reply_count 41 | * @property {number} view_count 42 | * @property {number} post_date 43 | * @property {string} thread_type 44 | * @property {boolean} thread_open 45 | * @property {number} last_post_date 46 | */ 47 | /** 48 | * @typedef {object} Reply 49 | * @property {number} reply_id 50 | * @property {number} author_id 51 | * @property {number} post_date 52 | * @property {string} message 53 | */ 54 | /** A helper type for thread-related API endpoints. */ 55 | export class ThreadsHelper { 56 | constructor(wrapper: any); 57 | /** List a page of threads you own or collaborate on. 58 | * 59 | * @param {SortOptions | undefined} sort An optional set of sort options. 60 | * @return {Array} An array of raw data objects. 61 | */ 62 | list(sort: SortOptions | undefined): Array; 63 | /** List all pages of threads you own or collaborate on. 64 | * 65 | * @param {SortOptions | undefined} sort An optional set of sort options. 66 | * @return {Array} An array of raw data objects. 67 | */ 68 | listAll(sort: SortOptions | undefined): Array; 69 | /** List multiple pages of threads you own or collaborate on until a condition is no longer met. 70 | * 71 | * @param {function(BasicThread):boolean} shouldContinue A function which determines if further pages are requested. 72 | * @param {SortOptions | undefined} sort An optional set of sort options. 73 | * 74 | * @return {Array} An array of raw data objects. 75 | */ 76 | listUntil(shouldContinue: (arg0: BasicThread) => boolean, sort: SortOptions | undefined): Array; 77 | /** Fetch information about a thread you own or collaborate on. 78 | * 79 | * @param {number} threadId The identifier of the thread. 80 | * @return {Thread} A raw data object. 81 | */ 82 | fetch(threadId: number): Thread; 83 | /** List a page of replies for a thread you own or collaborate on. 84 | * 85 | * @param {number} threadId The identifier of the thread. 86 | * @param {SortOptions | undefined} sort An optional set of sort options. 87 | * 88 | * @return {Array} An array of raw data objects. 89 | */ 90 | listReplies(threadId: number, sort: SortOptions | undefined): Array; 91 | /** List all pages of replies for a thread you own or collaborate on. 92 | * 93 | * @param {number} threadId The identifier of the thread. 94 | * @param {SortOptions | undefined} sort An optional set of sort options. 95 | * 96 | * @return {Array} An array of raw data objects. 97 | */ 98 | listRepliesAll(threadId: number, sort: SortOptions | undefined): Array; 99 | /** List multiple pages of replies for a thread you own or collaborate on until a condition is no longer met. 100 | * 101 | * @param {number} threadId The identifier of the thread. 102 | * @param {function(Reply):boolean} shouldContinue A function which determines if further pages are requested. 103 | * @param {SortOptions | undefined} sort An optional set of sort options. 104 | * 105 | * @return {Array} An array of raw data objects. 106 | */ 107 | listRepliesUntil(threadId: number, shouldContinue: (arg0: Reply) => boolean, sort: SortOptions | undefined): Array; 108 | /** Reply to a thread you own or collaborate on. 109 | * 110 | * @param {number} threadId The identifier of the thread. 111 | * @param {string} message The content of the new reply. 112 | * 113 | * @return {number} The identifier of the newly-created post. 114 | */ 115 | reply(threadId: number, message: string): number; 116 | #private; 117 | } 118 | import { SortOptions } from "../SortOptions"; 119 | //# sourceMappingURL=ThreadsHelper.d.ts.map -------------------------------------------------------------------------------- /types/helpers/ThreadsHelper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ThreadsHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/ThreadsHelper.js"],"names":[],"mappings":";eAOc,MAAM;WACN,MAAM;iBACN,MAAM;gBACN,MAAM;mBACN,MAAM;uBACN,MAAM;;;eAKN,MAAM;gBACN,MAAM;WACN,MAAM;iBACN,MAAM;gBACN,MAAM;eACN,MAAM;iBACN,MAAM;iBACN,OAAO;oBACP,MAAM;;;cAKN,MAAM;eACN,MAAM;eACN,MAAM;aACN,MAAM;;AA5BpB;;;;;;;;GAQG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AAEH,sDAAsD;AACtD;IAGI,0BAEC;IAED;;;;OAIG;IACH,WAHW,WAAW,GAAG,SAAS,GACtB,MAAM,WAAW,CAAC,CAI7B;IAED;;;;OAIG;IACH,cAHW,WAAW,GAAG,SAAS,GACtB,MAAM,WAAW,CAAC,CAI7B;IAED;;;;;;OAMG;IACH,iCALoB,WAAW,KAAE,OAAO,QAC7B,WAAW,GAAG,SAAS,GAEtB,MAAM,WAAW,CAAC,CAI7B;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACL,MAAM,CAIjB;IAED;;;;;;OAMG;IACH,sBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,KAAK,CAAC,CAIvB;IAED;;;;;;OAMG;IACH,yBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,KAAK,CAAC,CAIvB;IAED;;;;;;;OAOG;IACH,2BANW,MAAM,yBACG,KAAK,KAAE,OAAO,QACvB,WAAW,GAAG,SAAS,GAEtB,MAAM,KAAK,CAAC,CAIvB;IAED;;;;;;OAMG;IACH,gBALW,MAAM,WACN,MAAM,GAEL,MAAM,CAIjB;;CACJ"} -------------------------------------------------------------------------------- /types/helpers/members/MembersHelper.d.ts: -------------------------------------------------------------------------------- 1 | export type Member = { 2 | member_id: number; 3 | username: string; 4 | join_date: number; 5 | last_activity_date?: number; 6 | banned: boolean; 7 | suspended: boolean; 8 | restricted: boolean; 9 | disabled: boolean; 10 | premium: boolean; 11 | supreme: boolean; 12 | ultimate: boolean; 13 | discord_id?: number; 14 | avatar_url: string; 15 | post_count: number; 16 | resource_count: number; 17 | purchase_count: number; 18 | feedback_positive: number; 19 | feedback_neutral: number; 20 | feedback_negative: number; 21 | }; 22 | export type Ban = { 23 | member_id: number; 24 | banned_by_id: number; 25 | ban_date: number; 26 | reason: string; 27 | }; 28 | /** 29 | * @typedef {object} Member 30 | * @property {number} member_id 31 | * @property {string} username 32 | * @property {number} join_date 33 | * @property {number} [last_activity_date] 34 | * @property {boolean} banned 35 | * @property {boolean} suspended 36 | * @property {boolean} restricted 37 | * @property {boolean} disabled 38 | * @property {boolean} premium 39 | * @property {boolean} supreme 40 | * @property {boolean} ultimate 41 | * @property {number} [discord_id] 42 | * @property {string} avatar_url 43 | * @property {number} post_count 44 | * @property {number} resource_count 45 | * @property {number} purchase_count 46 | * @property {number} feedback_positive 47 | * @property {number} feedback_neutral 48 | * @property {number} feedback_negative 49 | */ 50 | /** 51 | * @typedef {object} Ban 52 | * @property {number} member_id 53 | * @property {number} banned_by_id 54 | * @property {number} ban_date 55 | * @property {string} reason 56 | */ 57 | /** A helper type for member-related API endpoints. */ 58 | export class MembersHelper { 59 | constructor(wrapper: any); 60 | /** Fetch information about yourself. 61 | * 62 | * @return {Member} A raw data object. 63 | */ 64 | self(): Member; 65 | /** Modify information about yourself. 66 | * 67 | * @param {string} aboutMe The 'about me' field content, or undefined. 68 | * @param {string} customTitle The 'custom title' field content, or undefined. 69 | * @param {string} signature The 'signature' field content, or undefined. 70 | */ 71 | modifySelf(aboutMe: string, customTitle: string, signature: string): Promise; 72 | /** Fetch information about a member. 73 | * 74 | * @param {number} memberId The identifier of the member. 75 | * @return {Member} A raw data object. 76 | */ 77 | fetch(memberId: number): Member; 78 | /** Fetch information about a member by username. 79 | * 80 | * @param {string} username The username of the member. 81 | * @return {Member} A raw data object. 82 | */ 83 | fetchByUsername(username: string): Member; 84 | /** Fetch information about a member by Discord identifier. 85 | * 86 | * @param {string} discordId The identifier of the Discord account. 87 | * @return {Member} A raw data object. 88 | */ 89 | fetchByDiscord(discordId: string): Member; 90 | /** Fetch a list of recently issued bans. 91 | * 92 | * @return {Array} An array of raw data objects. 93 | */ 94 | bans(): Array; 95 | /** Access profile post-related helper functions. 96 | * 97 | * @return {ProfilePostsHelper} A newly-constructed profile post helper instance. 98 | */ 99 | profilePosts(): ProfilePostsHelper; 100 | #private; 101 | } 102 | import { ProfilePostsHelper } from "./ProfilePostsHelper.js"; 103 | //# sourceMappingURL=MembersHelper.d.ts.map -------------------------------------------------------------------------------- /types/helpers/members/MembersHelper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"MembersHelper.d.ts","sourceRoot":"","sources":["../../../src/helpers/members/MembersHelper.js"],"names":[],"mappings":";eAOc,MAAM;cACN,MAAM;eACN,MAAM;yBACN,MAAM;YACN,OAAO;eACP,OAAO;gBACP,OAAO;cACP,OAAO;aACP,OAAO;aACP,OAAO;cACP,OAAO;iBACP,MAAM;gBACN,MAAM;gBACN,MAAM;oBACN,MAAM;oBACN,MAAM;uBACN,MAAM;sBACN,MAAM;uBACN,MAAM;;;eAKN,MAAM;kBACN,MAAM;cACN,MAAM;YACN,MAAM;;AA5BpB;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;GAMG;AAEH,sDAAsD;AACtD;IAGI,0BAEC;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;;;OAKG;IACH,oBAJW,MAAM,eACN,MAAM,aACN,MAAM,gBAKhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACL,MAAM,CAIjB;IAED;;;;OAIG;IACH,0BAHW,MAAM,GACL,MAAM,CAIjB;IAED;;;;OAIG;IACH,0BAHW,MAAM,GACL,MAAM,CAIjB;IAED;;;OAGG;IACH,QAFY,MAAM,GAAG,CAAC,CAIrB;IAED;;;OAGG;IACH,gBAFY,kBAAkB,CAI7B;;CACJ"} -------------------------------------------------------------------------------- /types/helpers/members/ProfilePostsHelper.d.ts: -------------------------------------------------------------------------------- 1 | export type ProfilePost = { 2 | profile_post_id: number; 3 | author_id: number; 4 | post_date: number; 5 | message: string; 6 | comment_count: number; 7 | }; 8 | /** 9 | * @typedef {object} ProfilePost 10 | * @property {number} profile_post_id 11 | * @property {number} author_id 12 | * @property {number} post_date 13 | * @property {string} message 14 | * @property {number} comment_count 15 | */ 16 | /** A helper type for profile post-related API endpoints. */ 17 | export class ProfilePostsHelper { 18 | constructor(wrapper: any); 19 | /** List a page of profile posts on your profile. 20 | * 21 | * @param {SortOptions | undefined} sort An optional set of sort options. 22 | * @return {Array} An array of raw data objects. 23 | */ 24 | list(sort: SortOptions | undefined): Array; 25 | /** List all pages of profile posts on your profile. 26 | * 27 | * @param {SortOptions | undefined} sort An optional set of sort options. 28 | * @return {Array} An array of raw data objects. 29 | */ 30 | listAll(sort: SortOptions | undefined): Array; 31 | /** List multiple pages of profile posts on your profile until a condition is no longer met. 32 | * 33 | * @param {function(ProfilePost):boolean} shouldContinue A function which determines if further pages are requested. 34 | * @param {SortOptions | undefined} sort An optional set of sort options. 35 | * @return {Array} An array of raw data objects. 36 | */ 37 | listUntil(shouldContinue: (arg0: ProfilePost) => boolean, sort: SortOptions | undefined): Array; 38 | /** Fetch information about a profile post on your profile. 39 | * 40 | * @param {number} profilePostId The identifier of the profile post to fetch. 41 | * @return {ProfilePost} A raw data object. 42 | */ 43 | fetch(profilePostId: number): ProfilePost; 44 | /** Create a new profile post on your profile. 45 | * 46 | * @param {string} message The content of the message to modify to. 47 | * @return {number} The identifer of the newly-created profile post. 48 | */ 49 | create(message: string): number; 50 | /** Modify a profile post on your profile that you've authored. 51 | * 52 | * @param {number} profilePostId The identifier of the profile post to modify. 53 | * @param {string} message The content of the message to modify to. 54 | */ 55 | modify(profilePostId: number, message: string): Promise; 56 | /** Delete a profile post on your profile that you've authored. 57 | * 58 | * @param {number} profilePostId The identifier of the profile post to delete. 59 | */ 60 | delete(profilePostId: number): Promise; 61 | #private; 62 | } 63 | import { SortOptions } from "../../SortOptions"; 64 | //# sourceMappingURL=ProfilePostsHelper.d.ts.map -------------------------------------------------------------------------------- /types/helpers/members/ProfilePostsHelper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ProfilePostsHelper.d.ts","sourceRoot":"","sources":["../../../src/helpers/members/ProfilePostsHelper.js"],"names":[],"mappings":";qBAOc,MAAM;eACN,MAAM;eACN,MAAM;aACN,MAAM;mBACN,MAAM;;AANpB;;;;;;;GAOG;AAEH,4DAA4D;AAC5D;IAGI,0BAEC;IAED;;;;OAIG;IACH,WAHW,WAAW,GAAG,SAAS,GACtB,MAAM,WAAW,CAAC,CAI7B;IAED;;;;OAIG;IACH,cAHW,WAAW,GAAG,SAAS,GACtB,MAAM,WAAW,CAAC,CAI7B;IAED;;;;;OAKG;IACH,iCAJoB,WAAW,KAAE,OAAO,QAC7B,WAAW,GAAG,SAAS,GACtB,MAAM,WAAW,CAAC,CAI7B;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,WAAW,CAItB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACL,MAAM,CAIjB;IAED;;;;OAIG;IACH,sBAHW,MAAM,WACN,MAAM,gBAIhB;IAED;;;OAGG;IACH,sBAFW,MAAM,gBAIhB;;CACJ"} -------------------------------------------------------------------------------- /types/helpers/resources/DownloadsHelper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"DownloadsHelper.d.ts","sourceRoot":"","sources":["../../../src/helpers/resources/DownloadsHelper.js"],"names":[],"mappings":";iBAOc,MAAM;gBACN,MAAM;mBACN,MAAM;mBACN,MAAM;;AALpB;;;;;;GAMG;AAEH,iEAAiE;AACjE;IAGI,0BAEC;IAED;;;;;;OAMG;IACH,iBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,QAAQ,CAAC,CAI1B;IAED;;;;;;OAMG;IACH,oBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,QAAQ,CAAC,CAI1B;IAED;;;;;;;OAOG;IACH,sBANW,MAAM,yBACG,QAAQ,KAAE,OAAO,QAC1B,WAAW,GAAG,SAAS,GAEtB,MAAM,QAAQ,CAAC,CAI1B;IAED;;;;;;;OAOG;IACH,yBANW,MAAM,YACN,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,QAAQ,CAAC,CAI1B;IAED;;;;;;;OAOG;IACH,4BANW,MAAM,YACN,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,QAAQ,CAAC,CAK1B;IAED;;;;;;;;OAQG;IACH,8BAPW,MAAM,YACN,MAAM,yBACG,QAAQ,KAAE,OAAO,QAC1B,WAAW,GAAG,SAAS,GAEtB,MAAM,QAAQ,CAAC,CAK1B;IAED;;;;;;;OAOG;IACH,0BANW,MAAM,aACN,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,QAAQ,CAAC,CAI1B;IAED;;;;;;;OAOG;IACH,6BANW,MAAM,aACN,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,QAAQ,CAAC,CAK1B;IAED;;;;;;;;OAQG;IACH,+BAPW,MAAM,aACN,MAAM,yBACG,QAAQ,KAAE,OAAO,QAC1B,WAAW,GAAG,SAAS,GAEtB,MAAM,QAAQ,CAAC,CAK1B;;CACJ"} -------------------------------------------------------------------------------- /types/helpers/resources/LicensesHelper.d.ts: -------------------------------------------------------------------------------- 1 | export type License = { 2 | license_id: number; 3 | purchaser_id: number; 4 | validated: boolean; 5 | permanent: boolean; 6 | active: boolean; 7 | start_date: number; 8 | end_date: number; 9 | previous_end_date: number; 10 | }; 11 | /** 12 | * @typedef {object} License 13 | * @property {number} license_id 14 | * @property {number} purchaser_id 15 | * @property {boolean} validated 16 | * @property {boolean} permanent 17 | * @property {boolean} active 18 | * @property {number} start_date 19 | * @property {number} end_date 20 | * @property {number} previous_end_date 21 | */ 22 | /** A helper type for resource license-related API endpoints. */ 23 | export class LicensesHelper { 24 | constructor(wrapper: any); 25 | /** List a page of licenses for a given resource. 26 | * 27 | * @param {number} resourceId The identifier of the resource. 28 | * @param {SortOptions | undefined} sort An optional set of sort options. 29 | * 30 | * @return {Array} An array of raw data objects. 31 | */ 32 | list(resourceId: number, sort: SortOptions | undefined): Array; 33 | /** List all pages of licenses for a given resource. 34 | * 35 | * @param {number} resourceId The identifier of the resource. 36 | * @param {SortOptions | undefined} sort An optional set of sort options. 37 | * 38 | * @return {Array} An array of raw data objects. 39 | */ 40 | listAll(resourceId: number, sort: SortOptions | undefined): Array; 41 | /** List multiple pages of licenses for a given resource until a condition is no longer met. 42 | * 43 | * @param {number} resourceId The identifier of the resource. 44 | * @param {function(License):boolean} shouldContinue A function which determines if further pages are requested. 45 | * @param {SortOptions | undefined} sort An optional set of sort options. 46 | * 47 | * @return {Array} An array of raw data objects. 48 | */ 49 | listUntil(resourceId: number, shouldContinue: (arg0: License) => boolean, sort: SortOptions | undefined): Array; 50 | /** Fetch a license for a given resource. 51 | * 52 | * @param {number} resourceId The identifier of the resource. 53 | * @param {number} licenseId The identifier of the license. 54 | * 55 | * @return {License} A raw data object. 56 | */ 57 | fetch(resourceId: number, licenseId: number): License; 58 | /** Fetch a member's license for a given resource. 59 | * 60 | * @param {number} resourceId The identifier of the resource. 61 | * @param {number} memberId The identifier of the member. 62 | * @param {number | undefined} nonce The download's NONCE value, or undefined if using a Private token. 63 | * @param {number | undefined} timestamp The download's UNIX timestamp, or undefined if using a Private token. 64 | * 65 | * @return {License} A raw data object. 66 | */ 67 | fetchMember(resourceId: number, memberId: number, nonce: number | undefined, timestamp: number | undefined): License; 68 | /** Modify a permanent license (and convert to permanent if currently temporary). 69 | * 70 | * @param {number} resourceId The identifier of the resource. 71 | * @param {number} licenseId The identifier of the license. 72 | * @param {boolean} active Whether or not the license should be active. 73 | */ 74 | modifyPermanent(resourceId: number, licenseId: number, active: boolean): Promise; 75 | /** Modify a temporary license (and convert to temporary if currently permanent). 76 | * 77 | * @param {number} resourceId The identifier of the resource. 78 | * @param {number} licenseId The identifier of the license. 79 | * @param {number} startDate The UNIX timestamp of when the license should start. 80 | * @param {number} endDate The UNIX timestamp of when the license should end. 81 | */ 82 | modifyTemporary(resourceId: number, licenseId: number, startDate: number, endDate: number): Promise; 83 | #private; 84 | } 85 | import { SortOptions } from "../../SortOptions"; 86 | //# sourceMappingURL=LicensesHelper.d.ts.map -------------------------------------------------------------------------------- /types/helpers/resources/LicensesHelper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"LicensesHelper.d.ts","sourceRoot":"","sources":["../../../src/helpers/resources/LicensesHelper.js"],"names":[],"mappings":";gBAOc,MAAM;kBACN,MAAM;eACN,OAAO;eACP,OAAO;YACP,OAAO;gBACP,MAAM;cACN,MAAM;uBACN,MAAM;;AATpB;;;;;;;;;;GAUG;AAEH,gEAAgE;AAChE;IAGI,0BAEC;IAED;;;;;;OAMG;IACH,iBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,OAAO,CAAC,CAIzB;IAED;;;;;;OAMG;IACH,oBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,OAAO,CAAC,CAIzB;IAED;;;;;;;OAOG;IACH,sBANW,MAAM,yBACG,OAAO,KAAE,OAAO,QACzB,WAAW,GAAG,SAAS,GAEtB,MAAM,OAAO,CAAC,CAIzB;IAED;;;;;;OAMG;IACH,kBALW,MAAM,aACN,MAAM,GAEL,OAAO,CAIlB;IAED;;;;;;;;OAQG;IACH,wBAPW,MAAM,YACN,MAAM,SACN,MAAM,GAAG,SAAS,aAClB,MAAM,GAAG,SAAS,GAEjB,OAAO,CAOlB;IAED;;;;;OAKG;IACH,4BAJW,MAAM,aACN,MAAM,UACN,OAAO,gBAKjB;IAED;;;;;;OAMG;IACH,4BALW,MAAM,aACN,MAAM,aACN,MAAM,WACN,MAAM,gBAKhB;;CACJ"} -------------------------------------------------------------------------------- /types/helpers/resources/PurchasesHelper.d.ts: -------------------------------------------------------------------------------- 1 | export type Purchase = { 2 | purchase_id: number; 3 | purchaser_id: number; 4 | license_id: number; 5 | renewal: boolean; 6 | status: string; 7 | price: number; 8 | currency: string; 9 | purchase_date: number; 10 | validation_date: number; 11 | }; 12 | /** 13 | * @typedef {object} Purchase 14 | * @property {number} purchase_id 15 | * @property {number} purchaser_id 16 | * @property {number} license_id 17 | * @property {boolean} renewal 18 | * @property {string} status 19 | * @property {number} price 20 | * @property {string} currency 21 | * @property {number} purchase_date 22 | * @property {number} validation_date 23 | */ 24 | /** A helper type for resource purchase-related API endpoints. */ 25 | export class PurchasesHelper { 26 | constructor(wrapper: any); 27 | /** List a page of purchases for a given resource. 28 | * 29 | * @param {number} resourceId The identifier of the resource. 30 | * @param {SortOptions | undefined} sort An optional set of sort options. 31 | * 32 | * @return {Array} An array of raw data objects. 33 | */ 34 | list(resourceId: number, sort: SortOptions | undefined): Array; 35 | /** List all pages of purchases for a given resource. 36 | * 37 | * @param {number} resourceId The identifier of the resource. 38 | * @param {SortOptions | undefined} sort An optional set of sort options. 39 | * 40 | * @return {Array} An array of raw data objects. 41 | */ 42 | listAll(resourceId: number, sort: SortOptions | undefined): Array; 43 | /** List multiple pages of purchases for a given resource until a condition is no longer met. 44 | * 45 | * @param {number} resourceId The identifier of the resource. 46 | * @param {function(Purchase):boolean} shouldContinue A function which determines if further pages are requested. 47 | * @param {SortOptions | undefined} sort An optional set of sort options. 48 | * 49 | * @return {Array} An array of raw data objects. 50 | */ 51 | listUntil(resourceId: number, shouldContinue: (arg0: Purchase) => boolean, sort: SortOptions | undefined): Array; 52 | /** Fetch a purchase for a given resource. 53 | * 54 | * @param {number} resourceId The identifier of the resource. 55 | * @param {number} purchaseId The identifier of the purchase. 56 | * 57 | * @return {Purchase} A raw data object. 58 | */ 59 | fetch(resourceId: number, purchaseId: number): Purchase; 60 | #private; 61 | } 62 | import { SortOptions } from "../../SortOptions"; 63 | //# sourceMappingURL=PurchasesHelper.d.ts.map -------------------------------------------------------------------------------- /types/helpers/resources/PurchasesHelper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"PurchasesHelper.d.ts","sourceRoot":"","sources":["../../../src/helpers/resources/PurchasesHelper.js"],"names":[],"mappings":";iBAOc,MAAM;kBACN,MAAM;gBACN,MAAM;aACN,OAAO;YACP,MAAM;WACN,MAAM;cACN,MAAM;mBACN,MAAM;qBACN,MAAM;;AAVpB;;;;;;;;;;;GAWG;AAEH,iEAAiE;AACjE;IAGI,0BAEC;IAED;;;;;;OAMG;IACH,iBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,QAAQ,CAAC,CAI1B;IAED;;;;;;OAMG;IACH,oBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,QAAQ,CAAC,CAI1B;IAED;;;;;;;OAOG;IACH,sBANW,MAAM,yBACG,QAAQ,KAAE,OAAO,QAC1B,WAAW,GAAG,SAAS,GAEtB,MAAM,QAAQ,CAAC,CAI1B;IAED;;;;;;OAMG;IACH,kBALW,MAAM,cACN,MAAM,GAEL,QAAQ,CAInB;;CACJ"} -------------------------------------------------------------------------------- /types/helpers/resources/ResourcesHelper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ResourcesHelper.d.ts","sourceRoot":"","sources":["../../../src/helpers/resources/ResourcesHelper.js"],"names":[],"mappings":";iBAcc,MAAM;eACN,MAAM;WACN,MAAM;cACN,MAAM;WACN,MAAM;cACN,MAAM;;;iBAKN,MAAM;eACN,MAAM;WACN,MAAM;cACN,MAAM;iBACN,MAAM;kBACN,MAAM;sBACN,MAAM;oBACN,MAAM;wBACN,MAAM;WACN,MAAM;cACN,MAAM;oBACN,MAAM;oBACN,MAAM;kBACN,MAAM;oBACN,MAAM;;;WAKN,MAAM;UACN,MAAM;WACN,MAAM;YACN,MAAM,GAAC,SAAS;;;cAKhB,MAAM;gBACN,MAAM;kBACN,MAAM;;;AAzCpB;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH,wDAAwD;AACxD;IAGI,0BAEC;IAED;;;;OAIG;IACH,WAHW,WAAW,GAAG,SAAS,GACtB,MAAM,aAAa,CAAC,CAI/B;IAMD;;;;OAIG;IACH,gBAHW,WAAW,GAAG,SAAS,GACtB,MAAM,aAAa,CAAC,CAI/B;IAED;;;;OAIG;IACH,mBAHW,WAAW,GAAG,SAAS,GACtB,MAAM,aAAa,CAAC,CAI/B;IAED;;;;;;;OAOG;IACH,sCANoB,aAAa,KAAE,OAAO,QAE/B,WAAW,GAAG,SAAS,GAEtB,MAAM,aAAa,CAAC,CAI/B;IAED;;;;OAIG;IACH,uBAHW,WAAW,GAAG,SAAS,GACtB,MAAM,aAAa,CAAC,CAI/B;IAED;;;;OAIG;IACH,0BAHW,WAAW,GAAG,SAAS,GACtB,MAAM,aAAa,CAAC,CAI/B;IAED;;;;;;;OAOG;IACH,6CANoB,aAAa,KAAE,OAAO,QAE/B,WAAW,GAAG,SAAS,GAEtB,MAAM,aAAa,CAAC,CAI/B;IAED;;;;;;OAMG;IACH,uBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,aAAa,CAAC,CAI/B;IAED;;;;;;OAMG;IACH,0BALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,aAAa,CAAC,CAI/B;IAED;;;;;;;;OAQG;IACH,4BAPW,MAAM,yBACG,aAAa,KAAE,OAAO,QAE/B,WAAW,GAAG,SAAS,GAEtB,MAAM,aAAa,CAAC,CAI/B;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACL,QAAQ,CAInB;IAED;;;;;;OAMG;IACH,mBALW,MAAM,SACN,MAAM,eACN,MAAM,WACN,MAAM,gBAKhB;IAED;;;;;;OAMG;IACH,yBALW,MAAM,MAAM,CAAC,WACb,MAAM,WAAW,CAAC,GAEjB,MAAM,CAKjB;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,SAAS,CAIpB;IAED;;;OAGG;IACH,aAFY,eAAe,CAI1B;IAED;;;OAGG;IACH,YAFY,cAAc,CAIzB;IAED;;;OAGG;IACH,aAFY,eAAe,CAI1B;IAED;;;OAGG;IACH,WAFY,aAAa,CAIxB;IAED;;;OAGG;IACH,WAFY,aAAa,CAIxB;IAED;;;OAGG;IACH,YAFY,cAAc,CAIzB;;CACJ"} -------------------------------------------------------------------------------- /types/helpers/resources/ReviewsHelper.d.ts: -------------------------------------------------------------------------------- 1 | export type Review = { 2 | review_id: number; 3 | reviewer_id: number; 4 | review_date: number; 5 | rating: number; 6 | message: string; 7 | response: string; 8 | }; 9 | /** 10 | * @typedef {object} Review 11 | * @property {number} review_id 12 | * @property {number} reviewer_id 13 | * @property {number} review_date 14 | * @property {number} rating 15 | * @property {string} message 16 | * @property {string} response 17 | */ 18 | /** A helper type for resource review-related API endpoints. */ 19 | export class ReviewsHelper { 20 | constructor(wrapper: any); 21 | /** List a page of reviews for a given resource. 22 | * 23 | * @param {number} resourceId The identifier of the resource. 24 | * @param {SortOptions | undefined} sort An optional set of sort options. 25 | * 26 | * @return {Array} An array of raw data objects. 27 | */ 28 | list(resourceId: number, sort: SortOptions | undefined): Array; 29 | /** List all pages of reviews for a given resource. 30 | * 31 | * @param {number} resourceId The identifier of the resource. 32 | * @param {SortOptions | undefined} sort An optional set of sort options. 33 | * 34 | * @return {Array} An array of raw data objects. 35 | */ 36 | listAll(resourceId: number, sort: SortOptions | undefined): Array; 37 | /** List multiple pages of reviews for a given resource until a condition is no longer met. 38 | * 39 | * @param {number} resourceId The identifier of the resource. 40 | * @param {function(Review):boolean} shouldContinue A function which determines if further pages are requested. 41 | * @param {SortOptions | undefined} sort An optional set of sort options. 42 | * 43 | * @return {Array} An array of raw data objects. 44 | */ 45 | listUntil(resourceId: number, shouldContinue: (arg0: Review) => boolean, sort: SortOptions | undefined): Array; 46 | /** Fetch a resource review by a member for a given resource. 47 | * 48 | * @param {number} resourceId The identifier of the resource. 49 | * @param {number} memberId The identifier of the member. 50 | * 51 | * @return {Review} A raw data object. 52 | */ 53 | fetch(resourceId: number, memberId: number): Review; 54 | /** Respond to a review for a given resource. 55 | * 56 | * @param {number} resourceId The identifier of the resource. 57 | * @param {number} reviewId The identifier of the review. 58 | * @param {string} response The content of the author response. 59 | */ 60 | respond(resourceId: number, reviewId: number, response: string): Promise; 61 | #private; 62 | } 63 | import { SortOptions } from "../../SortOptions"; 64 | //# sourceMappingURL=ReviewsHelper.d.ts.map -------------------------------------------------------------------------------- /types/helpers/resources/ReviewsHelper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ReviewsHelper.d.ts","sourceRoot":"","sources":["../../../src/helpers/resources/ReviewsHelper.js"],"names":[],"mappings":";eAOc,MAAM;iBACN,MAAM;iBACN,MAAM;YACN,MAAM;aACN,MAAM;cACN,MAAM;;AAPpB;;;;;;;;GAQG;AAEH,+DAA+D;AAC/D;IAGI,0BAEC;IAED;;;;;;OAMG;IACH,iBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,MAAM,CAAC,CAIxB;IAED;;;;;;OAMG;IACH,oBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,MAAM,CAAC,CAIxB;IAED;;;;;;;OAOG;IACH,sBANW,MAAM,yBACG,MAAM,KAAE,OAAO,QACxB,WAAW,GAAG,SAAS,GAEtB,MAAM,MAAM,CAAC,CAIxB;IAED;;;;;;OAMG;IACH,kBALW,MAAM,YACN,MAAM,GAEL,MAAM,CAIjB;IAED;;;;;OAKG;IACH,oBAJW,MAAM,YACN,MAAM,YACN,MAAM,gBAIhB;;CACJ"} -------------------------------------------------------------------------------- /types/helpers/resources/UpdatesHelper.d.ts: -------------------------------------------------------------------------------- 1 | export type Update = { 2 | update_id: number; 3 | title: string; 4 | message: string; 5 | update_date: number; 6 | }; 7 | /** 8 | * @typedef {object} Update 9 | * @property {number} update_id 10 | * @property {string} title 11 | * @property {string} message 12 | * @property {number} update_date 13 | */ 14 | /** A helper type for resource update-related API endpoints. */ 15 | export class UpdatesHelper { 16 | constructor(wrapper: any); 17 | /** List a page of updates for a given resource. 18 | * 19 | * @param {number} resourceId The identifier of the resource. 20 | * @param {SortOptions | undefined} sort An optional set of sort options. 21 | * 22 | * @return {Array} An array of raw data objects. 23 | */ 24 | list(resourceId: number, sort: SortOptions | undefined): Array; 25 | /** List all pages of updates for a given resource. 26 | * 27 | * @param {number} resourceId The identifier of the resource. 28 | * @param {SortOptions | undefined} sort An optional set of sort options. 29 | * 30 | * @return {Array} An array of raw data objects. 31 | */ 32 | listAll(resourceId: number, sort: SortOptions | undefined): Array; 33 | /** List multiple pages of updates for a given resource until a condition is no longer met. 34 | * 35 | * @param {number} resourceId The identifier of the resource. 36 | * @param {function(Update):boolean} shouldContinue A function which determines if further pages are requested. 37 | * @param {SortOptions | undefined} sort An optional set of sort options. 38 | * 39 | * @return {Array} An array of raw data objects. 40 | */ 41 | listUntil(resourceId: number, shouldContinue: (arg0: Update) => boolean, sort: SortOptions | undefined): Array; 42 | /** Fetch the latest update for a given resource. 43 | * 44 | * @param {number} resourceId The identifier of the resource. 45 | * 46 | * @return {Update} A raw data object. 47 | */ 48 | latest(resourceId: number): Update; 49 | /** Fetch an update for a given resource. 50 | * 51 | * @param {number} resourceId The identifier of the resource. 52 | * @param {number} updateId The identifier of the update. 53 | * 54 | * @return {Update} A raw data object. 55 | */ 56 | fetch(resourceId: number, updateId: number): Update; 57 | /** Delete an update for a given resource. 58 | * 59 | * @param {number} resourceId The identifier of the resource. 60 | * @param {number} updateId The identifier of the update. 61 | */ 62 | delete(resourceId: number, updateId: number): Promise; 63 | #private; 64 | } 65 | import { SortOptions } from "../../SortOptions"; 66 | //# sourceMappingURL=UpdatesHelper.d.ts.map -------------------------------------------------------------------------------- /types/helpers/resources/UpdatesHelper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"UpdatesHelper.d.ts","sourceRoot":"","sources":["../../../src/helpers/resources/UpdatesHelper.js"],"names":[],"mappings":";eAOc,MAAM;WACN,MAAM;aACN,MAAM;iBACN,MAAM;;AALpB;;;;;;GAMG;AAEH,+DAA+D;AAC/D;IAGI,0BAEC;IAED;;;;;;OAMG;IACH,iBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,MAAM,CAAC,CAIxB;IAED;;;;;;OAMG;IACH,oBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,MAAM,CAAC,CAIxB;IAED;;;;;;;OAOG;IACH,sBANW,MAAM,yBACG,MAAM,KAAE,OAAO,QACxB,WAAW,GAAG,SAAS,GAEtB,MAAM,MAAM,CAAC,CAIxB;IAED;;;;;OAKG;IACH,mBAJW,MAAM,GAEL,MAAM,CAIjB;IAED;;;;;;OAMG;IACH,kBALW,MAAM,YACN,MAAM,GAEL,MAAM,CAIjB;IAED;;;;OAIG;IACH,mBAHW,MAAM,YACN,MAAM,gBAIhB;;CACJ"} -------------------------------------------------------------------------------- /types/helpers/resources/VersionsHelper.d.ts: -------------------------------------------------------------------------------- 1 | export type Version = { 2 | version_id: number; 3 | update_id: number; 4 | name: string; 5 | release_date: number; 6 | download_count: number; 7 | }; 8 | /** 9 | * @typedef {object} Version 10 | * @property {number} version_id 11 | * @property {number} update_id 12 | * @property {string} name 13 | * @property {number} release_date 14 | * @property {number} download_count 15 | */ 16 | /** A helper type for resource version-related API endpoints. */ 17 | export class VersionsHelper { 18 | constructor(wrapper: any); 19 | /** List a page of versions for a given resource. 20 | * 21 | * @param {number} resourceId The identifier of the resource. 22 | * @param {SortOptions | undefined} sort An optional set of sort options. 23 | * 24 | * @return {Array} An array of raw data objects. 25 | */ 26 | list(resourceId: number, sort: SortOptions | undefined): Array; 27 | /** List all pages of versions for a given resource. 28 | * 29 | * @param {number} resourceId The identifier of the resource. 30 | * @param {SortOptions | undefined} sort An optional set of sort options. 31 | * 32 | * @return {Array} An array of raw data objects. 33 | */ 34 | listAll(resourceId: number, sort: SortOptions | undefined): Array; 35 | /** List multiple pages of versions for a given resource until a condition is no longer met. 36 | * 37 | * @param {number} resourceId The identifier of the resource. 38 | * @param {function(Version):boolean} shouldContinue A function which determines if further pages are requested. 39 | * @param {SortOptions | undefined} sort An optional set of sort options. 40 | * 41 | * @return {Array} An array of raw data objects. 42 | */ 43 | listUntil(resourceId: number, shouldContinue: (arg0: Version) => boolean, sort: SortOptions | undefined): Array; 44 | /** Fetch the latest version for a given resource. 45 | * 46 | * @param {number} resourceId The identifier of the resource. 47 | * 48 | * @return {Version} A raw data object. 49 | */ 50 | latest(resourceId: number): Version; 51 | /** Fetch a version for a given resource. 52 | * 53 | * @param {number} resourceId The identifier of the resource. 54 | * @param {number} versionId The identifier of the version. 55 | * 56 | * @return {Version} A raw data object. 57 | */ 58 | fetch(resourceId: number, versionId: number): Version; 59 | /** Delete a version for a given resource. 60 | * 61 | * @param {number} resourceId The identifier of the resource. 62 | * @param {number} versionId The identifier of the version. 63 | */ 64 | delete(resourceId: number, versionId: number): Promise; 65 | #private; 66 | } 67 | import { SortOptions } from "../../SortOptions"; 68 | //# sourceMappingURL=VersionsHelper.d.ts.map -------------------------------------------------------------------------------- /types/helpers/resources/VersionsHelper.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"VersionsHelper.d.ts","sourceRoot":"","sources":["../../../src/helpers/resources/VersionsHelper.js"],"names":[],"mappings":";gBAOc,MAAM;eACN,MAAM;UACN,MAAM;kBACN,MAAM;oBACN,MAAM;;AANpB;;;;;;;GAOG;AAEH,gEAAgE;AAChE;IAGI,0BAEC;IAED;;;;;;OAMG;IACH,iBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,OAAO,CAAC,CAIzB;IAED;;;;;;OAMG;IACH,oBALW,MAAM,QACN,WAAW,GAAG,SAAS,GAEtB,MAAM,OAAO,CAAC,CAIzB;IAED;;;;;;;OAOG;IACH,sBANW,MAAM,yBACG,OAAO,KAAE,OAAO,QACzB,WAAW,GAAG,SAAS,GAEtB,MAAM,OAAO,CAAC,CAIzB;IAED;;;;;OAKG;IACH,mBAJW,MAAM,GAEL,OAAO,CAIlB;IAED;;;;;;OAMG;IACH,kBALW,MAAM,aACN,MAAM,GAEL,OAAO,CAIlB;IAED;;;;OAIG;IACH,mBAHW,MAAM,aACN,MAAM,gBAIhB;;CACJ"} -------------------------------------------------------------------------------- /types/index.d.ts: -------------------------------------------------------------------------------- 1 | export const Token: typeof import("./Token.js").Token; 2 | export const TokenType: typeof import("./TokenType.js").TokenType; 3 | export const SortOptions: typeof import("./SortOptions.js").SortOptions; 4 | export const Http: typeof import("./Http.js").Http; 5 | export const APIError: typeof import("./APIError.js").APIError; 6 | export const Wrapper: typeof import("./Wrapper.js").Wrapper; 7 | export const AlertsHelper: typeof import("./helpers/AlertsHelper.js").AlertsHelper; 8 | export const ConversationsHelper: typeof import("./helpers/ConversationsHelper.js").ConversationsHelper; 9 | export const ThreadsHelper: typeof import("./helpers/ThreadsHelper.js").ThreadsHelper; 10 | export const MembersHelper: typeof import("./helpers/members/MembersHelper.js").MembersHelper; 11 | export const ProfilePostsHelper: typeof import("./helpers/members/ProfilePostsHelper.js").ProfilePostsHelper; 12 | export const ResourcesHelper: typeof import("./helpers/resources/ResourcesHelper.js").ResourcesHelper; 13 | export const DownloadsHelper: typeof import("./helpers/resources/DownloadsHelper.js").DownloadsHelper; 14 | export const LicensesHelper: typeof import("./helpers/resources/LicensesHelper.js").LicensesHelper; 15 | export const PurchasesHelper: typeof import("./helpers/resources/PurchasesHelper.js").PurchasesHelper; 16 | export const ReviewsHelper: typeof import("./helpers/resources/ReviewsHelper.js").ReviewsHelper; 17 | export const UpdatesHelper: typeof import("./helpers/resources/UpdatesHelper.js").UpdatesHelper; 18 | export const VersionsHelper: typeof import("./helpers/resources/VersionsHelper.js").VersionsHelper; 19 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""} --------------------------------------------------------------------------------