From 7acf12193b22057b5bf3db2eef5d8f17784bcd8f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 19:21:03 +0000 Subject: [PATCH] refactor(client): migrate pages to builder pattern --- .../com/withorb/api/models/AlertListPage.kt | 116 +++++++---- .../withorb/api/models/AlertListPageAsync.kt | 120 +++++++---- .../com/withorb/api/models/CouponListPage.kt | 112 +++++++--- .../withorb/api/models/CouponListPageAsync.kt | 116 ++++++++--- .../api/models/CouponSubscriptionListPage.kt | 113 +++++++--- .../models/CouponSubscriptionListPageAsync.kt | 117 ++++++++--- .../withorb/api/models/CreditNoteListPage.kt | 111 +++++++--- .../api/models/CreditNoteListPageAsync.kt | 114 +++++++--- .../CustomerBalanceTransactionListPage.kt | 137 ++++++++----- ...CustomerBalanceTransactionListPageAsync.kt | 140 ++++++++----- ...ustomerCreditLedgerListByExternalIdPage.kt | 191 ++++++++--------- ...erCreditLedgerListByExternalIdPageAsync.kt | 194 ++++++++---------- .../models/CustomerCreditLedgerListPage.kt | 186 ++++++++--------- .../CustomerCreditLedgerListPageAsync.kt | 190 ++++++++--------- .../CustomerCreditListByExternalIdPage.kt | 120 +++++++---- ...CustomerCreditListByExternalIdPageAsync.kt | 123 +++++++---- .../api/models/CustomerCreditListPage.kt | 116 +++++++---- .../api/models/CustomerCreditListPageAsync.kt | 118 +++++++---- ...CustomerCreditTopUpListByExternalIdPage.kt | 115 ++++++++--- ...merCreditTopUpListByExternalIdPageAsync.kt | 118 ++++++++--- .../api/models/CustomerCreditTopUpListPage.kt | 110 +++++++--- .../CustomerCreditTopUpListPageAsync.kt | 114 +++++++--- .../withorb/api/models/CustomerListPage.kt | 113 +++++++--- .../api/models/CustomerListPageAsync.kt | 116 ++++++++--- .../models/DimensionalPriceGroupListPage.kt | 109 +++++++--- .../DimensionalPriceGroupListPageAsync.kt | 112 +++++++--- .../api/models/EventBackfillListPage.kt | 115 ++++++++--- .../api/models/EventBackfillListPageAsync.kt | 117 +++++++---- .../com/withorb/api/models/InvoiceListPage.kt | 120 +++++++---- .../api/models/InvoiceListPageAsync.kt | 123 +++++++---- .../com/withorb/api/models/ItemListPage.kt | 103 +++++++--- .../withorb/api/models/ItemListPageAsync.kt | 110 +++++++--- .../com/withorb/api/models/MetricListPage.kt | 109 +++++++--- .../withorb/api/models/MetricListPageAsync.kt | 113 +++++++--- .../com/withorb/api/models/PlanListPage.kt | 108 +++++++--- .../withorb/api/models/PlanListPageAsync.kt | 115 ++++++++--- .../com/withorb/api/models/PriceListPage.kt | 109 +++++++--- .../withorb/api/models/PriceListPageAsync.kt | 113 +++++++--- .../models/SubscriptionFetchSchedulePage.kt | 115 ++++++++--- .../SubscriptionFetchSchedulePageAsync.kt | 118 ++++++++--- .../api/models/SubscriptionListPage.kt | 116 +++++++---- .../api/models/SubscriptionListPageAsync.kt | 119 +++++++---- .../services/async/AlertServiceAsyncImpl.kt | 10 +- .../services/async/CouponServiceAsyncImpl.kt | 10 +- .../async/CreditNoteServiceAsyncImpl.kt | 10 +- .../async/CustomerServiceAsyncImpl.kt | 10 +- .../DimensionalPriceGroupServiceAsyncImpl.kt | 10 +- .../services/async/InvoiceServiceAsyncImpl.kt | 10 +- .../services/async/ItemServiceAsyncImpl.kt | 10 +- .../services/async/MetricServiceAsyncImpl.kt | 10 +- .../services/async/PlanServiceAsyncImpl.kt | 10 +- .../services/async/PriceServiceAsyncImpl.kt | 10 +- .../async/SubscriptionServiceAsyncImpl.kt | 20 +- .../coupons/SubscriptionServiceAsyncImpl.kt | 10 +- .../BalanceTransactionServiceAsyncImpl.kt | 10 +- .../async/customers/CreditServiceAsyncImpl.kt | 20 +- .../credits/LedgerServiceAsyncImpl.kt | 20 +- .../credits/TopUpServiceAsyncImpl.kt | 20 +- .../async/events/BackfillServiceAsyncImpl.kt | 10 +- .../api/services/blocking/AlertServiceImpl.kt | 8 +- .../services/blocking/CouponServiceImpl.kt | 8 +- .../blocking/CreditNoteServiceImpl.kt | 8 +- .../services/blocking/CustomerServiceImpl.kt | 8 +- .../DimensionalPriceGroupServiceImpl.kt | 10 +- .../services/blocking/InvoiceServiceImpl.kt | 8 +- .../api/services/blocking/ItemServiceImpl.kt | 8 +- .../services/blocking/MetricServiceImpl.kt | 8 +- .../api/services/blocking/PlanServiceImpl.kt | 8 +- .../api/services/blocking/PriceServiceImpl.kt | 8 +- .../blocking/SubscriptionServiceImpl.kt | 16 +- .../coupons/SubscriptionServiceImpl.kt | 10 +- .../BalanceTransactionServiceImpl.kt | 10 +- .../blocking/customers/CreditServiceImpl.kt | 18 +- .../customers/credits/LedgerServiceImpl.kt | 20 +- .../customers/credits/TopUpServiceImpl.kt | 16 +- .../blocking/events/BackfillServiceImpl.kt | 6 +- 76 files changed, 3709 insertions(+), 1843 deletions(-) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt index 968452486..e34c1eaf8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.AlertService import java.util.Objects import java.util.Optional @@ -9,27 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of alerts within Orb. - * - * The request must specify one of `customer_id`, `external_customer_id`, or `subscription_id`. - * - * If querying by subscripion_id, the endpoint will return the subscription level alerts as well as - * the plan level alerts associated with the subscription. - * - * The list of alerts is ordered starting from the most recently created alert. This endpoint - * follows Orb's [standardized pagination format](/api-reference/pagination). - */ +/** @see [AlertService.list] */ class AlertListPage private constructor( - private val alertsService: AlertService, + private val service: AlertService, private val params: AlertListParams, private val response: AlertListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): AlertListPageResponse = response - /** * Delegates to [AlertListPageResponse], but gracefully handles missing data. * @@ -45,19 +33,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AlertListPage && alertsService == other.alertsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(alertsService, params, response) /* spotless:on */ - - override fun toString() = - "AlertListPage{alertsService=$alertsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -79,20 +54,75 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { alertsService.list(it) } - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): AlertListParams = params + + /** The response that this page was parsed from. */ + fun response(): AlertListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - alertsService: AlertService, - params: AlertListParams, - response: AlertListPageResponse, - ) = AlertListPage(alertsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [AlertListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertListPage]. */ + class Builder internal constructor() { + + private var service: AlertService? = null + private var params: AlertListParams? = null + private var response: AlertListPageResponse? = null + + @JvmSynthetic + internal fun from(alertListPage: AlertListPage) = apply { + service = alertListPage.service + params = alertListPage.params + response = alertListPage.response + } + + fun service(service: AlertService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: AlertListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: AlertListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [AlertListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AlertListPage = + AlertListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: AlertListPage) : Iterable { @@ -113,4 +143,16 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AlertListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = "AlertListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt index 8d822c7e0..8a37ce8d4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.AlertServiceAsync import java.util.Objects import java.util.Optional @@ -10,27 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of alerts within Orb. - * - * The request must specify one of `customer_id`, `external_customer_id`, or `subscription_id`. - * - * If querying by subscripion_id, the endpoint will return the subscription level alerts as well as - * the plan level alerts associated with the subscription. - * - * The list of alerts is ordered starting from the most recently created alert. This endpoint - * follows Orb's [standardized pagination format](/api-reference/pagination). - */ +/** @see [AlertServiceAsync.list] */ class AlertListPageAsync private constructor( - private val alertsService: AlertServiceAsync, + private val service: AlertServiceAsync, private val params: AlertListParams, private val response: AlertListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): AlertListPageResponse = response - /** * Delegates to [AlertListPageResponse], but gracefully handles missing data. * @@ -46,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AlertListPageAsync && alertsService == other.alertsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(alertsService, params, response) /* spotless:on */ - - override fun toString() = - "AlertListPageAsync{alertsService=$alertsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -80,22 +55,78 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { alertsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): AlertListParams = params + + /** The response that this page was parsed from. */ + fun response(): AlertListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - alertsService: AlertServiceAsync, - params: AlertListParams, - response: AlertListPageResponse, - ) = AlertListPageAsync(alertsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [AlertListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertListPageAsync]. */ + class Builder internal constructor() { + + private var service: AlertServiceAsync? = null + private var params: AlertListParams? = null + private var response: AlertListPageResponse? = null + + @JvmSynthetic + internal fun from(alertListPageAsync: AlertListPageAsync) = apply { + service = alertListPageAsync.service + params = alertListPageAsync.params + response = alertListPageAsync.response + } + + fun service(service: AlertServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: AlertListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: AlertListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [AlertListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AlertListPageAsync = + AlertListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: AlertListPageAsync) { @@ -123,4 +154,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AlertListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "AlertListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt index 031a19168..8fd79bede 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.CouponService import java.util.Objects import java.util.Optional @@ -9,23 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all coupons for an account in a list format. - * - * The list of coupons is ordered starting from the most recently created coupon. The response also - * includes `pagination_metadata`, which lets the caller retrieve the next page of results if they - * exist. More information about pagination can be found in the Pagination-metadata schema. - */ +/** @see [CouponService.list] */ class CouponListPage private constructor( - private val couponsService: CouponService, + private val service: CouponService, private val params: CouponListParams, private val response: CouponListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CouponListPageResponse = response - /** * Delegates to [CouponListPageResponse], but gracefully handles missing data. * @@ -41,19 +33,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CouponListPage && couponsService == other.couponsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(couponsService, params, response) /* spotless:on */ - - override fun toString() = - "CouponListPage{couponsService=$couponsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -75,20 +54,75 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { couponsService.list(it) } - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CouponListParams = params + + /** The response that this page was parsed from. */ + fun response(): CouponListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - couponsService: CouponService, - params: CouponListParams, - response: CouponListPageResponse, - ) = CouponListPage(couponsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [CouponListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CouponListPage]. */ + class Builder internal constructor() { + + private var service: CouponService? = null + private var params: CouponListParams? = null + private var response: CouponListPageResponse? = null + + @JvmSynthetic + internal fun from(couponListPage: CouponListPage) = apply { + service = couponListPage.service + params = couponListPage.params + response = couponListPage.response + } + + fun service(service: CouponService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CouponListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CouponListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CouponListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CouponListPage = + CouponListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CouponListPage) : Iterable { @@ -109,4 +143,16 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CouponListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = "CouponListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt index bb16ee294..6486b6da2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.CouponServiceAsync import java.util.Objects import java.util.Optional @@ -10,23 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all coupons for an account in a list format. - * - * The list of coupons is ordered starting from the most recently created coupon. The response also - * includes `pagination_metadata`, which lets the caller retrieve the next page of results if they - * exist. More information about pagination can be found in the Pagination-metadata schema. - */ +/** @see [CouponServiceAsync.list] */ class CouponListPageAsync private constructor( - private val couponsService: CouponServiceAsync, + private val service: CouponServiceAsync, private val params: CouponListParams, private val response: CouponListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CouponListPageResponse = response - /** * Delegates to [CouponListPageResponse], but gracefully handles missing data. * @@ -42,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CouponListPageAsync && couponsService == other.couponsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(couponsService, params, response) /* spotless:on */ - - override fun toString() = - "CouponListPageAsync{couponsService=$couponsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -76,22 +55,78 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { couponsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CouponListParams = params + + /** The response that this page was parsed from. */ + fun response(): CouponListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - couponsService: CouponServiceAsync, - params: CouponListParams, - response: CouponListPageResponse, - ) = CouponListPageAsync(couponsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [CouponListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CouponListPageAsync]. */ + class Builder internal constructor() { + + private var service: CouponServiceAsync? = null + private var params: CouponListParams? = null + private var response: CouponListPageResponse? = null + + @JvmSynthetic + internal fun from(couponListPageAsync: CouponListPageAsync) = apply { + service = couponListPageAsync.service + params = couponListPageAsync.params + response = couponListPageAsync.response + } + + fun service(service: CouponServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CouponListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CouponListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CouponListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CouponListPageAsync = + CouponListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CouponListPageAsync) { @@ -119,4 +154,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CouponListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CouponListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt index e32c6d862..77f174711 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.coupons.SubscriptionService import java.util.Objects import java.util.Optional @@ -9,22 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all subscriptions that have redeemed a given coupon as a - * [paginated](/api-reference/pagination) list, ordered starting from the most recently created - * subscription. For a full discussion of the subscription resource, see - * [Subscription](/core-concepts#subscription). - */ +/** @see [SubscriptionService.list] */ class CouponSubscriptionListPage private constructor( - private val subscriptionsService: SubscriptionService, + private val service: SubscriptionService, private val params: CouponSubscriptionListParams, private val response: Subscriptions, ) { - /** Returns the response that this page was parsed from. */ - fun response(): Subscriptions = response - /** * Delegates to [Subscriptions], but gracefully handles missing data. * @@ -40,19 +33,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CouponSubscriptionListPage && subscriptionsService == other.subscriptionsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionsService, params, response) /* spotless:on */ - - override fun toString() = - "CouponSubscriptionListPage{subscriptionsService=$subscriptionsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -74,20 +54,76 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { subscriptionsService.list(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CouponSubscriptionListParams = params + + /** The response that this page was parsed from. */ + fun response(): Subscriptions = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - subscriptionsService: SubscriptionService, - params: CouponSubscriptionListParams, - response: Subscriptions, - ) = CouponSubscriptionListPage(subscriptionsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [CouponSubscriptionListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CouponSubscriptionListPage]. */ + class Builder internal constructor() { + + private var service: SubscriptionService? = null + private var params: CouponSubscriptionListParams? = null + private var response: Subscriptions? = null + + @JvmSynthetic + internal fun from(couponSubscriptionListPage: CouponSubscriptionListPage) = apply { + service = couponSubscriptionListPage.service + params = couponSubscriptionListPage.params + response = couponSubscriptionListPage.response + } + + fun service(service: SubscriptionService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CouponSubscriptionListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: Subscriptions) = apply { this.response = response } + + /** + * Returns an immutable instance of [CouponSubscriptionListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CouponSubscriptionListPage = + CouponSubscriptionListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CouponSubscriptionListPage) : Iterable { @@ -108,4 +144,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CouponSubscriptionListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CouponSubscriptionListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt index 460589f69..47417e21c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.coupons.SubscriptionServiceAsync import java.util.Objects import java.util.Optional @@ -10,22 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all subscriptions that have redeemed a given coupon as a - * [paginated](/api-reference/pagination) list, ordered starting from the most recently created - * subscription. For a full discussion of the subscription resource, see - * [Subscription](/core-concepts#subscription). - */ +/** @see [SubscriptionServiceAsync.list] */ class CouponSubscriptionListPageAsync private constructor( - private val subscriptionsService: SubscriptionServiceAsync, + private val service: SubscriptionServiceAsync, private val params: CouponSubscriptionListParams, private val response: Subscriptions, ) { - /** Returns the response that this page was parsed from. */ - fun response(): Subscriptions = response - /** * Delegates to [Subscriptions], but gracefully handles missing data. * @@ -41,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CouponSubscriptionListPageAsync && subscriptionsService == other.subscriptionsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionsService, params, response) /* spotless:on */ - - override fun toString() = - "CouponSubscriptionListPageAsync{subscriptionsService=$subscriptionsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -75,22 +55,80 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { subscriptionsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CouponSubscriptionListParams = params + + /** The response that this page was parsed from. */ + fun response(): Subscriptions = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - subscriptionsService: SubscriptionServiceAsync, - params: CouponSubscriptionListParams, - response: Subscriptions, - ) = CouponSubscriptionListPageAsync(subscriptionsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [CouponSubscriptionListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CouponSubscriptionListPageAsync]. */ + class Builder internal constructor() { + + private var service: SubscriptionServiceAsync? = null + private var params: CouponSubscriptionListParams? = null + private var response: Subscriptions? = null + + @JvmSynthetic + internal fun from(couponSubscriptionListPageAsync: CouponSubscriptionListPageAsync) = + apply { + service = couponSubscriptionListPageAsync.service + params = couponSubscriptionListPageAsync.params + response = couponSubscriptionListPageAsync.response + } + + fun service(service: SubscriptionServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CouponSubscriptionListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: Subscriptions) = apply { this.response = response } + + /** + * Returns an immutable instance of [CouponSubscriptionListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CouponSubscriptionListPageAsync = + CouponSubscriptionListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CouponSubscriptionListPageAsync) { @@ -118,4 +156,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CouponSubscriptionListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CouponSubscriptionListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt index 4e94cace1..cbbd4f40b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.CreditNoteService import java.util.Objects import java.util.Optional @@ -9,21 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * Get a paginated list of CreditNotes. Users can also filter by customer_id, subscription_id, or - * external_customer_id. The credit notes will be returned in reverse chronological order by - * `creation_time`. - */ +/** @see [CreditNoteService.list] */ class CreditNoteListPage private constructor( - private val creditNotesService: CreditNoteService, + private val service: CreditNoteService, private val params: CreditNoteListParams, private val response: CreditNoteListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CreditNoteListPageResponse = response - /** * Delegates to [CreditNoteListPageResponse], but gracefully handles missing data. * @@ -39,19 +33,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditNoteListPage && creditNotesService == other.creditNotesService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(creditNotesService, params, response) /* spotless:on */ - - override fun toString() = - "CreditNoteListPage{creditNotesService=$creditNotesService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -73,20 +54,75 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { creditNotesService.list(it) } - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CreditNoteListParams = params + + /** The response that this page was parsed from. */ + fun response(): CreditNoteListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - creditNotesService: CreditNoteService, - params: CreditNoteListParams, - response: CreditNoteListPageResponse, - ) = CreditNoteListPage(creditNotesService, params, response) + /** + * Returns a mutable builder for constructing an instance of [CreditNoteListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditNoteListPage]. */ + class Builder internal constructor() { + + private var service: CreditNoteService? = null + private var params: CreditNoteListParams? = null + private var response: CreditNoteListPageResponse? = null + + @JvmSynthetic + internal fun from(creditNoteListPage: CreditNoteListPage) = apply { + service = creditNoteListPage.service + params = creditNoteListPage.params + response = creditNoteListPage.response + } + + fun service(service: CreditNoteService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CreditNoteListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CreditNoteListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CreditNoteListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditNoteListPage = + CreditNoteListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CreditNoteListPage) : Iterable { @@ -107,4 +143,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CreditNoteListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CreditNoteListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt index 7e1104d7b..104920cc9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.CreditNoteServiceAsync import java.util.Objects import java.util.Optional @@ -10,21 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * Get a paginated list of CreditNotes. Users can also filter by customer_id, subscription_id, or - * external_customer_id. The credit notes will be returned in reverse chronological order by - * `creation_time`. - */ +/** @see [CreditNoteServiceAsync.list] */ class CreditNoteListPageAsync private constructor( - private val creditNotesService: CreditNoteServiceAsync, + private val service: CreditNoteServiceAsync, private val params: CreditNoteListParams, private val response: CreditNoteListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CreditNoteListPageResponse = response - /** * Delegates to [CreditNoteListPageResponse], but gracefully handles missing data. * @@ -40,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditNoteListPageAsync && creditNotesService == other.creditNotesService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(creditNotesService, params, response) /* spotless:on */ - - override fun toString() = - "CreditNoteListPageAsync{creditNotesService=$creditNotesService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -74,22 +55,78 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { creditNotesService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CreditNoteListParams = params + + /** The response that this page was parsed from. */ + fun response(): CreditNoteListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - creditNotesService: CreditNoteServiceAsync, - params: CreditNoteListParams, - response: CreditNoteListPageResponse, - ) = CreditNoteListPageAsync(creditNotesService, params, response) + /** + * Returns a mutable builder for constructing an instance of [CreditNoteListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditNoteListPageAsync]. */ + class Builder internal constructor() { + + private var service: CreditNoteServiceAsync? = null + private var params: CreditNoteListParams? = null + private var response: CreditNoteListPageResponse? = null + + @JvmSynthetic + internal fun from(creditNoteListPageAsync: CreditNoteListPageAsync) = apply { + service = creditNoteListPageAsync.service + params = creditNoteListPageAsync.params + response = creditNoteListPageAsync.response + } + + fun service(service: CreditNoteServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CreditNoteListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CreditNoteListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CreditNoteListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditNoteListPageAsync = + CreditNoteListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CreditNoteListPageAsync) { @@ -117,4 +154,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CreditNoteListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CreditNoteListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt index 3188929b4..a313acd6a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.BalanceTransactionService import java.util.Objects import java.util.Optional @@ -9,42 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * ## The customer balance - * - * The customer balance is an amount in the customer's currency, which Orb automatically applies to - * subsequent invoices. This balance can be adjusted manually via Orb's webapp on the customer - * details page. You can use this balance to provide a fixed mid-period credit to the customer. - * Commonly, this is done due to system downtime/SLA violation, or an adhoc adjustment discussed - * with the customer. - * - * If the balance is a positive value at the time of invoicing, it represents that the customer has - * credit that should be used to offset the amount due on the next issued invoice. In this case, Orb - * will automatically reduce the next invoice by the balance amount, and roll over any remaining - * balance if the invoice is fully discounted. - * - * If the balance is a negative value at the time of invoicing, Orb will increase the invoice's - * amount due with a positive adjustment, and reset the balance to 0. - * - * This endpoint retrieves all customer balance transactions in reverse chronological order for a - * single customer, providing a complete audit trail of all adjustments and invoice applications. - * - * ## Eligibility - * - * The customer balance can only be applied to invoices or adjusted manually if invoices are not - * synced to a separate invoicing provider. If a payment gateway such as Stripe is used, the balance - * will be applied to the invoice before forwarding payment to the gateway. - */ +/** @see [BalanceTransactionService.list] */ class CustomerBalanceTransactionListPage private constructor( - private val balanceTransactionsService: BalanceTransactionService, + private val service: BalanceTransactionService, private val params: CustomerBalanceTransactionListParams, private val response: CustomerBalanceTransactionListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerBalanceTransactionListPageResponse = response - /** * Delegates to [CustomerBalanceTransactionListPageResponse], but gracefully handles missing * data. @@ -63,19 +36,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerBalanceTransactionListPage && balanceTransactionsService == other.balanceTransactionsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(balanceTransactionsService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerBalanceTransactionListPage{balanceTransactionsService=$balanceTransactionsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -97,20 +57,80 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { balanceTransactionsService.list(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerBalanceTransactionListParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerBalanceTransactionListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - balanceTransactionsService: BalanceTransactionService, - params: CustomerBalanceTransactionListParams, - response: CustomerBalanceTransactionListPageResponse, - ) = CustomerBalanceTransactionListPage(balanceTransactionsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [CustomerBalanceTransactionListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerBalanceTransactionListPage]. */ + class Builder internal constructor() { + + private var service: BalanceTransactionService? = null + private var params: CustomerBalanceTransactionListParams? = null + private var response: CustomerBalanceTransactionListPageResponse? = null + + @JvmSynthetic + internal fun from(customerBalanceTransactionListPage: CustomerBalanceTransactionListPage) = + apply { + service = customerBalanceTransactionListPage.service + params = customerBalanceTransactionListPage.params + response = customerBalanceTransactionListPage.response + } + + fun service(service: BalanceTransactionService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerBalanceTransactionListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CustomerBalanceTransactionListPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CustomerBalanceTransactionListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerBalanceTransactionListPage = + CustomerBalanceTransactionListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerBalanceTransactionListPage) : @@ -132,4 +152,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerBalanceTransactionListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerBalanceTransactionListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt index 83adacec9..6214987f0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.BalanceTransactionServiceAsync import java.util.Objects import java.util.Optional @@ -10,42 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * ## The customer balance - * - * The customer balance is an amount in the customer's currency, which Orb automatically applies to - * subsequent invoices. This balance can be adjusted manually via Orb's webapp on the customer - * details page. You can use this balance to provide a fixed mid-period credit to the customer. - * Commonly, this is done due to system downtime/SLA violation, or an adhoc adjustment discussed - * with the customer. - * - * If the balance is a positive value at the time of invoicing, it represents that the customer has - * credit that should be used to offset the amount due on the next issued invoice. In this case, Orb - * will automatically reduce the next invoice by the balance amount, and roll over any remaining - * balance if the invoice is fully discounted. - * - * If the balance is a negative value at the time of invoicing, Orb will increase the invoice's - * amount due with a positive adjustment, and reset the balance to 0. - * - * This endpoint retrieves all customer balance transactions in reverse chronological order for a - * single customer, providing a complete audit trail of all adjustments and invoice applications. - * - * ## Eligibility - * - * The customer balance can only be applied to invoices or adjusted manually if invoices are not - * synced to a separate invoicing provider. If a payment gateway such as Stripe is used, the balance - * will be applied to the invoice before forwarding payment to the gateway. - */ +/** @see [BalanceTransactionServiceAsync.list] */ class CustomerBalanceTransactionListPageAsync private constructor( - private val balanceTransactionsService: BalanceTransactionServiceAsync, + private val service: BalanceTransactionServiceAsync, private val params: CustomerBalanceTransactionListParams, private val response: CustomerBalanceTransactionListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerBalanceTransactionListPageResponse = response - /** * Delegates to [CustomerBalanceTransactionListPageResponse], but gracefully handles missing * data. @@ -64,19 +37,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerBalanceTransactionListPageAsync && balanceTransactionsService == other.balanceTransactionsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(balanceTransactionsService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerBalanceTransactionListPageAsync{balanceTransactionsService=$balanceTransactionsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -98,22 +58,83 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { balanceTransactionsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerBalanceTransactionListParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerBalanceTransactionListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - balanceTransactionsService: BalanceTransactionServiceAsync, - params: CustomerBalanceTransactionListParams, - response: CustomerBalanceTransactionListPageResponse, - ) = CustomerBalanceTransactionListPageAsync(balanceTransactionsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [CustomerBalanceTransactionListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerBalanceTransactionListPageAsync]. */ + class Builder internal constructor() { + + private var service: BalanceTransactionServiceAsync? = null + private var params: CustomerBalanceTransactionListParams? = null + private var response: CustomerBalanceTransactionListPageResponse? = null + + @JvmSynthetic + internal fun from( + customerBalanceTransactionListPageAsync: CustomerBalanceTransactionListPageAsync + ) = apply { + service = customerBalanceTransactionListPageAsync.service + params = customerBalanceTransactionListPageAsync.params + response = customerBalanceTransactionListPageAsync.response + } + + fun service(service: BalanceTransactionServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerBalanceTransactionListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CustomerBalanceTransactionListPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CustomerBalanceTransactionListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerBalanceTransactionListPageAsync = + CustomerBalanceTransactionListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerBalanceTransactionListPageAsync) { @@ -146,4 +167,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerBalanceTransactionListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerBalanceTransactionListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt index 505a0c671..a791b9c6a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.credits.LedgerService import java.util.Objects import java.util.Optional @@ -9,93 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of - * actions that have taken place to modify a customer's credit balance. This - * [paginated endpoint](/api-reference/pagination) lists these entries, starting from the most - * recent ledger entry. - * - * More details on using Orb's real-time credit feature are [here](/product-catalog/prepurchase). - * - * There are four major types of modifications to credit balance, detailed below. - * - * ## Increment - * - * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger - * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the total - * eligible starting and ending balance for the customer at the time the entry was added to the - * ledger. - * - * ## Decrement - * - * Deductions can occur as a result of an API call to create a ledger entry (see - * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. Both - * ledger entries present the `decrement` entry type. - * - * As usage for a customer is reported into Orb, credits may be deducted according to the customer's - * plan configuration. An automated deduction of this type will result in a ledger entry, also with - * a starting and ending balance. In order to provide better tracing capabilities for automatic - * deductions, Orb always associates each automatic deduction with the `event_id` at the time of - * ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are - * never deducted without an associated usage event. - * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring credit - * block_ first in order to ensure that all credits are utilized appropriately. As an example, if - * trial credits with an expiration date of 2 weeks from now are present for a customer, they will - * be used before any deductions take place from a non-expiring credit block. - * - * If there are multiple blocks with the same expiration date, Orb will deduct from the block with - * the _lower cost basis_ first (e.g. trial credits with a $0 cost basis before paid credits with a - * $5.00 cost basis). - * - * It's also possible for a single usage event's deduction to _span_ credit blocks. In this case, - * Orb will deduct from the next block, ending at the credit block which consists of unexpiring - * credits. Each of these deductions will lead to a _separate_ ledger entry, one per credit block - * that is deducted from. By default, the customer's total credit balance in Orb can be negative as - * a result of a decrement. - * - * ## Expiration change - * - * The expiry of credits can be changed as a result of the API (See - * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the - * balance as well as the initial and target expiry dates. - * - * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the `amount` - * represents the balance transferred. The credit block linked to the ledger entry is the source - * credit block from which there was an expiration change - * - * ## Credits expiry - * - * When a set of credits expire on pre-set expiration date, the customer's balance automatically - * reflects this change and adds an entry to the ledger indicating this event. Note that credit - * expiry should always happen close to a date boundary in the customer's timezone. - * - * ## Void initiated - * - * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number of - * credits that were remaining in the block at time of void. `void_reason` will be populated if the - * void is created with a reason. - * - * ## Void - * - * When a set of credits is voided, the customer's balance automatically reflects this change and - * adds an entry to the ledger indicating this event. - * - * ## Amendment - * - * When credits are added to a customer's balance as a result of a correction, this entry will be - * added to the ledger to indicate the adjustment of credits. - */ +/** @see [LedgerService.listByExternalId] */ class CustomerCreditLedgerListByExternalIdPage private constructor( - private val ledgerService: LedgerService, + private val service: LedgerService, private val params: CustomerCreditLedgerListByExternalIdParams, private val response: CustomerCreditLedgerListByExternalIdPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerCreditLedgerListByExternalIdPageResponse = response - /** * Delegates to [CustomerCreditLedgerListByExternalIdPageResponse], but gracefully handles * missing data. @@ -114,19 +36,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdPage && ledgerService == other.ledgerService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(ledgerService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerCreditLedgerListByExternalIdPage{ledgerService=$ledgerService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -148,20 +57,83 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { ledgerService.listByExternalId(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.listByExternalId(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerCreditLedgerListByExternalIdParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerCreditLedgerListByExternalIdPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - ledgerService: LedgerService, - params: CustomerCreditLedgerListByExternalIdParams, - response: CustomerCreditLedgerListByExternalIdPageResponse, - ) = CustomerCreditLedgerListByExternalIdPage(ledgerService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditLedgerListByExternalIdPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditLedgerListByExternalIdPage]. */ + class Builder internal constructor() { + + private var service: LedgerService? = null + private var params: CustomerCreditLedgerListByExternalIdParams? = null + private var response: CustomerCreditLedgerListByExternalIdPageResponse? = null + + @JvmSynthetic + internal fun from( + customerCreditLedgerListByExternalIdPage: CustomerCreditLedgerListByExternalIdPage + ) = apply { + service = customerCreditLedgerListByExternalIdPage.service + params = customerCreditLedgerListByExternalIdPage.params + response = customerCreditLedgerListByExternalIdPage.response + } + + fun service(service: LedgerService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerCreditLedgerListByExternalIdParams) = apply { + this.params = params + } + + /** The response that this page was parsed from. */ + fun response(response: CustomerCreditLedgerListByExternalIdPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CustomerCreditLedgerListByExternalIdPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerCreditLedgerListByExternalIdPage = + CustomerCreditLedgerListByExternalIdPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerCreditLedgerListByExternalIdPage) : @@ -183,4 +155,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerCreditLedgerListByExternalIdPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt index 99b78443d..ce9a3b860 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.credits.LedgerServiceAsync import java.util.Objects import java.util.Optional @@ -10,93 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of - * actions that have taken place to modify a customer's credit balance. This - * [paginated endpoint](/api-reference/pagination) lists these entries, starting from the most - * recent ledger entry. - * - * More details on using Orb's real-time credit feature are [here](/product-catalog/prepurchase). - * - * There are four major types of modifications to credit balance, detailed below. - * - * ## Increment - * - * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger - * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the total - * eligible starting and ending balance for the customer at the time the entry was added to the - * ledger. - * - * ## Decrement - * - * Deductions can occur as a result of an API call to create a ledger entry (see - * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. Both - * ledger entries present the `decrement` entry type. - * - * As usage for a customer is reported into Orb, credits may be deducted according to the customer's - * plan configuration. An automated deduction of this type will result in a ledger entry, also with - * a starting and ending balance. In order to provide better tracing capabilities for automatic - * deductions, Orb always associates each automatic deduction with the `event_id` at the time of - * ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are - * never deducted without an associated usage event. - * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring credit - * block_ first in order to ensure that all credits are utilized appropriately. As an example, if - * trial credits with an expiration date of 2 weeks from now are present for a customer, they will - * be used before any deductions take place from a non-expiring credit block. - * - * If there are multiple blocks with the same expiration date, Orb will deduct from the block with - * the _lower cost basis_ first (e.g. trial credits with a $0 cost basis before paid credits with a - * $5.00 cost basis). - * - * It's also possible for a single usage event's deduction to _span_ credit blocks. In this case, - * Orb will deduct from the next block, ending at the credit block which consists of unexpiring - * credits. Each of these deductions will lead to a _separate_ ledger entry, one per credit block - * that is deducted from. By default, the customer's total credit balance in Orb can be negative as - * a result of a decrement. - * - * ## Expiration change - * - * The expiry of credits can be changed as a result of the API (See - * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the - * balance as well as the initial and target expiry dates. - * - * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the `amount` - * represents the balance transferred. The credit block linked to the ledger entry is the source - * credit block from which there was an expiration change - * - * ## Credits expiry - * - * When a set of credits expire on pre-set expiration date, the customer's balance automatically - * reflects this change and adds an entry to the ledger indicating this event. Note that credit - * expiry should always happen close to a date boundary in the customer's timezone. - * - * ## Void initiated - * - * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number of - * credits that were remaining in the block at time of void. `void_reason` will be populated if the - * void is created with a reason. - * - * ## Void - * - * When a set of credits is voided, the customer's balance automatically reflects this change and - * adds an entry to the ledger indicating this event. - * - * ## Amendment - * - * When credits are added to a customer's balance as a result of a correction, this entry will be - * added to the ledger to indicate the adjustment of credits. - */ +/** @see [LedgerServiceAsync.listByExternalId] */ class CustomerCreditLedgerListByExternalIdPageAsync private constructor( - private val ledgerService: LedgerServiceAsync, + private val service: LedgerServiceAsync, private val params: CustomerCreditLedgerListByExternalIdParams, private val response: CustomerCreditLedgerListByExternalIdPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerCreditLedgerListByExternalIdPageResponse = response - /** * Delegates to [CustomerCreditLedgerListByExternalIdPageResponse], but gracefully handles * missing data. @@ -115,19 +37,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdPageAsync && ledgerService == other.ledgerService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(ledgerService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerCreditLedgerListByExternalIdPageAsync{ledgerService=$ledgerService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -149,22 +58,86 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { ledgerService.listByExternalId(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.listByExternalId(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerCreditLedgerListByExternalIdParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerCreditLedgerListByExternalIdPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - ledgerService: LedgerServiceAsync, - params: CustomerCreditLedgerListByExternalIdParams, - response: CustomerCreditLedgerListByExternalIdPageResponse, - ) = CustomerCreditLedgerListByExternalIdPageAsync(ledgerService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditLedgerListByExternalIdPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditLedgerListByExternalIdPageAsync]. */ + class Builder internal constructor() { + + private var service: LedgerServiceAsync? = null + private var params: CustomerCreditLedgerListByExternalIdParams? = null + private var response: CustomerCreditLedgerListByExternalIdPageResponse? = null + + @JvmSynthetic + internal fun from( + customerCreditLedgerListByExternalIdPageAsync: + CustomerCreditLedgerListByExternalIdPageAsync + ) = apply { + service = customerCreditLedgerListByExternalIdPageAsync.service + params = customerCreditLedgerListByExternalIdPageAsync.params + response = customerCreditLedgerListByExternalIdPageAsync.response + } + + fun service(service: LedgerServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerCreditLedgerListByExternalIdParams) = apply { + this.params = params + } + + /** The response that this page was parsed from. */ + fun response(response: CustomerCreditLedgerListByExternalIdPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CustomerCreditLedgerListByExternalIdPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerCreditLedgerListByExternalIdPageAsync = + CustomerCreditLedgerListByExternalIdPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerCreditLedgerListByExternalIdPageAsync) { @@ -197,4 +170,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerCreditLedgerListByExternalIdPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt index 8e77f055c..b5b1fbb43 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.credits.LedgerService import java.util.Objects import java.util.Optional @@ -9,93 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of - * actions that have taken place to modify a customer's credit balance. This - * [paginated endpoint](/api-reference/pagination) lists these entries, starting from the most - * recent ledger entry. - * - * More details on using Orb's real-time credit feature are [here](/product-catalog/prepurchase). - * - * There are four major types of modifications to credit balance, detailed below. - * - * ## Increment - * - * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger - * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the total - * eligible starting and ending balance for the customer at the time the entry was added to the - * ledger. - * - * ## Decrement - * - * Deductions can occur as a result of an API call to create a ledger entry (see - * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. Both - * ledger entries present the `decrement` entry type. - * - * As usage for a customer is reported into Orb, credits may be deducted according to the customer's - * plan configuration. An automated deduction of this type will result in a ledger entry, also with - * a starting and ending balance. In order to provide better tracing capabilities for automatic - * deductions, Orb always associates each automatic deduction with the `event_id` at the time of - * ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are - * never deducted without an associated usage event. - * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring credit - * block_ first in order to ensure that all credits are utilized appropriately. As an example, if - * trial credits with an expiration date of 2 weeks from now are present for a customer, they will - * be used before any deductions take place from a non-expiring credit block. - * - * If there are multiple blocks with the same expiration date, Orb will deduct from the block with - * the _lower cost basis_ first (e.g. trial credits with a $0 cost basis before paid credits with a - * $5.00 cost basis). - * - * It's also possible for a single usage event's deduction to _span_ credit blocks. In this case, - * Orb will deduct from the next block, ending at the credit block which consists of unexpiring - * credits. Each of these deductions will lead to a _separate_ ledger entry, one per credit block - * that is deducted from. By default, the customer's total credit balance in Orb can be negative as - * a result of a decrement. - * - * ## Expiration change - * - * The expiry of credits can be changed as a result of the API (See - * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the - * balance as well as the initial and target expiry dates. - * - * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the `amount` - * represents the balance transferred. The credit block linked to the ledger entry is the source - * credit block from which there was an expiration change - * - * ## Credits expiry - * - * When a set of credits expire on pre-set expiration date, the customer's balance automatically - * reflects this change and adds an entry to the ledger indicating this event. Note that credit - * expiry should always happen close to a date boundary in the customer's timezone. - * - * ## Void initiated - * - * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number of - * credits that were remaining in the block at time of void. `void_reason` will be populated if the - * void is created with a reason. - * - * ## Void - * - * When a set of credits is voided, the customer's balance automatically reflects this change and - * adds an entry to the ledger indicating this event. - * - * ## Amendment - * - * When credits are added to a customer's balance as a result of a correction, this entry will be - * added to the ledger to indicate the adjustment of credits. - */ +/** @see [LedgerService.list] */ class CustomerCreditLedgerListPage private constructor( - private val ledgerService: LedgerService, + private val service: LedgerService, private val params: CustomerCreditLedgerListParams, private val response: CustomerCreditLedgerListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerCreditLedgerListPageResponse = response - /** * Delegates to [CustomerCreditLedgerListPageResponse], but gracefully handles missing data. * @@ -112,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditLedgerListPage && ledgerService == other.ledgerService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(ledgerService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerCreditLedgerListPage{ledgerService=$ledgerService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -146,20 +55,78 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { ledgerService.list(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerCreditLedgerListParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerCreditLedgerListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - ledgerService: LedgerService, - params: CustomerCreditLedgerListParams, - response: CustomerCreditLedgerListPageResponse, - ) = CustomerCreditLedgerListPage(ledgerService, params, response) + /** + * Returns a mutable builder for constructing an instance of [CustomerCreditLedgerListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditLedgerListPage]. */ + class Builder internal constructor() { + + private var service: LedgerService? = null + private var params: CustomerCreditLedgerListParams? = null + private var response: CustomerCreditLedgerListPageResponse? = null + + @JvmSynthetic + internal fun from(customerCreditLedgerListPage: CustomerCreditLedgerListPage) = apply { + service = customerCreditLedgerListPage.service + params = customerCreditLedgerListPage.params + response = customerCreditLedgerListPage.response + } + + fun service(service: LedgerService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerCreditLedgerListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CustomerCreditLedgerListPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CustomerCreditLedgerListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerCreditLedgerListPage = + CustomerCreditLedgerListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerCreditLedgerListPage) : @@ -181,4 +148,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditLedgerListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerCreditLedgerListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt index e3d105245..31bb87655 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.credits.LedgerServiceAsync import java.util.Objects import java.util.Optional @@ -10,93 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of - * actions that have taken place to modify a customer's credit balance. This - * [paginated endpoint](/api-reference/pagination) lists these entries, starting from the most - * recent ledger entry. - * - * More details on using Orb's real-time credit feature are [here](/product-catalog/prepurchase). - * - * There are four major types of modifications to credit balance, detailed below. - * - * ## Increment - * - * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger - * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the total - * eligible starting and ending balance for the customer at the time the entry was added to the - * ledger. - * - * ## Decrement - * - * Deductions can occur as a result of an API call to create a ledger entry (see - * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. Both - * ledger entries present the `decrement` entry type. - * - * As usage for a customer is reported into Orb, credits may be deducted according to the customer's - * plan configuration. An automated deduction of this type will result in a ledger entry, also with - * a starting and ending balance. In order to provide better tracing capabilities for automatic - * deductions, Orb always associates each automatic deduction with the `event_id` at the time of - * ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are - * never deducted without an associated usage event. - * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring credit - * block_ first in order to ensure that all credits are utilized appropriately. As an example, if - * trial credits with an expiration date of 2 weeks from now are present for a customer, they will - * be used before any deductions take place from a non-expiring credit block. - * - * If there are multiple blocks with the same expiration date, Orb will deduct from the block with - * the _lower cost basis_ first (e.g. trial credits with a $0 cost basis before paid credits with a - * $5.00 cost basis). - * - * It's also possible for a single usage event's deduction to _span_ credit blocks. In this case, - * Orb will deduct from the next block, ending at the credit block which consists of unexpiring - * credits. Each of these deductions will lead to a _separate_ ledger entry, one per credit block - * that is deducted from. By default, the customer's total credit balance in Orb can be negative as - * a result of a decrement. - * - * ## Expiration change - * - * The expiry of credits can be changed as a result of the API (See - * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the - * balance as well as the initial and target expiry dates. - * - * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the `amount` - * represents the balance transferred. The credit block linked to the ledger entry is the source - * credit block from which there was an expiration change - * - * ## Credits expiry - * - * When a set of credits expire on pre-set expiration date, the customer's balance automatically - * reflects this change and adds an entry to the ledger indicating this event. Note that credit - * expiry should always happen close to a date boundary in the customer's timezone. - * - * ## Void initiated - * - * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number of - * credits that were remaining in the block at time of void. `void_reason` will be populated if the - * void is created with a reason. - * - * ## Void - * - * When a set of credits is voided, the customer's balance automatically reflects this change and - * adds an entry to the ledger indicating this event. - * - * ## Amendment - * - * When credits are added to a customer's balance as a result of a correction, this entry will be - * added to the ledger to indicate the adjustment of credits. - */ +/** @see [LedgerServiceAsync.list] */ class CustomerCreditLedgerListPageAsync private constructor( - private val ledgerService: LedgerServiceAsync, + private val service: LedgerServiceAsync, private val params: CustomerCreditLedgerListParams, private val response: CustomerCreditLedgerListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerCreditLedgerListPageResponse = response - /** * Delegates to [CustomerCreditLedgerListPageResponse], but gracefully handles missing data. * @@ -113,19 +35,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditLedgerListPageAsync && ledgerService == other.ledgerService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(ledgerService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerCreditLedgerListPageAsync{ledgerService=$ledgerService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -147,22 +56,82 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { ledgerService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerCreditLedgerListParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerCreditLedgerListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - ledgerService: LedgerServiceAsync, - params: CustomerCreditLedgerListParams, - response: CustomerCreditLedgerListPageResponse, - ) = CustomerCreditLedgerListPageAsync(ledgerService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditLedgerListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditLedgerListPageAsync]. */ + class Builder internal constructor() { + + private var service: LedgerServiceAsync? = null + private var params: CustomerCreditLedgerListParams? = null + private var response: CustomerCreditLedgerListPageResponse? = null + + @JvmSynthetic + internal fun from(customerCreditLedgerListPageAsync: CustomerCreditLedgerListPageAsync) = + apply { + service = customerCreditLedgerListPageAsync.service + params = customerCreditLedgerListPageAsync.params + response = customerCreditLedgerListPageAsync.response + } + + fun service(service: LedgerServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerCreditLedgerListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CustomerCreditLedgerListPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CustomerCreditLedgerListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerCreditLedgerListPageAsync = + CustomerCreditLedgerListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerCreditLedgerListPageAsync) { @@ -193,4 +162,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditLedgerListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerCreditLedgerListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt index 99b3ed708..c63f6aa65 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.CreditService import java.util.Objects import java.util.Optional @@ -9,25 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * Returns a paginated list of unexpired, non-zero credit blocks for a customer. - * - * If `include_all_blocks` is set to `true`, all credit blocks (including expired and depleted - * blocks) will be included in the response. - * - * Note that `currency` defaults to credits if not specified. To use a real world currency, set - * `currency` to an ISO 4217 string. - */ +/** @see [CreditService.listByExternalId] */ class CustomerCreditListByExternalIdPage private constructor( - private val creditsService: CreditService, + private val service: CreditService, private val params: CustomerCreditListByExternalIdParams, private val response: CustomerCreditListByExternalIdPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerCreditListByExternalIdPageResponse = response - /** * Delegates to [CustomerCreditListByExternalIdPageResponse], but gracefully handles missing * data. @@ -46,19 +36,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditListByExternalIdPage && creditsService == other.creditsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(creditsService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerCreditListByExternalIdPage{creditsService=$creditsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -80,20 +57,80 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { creditsService.listByExternalId(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.listByExternalId(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerCreditListByExternalIdParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerCreditListByExternalIdPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - creditsService: CreditService, - params: CustomerCreditListByExternalIdParams, - response: CustomerCreditListByExternalIdPageResponse, - ) = CustomerCreditListByExternalIdPage(creditsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditListByExternalIdPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditListByExternalIdPage]. */ + class Builder internal constructor() { + + private var service: CreditService? = null + private var params: CustomerCreditListByExternalIdParams? = null + private var response: CustomerCreditListByExternalIdPageResponse? = null + + @JvmSynthetic + internal fun from(customerCreditListByExternalIdPage: CustomerCreditListByExternalIdPage) = + apply { + service = customerCreditListByExternalIdPage.service + params = customerCreditListByExternalIdPage.params + response = customerCreditListByExternalIdPage.response + } + + fun service(service: CreditService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerCreditListByExternalIdParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CustomerCreditListByExternalIdPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CustomerCreditListByExternalIdPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerCreditListByExternalIdPage = + CustomerCreditListByExternalIdPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerCreditListByExternalIdPage) : @@ -115,4 +152,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditListByExternalIdPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerCreditListByExternalIdPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt index c039f2a62..a15138b23 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.CreditServiceAsync import java.util.Objects import java.util.Optional @@ -10,25 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * Returns a paginated list of unexpired, non-zero credit blocks for a customer. - * - * If `include_all_blocks` is set to `true`, all credit blocks (including expired and depleted - * blocks) will be included in the response. - * - * Note that `currency` defaults to credits if not specified. To use a real world currency, set - * `currency` to an ISO 4217 string. - */ +/** @see [CreditServiceAsync.listByExternalId] */ class CustomerCreditListByExternalIdPageAsync private constructor( - private val creditsService: CreditServiceAsync, + private val service: CreditServiceAsync, private val params: CustomerCreditListByExternalIdParams, private val response: CustomerCreditListByExternalIdPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerCreditListByExternalIdPageResponse = response - /** * Delegates to [CustomerCreditListByExternalIdPageResponse], but gracefully handles missing * data. @@ -47,19 +37,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditListByExternalIdPageAsync && creditsService == other.creditsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(creditsService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerCreditListByExternalIdPageAsync{creditsService=$creditsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -81,22 +58,83 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { creditsService.listByExternalId(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.listByExternalId(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerCreditListByExternalIdParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerCreditListByExternalIdPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - creditsService: CreditServiceAsync, - params: CustomerCreditListByExternalIdParams, - response: CustomerCreditListByExternalIdPageResponse, - ) = CustomerCreditListByExternalIdPageAsync(creditsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditListByExternalIdPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditListByExternalIdPageAsync]. */ + class Builder internal constructor() { + + private var service: CreditServiceAsync? = null + private var params: CustomerCreditListByExternalIdParams? = null + private var response: CustomerCreditListByExternalIdPageResponse? = null + + @JvmSynthetic + internal fun from( + customerCreditListByExternalIdPageAsync: CustomerCreditListByExternalIdPageAsync + ) = apply { + service = customerCreditListByExternalIdPageAsync.service + params = customerCreditListByExternalIdPageAsync.params + response = customerCreditListByExternalIdPageAsync.response + } + + fun service(service: CreditServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerCreditListByExternalIdParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CustomerCreditListByExternalIdPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CustomerCreditListByExternalIdPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerCreditListByExternalIdPageAsync = + CustomerCreditListByExternalIdPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerCreditListByExternalIdPageAsync) { @@ -129,4 +167,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditListByExternalIdPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerCreditListByExternalIdPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt index 0ded908e9..df86a0a8e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.CreditService import java.util.Objects import java.util.Optional @@ -9,25 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * Returns a paginated list of unexpired, non-zero credit blocks for a customer. - * - * If `include_all_blocks` is set to `true`, all credit blocks (including expired and depleted - * blocks) will be included in the response. - * - * Note that `currency` defaults to credits if not specified. To use a real world currency, set - * `currency` to an ISO 4217 string. - */ +/** @see [CreditService.list] */ class CustomerCreditListPage private constructor( - private val creditsService: CreditService, + private val service: CreditService, private val params: CustomerCreditListParams, private val response: CustomerCreditListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerCreditListPageResponse = response - /** * Delegates to [CustomerCreditListPageResponse], but gracefully handles missing data. * @@ -44,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditListPage && creditsService == other.creditsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(creditsService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerCreditListPage{creditsService=$creditsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -78,20 +55,76 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { creditsService.list(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerCreditListParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerCreditListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - creditsService: CreditService, - params: CustomerCreditListParams, - response: CustomerCreditListPageResponse, - ) = CustomerCreditListPage(creditsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [CustomerCreditListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditListPage]. */ + class Builder internal constructor() { + + private var service: CreditService? = null + private var params: CustomerCreditListParams? = null + private var response: CustomerCreditListPageResponse? = null + + @JvmSynthetic + internal fun from(customerCreditListPage: CustomerCreditListPage) = apply { + service = customerCreditListPage.service + params = customerCreditListPage.params + response = customerCreditListPage.response + } + + fun service(service: CreditService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerCreditListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CustomerCreditListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CustomerCreditListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerCreditListPage = + CustomerCreditListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerCreditListPage) : @@ -113,4 +146,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerCreditListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt index 4115333d7..03272689b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.CreditServiceAsync import java.util.Objects import java.util.Optional @@ -10,25 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * Returns a paginated list of unexpired, non-zero credit blocks for a customer. - * - * If `include_all_blocks` is set to `true`, all credit blocks (including expired and depleted - * blocks) will be included in the response. - * - * Note that `currency` defaults to credits if not specified. To use a real world currency, set - * `currency` to an ISO 4217 string. - */ +/** @see [CreditServiceAsync.list] */ class CustomerCreditListPageAsync private constructor( - private val creditsService: CreditServiceAsync, + private val service: CreditServiceAsync, private val params: CustomerCreditListParams, private val response: CustomerCreditListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerCreditListPageResponse = response - /** * Delegates to [CustomerCreditListPageResponse], but gracefully handles missing data. * @@ -45,19 +35,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditListPageAsync && creditsService == other.creditsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(creditsService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerCreditListPageAsync{creditsService=$creditsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -79,22 +56,78 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { creditsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerCreditListParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerCreditListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - creditsService: CreditServiceAsync, - params: CustomerCreditListParams, - response: CustomerCreditListPageResponse, - ) = CustomerCreditListPageAsync(creditsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [CustomerCreditListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditListPageAsync]. */ + class Builder internal constructor() { + + private var service: CreditServiceAsync? = null + private var params: CustomerCreditListParams? = null + private var response: CustomerCreditListPageResponse? = null + + @JvmSynthetic + internal fun from(customerCreditListPageAsync: CustomerCreditListPageAsync) = apply { + service = customerCreditListPageAsync.service + params = customerCreditListPageAsync.params + response = customerCreditListPageAsync.response + } + + fun service(service: CreditServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerCreditListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CustomerCreditListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CustomerCreditListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerCreditListPageAsync = + CustomerCreditListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerCreditListPageAsync) { @@ -125,4 +158,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerCreditListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt index 60fb71494..7e1662ead 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.credits.TopUpService import java.util.Objects import java.util.Optional @@ -9,17 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** List top-ups by external ID */ +/** @see [TopUpService.listByExternalId] */ class CustomerCreditTopUpListByExternalIdPage private constructor( - private val topUpsService: TopUpService, + private val service: TopUpService, private val params: CustomerCreditTopUpListByExternalIdParams, private val response: CustomerCreditTopUpListByExternalIdPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerCreditTopUpListByExternalIdPageResponse = response - /** * Delegates to [CustomerCreditTopUpListByExternalIdPageResponse], but gracefully handles * missing data. @@ -38,19 +36,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdPage && topUpsService == other.topUpsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(topUpsService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerCreditTopUpListByExternalIdPage{topUpsService=$topUpsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -72,20 +57,83 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { topUpsService.listByExternalId(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.listByExternalId(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerCreditTopUpListByExternalIdParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerCreditTopUpListByExternalIdPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - topUpsService: TopUpService, - params: CustomerCreditTopUpListByExternalIdParams, - response: CustomerCreditTopUpListByExternalIdPageResponse, - ) = CustomerCreditTopUpListByExternalIdPage(topUpsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpListByExternalIdPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditTopUpListByExternalIdPage]. */ + class Builder internal constructor() { + + private var service: TopUpService? = null + private var params: CustomerCreditTopUpListByExternalIdParams? = null + private var response: CustomerCreditTopUpListByExternalIdPageResponse? = null + + @JvmSynthetic + internal fun from( + customerCreditTopUpListByExternalIdPage: CustomerCreditTopUpListByExternalIdPage + ) = apply { + service = customerCreditTopUpListByExternalIdPage.service + params = customerCreditTopUpListByExternalIdPage.params + response = customerCreditTopUpListByExternalIdPage.response + } + + fun service(service: TopUpService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerCreditTopUpListByExternalIdParams) = apply { + this.params = params + } + + /** The response that this page was parsed from. */ + fun response(response: CustomerCreditTopUpListByExternalIdPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CustomerCreditTopUpListByExternalIdPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerCreditTopUpListByExternalIdPage = + CustomerCreditTopUpListByExternalIdPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerCreditTopUpListByExternalIdPage) : @@ -107,4 +155,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerCreditTopUpListByExternalIdPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt index dadcc6965..7ea10578a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.credits.TopUpServiceAsync import java.util.Objects import java.util.Optional @@ -10,17 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** List top-ups by external ID */ +/** @see [TopUpServiceAsync.listByExternalId] */ class CustomerCreditTopUpListByExternalIdPageAsync private constructor( - private val topUpsService: TopUpServiceAsync, + private val service: TopUpServiceAsync, private val params: CustomerCreditTopUpListByExternalIdParams, private val response: CustomerCreditTopUpListByExternalIdPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerCreditTopUpListByExternalIdPageResponse = response - /** * Delegates to [CustomerCreditTopUpListByExternalIdPageResponse], but gracefully handles * missing data. @@ -39,19 +37,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdPageAsync && topUpsService == other.topUpsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(topUpsService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerCreditTopUpListByExternalIdPageAsync{topUpsService=$topUpsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -73,22 +58,86 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { topUpsService.listByExternalId(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.listByExternalId(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerCreditTopUpListByExternalIdParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerCreditTopUpListByExternalIdPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - topUpsService: TopUpServiceAsync, - params: CustomerCreditTopUpListByExternalIdParams, - response: CustomerCreditTopUpListByExternalIdPageResponse, - ) = CustomerCreditTopUpListByExternalIdPageAsync(topUpsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpListByExternalIdPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditTopUpListByExternalIdPageAsync]. */ + class Builder internal constructor() { + + private var service: TopUpServiceAsync? = null + private var params: CustomerCreditTopUpListByExternalIdParams? = null + private var response: CustomerCreditTopUpListByExternalIdPageResponse? = null + + @JvmSynthetic + internal fun from( + customerCreditTopUpListByExternalIdPageAsync: + CustomerCreditTopUpListByExternalIdPageAsync + ) = apply { + service = customerCreditTopUpListByExternalIdPageAsync.service + params = customerCreditTopUpListByExternalIdPageAsync.params + response = customerCreditTopUpListByExternalIdPageAsync.response + } + + fun service(service: TopUpServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerCreditTopUpListByExternalIdParams) = apply { + this.params = params + } + + /** The response that this page was parsed from. */ + fun response(response: CustomerCreditTopUpListByExternalIdPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CustomerCreditTopUpListByExternalIdPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerCreditTopUpListByExternalIdPageAsync = + CustomerCreditTopUpListByExternalIdPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerCreditTopUpListByExternalIdPageAsync) { @@ -121,4 +170,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerCreditTopUpListByExternalIdPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt index a75a867c3..8b8931477 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.credits.TopUpService import java.util.Objects import java.util.Optional @@ -9,17 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** List top-ups */ +/** @see [TopUpService.list] */ class CustomerCreditTopUpListPage private constructor( - private val topUpsService: TopUpService, + private val service: TopUpService, private val params: CustomerCreditTopUpListParams, private val response: CustomerCreditTopUpListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerCreditTopUpListPageResponse = response - /** * Delegates to [CustomerCreditTopUpListPageResponse], but gracefully handles missing data. * @@ -36,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditTopUpListPage && topUpsService == other.topUpsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(topUpsService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerCreditTopUpListPage{topUpsService=$topUpsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -70,20 +55,78 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { topUpsService.list(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerCreditTopUpListParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerCreditTopUpListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - topUpsService: TopUpService, - params: CustomerCreditTopUpListParams, - response: CustomerCreditTopUpListPageResponse, - ) = CustomerCreditTopUpListPage(topUpsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [CustomerCreditTopUpListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditTopUpListPage]. */ + class Builder internal constructor() { + + private var service: TopUpService? = null + private var params: CustomerCreditTopUpListParams? = null + private var response: CustomerCreditTopUpListPageResponse? = null + + @JvmSynthetic + internal fun from(customerCreditTopUpListPage: CustomerCreditTopUpListPage) = apply { + service = customerCreditTopUpListPage.service + params = customerCreditTopUpListPage.params + response = customerCreditTopUpListPage.response + } + + fun service(service: TopUpService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerCreditTopUpListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CustomerCreditTopUpListPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CustomerCreditTopUpListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerCreditTopUpListPage = + CustomerCreditTopUpListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerCreditTopUpListPage) : @@ -105,4 +148,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditTopUpListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerCreditTopUpListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt index 3602bce09..311e993a7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.credits.TopUpServiceAsync import java.util.Objects import java.util.Optional @@ -10,17 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** List top-ups */ +/** @see [TopUpServiceAsync.list] */ class CustomerCreditTopUpListPageAsync private constructor( - private val topUpsService: TopUpServiceAsync, + private val service: TopUpServiceAsync, private val params: CustomerCreditTopUpListParams, private val response: CustomerCreditTopUpListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerCreditTopUpListPageResponse = response - /** * Delegates to [CustomerCreditTopUpListPageResponse], but gracefully handles missing data. * @@ -37,19 +35,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditTopUpListPageAsync && topUpsService == other.topUpsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(topUpsService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerCreditTopUpListPageAsync{topUpsService=$topUpsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -71,22 +56,82 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { topUpsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerCreditTopUpListParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerCreditTopUpListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - topUpsService: TopUpServiceAsync, - params: CustomerCreditTopUpListParams, - response: CustomerCreditTopUpListPageResponse, - ) = CustomerCreditTopUpListPageAsync(topUpsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditTopUpListPageAsync]. */ + class Builder internal constructor() { + + private var service: TopUpServiceAsync? = null + private var params: CustomerCreditTopUpListParams? = null + private var response: CustomerCreditTopUpListPageResponse? = null + + @JvmSynthetic + internal fun from(customerCreditTopUpListPageAsync: CustomerCreditTopUpListPageAsync) = + apply { + service = customerCreditTopUpListPageAsync.service + params = customerCreditTopUpListPageAsync.params + response = customerCreditTopUpListPageAsync.response + } + + fun service(service: TopUpServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerCreditTopUpListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CustomerCreditTopUpListPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CustomerCreditTopUpListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerCreditTopUpListPageAsync = + CustomerCreditTopUpListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerCreditTopUpListPageAsync) { @@ -117,4 +162,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditTopUpListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerCreditTopUpListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt index ba2dacdd6..4f51a3baa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.CustomerService import java.util.Objects import java.util.Optional @@ -9,23 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all customers for an account. The list of customers is ordered - * starting from the most recently created customer. This endpoint follows Orb's - * [standardized pagination format](/api-reference/pagination). - * - * See [Customer](/core-concepts##customer) for an overview of the customer model. - */ +/** @see [CustomerService.list] */ class CustomerListPage private constructor( - private val customersService: CustomerService, + private val service: CustomerService, private val params: CustomerListParams, private val response: CustomerListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerListPageResponse = response - /** * Delegates to [CustomerListPageResponse], but gracefully handles missing data. * @@ -41,19 +33,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerListPage && customersService == other.customersService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customersService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerListPage{customersService=$customersService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -75,20 +54,75 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { customersService.list(it) } - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerListParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - customersService: CustomerService, - params: CustomerListParams, - response: CustomerListPageResponse, - ) = CustomerListPage(customersService, params, response) + /** + * Returns a mutable builder for constructing an instance of [CustomerListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerListPage]. */ + class Builder internal constructor() { + + private var service: CustomerService? = null + private var params: CustomerListParams? = null + private var response: CustomerListPageResponse? = null + + @JvmSynthetic + internal fun from(customerListPage: CustomerListPage) = apply { + service = customerListPage.service + params = customerListPage.params + response = customerListPage.response + } + + fun service(service: CustomerService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CustomerListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CustomerListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerListPage = + CustomerListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerListPage) : Iterable { @@ -109,4 +143,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt index 706183379..849280469 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.CustomerServiceAsync import java.util.Objects import java.util.Optional @@ -10,23 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all customers for an account. The list of customers is ordered - * starting from the most recently created customer. This endpoint follows Orb's - * [standardized pagination format](/api-reference/pagination). - * - * See [Customer](/core-concepts##customer) for an overview of the customer model. - */ +/** @see [CustomerServiceAsync.list] */ class CustomerListPageAsync private constructor( - private val customersService: CustomerServiceAsync, + private val service: CustomerServiceAsync, private val params: CustomerListParams, private val response: CustomerListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): CustomerListPageResponse = response - /** * Delegates to [CustomerListPageResponse], but gracefully handles missing data. * @@ -42,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerListPageAsync && customersService == other.customersService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customersService, params, response) /* spotless:on */ - - override fun toString() = - "CustomerListPageAsync{customersService=$customersService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -76,22 +55,78 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { customersService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): CustomerListParams = params + + /** The response that this page was parsed from. */ + fun response(): CustomerListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - customersService: CustomerServiceAsync, - params: CustomerListParams, - response: CustomerListPageResponse, - ) = CustomerListPageAsync(customersService, params, response) + /** + * Returns a mutable builder for constructing an instance of [CustomerListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerListPageAsync]. */ + class Builder internal constructor() { + + private var service: CustomerServiceAsync? = null + private var params: CustomerListParams? = null + private var response: CustomerListPageResponse? = null + + @JvmSynthetic + internal fun from(customerListPageAsync: CustomerListPageAsync) = apply { + service = customerListPageAsync.service + params = customerListPageAsync.params + response = customerListPageAsync.response + } + + fun service(service: CustomerServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CustomerListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CustomerListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CustomerListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerListPageAsync = + CustomerListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: CustomerListPageAsync) { @@ -119,4 +154,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "CustomerListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt index b15fd5041..7d685ba51 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.DimensionalPriceGroupService import java.util.Objects import java.util.Optional @@ -9,17 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** List dimensional price groups */ +/** @see [DimensionalPriceGroupService.list] */ class DimensionalPriceGroupListPage private constructor( - private val dimensionalPriceGroupsService: DimensionalPriceGroupService, + private val service: DimensionalPriceGroupService, private val params: DimensionalPriceGroupListParams, private val response: DimensionalPriceGroups, ) { - /** Returns the response that this page was parsed from. */ - fun response(): DimensionalPriceGroups = response - /** * Delegates to [DimensionalPriceGroups], but gracefully handles missing data. * @@ -36,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceGroupListPage && dimensionalPriceGroupsService == other.dimensionalPriceGroupsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dimensionalPriceGroupsService, params, response) /* spotless:on */ - - override fun toString() = - "DimensionalPriceGroupListPage{dimensionalPriceGroupsService=$dimensionalPriceGroupsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -70,20 +55,77 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { dimensionalPriceGroupsService.list(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): DimensionalPriceGroupListParams = params + + /** The response that this page was parsed from. */ + fun response(): DimensionalPriceGroups = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - dimensionalPriceGroupsService: DimensionalPriceGroupService, - params: DimensionalPriceGroupListParams, - response: DimensionalPriceGroups, - ) = DimensionalPriceGroupListPage(dimensionalPriceGroupsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [DimensionalPriceGroupListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DimensionalPriceGroupListPage]. */ + class Builder internal constructor() { + + private var service: DimensionalPriceGroupService? = null + private var params: DimensionalPriceGroupListParams? = null + private var response: DimensionalPriceGroups? = null + + @JvmSynthetic + internal fun from(dimensionalPriceGroupListPage: DimensionalPriceGroupListPage) = apply { + service = dimensionalPriceGroupListPage.service + params = dimensionalPriceGroupListPage.params + response = dimensionalPriceGroupListPage.response + } + + fun service(service: DimensionalPriceGroupService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: DimensionalPriceGroupListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: DimensionalPriceGroups) = apply { this.response = response } + + /** + * Returns an immutable instance of [DimensionalPriceGroupListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionalPriceGroupListPage = + DimensionalPriceGroupListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: DimensionalPriceGroupListPage) : @@ -105,4 +147,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DimensionalPriceGroupListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "DimensionalPriceGroupListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt index 4e36fe97e..a823786c9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.DimensionalPriceGroupServiceAsync import java.util.Objects import java.util.Optional @@ -10,17 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** List dimensional price groups */ +/** @see [DimensionalPriceGroupServiceAsync.list] */ class DimensionalPriceGroupListPageAsync private constructor( - private val dimensionalPriceGroupsService: DimensionalPriceGroupServiceAsync, + private val service: DimensionalPriceGroupServiceAsync, private val params: DimensionalPriceGroupListParams, private val response: DimensionalPriceGroups, ) { - /** Returns the response that this page was parsed from. */ - fun response(): DimensionalPriceGroups = response - /** * Delegates to [DimensionalPriceGroups], but gracefully handles missing data. * @@ -37,19 +35,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceGroupListPageAsync && dimensionalPriceGroupsService == other.dimensionalPriceGroupsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dimensionalPriceGroupsService, params, response) /* spotless:on */ - - override fun toString() = - "DimensionalPriceGroupListPageAsync{dimensionalPriceGroupsService=$dimensionalPriceGroupsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -71,22 +56,80 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { dimensionalPriceGroupsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): DimensionalPriceGroupListParams = params + + /** The response that this page was parsed from. */ + fun response(): DimensionalPriceGroups = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - dimensionalPriceGroupsService: DimensionalPriceGroupServiceAsync, - params: DimensionalPriceGroupListParams, - response: DimensionalPriceGroups, - ) = DimensionalPriceGroupListPageAsync(dimensionalPriceGroupsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [DimensionalPriceGroupListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DimensionalPriceGroupListPageAsync]. */ + class Builder internal constructor() { + + private var service: DimensionalPriceGroupServiceAsync? = null + private var params: DimensionalPriceGroupListParams? = null + private var response: DimensionalPriceGroups? = null + + @JvmSynthetic + internal fun from(dimensionalPriceGroupListPageAsync: DimensionalPriceGroupListPageAsync) = + apply { + service = dimensionalPriceGroupListPageAsync.service + params = dimensionalPriceGroupListPageAsync.params + response = dimensionalPriceGroupListPageAsync.response + } + + fun service(service: DimensionalPriceGroupServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: DimensionalPriceGroupListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: DimensionalPriceGroups) = apply { this.response = response } + + /** + * Returns an immutable instance of [DimensionalPriceGroupListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionalPriceGroupListPageAsync = + DimensionalPriceGroupListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: DimensionalPriceGroupListPageAsync) { @@ -117,4 +160,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DimensionalPriceGroupListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "DimensionalPriceGroupListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt index 296e9dc08..bfcc86365 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.events.BackfillService import java.util.Objects import java.util.Optional @@ -9,24 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all backfills in a list format. - * - * The list of backfills is ordered starting from the most recently created backfill. The response - * also includes [`pagination_metadata`](/api-reference/pagination), which lets the caller retrieve - * the next page of results if they exist. More information about pagination can be found in the - * [Pagination-metadata schema](pagination). - */ +/** @see [BackfillService.list] */ class EventBackfillListPage private constructor( - private val backfillsService: BackfillService, + private val service: BackfillService, private val params: EventBackfillListParams, private val response: EventBackfillListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): EventBackfillListPageResponse = response - /** * Delegates to [EventBackfillListPageResponse], but gracefully handles missing data. * @@ -43,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EventBackfillListPage && backfillsService == other.backfillsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(backfillsService, params, response) /* spotless:on */ - - override fun toString() = - "EventBackfillListPage{backfillsService=$backfillsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -77,20 +55,76 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { backfillsService.list(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): EventBackfillListParams = params + + /** The response that this page was parsed from. */ + fun response(): EventBackfillListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - backfillsService: BackfillService, - params: EventBackfillListParams, - response: EventBackfillListPageResponse, - ) = EventBackfillListPage(backfillsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [EventBackfillListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventBackfillListPage]. */ + class Builder internal constructor() { + + private var service: BackfillService? = null + private var params: EventBackfillListParams? = null + private var response: EventBackfillListPageResponse? = null + + @JvmSynthetic + internal fun from(eventBackfillListPage: EventBackfillListPage) = apply { + service = eventBackfillListPage.service + params = eventBackfillListPage.params + response = eventBackfillListPage.response + } + + fun service(service: BackfillService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: EventBackfillListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: EventBackfillListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [EventBackfillListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventBackfillListPage = + EventBackfillListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: EventBackfillListPage) : @@ -112,4 +146,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EventBackfillListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "EventBackfillListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt index 623ca86e9..21a3d2533 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.events.BackfillServiceAsync import java.util.Objects import java.util.Optional @@ -10,24 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all backfills in a list format. - * - * The list of backfills is ordered starting from the most recently created backfill. The response - * also includes [`pagination_metadata`](/api-reference/pagination), which lets the caller retrieve - * the next page of results if they exist. More information about pagination can be found in the - * [Pagination-metadata schema](pagination). - */ +/** @see [BackfillServiceAsync.list] */ class EventBackfillListPageAsync private constructor( - private val backfillsService: BackfillServiceAsync, + private val service: BackfillServiceAsync, private val params: EventBackfillListParams, private val response: EventBackfillListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): EventBackfillListPageResponse = response - /** * Delegates to [EventBackfillListPageResponse], but gracefully handles missing data. * @@ -44,19 +35,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EventBackfillListPageAsync && backfillsService == other.backfillsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(backfillsService, params, response) /* spotless:on */ - - override fun toString() = - "EventBackfillListPageAsync{backfillsService=$backfillsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -78,22 +56,78 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { backfillsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): EventBackfillListParams = params + + /** The response that this page was parsed from. */ + fun response(): EventBackfillListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - backfillsService: BackfillServiceAsync, - params: EventBackfillListParams, - response: EventBackfillListPageResponse, - ) = EventBackfillListPageAsync(backfillsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [EventBackfillListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventBackfillListPageAsync]. */ + class Builder internal constructor() { + + private var service: BackfillServiceAsync? = null + private var params: EventBackfillListParams? = null + private var response: EventBackfillListPageResponse? = null + + @JvmSynthetic + internal fun from(eventBackfillListPageAsync: EventBackfillListPageAsync) = apply { + service = eventBackfillListPageAsync.service + params = eventBackfillListPageAsync.params + response = eventBackfillListPageAsync.response + } + + fun service(service: BackfillServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: EventBackfillListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: EventBackfillListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [EventBackfillListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventBackfillListPageAsync = + EventBackfillListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: EventBackfillListPageAsync) { @@ -124,4 +158,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EventBackfillListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "EventBackfillListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt index d125013b2..6584cb93d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.InvoiceService import java.util.Objects import java.util.Optional @@ -9,30 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all [`Invoice`](/core-concepts#invoice)s for an account in a list - * format. - * - * The list of invoices is ordered starting from the most recently issued invoice date. The response - * also includes [`pagination_metadata`](/api-reference/pagination), which lets the caller retrieve - * the next page of results if they exist. - * - * By default, this only returns invoices that are `issued`, `paid`, or `synced`. - * - * When fetching any `draft` invoices, this returns the last-computed invoice values for each draft - * invoice, which may not always be up-to-date since Orb regularly refreshes invoices - * asynchronously. - */ +/** @see [InvoiceService.list] */ class InvoiceListPage private constructor( - private val invoicesService: InvoiceService, + private val service: InvoiceService, private val params: InvoiceListParams, private val response: InvoiceListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): InvoiceListPageResponse = response - /** * Delegates to [InvoiceListPageResponse], but gracefully handles missing data. * @@ -48,19 +33,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoiceListPage && invoicesService == other.invoicesService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(invoicesService, params, response) /* spotless:on */ - - override fun toString() = - "InvoiceListPage{invoicesService=$invoicesService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -82,20 +54,75 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { invoicesService.list(it) } - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): InvoiceListParams = params + + /** The response that this page was parsed from. */ + fun response(): InvoiceListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - invoicesService: InvoiceService, - params: InvoiceListParams, - response: InvoiceListPageResponse, - ) = InvoiceListPage(invoicesService, params, response) + /** + * Returns a mutable builder for constructing an instance of [InvoiceListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvoiceListPage]. */ + class Builder internal constructor() { + + private var service: InvoiceService? = null + private var params: InvoiceListParams? = null + private var response: InvoiceListPageResponse? = null + + @JvmSynthetic + internal fun from(invoiceListPage: InvoiceListPage) = apply { + service = invoiceListPage.service + params = invoiceListPage.params + response = invoiceListPage.response + } + + fun service(service: InvoiceService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: InvoiceListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: InvoiceListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [InvoiceListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvoiceListPage = + InvoiceListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: InvoiceListPage) : Iterable { @@ -116,4 +143,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoiceListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "InvoiceListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt index 2796213d7..4ae13b3a0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.InvoiceServiceAsync import java.util.Objects import java.util.Optional @@ -10,30 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all [`Invoice`](/core-concepts#invoice)s for an account in a list - * format. - * - * The list of invoices is ordered starting from the most recently issued invoice date. The response - * also includes [`pagination_metadata`](/api-reference/pagination), which lets the caller retrieve - * the next page of results if they exist. - * - * By default, this only returns invoices that are `issued`, `paid`, or `synced`. - * - * When fetching any `draft` invoices, this returns the last-computed invoice values for each draft - * invoice, which may not always be up-to-date since Orb regularly refreshes invoices - * asynchronously. - */ +/** @see [InvoiceServiceAsync.list] */ class InvoiceListPageAsync private constructor( - private val invoicesService: InvoiceServiceAsync, + private val service: InvoiceServiceAsync, private val params: InvoiceListParams, private val response: InvoiceListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): InvoiceListPageResponse = response - /** * Delegates to [InvoiceListPageResponse], but gracefully handles missing data. * @@ -49,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoiceListPageAsync && invoicesService == other.invoicesService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(invoicesService, params, response) /* spotless:on */ - - override fun toString() = - "InvoiceListPageAsync{invoicesService=$invoicesService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -83,22 +55,78 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { invoicesService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): InvoiceListParams = params + + /** The response that this page was parsed from. */ + fun response(): InvoiceListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - invoicesService: InvoiceServiceAsync, - params: InvoiceListParams, - response: InvoiceListPageResponse, - ) = InvoiceListPageAsync(invoicesService, params, response) + /** + * Returns a mutable builder for constructing an instance of [InvoiceListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvoiceListPageAsync]. */ + class Builder internal constructor() { + + private var service: InvoiceServiceAsync? = null + private var params: InvoiceListParams? = null + private var response: InvoiceListPageResponse? = null + + @JvmSynthetic + internal fun from(invoiceListPageAsync: InvoiceListPageAsync) = apply { + service = invoiceListPageAsync.service + params = invoiceListPageAsync.params + response = invoiceListPageAsync.response + } + + fun service(service: InvoiceServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: InvoiceListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: InvoiceListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [InvoiceListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvoiceListPageAsync = + InvoiceListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: InvoiceListPageAsync) { @@ -126,4 +154,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoiceListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "InvoiceListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt index 86b88d770..49f8acf10 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.ItemService import java.util.Objects import java.util.Optional @@ -9,17 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** This endpoint returns a list of all Items, ordered in descending order by creation time. */ +/** @see [ItemService.list] */ class ItemListPage private constructor( - private val itemsService: ItemService, + private val service: ItemService, private val params: ItemListParams, private val response: ItemListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): ItemListPageResponse = response - /** * Delegates to [ItemListPageResponse], but gracefully handles missing data. * @@ -35,19 +33,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ItemListPage && itemsService == other.itemsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(itemsService, params, response) /* spotless:on */ - - override fun toString() = - "ItemListPage{itemsService=$itemsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -69,17 +54,75 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { itemsService.list(it) } - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): ItemListParams = params + + /** The response that this page was parsed from. */ + fun response(): ItemListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of(itemsService: ItemService, params: ItemListParams, response: ItemListPageResponse) = - ItemListPage(itemsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [ItemListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemListPage]. */ + class Builder internal constructor() { + + private var service: ItemService? = null + private var params: ItemListParams? = null + private var response: ItemListPageResponse? = null + + @JvmSynthetic + internal fun from(itemListPage: ItemListPage) = apply { + service = itemListPage.service + params = itemListPage.params + response = itemListPage.response + } + + fun service(service: ItemService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: ItemListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: ItemListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [ItemListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ItemListPage = + ItemListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: ItemListPage) : Iterable { @@ -100,4 +143,16 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ItemListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = "ItemListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt index d0178cd69..fb75f340f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.ItemServiceAsync import java.util.Objects import java.util.Optional @@ -10,17 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** This endpoint returns a list of all Items, ordered in descending order by creation time. */ +/** @see [ItemServiceAsync.list] */ class ItemListPageAsync private constructor( - private val itemsService: ItemServiceAsync, + private val service: ItemServiceAsync, private val params: ItemListParams, private val response: ItemListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): ItemListPageResponse = response - /** * Delegates to [ItemListPageResponse], but gracefully handles missing data. * @@ -36,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ItemListPageAsync && itemsService == other.itemsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(itemsService, params, response) /* spotless:on */ - - override fun toString() = - "ItemListPageAsync{itemsService=$itemsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -70,22 +55,78 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { itemsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): ItemListParams = params + + /** The response that this page was parsed from. */ + fun response(): ItemListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - itemsService: ItemServiceAsync, - params: ItemListParams, - response: ItemListPageResponse, - ) = ItemListPageAsync(itemsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [ItemListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemListPageAsync]. */ + class Builder internal constructor() { + + private var service: ItemServiceAsync? = null + private var params: ItemListParams? = null + private var response: ItemListPageResponse? = null + + @JvmSynthetic + internal fun from(itemListPageAsync: ItemListPageAsync) = apply { + service = itemListPageAsync.service + params = itemListPageAsync.params + response = itemListPageAsync.response + } + + fun service(service: ItemServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: ItemListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: ItemListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [ItemListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ItemListPageAsync = + ItemListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: ItemListPageAsync) { @@ -113,4 +154,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ItemListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "ItemListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt index a2154ad21..bd8cb5043 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.MetricService import java.util.Objects import java.util.Optional @@ -9,20 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * This endpoint is used to fetch [metric](/core-concepts##metric) details given a metric - * identifier. It returns information about the metrics including its name, description, and item. - */ +/** @see [MetricService.list] */ class MetricListPage private constructor( - private val metricsService: MetricService, + private val service: MetricService, private val params: MetricListParams, private val response: MetricListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): MetricListPageResponse = response - /** * Delegates to [MetricListPageResponse], but gracefully handles missing data. * @@ -39,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MetricListPage && metricsService == other.metricsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(metricsService, params, response) /* spotless:on */ - - override fun toString() = - "MetricListPage{metricsService=$metricsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -73,20 +55,75 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { metricsService.list(it) } - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): MetricListParams = params + + /** The response that this page was parsed from. */ + fun response(): MetricListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - metricsService: MetricService, - params: MetricListParams, - response: MetricListPageResponse, - ) = MetricListPage(metricsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [MetricListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricListPage]. */ + class Builder internal constructor() { + + private var service: MetricService? = null + private var params: MetricListParams? = null + private var response: MetricListPageResponse? = null + + @JvmSynthetic + internal fun from(metricListPage: MetricListPage) = apply { + service = metricListPage.service + params = metricListPage.params + response = metricListPage.response + } + + fun service(service: MetricService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: MetricListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: MetricListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [MetricListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MetricListPage = + MetricListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: MetricListPage) : Iterable { @@ -107,4 +144,16 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MetricListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = "MetricListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt index 9f1c9d41f..9f509035a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.MetricServiceAsync import java.util.Objects import java.util.Optional @@ -10,20 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * This endpoint is used to fetch [metric](/core-concepts##metric) details given a metric - * identifier. It returns information about the metrics including its name, description, and item. - */ +/** @see [MetricServiceAsync.list] */ class MetricListPageAsync private constructor( - private val metricsService: MetricServiceAsync, + private val service: MetricServiceAsync, private val params: MetricListParams, private val response: MetricListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): MetricListPageResponse = response - /** * Delegates to [MetricListPageResponse], but gracefully handles missing data. * @@ -40,19 +35,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MetricListPageAsync && metricsService == other.metricsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(metricsService, params, response) /* spotless:on */ - - override fun toString() = - "MetricListPageAsync{metricsService=$metricsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -74,22 +56,78 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { metricsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): MetricListParams = params + + /** The response that this page was parsed from. */ + fun response(): MetricListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - metricsService: MetricServiceAsync, - params: MetricListParams, - response: MetricListPageResponse, - ) = MetricListPageAsync(metricsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [MetricListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricListPageAsync]. */ + class Builder internal constructor() { + + private var service: MetricServiceAsync? = null + private var params: MetricListParams? = null + private var response: MetricListPageResponse? = null + + @JvmSynthetic + internal fun from(metricListPageAsync: MetricListPageAsync) = apply { + service = metricListPageAsync.service + params = metricListPageAsync.params + response = metricListPageAsync.response + } + + fun service(service: MetricServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: MetricListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: MetricListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [MetricListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MetricListPageAsync = + MetricListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: MetricListPageAsync) { @@ -120,4 +158,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MetricListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "MetricListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt index 9df790806..3442a4638 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.PlanService import java.util.Objects import java.util.Optional @@ -9,22 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all [plans](/core-concepts#plan-and-price) for an account in a - * list format. The list of plans is ordered starting from the most recently created plan. The - * response also includes [`pagination_metadata`](/api-reference/pagination), which lets the caller - * retrieve the next page of results if they exist. - */ +/** @see [PlanService.list] */ class PlanListPage private constructor( - private val plansService: PlanService, + private val service: PlanService, private val params: PlanListParams, private val response: PlanListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): PlanListPageResponse = response - /** * Delegates to [PlanListPageResponse], but gracefully handles missing data. * @@ -40,19 +33,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanListPage && plansService == other.plansService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(plansService, params, response) /* spotless:on */ - - override fun toString() = - "PlanListPage{plansService=$plansService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -74,17 +54,75 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { plansService.list(it) } - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): PlanListParams = params + + /** The response that this page was parsed from. */ + fun response(): PlanListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of(plansService: PlanService, params: PlanListParams, response: PlanListPageResponse) = - PlanListPage(plansService, params, response) + /** + * Returns a mutable builder for constructing an instance of [PlanListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanListPage]. */ + class Builder internal constructor() { + + private var service: PlanService? = null + private var params: PlanListParams? = null + private var response: PlanListPageResponse? = null + + @JvmSynthetic + internal fun from(planListPage: PlanListPage) = apply { + service = planListPage.service + params = planListPage.params + response = planListPage.response + } + + fun service(service: PlanService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: PlanListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: PlanListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [PlanListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanListPage = + PlanListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: PlanListPage) : Iterable { @@ -105,4 +143,16 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = "PlanListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt index f8154d594..f12c610fe 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.PlanServiceAsync import java.util.Objects import java.util.Optional @@ -10,22 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all [plans](/core-concepts#plan-and-price) for an account in a - * list format. The list of plans is ordered starting from the most recently created plan. The - * response also includes [`pagination_metadata`](/api-reference/pagination), which lets the caller - * retrieve the next page of results if they exist. - */ +/** @see [PlanServiceAsync.list] */ class PlanListPageAsync private constructor( - private val plansService: PlanServiceAsync, + private val service: PlanServiceAsync, private val params: PlanListParams, private val response: PlanListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): PlanListPageResponse = response - /** * Delegates to [PlanListPageResponse], but gracefully handles missing data. * @@ -41,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanListPageAsync && plansService == other.plansService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(plansService, params, response) /* spotless:on */ - - override fun toString() = - "PlanListPageAsync{plansService=$plansService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -75,22 +55,78 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { plansService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): PlanListParams = params + + /** The response that this page was parsed from. */ + fun response(): PlanListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - plansService: PlanServiceAsync, - params: PlanListParams, - response: PlanListPageResponse, - ) = PlanListPageAsync(plansService, params, response) + /** + * Returns a mutable builder for constructing an instance of [PlanListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanListPageAsync]. */ + class Builder internal constructor() { + + private var service: PlanServiceAsync? = null + private var params: PlanListParams? = null + private var response: PlanListPageResponse? = null + + @JvmSynthetic + internal fun from(planListPageAsync: PlanListPageAsync) = apply { + service = planListPageAsync.service + params = planListPageAsync.params + response = planListPageAsync.response + } + + fun service(service: PlanServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: PlanListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: PlanListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [PlanListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanListPageAsync = + PlanListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: PlanListPageAsync) { @@ -118,4 +154,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "PlanListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt index a465d17a7..90ac2e313 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.PriceService import java.util.Objects import java.util.Optional @@ -9,20 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * This endpoint is used to list all add-on prices created using the - * [price creation endpoint](/api-reference/price/create-price). - */ +/** @see [PriceService.list] */ class PriceListPage private constructor( - private val pricesService: PriceService, + private val service: PriceService, private val params: PriceListParams, private val response: PriceListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): PriceListPageResponse = response - /** * Delegates to [PriceListPageResponse], but gracefully handles missing data. * @@ -38,19 +33,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceListPage && pricesService == other.pricesService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(pricesService, params, response) /* spotless:on */ - - override fun toString() = - "PriceListPage{pricesService=$pricesService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -72,20 +54,75 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { pricesService.list(it) } - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): PriceListParams = params + + /** The response that this page was parsed from. */ + fun response(): PriceListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - pricesService: PriceService, - params: PriceListParams, - response: PriceListPageResponse, - ) = PriceListPage(pricesService, params, response) + /** + * Returns a mutable builder for constructing an instance of [PriceListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PriceListPage]. */ + class Builder internal constructor() { + + private var service: PriceService? = null + private var params: PriceListParams? = null + private var response: PriceListPageResponse? = null + + @JvmSynthetic + internal fun from(priceListPage: PriceListPage) = apply { + service = priceListPage.service + params = priceListPage.params + response = priceListPage.response + } + + fun service(service: PriceService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: PriceListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: PriceListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [PriceListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PriceListPage = + PriceListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: PriceListPage) : Iterable { @@ -106,4 +143,16 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = "PriceListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt index d149b008f..e38c33a45 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.PriceServiceAsync import java.util.Objects import java.util.Optional @@ -10,20 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * This endpoint is used to list all add-on prices created using the - * [price creation endpoint](/api-reference/price/create-price). - */ +/** @see [PriceServiceAsync.list] */ class PriceListPageAsync private constructor( - private val pricesService: PriceServiceAsync, + private val service: PriceServiceAsync, private val params: PriceListParams, private val response: PriceListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): PriceListPageResponse = response - /** * Delegates to [PriceListPageResponse], but gracefully handles missing data. * @@ -39,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceListPageAsync && pricesService == other.pricesService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(pricesService, params, response) /* spotless:on */ - - override fun toString() = - "PriceListPageAsync{pricesService=$pricesService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -73,22 +55,78 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { pricesService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): PriceListParams = params + + /** The response that this page was parsed from. */ + fun response(): PriceListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - pricesService: PriceServiceAsync, - params: PriceListParams, - response: PriceListPageResponse, - ) = PriceListPageAsync(pricesService, params, response) + /** + * Returns a mutable builder for constructing an instance of [PriceListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PriceListPageAsync]. */ + class Builder internal constructor() { + + private var service: PriceServiceAsync? = null + private var params: PriceListParams? = null + private var response: PriceListPageResponse? = null + + @JvmSynthetic + internal fun from(priceListPageAsync: PriceListPageAsync) = apply { + service = priceListPageAsync.service + params = priceListPageAsync.params + response = priceListPageAsync.response + } + + fun service(service: PriceServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: PriceListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: PriceListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [PriceListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PriceListPageAsync = + PriceListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: PriceListPageAsync) { @@ -116,4 +154,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "PriceListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt index d9442f317..2e815413a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.SubscriptionService import java.util.Objects import java.util.Optional @@ -9,21 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a [paginated](/api-reference/pagination) list of all plans associated with - * a subscription along with their start and end dates. This list contains the subscription's - * initial plan along with past and future plan changes. - */ +/** @see [SubscriptionService.fetchSchedule] */ class SubscriptionFetchSchedulePage private constructor( - private val subscriptionsService: SubscriptionService, + private val service: SubscriptionService, private val params: SubscriptionFetchScheduleParams, private val response: SubscriptionFetchSchedulePageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): SubscriptionFetchSchedulePageResponse = response - /** * Delegates to [SubscriptionFetchSchedulePageResponse], but gracefully handles missing data. * @@ -40,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionFetchSchedulePage && subscriptionsService == other.subscriptionsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionsService, params, response) /* spotless:on */ - - override fun toString() = - "SubscriptionFetchSchedulePage{subscriptionsService=$subscriptionsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -74,20 +55,79 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { subscriptionsService.fetchSchedule(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.fetchSchedule(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): SubscriptionFetchScheduleParams = params + + /** The response that this page was parsed from. */ + fun response(): SubscriptionFetchSchedulePageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - subscriptionsService: SubscriptionService, - params: SubscriptionFetchScheduleParams, - response: SubscriptionFetchSchedulePageResponse, - ) = SubscriptionFetchSchedulePage(subscriptionsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionFetchSchedulePage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionFetchSchedulePage]. */ + class Builder internal constructor() { + + private var service: SubscriptionService? = null + private var params: SubscriptionFetchScheduleParams? = null + private var response: SubscriptionFetchSchedulePageResponse? = null + + @JvmSynthetic + internal fun from(subscriptionFetchSchedulePage: SubscriptionFetchSchedulePage) = apply { + service = subscriptionFetchSchedulePage.service + params = subscriptionFetchSchedulePage.params + response = subscriptionFetchSchedulePage.response + } + + fun service(service: SubscriptionService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: SubscriptionFetchScheduleParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: SubscriptionFetchSchedulePageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [SubscriptionFetchSchedulePage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionFetchSchedulePage = + SubscriptionFetchSchedulePage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: SubscriptionFetchSchedulePage) : @@ -109,4 +149,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionFetchSchedulePage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "SubscriptionFetchSchedulePage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt index c8e1a1965..b98954526 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.SubscriptionServiceAsync import java.util.Objects import java.util.Optional @@ -10,21 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a [paginated](/api-reference/pagination) list of all plans associated with - * a subscription along with their start and end dates. This list contains the subscription's - * initial plan along with past and future plan changes. - */ +/** @see [SubscriptionServiceAsync.fetchSchedule] */ class SubscriptionFetchSchedulePageAsync private constructor( - private val subscriptionsService: SubscriptionServiceAsync, + private val service: SubscriptionServiceAsync, private val params: SubscriptionFetchScheduleParams, private val response: SubscriptionFetchSchedulePageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): SubscriptionFetchSchedulePageResponse = response - /** * Delegates to [SubscriptionFetchSchedulePageResponse], but gracefully handles missing data. * @@ -41,19 +35,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionFetchSchedulePageAsync && subscriptionsService == other.subscriptionsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionsService, params, response) /* spotless:on */ - - override fun toString() = - "SubscriptionFetchSchedulePageAsync{subscriptionsService=$subscriptionsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -75,22 +56,82 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { subscriptionsService.fetchSchedule(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.fetchSchedule(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): SubscriptionFetchScheduleParams = params + + /** The response that this page was parsed from. */ + fun response(): SubscriptionFetchSchedulePageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - subscriptionsService: SubscriptionServiceAsync, - params: SubscriptionFetchScheduleParams, - response: SubscriptionFetchSchedulePageResponse, - ) = SubscriptionFetchSchedulePageAsync(subscriptionsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionFetchSchedulePageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionFetchSchedulePageAsync]. */ + class Builder internal constructor() { + + private var service: SubscriptionServiceAsync? = null + private var params: SubscriptionFetchScheduleParams? = null + private var response: SubscriptionFetchSchedulePageResponse? = null + + @JvmSynthetic + internal fun from(subscriptionFetchSchedulePageAsync: SubscriptionFetchSchedulePageAsync) = + apply { + service = subscriptionFetchSchedulePageAsync.service + params = subscriptionFetchSchedulePageAsync.params + response = subscriptionFetchSchedulePageAsync.response + } + + fun service(service: SubscriptionServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: SubscriptionFetchScheduleParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: SubscriptionFetchSchedulePageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [SubscriptionFetchSchedulePageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionFetchSchedulePageAsync = + SubscriptionFetchSchedulePageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: SubscriptionFetchSchedulePageAsync) { @@ -121,4 +162,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionFetchSchedulePageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "SubscriptionFetchSchedulePageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt index f052b9502..6dbe30e25 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.SubscriptionService import java.util.Objects import java.util.Optional @@ -9,26 +10,14 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all subscriptions for an account as a - * [paginated](/api-reference/pagination) list, ordered starting from the most recently created - * subscription. For a full discussion of the subscription resource, see - * [Subscription](/core-concepts##subscription). - * - * Subscriptions can be filtered for a specific customer by using either the customer_id or - * external_customer_id query parameters. To filter subscriptions for multiple customers, use the - * customer_id[] or external_customer_id[] query parameters. - */ +/** @see [SubscriptionService.list] */ class SubscriptionListPage private constructor( - private val subscriptionsService: SubscriptionService, + private val service: SubscriptionService, private val params: SubscriptionListParams, private val response: Subscriptions, ) { - /** Returns the response that this page was parsed from. */ - fun response(): Subscriptions = response - /** * Delegates to [Subscriptions], but gracefully handles missing data. * @@ -44,19 +33,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionListPage && subscriptionsService == other.subscriptionsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionsService, params, response) /* spotless:on */ - - override fun toString() = - "SubscriptionListPage{subscriptionsService=$subscriptionsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -78,20 +54,75 @@ private constructor( ) } - fun getNextPage(): Optional { - return getNextPageParams().map { subscriptionsService.list(it) } - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): SubscriptionListParams = params + + /** The response that this page was parsed from. */ + fun response(): Subscriptions = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - subscriptionsService: SubscriptionService, - params: SubscriptionListParams, - response: Subscriptions, - ) = SubscriptionListPage(subscriptionsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [SubscriptionListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionListPage]. */ + class Builder internal constructor() { + + private var service: SubscriptionService? = null + private var params: SubscriptionListParams? = null + private var response: Subscriptions? = null + + @JvmSynthetic + internal fun from(subscriptionListPage: SubscriptionListPage) = apply { + service = subscriptionListPage.service + params = subscriptionListPage.params + response = subscriptionListPage.response + } + + fun service(service: SubscriptionService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: SubscriptionListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: Subscriptions) = apply { this.response = response } + + /** + * Returns an immutable instance of [SubscriptionListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionListPage = + SubscriptionListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: SubscriptionListPage) : Iterable { @@ -112,4 +143,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "SubscriptionListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt index 16d9c4203..455951073 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.checkRequired import com.withorb.api.services.async.SubscriptionServiceAsync import java.util.Objects import java.util.Optional @@ -10,26 +11,14 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * This endpoint returns a list of all subscriptions for an account as a - * [paginated](/api-reference/pagination) list, ordered starting from the most recently created - * subscription. For a full discussion of the subscription resource, see - * [Subscription](/core-concepts##subscription). - * - * Subscriptions can be filtered for a specific customer by using either the customer_id or - * external_customer_id query parameters. To filter subscriptions for multiple customers, use the - * customer_id[] or external_customer_id[] query parameters. - */ +/** @see [SubscriptionServiceAsync.list] */ class SubscriptionListPageAsync private constructor( - private val subscriptionsService: SubscriptionServiceAsync, + private val service: SubscriptionServiceAsync, private val params: SubscriptionListParams, private val response: Subscriptions, ) { - /** Returns the response that this page was parsed from. */ - fun response(): Subscriptions = response - /** * Delegates to [Subscriptions], but gracefully handles missing data. * @@ -45,19 +34,6 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionListPageAsync && subscriptionsService == other.subscriptionsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionsService, params, response) /* spotless:on */ - - override fun toString() = - "SubscriptionListPageAsync{subscriptionsService=$subscriptionsService, params=$params, response=$response}" - fun hasNextPage(): Boolean = data().isNotEmpty() && paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent @@ -79,22 +55,78 @@ private constructor( ) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { subscriptionsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) + /** The parameters that were used to request this page. */ + fun params(): SubscriptionListParams = params + + /** The response that this page was parsed from. */ + fun response(): Subscriptions = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - subscriptionsService: SubscriptionServiceAsync, - params: SubscriptionListParams, - response: Subscriptions, - ) = SubscriptionListPageAsync(subscriptionsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [SubscriptionListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionListPageAsync]. */ + class Builder internal constructor() { + + private var service: SubscriptionServiceAsync? = null + private var params: SubscriptionListParams? = null + private var response: Subscriptions? = null + + @JvmSynthetic + internal fun from(subscriptionListPageAsync: SubscriptionListPageAsync) = apply { + service = subscriptionListPageAsync.service + params = subscriptionListPageAsync.params + response = subscriptionListPageAsync.response + } + + fun service(service: SubscriptionServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: SubscriptionListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: Subscriptions) = apply { this.response = response } + + /** + * Returns an immutable instance of [SubscriptionListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionListPageAsync = + SubscriptionListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: SubscriptionListPageAsync) { @@ -122,4 +154,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "SubscriptionListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt index eed3630c1..3a07f60d7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt @@ -184,11 +184,11 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie } } .let { - AlertListPageAsync.of( - AlertServiceAsyncImpl(clientOptions), - params, - it, - ) + AlertListPageAsync.builder() + .service(AlertServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt index d4991cdc1..38a83bca3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt @@ -137,11 +137,11 @@ class CouponServiceAsyncImpl internal constructor(private val clientOptions: Cli } } .let { - CouponListPageAsync.of( - CouponServiceAsyncImpl(clientOptions), - params, - it, - ) + CouponListPageAsync.builder() + .service(CouponServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt index 891b2d6cf..1c25b2ee0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt @@ -115,11 +115,11 @@ class CreditNoteServiceAsyncImpl internal constructor(private val clientOptions: } } .let { - CreditNoteListPageAsync.of( - CreditNoteServiceAsyncImpl(clientOptions), - params, - it, - ) + CreditNoteListPageAsync.builder() + .service(CreditNoteServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt index 480be9063..7ed7766fb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt @@ -237,11 +237,11 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C } } .let { - CustomerListPageAsync.of( - CustomerServiceAsyncImpl(clientOptions), - params, - it, - ) + CustomerListPageAsync.builder() + .service(CustomerServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncImpl.kt index d1f32baf5..b65239766 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncImpl.kt @@ -166,11 +166,11 @@ internal constructor(private val clientOptions: ClientOptions) : DimensionalPric } } .let { - DimensionalPriceGroupListPageAsync.of( - DimensionalPriceGroupServiceAsyncImpl(clientOptions), - params, - it, - ) + DimensionalPriceGroupListPageAsync.builder() + .service(DimensionalPriceGroupServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt index ab74d7532..e63e0397c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt @@ -194,11 +194,11 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl } } .let { - InvoiceListPageAsync.of( - InvoiceServiceAsyncImpl(clientOptions), - params, - it, - ) + InvoiceListPageAsync.builder() + .service(InvoiceServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt index c8208fdf5..3bca007f3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt @@ -153,11 +153,11 @@ class ItemServiceAsyncImpl internal constructor(private val clientOptions: Clien } } .let { - ItemListPageAsync.of( - ItemServiceAsyncImpl(clientOptions), - params, - it, - ) + ItemListPageAsync.builder() + .service(ItemServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt index 9f5c70083..7fcfab11f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt @@ -153,11 +153,11 @@ class MetricServiceAsyncImpl internal constructor(private val clientOptions: Cli } } .let { - MetricListPageAsync.of( - MetricServiceAsyncImpl(clientOptions), - params, - it, - ) + MetricListPageAsync.builder() + .service(MetricServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt index 34d60774b..6ed6bd374 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt @@ -167,11 +167,11 @@ class PlanServiceAsyncImpl internal constructor(private val clientOptions: Clien } } .let { - PlanListPageAsync.of( - PlanServiceAsyncImpl(clientOptions), - params, - it, - ) + PlanListPageAsync.builder() + .service(PlanServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt index c3224575b..0e1e32a6f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt @@ -177,11 +177,11 @@ class PriceServiceAsyncImpl internal constructor(private val clientOptions: Clie } } .let { - PriceListPageAsync.of( - PriceServiceAsyncImpl(clientOptions), - params, - it, - ) + PriceListPageAsync.builder() + .service(PriceServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncImpl.kt index 3ef14351b..add175fcb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncImpl.kt @@ -267,11 +267,11 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption } } .let { - SubscriptionListPageAsync.of( - SubscriptionServiceAsyncImpl(clientOptions), - params, - it, - ) + SubscriptionListPageAsync.builder() + .service(SubscriptionServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } @@ -394,11 +394,11 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption } } .let { - SubscriptionFetchSchedulePageAsync.of( - SubscriptionServiceAsyncImpl(clientOptions), - params, - it, - ) + SubscriptionFetchSchedulePageAsync.builder() + .service(SubscriptionServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt index 50cd70121..f749a531e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt @@ -66,11 +66,11 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption } } .let { - CouponSubscriptionListPageAsync.of( - SubscriptionServiceAsyncImpl(clientOptions), - params, - it, - ) + CouponSubscriptionListPageAsync.builder() + .service(SubscriptionServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt index 1efbff97b..b2c2284d4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt @@ -108,11 +108,11 @@ internal constructor(private val clientOptions: ClientOptions) : BalanceTransact } } .let { - CustomerBalanceTransactionListPageAsync.of( - BalanceTransactionServiceAsyncImpl(clientOptions), - params, - it, - ) + CustomerBalanceTransactionListPageAsync.builder() + .service(BalanceTransactionServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt index 47c8154ca..39fad882b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt @@ -101,11 +101,11 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli } } .let { - CustomerCreditListPageAsync.of( - CreditServiceAsyncImpl(clientOptions), - params, - it, - ) + CustomerCreditListPageAsync.builder() + .service(CreditServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } @@ -143,11 +143,11 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli } } .let { - CustomerCreditListByExternalIdPageAsync.of( - CreditServiceAsyncImpl(clientOptions), - params, - it, - ) + CustomerCreditListByExternalIdPageAsync.builder() + .service(CreditServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt index 7aa39f4d7..111daf6ab 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt @@ -96,11 +96,11 @@ class LedgerServiceAsyncImpl internal constructor(private val clientOptions: Cli } } .let { - CustomerCreditLedgerListPageAsync.of( - LedgerServiceAsyncImpl(clientOptions), - params, - it, - ) + CustomerCreditLedgerListPageAsync.builder() + .service(LedgerServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } @@ -211,11 +211,11 @@ class LedgerServiceAsyncImpl internal constructor(private val clientOptions: Cli } } .let { - CustomerCreditLedgerListByExternalIdPageAsync.of( - LedgerServiceAsyncImpl(clientOptions), - params, - it, - ) + CustomerCreditLedgerListByExternalIdPageAsync.builder() + .service(LedgerServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt index 2abbb3eda..09ca25318 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt @@ -145,11 +145,11 @@ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: Clie } } .let { - CustomerCreditTopUpListPageAsync.of( - TopUpServiceAsyncImpl(clientOptions), - params, - it, - ) + CustomerCreditTopUpListPageAsync.builder() + .service(TopUpServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } @@ -283,11 +283,11 @@ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: Clie } } .let { - CustomerCreditTopUpListByExternalIdPageAsync.of( - TopUpServiceAsyncImpl(clientOptions), - params, - it, - ) + CustomerCreditTopUpListByExternalIdPageAsync.builder() + .service(TopUpServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt index a9f522f94..cff62b177 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt @@ -135,11 +135,11 @@ class BackfillServiceAsyncImpl internal constructor(private val clientOptions: C } } .let { - EventBackfillListPageAsync.of( - BackfillServiceAsyncImpl(clientOptions), - params, - it, - ) + EventBackfillListPageAsync.builder() + .service(BackfillServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt index 85bed6a73..31e2fed93 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt @@ -159,7 +159,13 @@ class AlertServiceImpl internal constructor(private val clientOptions: ClientOpt it.validate() } } - .let { AlertListPage.of(AlertServiceImpl(clientOptions), params, it) } + .let { + AlertListPage.builder() + .service(AlertServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt index 9c51dfb87..517aa4ba6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt @@ -118,7 +118,13 @@ class CouponServiceImpl internal constructor(private val clientOptions: ClientOp it.validate() } } - .let { CouponListPage.of(CouponServiceImpl(clientOptions), params, it) } + .let { + CouponListPage.builder() + .service(CouponServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt index 211aa5be0..a036d08b6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt @@ -105,7 +105,13 @@ class CreditNoteServiceImpl internal constructor(private val clientOptions: Clie it.validate() } } - .let { CreditNoteListPage.of(CreditNoteServiceImpl(clientOptions), params, it) } + .let { + CreditNoteListPage.builder() + .service(CreditNoteServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt index 545211222..da329b172 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt @@ -216,7 +216,13 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client it.validate() } } - .let { CustomerListPage.of(CustomerServiceImpl(clientOptions), params, it) } + .let { + CustomerListPage.builder() + .service(CustomerServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceImpl.kt index 39ad5f9b1..5aef96249 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceImpl.kt @@ -154,11 +154,11 @@ internal constructor(private val clientOptions: ClientOptions) : DimensionalPric } } .let { - DimensionalPriceGroupListPage.of( - DimensionalPriceGroupServiceImpl(clientOptions), - params, - it, - ) + DimensionalPriceGroupListPage.builder() + .service(DimensionalPriceGroupServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt index 62401c8bf..9ca3b288d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt @@ -163,7 +163,13 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO it.validate() } } - .let { InvoiceListPage.of(InvoiceServiceImpl(clientOptions), params, it) } + .let { + InvoiceListPage.builder() + .service(InvoiceServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt index b69537f38..04065b321 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt @@ -130,7 +130,13 @@ class ItemServiceImpl internal constructor(private val clientOptions: ClientOpti it.validate() } } - .let { ItemListPage.of(ItemServiceImpl(clientOptions), params, it) } + .let { + ItemListPage.builder() + .service(ItemServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt index 36f676bcb..cc6119c69 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt @@ -137,7 +137,13 @@ class MetricServiceImpl internal constructor(private val clientOptions: ClientOp it.validate() } } - .let { MetricListPage.of(MetricServiceImpl(clientOptions), params, it) } + .let { + MetricListPage.builder() + .service(MetricServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt index 002b52448..a817592dc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt @@ -144,7 +144,13 @@ class PlanServiceImpl internal constructor(private val clientOptions: ClientOpti it.validate() } } - .let { PlanListPage.of(PlanServiceImpl(clientOptions), params, it) } + .let { + PlanListPage.builder() + .service(PlanServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt index 3bcec6ac4..556cb014d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt @@ -154,7 +154,13 @@ class PriceServiceImpl internal constructor(private val clientOptions: ClientOpt it.validate() } } - .let { PriceListPage.of(PriceServiceImpl(clientOptions), params, it) } + .let { + PriceListPage.builder() + .service(PriceServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionServiceImpl.kt index 810703218..f327e26bb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionServiceImpl.kt @@ -254,7 +254,11 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl } } .let { - SubscriptionListPage.of(SubscriptionServiceImpl(clientOptions), params, it) + SubscriptionListPage.builder() + .service(SubscriptionServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } @@ -365,11 +369,11 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl } } .let { - SubscriptionFetchSchedulePage.of( - SubscriptionServiceImpl(clientOptions), - params, - it, - ) + SubscriptionFetchSchedulePage.builder() + .service(SubscriptionServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt index 72ccf4255..d19b9301f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt @@ -63,11 +63,11 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl } } .let { - CouponSubscriptionListPage.of( - SubscriptionServiceImpl(clientOptions), - params, - it, - ) + CouponSubscriptionListPage.builder() + .service(SubscriptionServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt index ad57833c1..f5b3f8885 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt @@ -102,11 +102,11 @@ class BalanceTransactionServiceImpl internal constructor(private val clientOptio } } .let { - CustomerBalanceTransactionListPage.of( - BalanceTransactionServiceImpl(clientOptions), - params, - it, - ) + CustomerBalanceTransactionListPage.builder() + .service(BalanceTransactionServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt index 4be4dbfc8..421613a6f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt @@ -97,7 +97,13 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp it.validate() } } - .let { CustomerCreditListPage.of(CreditServiceImpl(clientOptions), params, it) } + .let { + CustomerCreditListPage.builder() + .service(CreditServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } } } @@ -131,11 +137,11 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp } } .let { - CustomerCreditListByExternalIdPage.of( - CreditServiceImpl(clientOptions), - params, - it, - ) + CustomerCreditListByExternalIdPage.builder() + .service(CreditServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt index 373c45110..25a4c60b8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt @@ -93,11 +93,11 @@ class LedgerServiceImpl internal constructor(private val clientOptions: ClientOp } } .let { - CustomerCreditLedgerListPage.of( - LedgerServiceImpl(clientOptions), - params, - it, - ) + CustomerCreditLedgerListPage.builder() + .service(LedgerServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } @@ -199,11 +199,11 @@ class LedgerServiceImpl internal constructor(private val clientOptions: ClientOp } } .let { - CustomerCreditLedgerListByExternalIdPage.of( - LedgerServiceImpl(clientOptions), - params, - it, - ) + CustomerCreditLedgerListByExternalIdPage.builder() + .service(LedgerServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt index 5051e0e9a..626104a6e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt @@ -138,7 +138,11 @@ class TopUpServiceImpl internal constructor(private val clientOptions: ClientOpt } } .let { - CustomerCreditTopUpListPage.of(TopUpServiceImpl(clientOptions), params, it) + CustomerCreditTopUpListPage.builder() + .service(TopUpServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } @@ -260,11 +264,11 @@ class TopUpServiceImpl internal constructor(private val clientOptions: ClientOpt } } .let { - CustomerCreditTopUpListByExternalIdPage.of( - TopUpServiceImpl(clientOptions), - params, - it, - ) + CustomerCreditTopUpListByExternalIdPage.builder() + .service(TopUpServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt index 7de1684e2..5f2af3181 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt @@ -129,7 +129,11 @@ class BackfillServiceImpl internal constructor(private val clientOptions: Client } } .let { - EventBackfillListPage.of(BackfillServiceImpl(clientOptions), params, it) + EventBackfillListPage.builder() + .service(BackfillServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } }