-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[kotlin-client] Add licenses API example
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
kotlin/src/main/kotlin/org/jetbrains/qodana/cloudclient/examples/gift.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() { | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
kotlin/src/main/kotlin/org/jetbrains/qodana/cloudclient/examples/qodana-example.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |