From dae94079c4d600c7ac536ed9cd401f0d99d81661 Mon Sep 17 00:00:00 2001 From: Mikhail Shagvaliev Date: Tue, 13 Aug 2024 20:35:09 +0200 Subject: [PATCH] [kotlin-client] Add licenses API example --- .../qodana/cloudclient/examples/gift.kt | 49 +++++++++++++++++++ .../cloudclient/examples/qodana-example.kt | 25 ++++++++++ 2 files changed, 74 insertions(+) create mode 100644 kotlin/src/main/kotlin/org/jetbrains/qodana/cloudclient/examples/gift.kt create mode 100644 kotlin/src/main/kotlin/org/jetbrains/qodana/cloudclient/examples/qodana-example.kt diff --git a/kotlin/src/main/kotlin/org/jetbrains/qodana/cloudclient/examples/gift.kt b/kotlin/src/main/kotlin/org/jetbrains/qodana/cloudclient/examples/gift.kt new file mode 100644 index 0000000..67607d1 --- /dev/null +++ b/kotlin/src/main/kotlin/org/jetbrains/qodana/cloudclient/examples/gift.kt @@ -0,0 +1,49 @@ +@file:Suppress("UNUSED_PARAMETER", "unused", "UnusedReceiverParameter") + +package org.jetbrains.qodana.cloudclient.examples + +internal class QodanaPage(val url: String) + +internal fun QodanaPage.buyUltimatePlus(): BuyPage { + return BuyPage() +} + +internal class BuyPage + +internal fun BuyPage.applyAnnualDiscountForThreeContributors(discountCode: String) { +} + +internal fun BuyPage.fillPaymentDetails() {} + +internal fun BuyPage.orderAndPay(): String { + return "" +} + +internal fun getQodanaCloudProjectToken(license: String): String { + return "token" +} + +internal fun analyzeRepository(url: String, qodanaLicense: String, block: AnalyzeRepository.() -> Unit): AnalyzeRepository { + return AnalyzeRepository(url, qodanaLicense) +} + +internal class AnalyzeRepository(val url: String, qodanaLicense: String) { + fun checkLicensesCompliance() { + } + + fun checkVulnerabilities() { + } + + fun checkCodeStyle() { + } + + fun checkBugs() { + + } + + fun checkCoverage() { + } + + fun setQualityGate() { + } +} diff --git a/kotlin/src/main/kotlin/org/jetbrains/qodana/cloudclient/examples/qodana-example.kt b/kotlin/src/main/kotlin/org/jetbrains/qodana/cloudclient/examples/qodana-example.kt new file mode 100644 index 0000000..2c5680b --- /dev/null +++ b/kotlin/src/main/kotlin/org/jetbrains/qodana/cloudclient/examples/qodana-example.kt @@ -0,0 +1,25 @@ +package org.jetbrains.qodana.cloudclient.examples + +@Suppress("unused") +internal fun licenseApiExample() { + val qodanaPage = QodanaPage("https://www.jetbrains.com/qodana/") + val buyPage = qodanaPage.buyUltimatePlus() + + val qodanaFullDiscountCoupon = "xoxp-12345678901-987654321012-987654321012-1234123412341234567890abcdef12345" + buyPage.applyAnnualDiscountForThreeContributors(qodanaFullDiscountCoupon) + buyPage.fillPaymentDetails() + val qodanaLicense = buyPage.orderAndPay() +} + +private fun enjoy(qodanaLicense: String) { + val token = getQodanaCloudProjectToken(qodanaLicense) + analyzeRepository("https://github.com/my-project", token) { + checkLicensesCompliance() + checkVulnerabilities() + checkCodeStyle() + checkCoverage() + checkBugs() + + setQualityGate() + } +}