Skip to content

Commit ad6e081

Browse files
feat(client)!: breaking change to re-use types
A number of types that were previously defined in-line at each call site have now been declared as shareable types. This has the benefit of greatly reducing the number of duplicated definitions of the same types, but is also a breaking change since these types will be moving to a shared single definition. A summary of the new types is below: Billing Configuration Models - Address - BillingCycleAnchorConfiguration - BillingCycleConfiguration - FixedFeeQuantityScheduleEntry - FixedFeeQuantityTransition - CustomExpiration - SubLineItemGrouping Pricing Models (Base) - Price - PriceUnitPrice - PricePackagePrice - PriceMatrixPrice - PriceTieredPrice - PriceTieredBPSPrice - PriceBPSPrice - PriceBulkBPSPrice - PriceBulkPrice - PriceInterval Advanced Pricing Models - PriceThresholdTotalAmountPrice - PriceTieredPackagePrice - PriceTieredWithMinimumPrice - PricePackageWithAllocationPrice - PriceMatrixWithAllocationPrice - PriceTieredWithProrationPrice - PriceUnitWithProrationPrice - PriceGroupedAllocationPrice - PriceMatrixWithDisplayNamePrice Discount and Adjustment Models - AmountDiscount - PercentageDiscount - UsageDiscount - TrialDiscount - Discount - CouponRedemption (formerly SubscriptionRedeemedCoupon) - TransformPriceFilter - AdjustmentInterval - AdjustmentIntervalAdjustment Monetary Adjustment Models - MonetaryAmountDiscountAdjustment - MonetaryMaximumAdjustment - MonetaryMinimumAdjustment - MonetaryPercentageDiscountAdjustment - MonetaryUsageDiscountAdjustment Plan Phase Adjustment Models - PlanPhaseAmountDiscountAdjustment - PlanPhaseMaximumAdjustment - PlanPhaseMinimumAdjustment - PlanPhasePercentageDiscountAdjustment - PlanPhaseUsageDiscountAdjustment Limit Models - Maximum (formerly PlanMaximum) - Minimum (formerly PlanMinimum) - MinimumInterval (formerly SubscriptionMinimumInterval) - MaximumInterval (formerly SubscriptionMaximumInterval) Cost and Allocation Models - AggregatedCost - PerPriceCost - Allocation - SubscriptionTrialInfo Configuration Parameter Models - BPSConfigParam - BulkBPSConfigParam - BulkConfigParam - MatrixConfigParam - PackageConfigParam - TieredBPSConfigParam - TieredConfigParam - UnitConfigParam Reference Models - CustomerMinified - SubscriptionMinified - InvoiceTiny - CreditNoteTiny - ItemSlim - BillableMetricTiny - TaxAmount Dimensional Pricing Models - DimensionalPriceConfiguration - MatrixValue
1 parent 0907df6 commit ad6e081

503 files changed

Lines changed: 241379 additions & 1482718 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 115
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-fee4c7438579fd72ae7c08ad11cc502da279ad3cccfe2235b18afcacc91ad0d9.yml
33
openapi_spec_hash: dc9d553a388715ba22d873aee54a3ed1
4-
config_hash: 1e2186b09e57d7d27b6ab5c8e6410b31
4+
config_hash: 38d4539e31b962c34d7ceb224b161855

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,11 @@ To set undocumented parameters on _nested_ headers, query params, or body classe
486486

487487
```java
488488
import com.withorb.api.core.JsonValue;
489+
import com.withorb.api.models.AddressInput;
489490
import com.withorb.api.models.CustomerCreateParams;
490491

491492
CustomerCreateParams params = CustomerCreateParams.builder()
492-
.billingAddress(CustomerCreateParams.BillingAddress.builder()
493+
.billingAddress(AddressInput.builder()
493494
.putAdditionalProperty("secretProperty", JsonValue.from("42"))
494495
.build())
495496
.build();
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.withorb.api.models
4+
5+
import com.fasterxml.jackson.annotation.JsonAnyGetter
6+
import com.fasterxml.jackson.annotation.JsonAnySetter
7+
import com.fasterxml.jackson.annotation.JsonCreator
8+
import com.fasterxml.jackson.annotation.JsonProperty
9+
import com.withorb.api.core.ExcludeMissing
10+
import com.withorb.api.core.JsonField
11+
import com.withorb.api.core.JsonMissing
12+
import com.withorb.api.core.JsonValue
13+
import com.withorb.api.core.checkRequired
14+
import com.withorb.api.errors.OrbInvalidDataException
15+
import java.util.Collections
16+
import java.util.Objects
17+
18+
class AccountingProviderConfig
19+
private constructor(
20+
private val externalProviderId: JsonField<String>,
21+
private val providerType: JsonField<String>,
22+
private val additionalProperties: MutableMap<String, JsonValue>,
23+
) {
24+
25+
@JsonCreator
26+
private constructor(
27+
@JsonProperty("external_provider_id")
28+
@ExcludeMissing
29+
externalProviderId: JsonField<String> = JsonMissing.of(),
30+
@JsonProperty("provider_type")
31+
@ExcludeMissing
32+
providerType: JsonField<String> = JsonMissing.of(),
33+
) : this(externalProviderId, providerType, mutableMapOf())
34+
35+
/**
36+
* @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly
37+
* missing or null (e.g. if the server responded with an unexpected value).
38+
*/
39+
fun externalProviderId(): String = externalProviderId.getRequired("external_provider_id")
40+
41+
/**
42+
* @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly
43+
* missing or null (e.g. if the server responded with an unexpected value).
44+
*/
45+
fun providerType(): String = providerType.getRequired("provider_type")
46+
47+
/**
48+
* Returns the raw JSON value of [externalProviderId].
49+
*
50+
* Unlike [externalProviderId], this method doesn't throw if the JSON field has an unexpected
51+
* type.
52+
*/
53+
@JsonProperty("external_provider_id")
54+
@ExcludeMissing
55+
fun _externalProviderId(): JsonField<String> = externalProviderId
56+
57+
/**
58+
* Returns the raw JSON value of [providerType].
59+
*
60+
* Unlike [providerType], this method doesn't throw if the JSON field has an unexpected type.
61+
*/
62+
@JsonProperty("provider_type")
63+
@ExcludeMissing
64+
fun _providerType(): JsonField<String> = providerType
65+
66+
@JsonAnySetter
67+
private fun putAdditionalProperty(key: String, value: JsonValue) {
68+
additionalProperties.put(key, value)
69+
}
70+
71+
@JsonAnyGetter
72+
@ExcludeMissing
73+
fun _additionalProperties(): Map<String, JsonValue> =
74+
Collections.unmodifiableMap(additionalProperties)
75+
76+
fun toBuilder() = Builder().from(this)
77+
78+
companion object {
79+
80+
/**
81+
* Returns a mutable builder for constructing an instance of [AccountingProviderConfig].
82+
*
83+
* The following fields are required:
84+
* ```java
85+
* .externalProviderId()
86+
* .providerType()
87+
* ```
88+
*/
89+
@JvmStatic fun builder() = Builder()
90+
}
91+
92+
/** A builder for [AccountingProviderConfig]. */
93+
class Builder internal constructor() {
94+
95+
private var externalProviderId: JsonField<String>? = null
96+
private var providerType: JsonField<String>? = null
97+
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
98+
99+
@JvmSynthetic
100+
internal fun from(accountingProviderConfig: AccountingProviderConfig) = apply {
101+
externalProviderId = accountingProviderConfig.externalProviderId
102+
providerType = accountingProviderConfig.providerType
103+
additionalProperties = accountingProviderConfig.additionalProperties.toMutableMap()
104+
}
105+
106+
fun externalProviderId(externalProviderId: String) =
107+
externalProviderId(JsonField.of(externalProviderId))
108+
109+
/**
110+
* Sets [Builder.externalProviderId] to an arbitrary JSON value.
111+
*
112+
* You should usually call [Builder.externalProviderId] with a well-typed [String] value
113+
* instead. This method is primarily for setting the field to an undocumented or not yet
114+
* supported value.
115+
*/
116+
fun externalProviderId(externalProviderId: JsonField<String>) = apply {
117+
this.externalProviderId = externalProviderId
118+
}
119+
120+
fun providerType(providerType: String) = providerType(JsonField.of(providerType))
121+
122+
/**
123+
* Sets [Builder.providerType] to an arbitrary JSON value.
124+
*
125+
* You should usually call [Builder.providerType] with a well-typed [String] value instead.
126+
* This method is primarily for setting the field to an undocumented or not yet supported
127+
* value.
128+
*/
129+
fun providerType(providerType: JsonField<String>) = apply {
130+
this.providerType = providerType
131+
}
132+
133+
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
134+
this.additionalProperties.clear()
135+
putAllAdditionalProperties(additionalProperties)
136+
}
137+
138+
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
139+
additionalProperties.put(key, value)
140+
}
141+
142+
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
143+
this.additionalProperties.putAll(additionalProperties)
144+
}
145+
146+
fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
147+
148+
fun removeAllAdditionalProperties(keys: Set<String>) = apply {
149+
keys.forEach(::removeAdditionalProperty)
150+
}
151+
152+
/**
153+
* Returns an immutable instance of [AccountingProviderConfig].
154+
*
155+
* Further updates to this [Builder] will not mutate the returned instance.
156+
*
157+
* The following fields are required:
158+
* ```java
159+
* .externalProviderId()
160+
* .providerType()
161+
* ```
162+
*
163+
* @throws IllegalStateException if any required field is unset.
164+
*/
165+
fun build(): AccountingProviderConfig =
166+
AccountingProviderConfig(
167+
checkRequired("externalProviderId", externalProviderId),
168+
checkRequired("providerType", providerType),
169+
additionalProperties.toMutableMap(),
170+
)
171+
}
172+
173+
private var validated: Boolean = false
174+
175+
fun validate(): AccountingProviderConfig = apply {
176+
if (validated) {
177+
return@apply
178+
}
179+
180+
externalProviderId()
181+
providerType()
182+
validated = true
183+
}
184+
185+
fun isValid(): Boolean =
186+
try {
187+
validate()
188+
true
189+
} catch (e: OrbInvalidDataException) {
190+
false
191+
}
192+
193+
/**
194+
* Returns a score indicating how many valid values are contained in this object recursively.
195+
*
196+
* Used for best match union deserialization.
197+
*/
198+
@JvmSynthetic
199+
internal fun validity(): Int =
200+
(if (externalProviderId.asKnown().isPresent) 1 else 0) +
201+
(if (providerType.asKnown().isPresent) 1 else 0)
202+
203+
override fun equals(other: Any?): Boolean {
204+
if (this === other) {
205+
return true
206+
}
207+
208+
return /* spotless:off */ other is AccountingProviderConfig && externalProviderId == other.externalProviderId && providerType == other.providerType && additionalProperties == other.additionalProperties /* spotless:on */
209+
}
210+
211+
/* spotless:off */
212+
private val hashCode: Int by lazy { Objects.hash(externalProviderId, providerType, additionalProperties) }
213+
/* spotless:on */
214+
215+
override fun hashCode(): Int = hashCode
216+
217+
override fun toString() =
218+
"AccountingProviderConfig{externalProviderId=$externalProviderId, providerType=$providerType, additionalProperties=$additionalProperties}"
219+
}

0 commit comments

Comments
 (0)