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 .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 95
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-2d3a73c9f2d68452fa3b7bcaa9385e312d042383f15cad982657a32c72197126.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-ba6405a18533c3a25d39dd75a279ef46ce41d33d478441376ecd3ebd54f9088c.yml
5 changes: 2 additions & 3 deletions orb-java-core/src/main/kotlin/com/withorb/api/core/Values.kt
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,8 @@ internal constructor(
}
}

override fun toString(): String {
return "MultipartFormValue(name='$name', contentType=$contentType, filename=$filename, value=${valueToString()})"
}
override fun toString(): String =
"MultipartFormValue{name=$name, contentType=$contentType, filename=$filename, value=${valueToString()}}"

private fun valueToString(): String =
when (value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private constructor(
) {

override fun toString(): String =
"HttpRequest {method=$method, pathSegments=$pathSegments, queryParams=$queryParams, headers=$headers, body=$body}"
"HttpRequest{method=$method, pathSegments=$pathSegments, queryParams=$queryParams, headers=$headers, body=$body}"

companion object {
@JvmStatic fun builder() = Builder()
Expand Down
22 changes: 16 additions & 6 deletions orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.withorb.api.errors.OrbInvalidDataException
import java.time.OffsetDateTime
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

/**
* A coupon represents a reusable discount configuration that can be applied either as a fixed or
Expand Down Expand Up @@ -388,14 +389,23 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Discount {
val json = JsonValue.fromJsonNode(node)
tryDeserialize(node, jacksonTypeRef<PercentageDiscount>()) { it.validate() }
?.let {
return Discount(percentageDiscount = it, _json = json)
val discountType =
json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull()

when (discountType) {
"percentage" -> {
tryDeserialize(node, jacksonTypeRef<PercentageDiscount>()) { it.validate() }
?.let {
return Discount(percentageDiscount = it, _json = json)
}
}
tryDeserialize(node, jacksonTypeRef<AmountDiscount>()) { it.validate() }
?.let {
return Discount(amountDiscount = it, _json = json)
"amount" -> {
tryDeserialize(node, jacksonTypeRef<AmountDiscount>()) { it.validate() }
?.let {
return Discount(amountDiscount = it, _json = json)
}
}
}

return Discount(_json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.withorb.api.errors.OrbInvalidDataException
import com.withorb.api.models.*
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

class CouponCreateParams
constructor(
Expand Down Expand Up @@ -435,16 +436,27 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Discount {
val json = JsonValue.fromJsonNode(node)
tryDeserialize(node, jacksonTypeRef<NewCouponPercentageDiscount>()) {
it.validate()
val discountType =
json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull()

when (discountType) {
"percentage" -> {
tryDeserialize(node, jacksonTypeRef<NewCouponPercentageDiscount>()) {
it.validate()
}
?.let {
return Discount(newCouponPercentageDiscount = it, _json = json)
}
}
?.let {
return Discount(newCouponPercentageDiscount = it, _json = json)
}
tryDeserialize(node, jacksonTypeRef<NewCouponAmountDiscount>()) { it.validate() }
?.let {
return Discount(newCouponAmountDiscount = it, _json = json)
"amount" -> {
tryDeserialize(node, jacksonTypeRef<NewCouponAmountDiscount>()) {
it.validate()
}
?.let {
return Discount(newCouponAmountDiscount = it, _json = json)
}
}
}

return Discount(_json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.withorb.api.errors.OrbInvalidDataException
import com.withorb.api.models.*
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

class CustomerCreateParams
constructor(
Expand Down Expand Up @@ -1767,14 +1768,30 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): TaxConfiguration {
val json = JsonValue.fromJsonNode(node)
tryDeserialize(node, jacksonTypeRef<NewAvalaraTaxConfiguration>()) { it.validate() }
?.let {
return TaxConfiguration(newAvalaraTaxConfiguration = it, _json = json)
val taxProvider =
json.asObject().getOrNull()?.get("tax_provider")?.asString()?.getOrNull()

when (taxProvider) {
"avalara" -> {
tryDeserialize(node, jacksonTypeRef<NewAvalaraTaxConfiguration>()) {
it.validate()
}
?.let {
return TaxConfiguration(
newAvalaraTaxConfiguration = it,
_json = json
)
}
}
tryDeserialize(node, jacksonTypeRef<NewTaxJarConfiguration>()) { it.validate() }
?.let {
return TaxConfiguration(newTaxJarConfiguration = it, _json = json)
"taxjar" -> {
tryDeserialize(node, jacksonTypeRef<NewTaxJarConfiguration>()) {
it.validate()
}
?.let {
return TaxConfiguration(newTaxJarConfiguration = it, _json = json)
}
}
}

return TaxConfiguration(_json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import java.time.LocalDate
import java.time.OffsetDateTime
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

class CustomerCreditLedgerCreateEntryByExternalIdParams
constructor(
Expand Down Expand Up @@ -326,43 +327,71 @@ constructor(
node: JsonNode
): CustomerCreditLedgerCreateEntryByExternalIdBody {
val json = JsonValue.fromJsonNode(node)
tryDeserialize(node, jacksonTypeRef<AddIncrementCreditLedgerEntryRequestParams>())
?.let {
return CustomerCreditLedgerCreateEntryByExternalIdBody(
addIncrementCreditLedgerEntryRequestParams = it,
_json = json
)
val entryType =
json.asObject().getOrNull()?.get("entry_type")?.asString()?.getOrNull()

when (entryType) {
"increment" -> {
tryDeserialize(
node,
jacksonTypeRef<AddIncrementCreditLedgerEntryRequestParams>()
)
?.let {
return CustomerCreditLedgerCreateEntryByExternalIdBody(
addIncrementCreditLedgerEntryRequestParams = it,
_json = json
)
}
}
tryDeserialize(node, jacksonTypeRef<AddDecrementCreditLedgerEntryRequestParams>())
?.let {
return CustomerCreditLedgerCreateEntryByExternalIdBody(
addDecrementCreditLedgerEntryRequestParams = it,
_json = json
)
"decrement" -> {
tryDeserialize(
node,
jacksonTypeRef<AddDecrementCreditLedgerEntryRequestParams>()
)
?.let {
return CustomerCreditLedgerCreateEntryByExternalIdBody(
addDecrementCreditLedgerEntryRequestParams = it,
_json = json
)
}
}
tryDeserialize(
node,
jacksonTypeRef<AddExpirationChangeCreditLedgerEntryRequestParams>()
)
?.let {
return CustomerCreditLedgerCreateEntryByExternalIdBody(
addExpirationChangeCreditLedgerEntryRequestParams = it,
_json = json
)
"expiration_change" -> {
tryDeserialize(
node,
jacksonTypeRef<AddExpirationChangeCreditLedgerEntryRequestParams>()
)
?.let {
return CustomerCreditLedgerCreateEntryByExternalIdBody(
addExpirationChangeCreditLedgerEntryRequestParams = it,
_json = json
)
}
}
tryDeserialize(node, jacksonTypeRef<AddVoidCreditLedgerEntryRequestParams>())?.let {
return CustomerCreditLedgerCreateEntryByExternalIdBody(
addVoidCreditLedgerEntryRequestParams = it,
_json = json
)
}
tryDeserialize(node, jacksonTypeRef<AddAmendmentCreditLedgerEntryRequestParams>())
?.let {
return CustomerCreditLedgerCreateEntryByExternalIdBody(
addAmendmentCreditLedgerEntryRequestParams = it,
_json = json
)
"void" -> {
tryDeserialize(
node,
jacksonTypeRef<AddVoidCreditLedgerEntryRequestParams>()
)
?.let {
return CustomerCreditLedgerCreateEntryByExternalIdBody(
addVoidCreditLedgerEntryRequestParams = it,
_json = json
)
}
}
"amendment" -> {
tryDeserialize(
node,
jacksonTypeRef<AddAmendmentCreditLedgerEntryRequestParams>()
)
?.let {
return CustomerCreditLedgerCreateEntryByExternalIdBody(
addAmendmentCreditLedgerEntryRequestParams = it,
_json = json
)
}
}
}

return CustomerCreditLedgerCreateEntryByExternalIdBody(_json = json)
}
Expand Down
Loading