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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ import java.util.stream.Stream
import java.util.stream.StreamSupport
import kotlin.jvm.optionals.getOrNull

/**
* (Available March 4, 2025) List network total records with optional filters. Not available in
* sandbox.
*/
/** List network total records with optional filters. Not available in sandbox. */
class ReportSettlementNetworkTotalListPage
private constructor(
private val networkTotalsService: NetworkTotalService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ import java.util.concurrent.CompletableFuture
import java.util.concurrent.Executor
import java.util.function.Predicate

/**
* (Available March 4, 2025) List network total records with optional filters. Not available in
* sandbox.
*/
/** List network total records with optional filters. Not available in sandbox. */
class ReportSettlementNetworkTotalListPageAsync
private constructor(
private val networkTotalsService: NetworkTotalServiceAsync,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

/**
* (Available March 4, 2025) List network total records with optional filters. Not available in
* sandbox.
*/
/** List network total records with optional filters. Not available in sandbox. */
class ReportSettlementNetworkTotalListParams
private constructor(
private val begin: OffsetDateTime?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import com.lithic.api.core.http.Headers
import com.lithic.api.core.http.QueryParams
import java.util.Objects

/**
* (Available March 4, 2025) Retrieve a specific network total record by token. Not available in
* sandbox.
*/
/** Retrieve a specific network total record by token. Not available in sandbox. */
class ReportSettlementNetworkTotalRetrieveParams
private constructor(
private val token: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@ private constructor(
class Filters
@JsonCreator
private constructor(
@JsonProperty("exclude_countries")
@ExcludeMissing
private val excludeCountries: JsonField<List<String>> = JsonMissing.of(),
@JsonProperty("exclude_mccs")
@ExcludeMissing
private val excludeMccs: JsonField<List<String>> = JsonMissing.of(),
@JsonProperty("include_countries")
@ExcludeMissing
private val includeCountries: JsonField<List<String>> = JsonMissing.of(),
Expand All @@ -295,6 +301,20 @@ private constructor(
private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
) {

/**
* ISO-3166-1 alpha-3 Country Codes to exclude from the velocity calculation. Transactions
* matching any of the provided will be excluded from the calculated velocity.
*/
fun excludeCountries(): Optional<List<String>> =
Optional.ofNullable(excludeCountries.getNullable("exclude_countries"))

/**
* Merchant Category Codes to exclude from the velocity calculation. Transactions matching
* this MCC will be excluded from the calculated velocity.
*/
fun excludeMccs(): Optional<List<String>> =
Optional.ofNullable(excludeMccs.getNullable("exclude_mccs"))

/**
* ISO-3166-1 alpha-3 Country Codes to include in the velocity calculation. Transactions not
* matching any of the provided will not be included in the calculated velocity.
Expand All @@ -309,6 +329,22 @@ private constructor(
fun includeMccs(): Optional<List<String>> =
Optional.ofNullable(includeMccs.getNullable("include_mccs"))

/**
* ISO-3166-1 alpha-3 Country Codes to exclude from the velocity calculation. Transactions
* matching any of the provided will be excluded from the calculated velocity.
*/
@JsonProperty("exclude_countries")
@ExcludeMissing
fun _excludeCountries(): JsonField<List<String>> = excludeCountries

/**
* Merchant Category Codes to exclude from the velocity calculation. Transactions matching
* this MCC will be excluded from the calculated velocity.
*/
@JsonProperty("exclude_mccs")
@ExcludeMissing
fun _excludeMccs(): JsonField<List<String>> = excludeMccs

/**
* ISO-3166-1 alpha-3 Country Codes to include in the velocity calculation. Transactions not
* matching any of the provided will not be included in the calculated velocity.
Expand Down Expand Up @@ -336,6 +372,8 @@ private constructor(
return@apply
}

excludeCountries()
excludeMccs()
includeCountries()
includeMccs()
validated = true
Expand All @@ -352,17 +390,91 @@ private constructor(
/** A builder for [Filters]. */
class Builder internal constructor() {

private var excludeCountries: JsonField<MutableList<String>>? = null
private var excludeMccs: JsonField<MutableList<String>>? = null
private var includeCountries: JsonField<MutableList<String>>? = null
private var includeMccs: JsonField<MutableList<String>>? = null
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(filters: Filters) = apply {
excludeCountries = filters.excludeCountries.map { it.toMutableList() }
excludeMccs = filters.excludeMccs.map { it.toMutableList() }
includeCountries = filters.includeCountries.map { it.toMutableList() }
includeMccs = filters.includeMccs.map { it.toMutableList() }
additionalProperties = filters.additionalProperties.toMutableMap()
}

/**
* ISO-3166-1 alpha-3 Country Codes to exclude from the velocity calculation.
* Transactions matching any of the provided will be excluded from the calculated
* velocity.
*/
fun excludeCountries(excludeCountries: List<String>?) =
excludeCountries(JsonField.ofNullable(excludeCountries))

/**
* ISO-3166-1 alpha-3 Country Codes to exclude from the velocity calculation.
* Transactions matching any of the provided will be excluded from the calculated
* velocity.
*/
fun excludeCountries(excludeCountries: Optional<List<String>>) =
excludeCountries(excludeCountries.getOrNull())

/**
* ISO-3166-1 alpha-3 Country Codes to exclude from the velocity calculation.
* Transactions matching any of the provided will be excluded from the calculated
* velocity.
*/
fun excludeCountries(excludeCountries: JsonField<List<String>>) = apply {
this.excludeCountries = excludeCountries.map { it.toMutableList() }
}

/**
* ISO-3166-1 alpha-3 Country Codes to exclude from the velocity calculation.
* Transactions matching any of the provided will be excluded from the calculated
* velocity.
*/
fun addExcludeCountry(excludeCountry: String) = apply {
excludeCountries =
(excludeCountries ?: JsonField.of(mutableListOf())).also {
checkKnown("excludeCountries", it).add(excludeCountry)
}
}

/**
* Merchant Category Codes to exclude from the velocity calculation. Transactions
* matching this MCC will be excluded from the calculated velocity.
*/
fun excludeMccs(excludeMccs: List<String>?) =
excludeMccs(JsonField.ofNullable(excludeMccs))

/**
* Merchant Category Codes to exclude from the velocity calculation. Transactions
* matching this MCC will be excluded from the calculated velocity.
*/
fun excludeMccs(excludeMccs: Optional<List<String>>) =
excludeMccs(excludeMccs.getOrNull())

/**
* Merchant Category Codes to exclude from the velocity calculation. Transactions
* matching this MCC will be excluded from the calculated velocity.
*/
fun excludeMccs(excludeMccs: JsonField<List<String>>) = apply {
this.excludeMccs = excludeMccs.map { it.toMutableList() }
}

/**
* Merchant Category Codes to exclude from the velocity calculation. Transactions
* matching this MCC will be excluded from the calculated velocity.
*/
fun addExcludeMcc(excludeMcc: String) = apply {
excludeMccs =
(excludeMccs ?: JsonField.of(mutableListOf())).also {
checkKnown("excludeMccs", it).add(excludeMcc)
}
}

/**
* ISO-3166-1 alpha-3 Country Codes to include in the velocity calculation. Transactions
* not matching any of the provided will not be included in the calculated velocity.
Expand Down Expand Up @@ -450,6 +562,8 @@ private constructor(

fun build(): Filters =
Filters(
(excludeCountries ?: JsonMissing.of()).map { it.toImmutable() },
(excludeMccs ?: JsonMissing.of()).map { it.toImmutable() },
(includeCountries ?: JsonMissing.of()).map { it.toImmutable() },
(includeMccs ?: JsonMissing.of()).map { it.toImmutable() },
additionalProperties.toImmutable(),
Expand All @@ -461,17 +575,17 @@ private constructor(
return true
}

return /* spotless:off */ other is Filters && includeCountries == other.includeCountries && includeMccs == other.includeMccs && additionalProperties == other.additionalProperties /* spotless:on */
return /* spotless:off */ other is Filters && excludeCountries == other.excludeCountries && excludeMccs == other.excludeMccs && includeCountries == other.includeCountries && includeMccs == other.includeMccs && additionalProperties == other.additionalProperties /* spotless:on */
}

/* spotless:off */
private val hashCode: Int by lazy { Objects.hash(includeCountries, includeMccs, additionalProperties) }
private val hashCode: Int by lazy { Objects.hash(excludeCountries, excludeMccs, includeCountries, includeMccs, additionalProperties) }
/* spotless:on */

override fun hashCode(): Int = hashCode

override fun toString() =
"Filters{includeCountries=$includeCountries, includeMccs=$includeMccs, additionalProperties=$additionalProperties}"
"Filters{excludeCountries=$excludeCountries, excludeMccs=$excludeMccs, includeCountries=$includeCountries, includeMccs=$includeMccs, additionalProperties=$additionalProperties}"
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ interface NetworkTotalServiceAsync {
*/
fun withRawResponse(): WithRawResponse

/**
* (Available March 4, 2025) Retrieve a specific network total record by token. Not available in
* sandbox.
*/
/** Retrieve a specific network total record by token. Not available in sandbox. */
fun retrieve(
params: ReportSettlementNetworkTotalRetrieveParams
): CompletableFuture<NetworkTotalRetrieveResponse> = retrieve(params, RequestOptions.none())
Expand All @@ -32,10 +29,7 @@ interface NetworkTotalServiceAsync {
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture<NetworkTotalRetrieveResponse>

/**
* (Available March 4, 2025) List network total records with optional filters. Not available in
* sandbox.
*/
/** List network total records with optional filters. Not available in sandbox. */
fun list(): CompletableFuture<ReportSettlementNetworkTotalListPageAsync> =
list(ReportSettlementNetworkTotalListParams.none())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ interface NetworkTotalService {
*/
fun withRawResponse(): WithRawResponse

/**
* (Available March 4, 2025) Retrieve a specific network total record by token. Not available in
* sandbox.
*/
/** Retrieve a specific network total record by token. Not available in sandbox. */
fun retrieve(params: ReportSettlementNetworkTotalRetrieveParams): NetworkTotalRetrieveResponse =
retrieve(params, RequestOptions.none())

Expand All @@ -30,10 +27,7 @@ interface NetworkTotalService {
requestOptions: RequestOptions = RequestOptions.none(),
): NetworkTotalRetrieveResponse

/**
* (Available March 4, 2025) List network total records with optional filters. Not available in
* sandbox.
*/
/** List network total records with optional filters. Not available in sandbox. */
fun list(): ReportSettlementNetworkTotalListPage =
list(ReportSettlementNetworkTotalListParams.none())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class VelocityLimitParamsTest {
VelocityLimitParams.builder()
.filters(
VelocityLimitParams.Filters.builder()
.addExcludeCountry("USD")
.addExcludeMcc("5542")
.addIncludeCountry("USD")
.addIncludeMcc("5542")
.build()
Expand All @@ -26,6 +28,8 @@ class VelocityLimitParamsTest {
assertThat(velocityLimitParams.filters())
.isEqualTo(
VelocityLimitParams.Filters.builder()
.addExcludeCountry("USD")
.addExcludeMcc("5542")
.addIncludeCountry("USD")
.addIncludeMcc("5542")
.build()
Expand Down