Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.41.0"
".": "0.42.0"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.42.0 (2025-03-05)

Full Changelog: [v0.41.0...v0.42.0](https://github.com/orbcorp/orb-java/compare/v0.41.0...v0.42.0)

### Features

* **api:** manual updates ([#305](https://github.com/orbcorp/orb-java/issues/305)) ([14c52ec](https://github.com/orbcorp/orb-java/commit/14c52ecdb2cb3968fc4d7e387317b405dc2b8867))

## 0.41.0 (2025-03-05)

Full Changelog: [v0.40.0...v0.41.0](https://github.com/orbcorp/orb-java/compare/v0.40.0...v0.41.0)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.41.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.42.0)

<!-- x-release-please-end -->

Expand All @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho
### Gradle

```kotlin
implementation("com.withorb.api:orb-java:0.41.0")
implementation("com.withorb.api:orb-java:0.42.0")
```

### Maven
Expand All @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:0.41.0")
<dependency>
<groupId>com.withorb.api</groupId>
<artifactId>orb-java</artifactId>
<version>0.41.0</version>
<version>0.42.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
allprojects {
group = "com.withorb.api"
version = "0.41.0" // x-release-please-version
version = "0.42.0" // x-release-please-version
}
320 changes: 0 additions & 320 deletions orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

package com.withorb.api.models

import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.core.ObjectCodec
import com.fasterxml.jackson.databind.JsonNode
Expand All @@ -15,17 +11,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.withorb.api.core.BaseDeserializer
import com.withorb.api.core.BaseSerializer
import com.withorb.api.core.Enum
import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonField
import com.withorb.api.core.JsonMissing
import com.withorb.api.core.JsonValue
import com.withorb.api.core.NoAutoDetect
import com.withorb.api.core.checkKnown
import com.withorb.api.core.checkRequired
import com.withorb.api.core.getOrThrow
import com.withorb.api.core.immutableEmptyMap
import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
import java.util.Objects
import java.util.Optional
Expand Down Expand Up @@ -219,311 +206,4 @@ private constructor(
}
}
}

@NoAutoDetect
class UsageDiscount
@JsonCreator
private constructor(
@JsonProperty("applies_to_price_ids")
@ExcludeMissing
private val appliesToPriceIds: JsonField<List<String>> = JsonMissing.of(),
@JsonProperty("discount_type")
@ExcludeMissing
private val discountType: JsonField<DiscountType> = JsonMissing.of(),
@JsonProperty("usage_discount")
@ExcludeMissing
private val usageDiscount: JsonField<Double> = JsonMissing.of(),
@JsonProperty("reason")
@ExcludeMissing
private val reason: JsonField<String> = JsonMissing.of(),
@JsonAnySetter
private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
) {

/**
* List of price_ids that this discount applies to. For plan/plan phase discounts, this can
* be a subset of prices.
*/
fun appliesToPriceIds(): List<String> =
appliesToPriceIds.getRequired("applies_to_price_ids")

fun discountType(): DiscountType = discountType.getRequired("discount_type")

/**
* Only available if discount_type is `usage`. Number of usage units that this discount is
* for
*/
fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount")

fun reason(): Optional<String> = Optional.ofNullable(reason.getNullable("reason"))

/**
* List of price_ids that this discount applies to. For plan/plan phase discounts, this can
* be a subset of prices.
*/
@JsonProperty("applies_to_price_ids")
@ExcludeMissing
fun _appliesToPriceIds(): JsonField<List<String>> = appliesToPriceIds

@JsonProperty("discount_type")
@ExcludeMissing
fun _discountType(): JsonField<DiscountType> = discountType

/**
* Only available if discount_type is `usage`. Number of usage units that this discount is
* for
*/
@JsonProperty("usage_discount")
@ExcludeMissing
fun _usageDiscount(): JsonField<Double> = usageDiscount

@JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField<String> = reason

@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties

private var validated: Boolean = false

fun validate(): UsageDiscount = apply {
if (validated) {
return@apply
}

appliesToPriceIds()
discountType()
usageDiscount()
reason()
validated = true
}

fun toBuilder() = Builder().from(this)

companion object {

/**
* Returns a mutable builder for constructing an instance of [UsageDiscount].
*
* The following fields are required:
* ```java
* .appliesToPriceIds()
* .discountType()
* .usageDiscount()
* ```
*/
@JvmStatic fun builder() = Builder()
}

/** A builder for [UsageDiscount]. */
class Builder internal constructor() {

private var appliesToPriceIds: JsonField<MutableList<String>>? = null
private var discountType: JsonField<DiscountType>? = null
private var usageDiscount: JsonField<Double>? = null
private var reason: JsonField<String> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(usageDiscount: UsageDiscount) = apply {
appliesToPriceIds = usageDiscount.appliesToPriceIds.map { it.toMutableList() }
discountType = usageDiscount.discountType
this.usageDiscount = usageDiscount.usageDiscount
reason = usageDiscount.reason
additionalProperties = usageDiscount.additionalProperties.toMutableMap()
}

/**
* List of price_ids that this discount applies to. For plan/plan phase discounts, this
* can be a subset of prices.
*/
fun appliesToPriceIds(appliesToPriceIds: List<String>) =
appliesToPriceIds(JsonField.of(appliesToPriceIds))

/**
* List of price_ids that this discount applies to. For plan/plan phase discounts, this
* can be a subset of prices.
*/
fun appliesToPriceIds(appliesToPriceIds: JsonField<List<String>>) = apply {
this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() }
}

/**
* List of price_ids that this discount applies to. For plan/plan phase discounts, this
* can be a subset of prices.
*/
fun addAppliesToPriceId(appliesToPriceId: String) = apply {
appliesToPriceIds =
(appliesToPriceIds ?: JsonField.of(mutableListOf())).also {
checkKnown("appliesToPriceIds", it).add(appliesToPriceId)
}
}

fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType))

fun discountType(discountType: JsonField<DiscountType>) = apply {
this.discountType = discountType
}

/**
* Only available if discount_type is `usage`. Number of usage units that this discount
* is for
*/
fun usageDiscount(usageDiscount: Double) = usageDiscount(JsonField.of(usageDiscount))

/**
* Only available if discount_type is `usage`. Number of usage units that this discount
* is for
*/
fun usageDiscount(usageDiscount: JsonField<Double>) = apply {
this.usageDiscount = usageDiscount
}

fun reason(reason: String?) = reason(JsonField.ofNullable(reason))

fun reason(reason: Optional<String>) = reason(reason.orElse(null))

fun reason(reason: JsonField<String>) = apply { this.reason = reason }

fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
}

fun putAdditionalProperty(key: String, value: JsonValue) = apply {
additionalProperties.put(key, value)
}

fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.putAll(additionalProperties)
}

fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }

fun removeAllAdditionalProperties(keys: Set<String>) = apply {
keys.forEach(::removeAdditionalProperty)
}

fun build(): UsageDiscount =
UsageDiscount(
checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() },
checkRequired("discountType", discountType),
checkRequired("usageDiscount", usageDiscount),
reason,
additionalProperties.toImmutable(),
)
}

class DiscountType @JsonCreator private constructor(private val value: JsonField<String>) :
Enum {

/**
* Returns this class instance's raw value.
*
* This is usually only useful if this instance was deserialized from data that doesn't
* match any known member, and you want to know that value. For example, if the SDK is
* on an older version than the API, then the API may respond with new members that the
* SDK is unaware of.
*/
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value

companion object {

@JvmField val USAGE = of("usage")

@JvmStatic fun of(value: String) = DiscountType(JsonField.of(value))
}

/** An enum containing [DiscountType]'s known values. */
enum class Known {
USAGE
}

/**
* An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] member.
*
* An instance of [DiscountType] can contain an unknown value in a couple of cases:
* - It was deserialized from data that doesn't match any known member. For example, if
* the SDK is on an older version than the API, then the API may respond with new
* members that the SDK is unaware of.
* - It was constructed with an arbitrary value using the [of] method.
*/
enum class Value {
USAGE,
/**
* An enum member indicating that [DiscountType] was instantiated with an unknown
* value.
*/
_UNKNOWN,
}

/**
* Returns an enum member corresponding to this class instance's value, or
* [Value._UNKNOWN] if the class was instantiated with an unknown value.
*
* Use the [known] method instead if you're certain the value is always known or if you
* want to throw for the unknown case.
*/
fun value(): Value =
when (this) {
USAGE -> Value.USAGE
else -> Value._UNKNOWN
}

/**
* Returns an enum member corresponding to this class instance's value.
*
* Use the [value] method instead if you're uncertain the value is always known and
* don't want to throw for the unknown case.
*
* @throws OrbInvalidDataException if this class instance's value is a not a known
* member.
*/
fun known(): Known =
when (this) {
USAGE -> Known.USAGE
else -> throw OrbInvalidDataException("Unknown DiscountType: $value")
}

/**
* Returns this class instance's primitive wire representation.
*
* This differs from the [toString] method because that method is primarily for
* debugging and generally doesn't throw.
*
* @throws OrbInvalidDataException if this class instance's value does not have the
* expected primitive type.
*/
fun asString(): String =
_value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") }

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */
}

override fun hashCode() = value.hashCode()

override fun toString() = value.toString()
}

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is UsageDiscount && appliesToPriceIds == other.appliesToPriceIds && discountType == other.discountType && usageDiscount == other.usageDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */
}

/* spotless:off */
private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, discountType, usageDiscount, reason, additionalProperties) }
/* spotless:on */

override fun hashCode(): Int = hashCode

override fun toString() =
"UsageDiscount{appliesToPriceIds=$appliesToPriceIds, discountType=$discountType, usageDiscount=$usageDiscount, reason=$reason, additionalProperties=$additionalProperties}"
}
}
Loading
Loading