diff --git a/package-lock.json b/package-lock.json index 9f1642ad..06e579f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "integration-test" ], "dependencies": { - "@autifyhq/autify-sdk": "^0.18.0", + "@autifyhq/autify-sdk": "^0.19.0", "@oclif/core": "^2.15.0", "@oclif/errors": "^1.3.6", "@oclif/plugin-help": "^5.2.20", @@ -138,9 +138,9 @@ "link": true }, "node_modules/@autifyhq/autify-sdk": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@autifyhq/autify-sdk/-/autify-sdk-0.18.0.tgz", - "integrity": "sha512-Gh/DYowTAyrMSZOVSG09bqfRjyYtH8nvJMUoxKycG3eb6w3CWuhwh6mg2Rzm02KKqOi1nb/bBs0E4/283rhrFw==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/@autifyhq/autify-sdk/-/autify-sdk-0.19.0.tgz", + "integrity": "sha512-WljlVPEYhYS7kpk7q53QcdNle7rdVqn54JQaeiNL6fmQCyYGzYGXpw6gqVstVjwZxge37Aznea0FmIat/69bzQ==", "dependencies": { "axios": "^1.2.2", "axios-logger": "^2.7.0", @@ -13502,9 +13502,9 @@ } }, "@autifyhq/autify-sdk": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@autifyhq/autify-sdk/-/autify-sdk-0.18.0.tgz", - "integrity": "sha512-Gh/DYowTAyrMSZOVSG09bqfRjyYtH8nvJMUoxKycG3eb6w3CWuhwh6mg2Rzm02KKqOi1nb/bBs0E4/283rhrFw==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/@autifyhq/autify-sdk/-/autify-sdk-0.19.0.tgz", + "integrity": "sha512-WljlVPEYhYS7kpk7q53QcdNle7rdVqn54JQaeiNL6fmQCyYGzYGXpw6gqVstVjwZxge37Aznea0FmIat/69bzQ==", "requires": { "axios": "^1.2.2", "axios-logger": "^2.7.0", diff --git a/package.json b/package.json index 59dcbb69..a1dfb1e4 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "/oclif.manifest.json" ], "dependencies": { - "@autifyhq/autify-sdk": "^0.18.0", + "@autifyhq/autify-sdk": "^0.19.0", "@oclif/core": "^2.15.0", "@oclif/errors": "^1.3.6", "@oclif/plugin-help": "^5.2.20", diff --git a/src/commands/web/api/get-credit-usage.ts b/src/commands/web/api/get-credit-usage.ts new file mode 100644 index 00000000..8b798872 --- /dev/null +++ b/src/commands/web/api/get-credit-usage.ts @@ -0,0 +1,54 @@ +import { Command, Flags } from "@oclif/core"; +import { getWebClient } from "../../../autify/web/getWebClient"; + +export default class WebApiGetCreditUsage extends Command { + static description = + "Get the number of credits used in the project\\ \\ Notes:\\ This endpoint works only for organizations on credit-based plans. It always returns 0 for `credits_consumed` and `credit_consumption_event_count` if your organization is on a run-based plan."; + + static examples = ["<%= config.bin %> <%= command.id %>"]; + + static flags = { + "project-id": Flags.integer({ + description: + "For example, 1 for the following URL: https://app.autify.com/projects/1/credits", + required: true, + }), + "date-from": Flags.string({ + description: + "The date to start counting used credits from.\\ If not specified, the date will be set to 1 week ago.\\ Up to 90 days in advance can be specified. If the specified date is more than 90 days in the past, the date will be set to 90 days ago.\\ Date must follow the format YYYY-MM-DD (example: "2023-09-21").", + required: false, + }), + "date-to": Flags.string({ + description: + "The date to end counting used credits from.\\ If not specified, the date will be set to today.\\ Date must follow the format YYYY-MM-DD (example: "2023-09-28").", + required: false, + }), + "scenario-id": Flags.integer({ + description: "The scenario ID to filter used credits by.", + required: false, + }), + "test-plan-id": Flags.integer({ + description: "The test plan ID to filter used credits by.", + required: false, + }), + "user-id": Flags.integer({ + description: "The user ID that executed tests to filter used credits by.", + required: false, + }), + }; + + public async run(): Promise { + const { flags } = await this.parse(WebApiGetCreditUsage); + const { configDir, userAgent } = this.config; + const client = getWebClient(configDir, userAgent); + const res = await client.getCreditUsage( + flags["project-id"], + flags["date-from"], + flags["date-to"], + flags["scenario-id"], + flags["test-plan-id"], + flags["user-id"] + ); + console.log(JSON.stringify(res.data, null, 2)); + } +} diff --git a/src/commands/web/api/get-project-info.ts b/src/commands/web/api/get-project-info.ts new file mode 100644 index 00000000..d06c8921 --- /dev/null +++ b/src/commands/web/api/get-project-info.ts @@ -0,0 +1,24 @@ +import { Command, Flags } from "@oclif/core"; +import { getWebClient } from "../../../autify/web/getWebClient"; + +export default class WebApiGetProjectInfo extends Command { + static description = "Get project information."; + + static examples = ["<%= config.bin %> <%= command.id %>"]; + + static flags = { + "project-id": Flags.integer({ + description: + "For example, 1 for the following URL: https://app.autify.com/projects/1/project_info", + required: true, + }), + }; + + public async run(): Promise { + const { flags } = await this.parse(WebApiGetProjectInfo); + const { configDir, userAgent } = this.config; + const client = getWebClient(configDir, userAgent); + const res = await client.getProjectInfo(flags["project-id"]); + console.log(JSON.stringify(res.data, null, 2)); + } +}