From d556d487e72b67b907269fe40117cbf5a42b1be0 Mon Sep 17 00:00:00 2001 From: Dmitry Marchuk Date: Sat, 10 Aug 2024 13:56:52 +0300 Subject: [PATCH] Update dependencies && start updating APIs --- .idea/kotlinc.xml | 2 +- build.gradle.kts | 22 +-- .../smaugfm/lunchmoney/api/LunchmoneyApi.kt | 14 +- ...egoryMultiple.kt => LunchmoneyCategory.kt} | 15 +- ...gorySingle.kt => LunchmoneyCategoryOld.kt} | 2 +- .../lunchmoney/model/LunchmoneyTransaction.kt | 64 +++++++-- .../model/LunchmoneyTransactionChild.kt | 32 +++++ .../model/LunchmoneyTransactionTag.kt | 3 +- .../lunchmoney/model/LunchmoneyUser.kt | 8 ++ .../enumeration/LunchmoneyAssetStatus.kt | 6 + .../LunchmoneyRecurringExpenseType.kt | 3 +- .../LunchmoneyTransactionSource.kt | 5 + .../LunchmoneyTransactionStatus.kt | 2 - .../category/AddToCategoryGroupRequest.kt | 4 +- .../category/GetAllCategoriesRequest.kt | 8 +- .../category/GetSingleCategoryRequest.kt | 4 +- .../CreateUpdateCategoryRequestParams.kt | 12 +- .../category/params/GetAllCategoriesParams.kt | 21 +++ .../response/GetAllCategoriesResponse.kt | 4 +- .../response/GetAllTransactionsResponse.kt | 3 +- .../serializer/AssetStatusSerializer.kt | 8 ++ .../serializer/AssetTypeSerializer.kt | 2 +- .../serializer/CryptoSourceSerializer.kt | 2 +- .../serializer/LowercaseEnumSerializer.kt | 2 +- .../RecurringExpenseSourceSerializer.kt | 2 +- .../RecurringExpenseTypeSerializer.kt | 2 +- .../serializer/TransactionSourceSerializer.kt | 9 ++ .../serializer/TransactionStatusSerializer.kt | 2 +- .../smaugfm/lunchmoney/AuthorizationTest.kt | 5 +- .../lunchmoney/JsonSchemaUpToDateTest.kt | 14 +- .../lunchmoney/api/RequestExecutorTest.kt | 7 +- .../category/AddToCategoryGroupRequestTest.kt | 4 +- .../CreateCategoryGroupRequestTest.kt | 9 +- .../category/CreateCategoryRequestTest.kt | 23 ++-- .../category/DeleteCategoryRequestTest.kt | 4 +- .../request/category/GetAllCategoriesTest.kt | 27 +++- .../category/GetSingleCategoryRequestTest.kt | 9 +- .../category/UpdateCategoryRequestTest.kt | 3 +- .../request/tag/GetAllTagsRequestTest.kt | 4 +- .../transaction/GetAllTransactionsTest.kt | 113 ++++++++------- .../GetSingleTransactionRequestTest.kt | 130 ++++++++++++------ .../InsertTransactionsRequestTest.kt | 4 +- .../request/user/GetCurrentUserRequestTest.kt | 2 + .../resources/response/getAllCategories.json | 14 +- src/test/resources/response/getAllTags.json | 6 +- .../response/getAllTransactions.json | 108 +++++++++------ .../resources/response/getCurrentUser.json | 1 + .../response/getSingleTransaction.json | 66 ++++++--- 48 files changed, 545 insertions(+), 271 deletions(-) rename src/main/kotlin/io/github/smaugfm/lunchmoney/model/{LunchmoneyCategoryMultiple.kt => LunchmoneyCategory.kt} (55%) rename src/main/kotlin/io/github/smaugfm/lunchmoney/model/{LunchmoneyCategorySingle.kt => LunchmoneyCategoryOld.kt} (92%) create mode 100644 src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyTransactionChild.kt create mode 100644 src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyAssetStatus.kt create mode 100644 src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyTransactionSource.kt create mode 100644 src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/params/GetAllCategoriesParams.kt create mode 100644 src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/AssetStatusSerializer.kt create mode 100644 src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/TransactionSourceSerializer.kt diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 0fc3113..6d0ee1c 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 5e31706..1ad0bfb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,11 +7,11 @@ import org.jlleitschuh.gradle.ktlint.KtlintExtension import org.jlleitschuh.gradle.ktlint.reporter.ReporterType plugins { - kotlin("jvm") version "1.8.10" - kotlin("plugin.serialization") version "1.8.10" + kotlin("jvm") version "2.0.0" + kotlin("plugin.serialization") version "2.0.0" id("org.jlleitschuh.gradle.ktlint") version "11.2.0" id("io.gitlab.arturbosch.detekt") version "1.22.0" - id("org.jetbrains.dokka") version "1.8.10" + id("org.jetbrains.dokka") version "1.9.20" id("com.github.breadmoirai.github-release") version "2.4.1" signing `maven-publish` @@ -25,30 +25,30 @@ repositories { mavenCentral() } -val reactorCore = "3.5.2" -val reactorNetty = "1.1.2" +val reactor= "3.6.8" +val reactorNetty = "1.1.21" val mockserver = "5.15.0" -val logback = "1.4.5" +val logback = "1.5.6" val javaVersion = "11" val resilience4jVersion = "1.7.0" dependencies { - api("io.projectreactor:reactor-core:$reactorCore") + api("io.projectreactor:reactor-core:$reactor") api("io.projectreactor.netty:reactor-netty-http:$reactorNetty") api("io.projectreactor.netty:reactor-netty-core:$reactorNetty") implementation("io.github.microutils:kotlin-logging-jvm:3.0.5") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1") testImplementation("org.mock-server:mockserver-netty:$mockserver") testImplementation("org.mock-server:mockserver-client-java:$mockserver") testImplementation("io.github.resilience4j:resilience4j-retry:$resilience4jVersion") testImplementation("io.github.resilience4j:resilience4j-reactor:$resilience4jVersion") testImplementation("io.github.resilience4j:resilience4j-kotlin:$resilience4jVersion") - testImplementation("io.projectreactor:reactor-test:$reactorCore") + testImplementation("io.projectreactor:reactor-test:$reactor") testImplementation("io.mockk:mockk:1.13.4") - testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.25") + testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.28.1") testImplementation("ch.qos.logback:logback-core:$logback") testImplementation("ch.qos.logback:logback-classic:$logback") - testImplementation("io.projectreactor:reactor-tools:3.5.7") + testImplementation("io.projectreactor:reactor-tools:$reactor") testImplementation(kotlin("test")) } diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/api/LunchmoneyApi.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/api/LunchmoneyApi.kt index 2fa3a56..8115d04 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/api/LunchmoneyApi.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/api/LunchmoneyApi.kt @@ -2,8 +2,8 @@ package io.github.smaugfm.lunchmoney.api import io.github.smaugfm.lunchmoney.model.LunchmoneyAsset import io.github.smaugfm.lunchmoney.model.LunchmoneyBudget -import io.github.smaugfm.lunchmoney.model.LunchmoneyCategoryMultiple -import io.github.smaugfm.lunchmoney.model.LunchmoneyCategorySingle +import io.github.smaugfm.lunchmoney.model.LunchmoneyCategory +import io.github.smaugfm.lunchmoney.model.LunchmoneyCategoryOld import io.github.smaugfm.lunchmoney.model.LunchmoneyCrypto import io.github.smaugfm.lunchmoney.model.LunchmoneyInsertTransaction import io.github.smaugfm.lunchmoney.model.LunchmoneyPlaidAccount @@ -218,7 +218,7 @@ class LunchmoneyApi internal constructor( groupId: Long, categoryIds: List? = null, newCategories: List? = null - ): Mono = execute( + ): Mono = execute( AddToCategoryGroupRequest( groupId, AddToCategoryGroupsParams( @@ -266,7 +266,6 @@ class LunchmoneyApi internal constructor( isIncome = isIncome, excludeFromBudget = excludeFromBudget, excludeFromTotals = excludeFromTotals, - categoryIds = categoryIds, groupId = groupId ) ) @@ -280,11 +279,11 @@ class LunchmoneyApi internal constructor( ForceDeleteCategoryRequest(categoryId) ) - fun getAllCategories(): Mono> = execute( + fun getAllCategories(): Mono> = execute( GetAllCategoriesRequest() ).map { it.categories } - fun getSingleCategory(categoryId: Long): Mono = execute( + fun getSingleCategory(categoryId: Long): Mono = execute( GetSingleCategoryRequest(categoryId) ) @@ -302,11 +301,10 @@ class LunchmoneyApi internal constructor( categoryId, CreateUpdateCategoryRequestParams( name = name, - isIncome = isIncome, description = description, + isIncome = isIncome, excludeFromBudget = excludeFromBudget, excludeFromTotals = excludeFromTotals, - categoryIds = categoryIds, groupId = groupId ) ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyCategoryMultiple.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyCategory.kt similarity index 55% rename from src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyCategoryMultiple.kt rename to src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyCategory.kt index f043359..3032665 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyCategoryMultiple.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyCategory.kt @@ -8,15 +8,20 @@ import kotlinx.serialization.UseSerializers import java.time.Instant @Serializable -data class LunchmoneyCategoryMultiple( +data class LunchmoneyCategory( val id: Long, val name: String, val description: String? = null, val isIncome: Boolean, val excludeFromBudget: Boolean, val excludeFromTotals: Boolean, - val updatedAt: Instant, - val createdAt: Instant, - val isGroup: Boolean, - val groupId: Long? = null + val archived: Boolean? = null, + val archivedOn: Instant? = null, + val updatedAt: Instant? = null, + val createdAt: Instant? = null, + val isGroup: Boolean? = null, + val groupCategoryName: String? = null, + val groupId: Long? = null, + val order: Long? = null, + val children: List? = null ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyCategorySingle.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyCategoryOld.kt similarity index 92% rename from src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyCategorySingle.kt rename to src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyCategoryOld.kt index 3747a59..92f8101 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyCategorySingle.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyCategoryOld.kt @@ -3,7 +3,7 @@ package io.github.smaugfm.lunchmoney.model import kotlinx.serialization.Serializable @Serializable -data class LunchmoneyCategorySingle( +data class LunchmoneyCategoryOld( val id: Long, val name: String, val description: String? = null, diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyTransaction.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyTransaction.kt index f96629c..1966522 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyTransaction.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyTransaction.kt @@ -2,19 +2,31 @@ TransactionStatusSerializer::class, LocalDateSerializer::class, BigDecimalSerializer::class, - CurrencySerializer::class + CurrencySerializer::class, + InstantSerializer::class, + AssetStatusSerializer::class, + RecurringExpenseTypeSerializer::class, + TransactionSourceSerializer::class ) package io.github.smaugfm.lunchmoney.model +import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyAssetStatus +import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyRecurringExpenseType +import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyTransactionSource import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyTransactionStatus +import io.github.smaugfm.lunchmoney.serializer.AssetStatusSerializer import io.github.smaugfm.lunchmoney.serializer.BigDecimalSerializer import io.github.smaugfm.lunchmoney.serializer.CurrencySerializer +import io.github.smaugfm.lunchmoney.serializer.InstantSerializer import io.github.smaugfm.lunchmoney.serializer.LocalDateSerializer +import io.github.smaugfm.lunchmoney.serializer.RecurringExpenseTypeSerializer +import io.github.smaugfm.lunchmoney.serializer.TransactionSourceSerializer import io.github.smaugfm.lunchmoney.serializer.TransactionStatusSerializer import kotlinx.serialization.Serializable import kotlinx.serialization.UseSerializers import java.math.BigDecimal +import java.time.Instant import java.time.LocalDate import java.util.Currency @@ -26,21 +38,47 @@ data class LunchmoneyTransaction( val amount: BigDecimal, val currency: Currency, val toBase: Double, - val notes: String? = null, val categoryId: Long? = null, - val assetId: Long? = null, + val categoryName: String? = null, + val categoryGroupId: Long? = null, + val categoryGroupName: String? = null, + val isIncome: Boolean, + val excludeFromBudget: Boolean, + val excludeFromTotals: Boolean, + val createdAt: Instant, + val updatedAt: Instant, + val status: LunchmoneyTransactionStatus? = null, + val isPending: Boolean, + val notes: String? = null, + val originalName: String? = null, val recurringId: Long? = null, - val plaidAccountId: Long? = null, - val status: LunchmoneyTransactionStatus, + val recurringPayee: String? = null, + val recurringDescription: String? = null, + val recurringCadence: String? = null, + val recurringType: LunchmoneyRecurringExpenseType? = null, + val recurringAmount: BigDecimal? = null, + val recurringCurrency: Currency? = null, val parentId: Long? = null, - val isGroup: Boolean, + val hasChildren: Boolean? = null, val groupId: Long? = null, - val externalId: String? = null, + val isGroup: Boolean, + val assetId: Long? = null, + val assetInstitutionName: String? = null, + val assetName: String? = null, + val assetDisplayName: String? = null, + val assetStatus: LunchmoneyAssetStatus? = null, + val plaidAccountId: Long? = null, + val plaidAccountName: String? = null, + val plaidAccountMask: Long? = null, + val institutionName: String? = null, + val plaidAccountDisplayName: String? = null, + val plaidMetadata: String? = null, + val plaidCategory: String? = null, + val source: LunchmoneyTransactionSource? = null, + val displayName: String, + val displayNotes: String? = null, + val accountDisplayName: String, val tags: List? = null, - val originalName: String? = null, - val type: String? = null, - val subtype: String? = null, - val fees: String? = null, - val price: String? = null, - val quantity: String? = null + val children: List? = null, + val externalId: String? = null, ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyTransactionChild.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyTransactionChild.kt new file mode 100644 index 0000000..367be2c --- /dev/null +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyTransactionChild.kt @@ -0,0 +1,32 @@ +@file:UseSerializers( + LocalDateSerializer::class, + BigDecimalSerializer::class, + CurrencySerializer::class, + InstantSerializer::class, +) + +package io.github.smaugfm.lunchmoney.model + +import io.github.smaugfm.lunchmoney.serializer.BigDecimalSerializer +import io.github.smaugfm.lunchmoney.serializer.CurrencySerializer +import io.github.smaugfm.lunchmoney.serializer.InstantSerializer +import io.github.smaugfm.lunchmoney.serializer.LocalDateSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.UseSerializers +import java.math.BigDecimal +import java.time.LocalDate +import java.util.Currency + +@Serializable +data class LunchmoneyTransactionChild( + val id: Long, + val date: LocalDate, + val payee: String, + val amount: BigDecimal, + val currency: Currency, + val formattedDate: LocalDate, + val notes: String? = null, + val assetId: Long? = null, + val plaidAccountId: Long? = null, + val toBase: Double +) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyTransactionTag.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyTransactionTag.kt index ca83bda..58f5b8d 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyTransactionTag.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyTransactionTag.kt @@ -6,5 +6,6 @@ import kotlinx.serialization.Serializable data class LunchmoneyTransactionTag( val id: Long, val name: String, - val description: String? = null + val description: String? = null, + val archived: Boolean? = null, ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyUser.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyUser.kt index a38095c..c595f24 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyUser.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/LunchmoneyUser.kt @@ -1,6 +1,13 @@ +@file:UseSerializers( + CurrencySerializer::class +) + package io.github.smaugfm.lunchmoney.model +import io.github.smaugfm.lunchmoney.serializer.CurrencySerializer import kotlinx.serialization.Serializable +import kotlinx.serialization.UseSerializers +import java.util.Currency @Serializable data class LunchmoneyUser( @@ -9,5 +16,6 @@ data class LunchmoneyUser( val userEmail: String, val accountId: Long, val budgetName: String, + val primaryCurrency: Currency, val apiKeyLabel: String? = null ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyAssetStatus.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyAssetStatus.kt new file mode 100644 index 0000000..48a9d1f --- /dev/null +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyAssetStatus.kt @@ -0,0 +1,6 @@ +package io.github.smaugfm.lunchmoney.model.enumeration + +enum class LunchmoneyAssetStatus { + Active, + Closed +} diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyRecurringExpenseType.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyRecurringExpenseType.kt index 5cf71d7..80ee0f3 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyRecurringExpenseType.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyRecurringExpenseType.kt @@ -2,5 +2,6 @@ package io.github.smaugfm.lunchmoney.model.enumeration enum class LunchmoneyRecurringExpenseType { CLEARED, - SUGGESTED + SUGGESTED, + DISMISSED } diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyTransactionSource.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyTransactionSource.kt new file mode 100644 index 0000000..d24da9f --- /dev/null +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyTransactionSource.kt @@ -0,0 +1,5 @@ +package io.github.smaugfm.lunchmoney.model.enumeration + +enum class LunchmoneyTransactionSource { + Api, Csv, Manual, Merge, Plaid, Recurring, Rule, User +} diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyTransactionStatus.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyTransactionStatus.kt index c3c0dc1..a8b2be6 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyTransactionStatus.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/model/enumeration/LunchmoneyTransactionStatus.kt @@ -3,7 +3,5 @@ package io.github.smaugfm.lunchmoney.model.enumeration enum class LunchmoneyTransactionStatus { CLEARED, UNCLEARED, - RECURRING, - RECURRING_SUGGESTED, PENDING } diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/AddToCategoryGroupRequest.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/AddToCategoryGroupRequest.kt index 3057fd1..8c7a90a 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/AddToCategoryGroupRequest.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/AddToCategoryGroupRequest.kt @@ -1,14 +1,14 @@ package io.github.smaugfm.lunchmoney.request.category import io.github.smaugfm.lunchmoney.helper.PathAndQuery -import io.github.smaugfm.lunchmoney.model.LunchmoneyCategorySingle +import io.github.smaugfm.lunchmoney.model.LunchmoneyCategoryOld import io.github.smaugfm.lunchmoney.request.base.LunchmoneyAbstractPostRequest import io.github.smaugfm.lunchmoney.request.category.params.AddToCategoryGroupsParams internal class AddToCategoryGroupRequest( groupId: Long, params: AddToCategoryGroupsParams -) : LunchmoneyAbstractPostRequest( +) : LunchmoneyAbstractPostRequest( PathAndQuery .segment("categories") .segment("group") diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/GetAllCategoriesRequest.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/GetAllCategoriesRequest.kt index b8a4fd6..63b9dc2 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/GetAllCategoriesRequest.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/GetAllCategoriesRequest.kt @@ -2,8 +2,10 @@ package io.github.smaugfm.lunchmoney.request.category import io.github.smaugfm.lunchmoney.helper.PathAndQuery import io.github.smaugfm.lunchmoney.request.base.LunchmoneyAbstractGetRequest +import io.github.smaugfm.lunchmoney.request.category.params.GetAllCategoriesParams import io.github.smaugfm.lunchmoney.response.GetAllCategoriesResponse -internal class GetAllCategoriesRequest : LunchmoneyAbstractGetRequest( - PathAndQuery.segment("categories") -) +internal class GetAllCategoriesRequest(val params: GetAllCategoriesParams? = null) : + LunchmoneyAbstractGetRequest( + PathAndQuery.segment("categories").query(params) + ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/GetSingleCategoryRequest.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/GetSingleCategoryRequest.kt index d24df0b..28ce575 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/GetSingleCategoryRequest.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/GetSingleCategoryRequest.kt @@ -1,11 +1,11 @@ package io.github.smaugfm.lunchmoney.request.category import io.github.smaugfm.lunchmoney.helper.PathAndQuery -import io.github.smaugfm.lunchmoney.model.LunchmoneyCategorySingle +import io.github.smaugfm.lunchmoney.model.LunchmoneyCategory import io.github.smaugfm.lunchmoney.request.base.LunchmoneyAbstractGetRequest internal class GetSingleCategoryRequest( id: Long -) : LunchmoneyAbstractGetRequest( +) : LunchmoneyAbstractGetRequest( PathAndQuery.segment("categories").segment(id) ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/params/CreateUpdateCategoryRequestParams.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/params/CreateUpdateCategoryRequestParams.kt index cbb098c..d47d21a 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/params/CreateUpdateCategoryRequestParams.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/params/CreateUpdateCategoryRequestParams.kt @@ -5,10 +5,10 @@ import kotlinx.serialization.Serializable @Serializable internal class CreateUpdateCategoryRequestParams( val name: String?, - val isIncome: Boolean, - val excludeFromBudget: Boolean, - val excludeFromTotals: Boolean, - val description: String?, - val categoryIds: List?, - val groupId: Long? + val description: String? = null, + val isIncome: Boolean? = null, + val excludeFromBudget: Boolean? = null, + val excludeFromTotals: Boolean? = null, + val archived: Boolean? = null, + val groupId: Long? = null ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/params/GetAllCategoriesParams.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/params/GetAllCategoriesParams.kt new file mode 100644 index 0000000..f0f91cc --- /dev/null +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/request/category/params/GetAllCategoriesParams.kt @@ -0,0 +1,21 @@ +package io.github.smaugfm.lunchmoney.request.category.params + +import io.github.smaugfm.lunchmoney.serializer.LowercaseEnumSerializer +import kotlinx.serialization.Serializable + +@Serializable +internal data class GetAllCategoriesParams( + @Serializable(with = FormatSerializer::class) + val format: Format? = null +) { + + enum class Format { + Flattened, + Nested + } + + internal object FormatSerializer : LowercaseEnumSerializer( + "AssetType", + Format.entries.toTypedArray() + ) +} diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/response/GetAllCategoriesResponse.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/response/GetAllCategoriesResponse.kt index bf2edd6..d3b0914 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/response/GetAllCategoriesResponse.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/response/GetAllCategoriesResponse.kt @@ -1,9 +1,9 @@ package io.github.smaugfm.lunchmoney.response -import io.github.smaugfm.lunchmoney.model.LunchmoneyCategoryMultiple +import io.github.smaugfm.lunchmoney.model.LunchmoneyCategory import kotlinx.serialization.Serializable @Serializable internal data class GetAllCategoriesResponse( - val categories: List + val categories: List ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/response/GetAllTransactionsResponse.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/response/GetAllTransactionsResponse.kt index cb2f674..67febfa 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/response/GetAllTransactionsResponse.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/response/GetAllTransactionsResponse.kt @@ -5,5 +5,6 @@ import kotlinx.serialization.Serializable @Serializable internal data class GetAllTransactionsResponse( - val transactions: List + val transactions: List, + val hasMore: Boolean, ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/AssetStatusSerializer.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/AssetStatusSerializer.kt new file mode 100644 index 0000000..d3f1a6d --- /dev/null +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/AssetStatusSerializer.kt @@ -0,0 +1,8 @@ +package io.github.smaugfm.lunchmoney.serializer + +import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyAssetStatus + +internal object AssetStatusSerializer : LowercaseEnumSerializer( + "AssetStatus", + LunchmoneyAssetStatus.entries.toTypedArray() +) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/AssetTypeSerializer.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/AssetTypeSerializer.kt index e3445cf..062e44c 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/AssetTypeSerializer.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/AssetTypeSerializer.kt @@ -4,5 +4,5 @@ import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyAssetType internal object AssetTypeSerializer : LowercaseEnumSerializer( "AssetType", - LunchmoneyAssetType.values() + LunchmoneyAssetType.entries.toTypedArray() ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/CryptoSourceSerializer.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/CryptoSourceSerializer.kt index ed980fa..73a750d 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/CryptoSourceSerializer.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/CryptoSourceSerializer.kt @@ -4,5 +4,5 @@ import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyCryptoSource internal class CryptoSourceSerializer : LowercaseEnumSerializer( "CryptoSource", - LunchmoneyCryptoSource.values() + LunchmoneyCryptoSource.entries.toTypedArray() ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/LowercaseEnumSerializer.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/LowercaseEnumSerializer.kt index 8e385c1..5f91092 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/LowercaseEnumSerializer.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/LowercaseEnumSerializer.kt @@ -7,7 +7,7 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -internal open class LowercaseEnumSerializer>( +open class LowercaseEnumSerializer>( private val descriptorName: String, private val values: Array ) : KSerializer { diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/RecurringExpenseSourceSerializer.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/RecurringExpenseSourceSerializer.kt index 9bbfe99..7a50c48 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/RecurringExpenseSourceSerializer.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/RecurringExpenseSourceSerializer.kt @@ -5,5 +5,5 @@ import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyRecurringExpense internal object RecurringExpenseSourceSerializer : LowercaseEnumSerializer( "RecurringExpenseSource", - LunchmoneyRecurringExpenseSource.values() + LunchmoneyRecurringExpenseSource.entries.toTypedArray() ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/RecurringExpenseTypeSerializer.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/RecurringExpenseTypeSerializer.kt index f472808..3aab943 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/RecurringExpenseTypeSerializer.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/RecurringExpenseTypeSerializer.kt @@ -5,5 +5,5 @@ import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyRecurringExpense internal object RecurringExpenseTypeSerializer : LowercaseEnumSerializer( "RecurringExpenseType", - LunchmoneyRecurringExpenseType.values() + LunchmoneyRecurringExpenseType.entries.toTypedArray() ) diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/TransactionSourceSerializer.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/TransactionSourceSerializer.kt new file mode 100644 index 0000000..1b903f6 --- /dev/null +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/TransactionSourceSerializer.kt @@ -0,0 +1,9 @@ +package io.github.smaugfm.lunchmoney.serializer + +import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyTransactionSource + +class TransactionSourceSerializer : LowercaseEnumSerializer( + "TransactionSource", + LunchmoneyTransactionSource.entries.toTypedArray() +) { +} diff --git a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/TransactionStatusSerializer.kt b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/TransactionStatusSerializer.kt index 606a12f..6c5242e 100644 --- a/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/TransactionStatusSerializer.kt +++ b/src/main/kotlin/io/github/smaugfm/lunchmoney/serializer/TransactionStatusSerializer.kt @@ -5,5 +5,5 @@ import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyTransactionStatu internal object TransactionStatusSerializer : LowercaseEnumSerializer( "TransactionStatus", - LunchmoneyTransactionStatus.values() + LunchmoneyTransactionStatus.entries.toTypedArray() ) diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/AuthorizationTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/AuthorizationTest.kt index 800d64c..3468e9e 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/AuthorizationTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/AuthorizationTest.kt @@ -1,5 +1,6 @@ package io.github.smaugfm.lunchmoney +import assertk.assertFailure import assertk.assertThat import assertk.assertions.cause import assertk.assertions.contains @@ -8,6 +9,7 @@ import assertk.assertions.isInstanceOf import assertk.assertions.isNotNull import assertk.assertions.prop import io.github.smaugfm.lunchmoney.exception.LunchmoneyApiResponseException +import io.github.smaugfm.lunchmoney.model.LunchmoneyUser import io.github.smaugfm.lunchmoney.request.user.GetCurrentUserRequest import org.junit.jupiter.api.Test @@ -21,8 +23,7 @@ internal class AuthorizationTest : TestMockServerBase() { PORT ) val request = GetCurrentUserRequest() - assertThat { api.execute(request).block() } - .isFailure() + assertFailure { api.execute(request).block() } .isInstanceOf(RuntimeException::class) .cause() .isNotNull() diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/JsonSchemaUpToDateTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/JsonSchemaUpToDateTest.kt index 78471be..7b2cb20 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/JsonSchemaUpToDateTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/JsonSchemaUpToDateTest.kt @@ -10,7 +10,7 @@ import assertk.assertions.isTrue import assertk.assertions.prop import assertk.assertions.size import io.github.smaugfm.lunchmoney.api.LunchmoneyApi -import io.github.smaugfm.lunchmoney.model.LunchmoneyCategorySingle +import io.github.smaugfm.lunchmoney.model.LunchmoneyCategory import io.github.smaugfm.lunchmoney.model.LunchmoneyInsertTransaction import io.github.smaugfm.lunchmoney.model.LunchmoneyTransaction import io.github.smaugfm.lunchmoney.model.LunchmoneyUpdateTransaction @@ -52,16 +52,16 @@ class JsonSchemaUpToDateTest : TestBase() { try { var cat = api.getSingleCategory(id).block()!! assertThat(cat) - .prop(LunchmoneyCategorySingle::id) + .prop(LunchmoneyCategory::id) .isEqualTo(id) assertThat(cat) - .prop(LunchmoneyCategorySingle::name) + .prop(LunchmoneyCategory::name) .isEqualTo(catName) assertThat(api.updateCategory(id, true, false, false, catName2).block()!!).isTrue() cat = api.getSingleCategory(id).block()!! assertThat(cat) - .prop(LunchmoneyCategorySingle::name) + .prop(LunchmoneyCategory::name) .isEqualTo(catName2) } finally { assertThat(api.forceDeleteCategory(id).block()!!).isTrue() @@ -76,16 +76,16 @@ class JsonSchemaUpToDateTest : TestBase() { try { var cat = api.getSingleCategory(id).block()!! assertThat(cat) - .prop(LunchmoneyCategorySingle::id) + .prop(LunchmoneyCategory::id) .isEqualTo(id) assertThat(cat) - .prop(LunchmoneyCategorySingle::name) + .prop(LunchmoneyCategory::name) .isEqualTo(catName) assertThat(api.updateCategory(id, true, false, false, catName2).block()!!).isTrue() cat = api.getSingleCategory(id).block()!! assertThat(cat) - .prop(LunchmoneyCategorySingle::name) + .prop(LunchmoneyCategory::name) .isEqualTo(catName2) } finally { assertThat(api.forceDeleteCategory(id).block()!!).isTrue() diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/api/RequestExecutorTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/api/RequestExecutorTest.kt index 49ec110..07d798d 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/api/RequestExecutorTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/api/RequestExecutorTest.kt @@ -1,6 +1,7 @@ package io.github.smaugfm.lunchmoney.api import assertk.all +import assertk.assertFailure import assertk.assertThat import assertk.assertions.isEmpty import assertk.assertions.isEqualTo @@ -51,8 +52,7 @@ class RequestExecutorTest : TestMockServerBase() { .withStatusCode(500) ) val request = GetCurrentUserRequest() - assertThat { api.execute(request).block() } - .isFailure() + assertFailure { api.execute(request).block() } .isInstanceOf(RuntimeException::class) .prop(Throwable::cause) .isNotNull() @@ -90,8 +90,7 @@ class RequestExecutorTest : TestMockServerBase() { .withStatusCode(500) .withBody(body) ) - assertThat { api.execute(GetCurrentUserRequest()).block() } - .isFailure() + assertFailure { api.execute(GetCurrentUserRequest()).block() } .isInstanceOf(RuntimeException::class) .prop(Throwable::cause) .transform { it as LunchmoneyApiResponseException } diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/AddToCategoryGroupRequestTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/AddToCategoryGroupRequestTest.kt index 677f073..a965ce8 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/AddToCategoryGroupRequestTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/AddToCategoryGroupRequestTest.kt @@ -5,7 +5,7 @@ import assertk.assertions.isEqualTo import io.github.smaugfm.lunchmoney.TestMockServerBase import io.github.smaugfm.lunchmoney.Util.getResourceAsString import io.github.smaugfm.lunchmoney.model.LunchmoneyCategoryChild -import io.github.smaugfm.lunchmoney.model.LunchmoneyCategorySingle +import io.github.smaugfm.lunchmoney.model.LunchmoneyCategoryOld import io.github.smaugfm.lunchmoney.request.category.params.AddToCategoryGroupsParams import org.junit.jupiter.api.Test import java.time.Instant @@ -34,7 +34,7 @@ internal class AddToCategoryGroupRequestTest : TestMockServerBase() { ) assertThat(api.execute(request).block()) .isEqualTo( - LunchmoneyCategorySingle( + LunchmoneyCategoryOld( 315358L, "Food & Drink", null, diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/CreateCategoryGroupRequestTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/CreateCategoryGroupRequestTest.kt index cebf2ca..c55a2dd 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/CreateCategoryGroupRequestTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/CreateCategoryGroupRequestTest.kt @@ -1,5 +1,6 @@ package io.github.smaugfm.lunchmoney.request.category +import assertk.assertFailure import assertk.assertThat import assertk.assertions.cause import assertk.assertions.contains @@ -7,7 +8,6 @@ import assertk.assertions.isEqualTo import assertk.assertions.isFailure import assertk.assertions.isInstanceOf import assertk.assertions.isNotNull -import assertk.assertions.isSuccess import assertk.assertions.prop import io.github.smaugfm.lunchmoney.TestMockServerBase import io.github.smaugfm.lunchmoney.Util.getResourceAsString @@ -36,8 +36,8 @@ internal class CreateCategoryGroupRequestTest : TestMockServerBase() { CreateCategoryGroupRequestParams("vasa") ) - assertThat { api.execute(request).block() } - .isSuccess().isEqualTo( + assertThat(api.execute(request).block()) + .isEqualTo( CreateCategoryResponse(1234L) ) } @@ -57,8 +57,7 @@ internal class CreateCategoryGroupRequestTest : TestMockServerBase() { val createCategoryRequest = CreateCategoryGroupRequest( CreateCategoryGroupRequestParams("vasa") ) - assertThat { api.execute(createCategoryRequest).block() } - .isFailure() + assertFailure { api.execute(createCategoryRequest).block() } .isInstanceOf(RuntimeException::class) .cause() .isNotNull() diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/CreateCategoryRequestTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/CreateCategoryRequestTest.kt index bbeb63c..69e12b8 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/CreateCategoryRequestTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/CreateCategoryRequestTest.kt @@ -1,10 +1,10 @@ package io.github.smaugfm.lunchmoney.request.category +import assertk.assertFailure import assertk.assertThat import assertk.assertions.cause import assertk.assertions.contains import assertk.assertions.isEqualTo -import assertk.assertions.isFailure import assertk.assertions.isInstanceOf import assertk.assertions.isNotNull import assertk.assertions.prop @@ -34,12 +34,11 @@ internal class CreateCategoryRequestTest : TestMockServerBase() { val request = CreateCategoryRequest( CreateUpdateCategoryRequestParams( "vasa", - false, - false, - false, null, - null, - null + isIncome = false, + excludeFromBudget = false, + excludeFromTotals = false, + archived = null ) ) assertThat(api.execute(request).block()) @@ -61,16 +60,14 @@ internal class CreateCategoryRequestTest : TestMockServerBase() { val createCategoryRequest = CreateCategoryRequest( CreateUpdateCategoryRequestParams( "vasa", - false, - false, - false, null, - null, - null + false, + excludeFromBudget = false, + excludeFromTotals = false, + archived = null ) ) - assertThat { api.execute(createCategoryRequest).block() } - .isFailure() + assertFailure { api.execute(createCategoryRequest).block() } .isInstanceOf(RuntimeException::class) .cause() .isNotNull() diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/DeleteCategoryRequestTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/DeleteCategoryRequestTest.kt index 5178a10..4ced00f 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/DeleteCategoryRequestTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/DeleteCategoryRequestTest.kt @@ -1,5 +1,6 @@ package io.github.smaugfm.lunchmoney.request.category +import assertk.assertFailure import assertk.assertThat import assertk.assertions.cause import assertk.assertions.isEqualTo @@ -52,8 +53,7 @@ internal class DeleteCategoryRequestTest : TestMockServerBase() { val deleteCategoryRequest = DeleteCategoryRequest( id ) - assertThat { api.execute(deleteCategoryRequest).block() } - .isFailure() + assertFailure { api.execute(deleteCategoryRequest).block() } .isInstanceOf(RuntimeException::class) .cause() .isNotNull() diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/GetAllCategoriesTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/GetAllCategoriesTest.kt index 1d50943..440f3f9 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/GetAllCategoriesTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/GetAllCategoriesTest.kt @@ -4,7 +4,9 @@ import assertk.assertThat import assertk.assertions.isEqualTo import io.github.smaugfm.lunchmoney.TestMockServerBase import io.github.smaugfm.lunchmoney.Util.getResourceAsString -import io.github.smaugfm.lunchmoney.model.LunchmoneyCategoryMultiple +import io.github.smaugfm.lunchmoney.model.LunchmoneyCategory +import io.github.smaugfm.lunchmoney.model.LunchmoneyCategoryChild +import io.github.smaugfm.lunchmoney.request.category.params.GetAllCategoriesParams import io.github.smaugfm.lunchmoney.response.GetAllCategoriesResponse import org.junit.jupiter.api.Test import org.mockserver.model.HttpRequest.request @@ -24,12 +26,15 @@ internal class GetAllCategoriesTest : TestMockServerBase() { .withContentType(MediaType.APPLICATION_JSON_UTF_8) .withBody(getResourceAsString("response/getAllCategories.json")) ) - val request = GetAllCategoriesRequest() + val request = + GetAllCategoriesRequest( + GetAllCategoriesParams(format = GetAllCategoriesParams.Format.Flattened) + ) assertThat(api.execute(request).block()) .isEqualTo( GetAllCategoriesResponse( listOf( - LunchmoneyCategoryMultiple( + LunchmoneyCategory( id = 427748L, name = "Alcohol, Bars", description = null, @@ -39,9 +44,10 @@ internal class GetAllCategoriesTest : TestMockServerBase() { updatedAt = Instant.parse("2023-02-02T14:57:43.447Z"), createdAt = Instant.parse("2023-02-02T14:57:43.447Z"), isGroup = false, - groupId = null + groupId = null, + order = 0 ), - LunchmoneyCategoryMultiple( + LunchmoneyCategory( id = 427749L, name = "Coffee Shops", description = null, @@ -51,7 +57,16 @@ internal class GetAllCategoriesTest : TestMockServerBase() { updatedAt = Instant.parse("2023-02-02T14:57:43.459Z"), createdAt = Instant.parse("2023-02-02T14:57:43.459Z"), isGroup = false, - groupId = 427758L + groupId = 427758L, + order = 0, + children = listOf( + LunchmoneyCategoryChild( + id = 315162, + name = "Alcohol, Bars", + description = null, + createdAt = Instant.parse("2022-03-06T20:11:36.066Z"), + ) + ) ) ) ) diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/GetSingleCategoryRequestTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/GetSingleCategoryRequestTest.kt index 8eac01e..f2a4b3a 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/GetSingleCategoryRequestTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/GetSingleCategoryRequestTest.kt @@ -4,8 +4,9 @@ import assertk.assertThat import assertk.assertions.isEqualTo import io.github.smaugfm.lunchmoney.TestMockServerBase import io.github.smaugfm.lunchmoney.Util.getResourceAsString +import io.github.smaugfm.lunchmoney.model.LunchmoneyCategory import io.github.smaugfm.lunchmoney.model.LunchmoneyCategoryChild -import io.github.smaugfm.lunchmoney.model.LunchmoneyCategorySingle +import io.github.smaugfm.lunchmoney.model.LunchmoneyCategoryOld import org.junit.jupiter.api.Test import org.mockserver.model.HttpRequest.request import org.mockserver.model.HttpResponse.response @@ -29,7 +30,7 @@ internal class GetSingleCategoryRequestTest : TestMockServerBase() { val request = GetSingleCategoryRequest(id) assertThat(api.execute(request).block()) .isEqualTo( - LunchmoneyCategorySingle( + LunchmoneyCategory( id = id, name = "Shopping", description = null, @@ -60,7 +61,7 @@ internal class GetSingleCategoryRequestTest : TestMockServerBase() { val getSingleCategoryRequest = GetSingleCategoryRequest(id) assertThat(api.execute(getSingleCategoryRequest).block()) .isEqualTo( - LunchmoneyCategorySingle( + LunchmoneyCategory( id = id, name = "Food", description = "Consumables", @@ -104,7 +105,7 @@ internal class GetSingleCategoryRequestTest : TestMockServerBase() { val getSingleCategoryRequest = GetSingleCategoryRequest(id) assertThat(api.execute(getSingleCategoryRequest).block()) .isEqualTo( - LunchmoneyCategorySingle( + LunchmoneyCategory( id, "Coffee Shops", null, diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/UpdateCategoryRequestTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/UpdateCategoryRequestTest.kt index 9f38942..abbc87a 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/UpdateCategoryRequestTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/category/UpdateCategoryRequestTest.kt @@ -24,11 +24,10 @@ internal class UpdateCategoryRequestTest : TestMockServerBase() { id, CreateUpdateCategoryRequestParams( "vasa", + null, true, true, true, - null, - null, null ) ) diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/tag/GetAllTagsRequestTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/tag/GetAllTagsRequestTest.kt index ec3e5ac..f861f1d 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/tag/GetAllTagsRequestTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/tag/GetAllTagsRequestTest.kt @@ -28,8 +28,8 @@ internal class GetAllTagsRequestTest : TestMockServerBase() { assertThat(api.execute(request).block()) .isNotNull() .containsExactlyInAnyOrder( - LunchmoneyTransactionTag(1807L, "Wedding", "All wedding-related expenses"), - LunchmoneyTransactionTag(1808L, "Honeymoon", "All honeymoon-related expenses") + LunchmoneyTransactionTag(1807L, "Wedding", "All wedding-related expenses", false), + LunchmoneyTransactionTag(1808L, "Honeymoon", "All honeymoon-related expenses", false) ) } } diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/transaction/GetAllTransactionsTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/transaction/GetAllTransactionsTest.kt index 093a9eb..262f3c2 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/transaction/GetAllTransactionsTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/transaction/GetAllTransactionsTest.kt @@ -5,6 +5,8 @@ import assertk.assertions.isEqualTo import io.github.smaugfm.lunchmoney.TestMockServerBase import io.github.smaugfm.lunchmoney.Util.getResourceAsString import io.github.smaugfm.lunchmoney.model.LunchmoneyTransaction +import io.github.smaugfm.lunchmoney.model.LunchmoneyTransactionChild +import io.github.smaugfm.lunchmoney.model.LunchmoneyTransactionTag import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyTransactionStatus import io.github.smaugfm.lunchmoney.request.transaction.params.GetAllTransactionsParams import io.github.smaugfm.lunchmoney.response.GetAllTransactionsResponse @@ -13,6 +15,7 @@ import org.mockserver.model.HttpRequest.request import org.mockserver.model.HttpResponse.response import org.mockserver.model.MediaType import java.math.BigDecimal +import java.time.Instant import java.time.LocalDate import java.util.Currency @@ -28,7 +31,7 @@ internal class GetAllTransactionsTest : TestMockServerBase() { .withQueryStringParameter("asset_id", "1234") .withQueryStringParameter("group_id", "1234") .withQueryStringParameter("is_group", "false") - .withQueryStringParameter("status", "recurring") + .withQueryStringParameter("status", "cleared") .withQueryStringParameter("offset", "1234") .withQueryStringParameter("limit", "1234") .withQueryStringParameter("start_date", "2020-12-20") @@ -49,7 +52,7 @@ internal class GetAllTransactionsTest : TestMockServerBase() { assetId = 1234L, groupId = 1234L, isGroup = false, - status = LunchmoneyTransactionStatus.RECURRING, + status = LunchmoneyTransactionStatus.CLEARED, offset = 1234L, limit = 1234L, startDate = LocalDate.of(2020, 12, 20), @@ -63,56 +66,70 @@ internal class GetAllTransactionsTest : TestMockServerBase() { GetAllTransactionsResponse( listOf( LunchmoneyTransaction( - id = 602L, - date = LocalDate.of(2020, 1, 1), - payee = "Starbucks", - amount = BigDecimal("4.5000"), - currency = Currency.getInstance("CAD"), - toBase = 4.5, - notes = "Frappuccino", - categoryId = null, - assetId = null, - recurringId = null, - plaidAccountId = null, - status = LunchmoneyTransactionStatus.CLEARED, - parentId = null, - isGroup = false, - groupId = null, - externalId = null, - tags = null, - originalName = "STARBUCKS NW 32804", - type = null, - subtype = null, - fees = null, - price = null, - quantity = null - ), - LunchmoneyTransaction( - id = 603L, - date = LocalDate.of(2020, 1, 2), - payee = "Walmart", - amount = BigDecimal("20.9100"), + id = 246946944, + date = LocalDate.parse("2023-07-18"), + amount = BigDecimal.valueOf(53.19), currency = Currency.getInstance("USD"), - toBase = 20.91, + toBase = 53.19, + payee = "Amazon", + categoryId = 315172, + categoryName = "Restaurants", + categoryGroupId = 315358, + categoryGroupName = "Food & Drink", + isIncome = false, + excludeFromBudget = false, + excludeFromTotals = false, + createdAt = Instant.parse("2023-09-09T08:43:05.875Z"), + updatedAt = Instant.parse("2023-10-09T06:07:03.105Z"), + status = LunchmoneyTransactionStatus.CLEARED, + isPending = false, notes = null, - categoryId = null, - assetId = 153L, + originalName = null, recurringId = null, - plaidAccountId = null, - status = LunchmoneyTransactionStatus.UNCLEARED, - parentId = null, - isGroup = false, + recurringPayee = null, + recurringDescription = null, + recurringCadence = null, + recurringType = null, + recurringAmount = null, + recurringCurrency = null, + parentId = 225508713, + hasChildren = false, groupId = null, - externalId = "jf2r3t98o943", - tags = null, - originalName = "Walmart Superstore ON 39208", - type = null, - subtype = null, - fees = null, - price = null, - quantity = null - ) - ) + isGroup = false, + assetId = null, + assetInstitutionName = null, + assetName = null, + assetDisplayName = null, + assetStatus = null, + plaidAccountId = 76602, + plaidAccountName = "Amazon Whole Foods Visa", + plaidAccountMask = 6299, + institutionName = "Chase", + plaidAccountDisplayName = "Amazon Whole Foods Visa", + plaidMetadata = null, + plaidCategory = null, + source = null, + displayName = "Amazon", + displayNotes = null, + accountDisplayName = "Amazon Whole Foods Visa", + tags = listOf(LunchmoneyTransactionTag(76543, "Amazon")), + children = listOf( + LunchmoneyTransactionChild( + id = 246946948, + payee = "Child Transaction One", + amount = BigDecimal.valueOf(-33.6), + currency = Currency.getInstance("CAD"), + date = LocalDate.parse("2023-08-10"), + formattedDate = LocalDate.parse("2023-09-10"), + notes = null, + assetId = 7409, + plaidAccountId = null, + toBase = -33.6 + ) + ) + ), + ), + hasMore = true ) ) } diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/transaction/GetSingleTransactionRequestTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/transaction/GetSingleTransactionRequestTest.kt index f8f49be..8dd81ea 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/transaction/GetSingleTransactionRequestTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/transaction/GetSingleTransactionRequestTest.kt @@ -5,6 +5,7 @@ import assertk.assertions.isEqualTo import io.github.smaugfm.lunchmoney.TestMockServerBase import io.github.smaugfm.lunchmoney.Util.getResourceAsString import io.github.smaugfm.lunchmoney.model.LunchmoneyTransaction +import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyTransactionSource import io.github.smaugfm.lunchmoney.model.enumeration.LunchmoneyTransactionStatus import io.github.smaugfm.lunchmoney.request.transaction.params.GetSingleTransactionParams import org.junit.jupiter.api.Test @@ -12,6 +13,7 @@ import org.mockserver.model.HttpRequest.request import org.mockserver.model.HttpResponse.response import org.mockserver.model.MediaType import java.math.BigDecimal +import java.time.Instant import java.time.LocalDate import java.util.Currency @@ -33,29 +35,53 @@ internal class GetSingleTransactionRequestTest : TestMockServerBase() { assertThat(api.execute(request).block()) .isEqualTo( LunchmoneyTransaction( - id = 602L, - date = LocalDate.of(2020, 1, 1), - payee = "Starbucks", - amount = BigDecimal("4.5000"), - currency = Currency.getInstance("CAD"), - toBase = 4.5, - notes = "Frappuccino", - categoryId = null, - assetId = null, - recurringId = null, - plaidAccountId = null, + id = 480887173, + date = LocalDate.of(2023, 11, 29), + payee = "Walmart", + amount = BigDecimal("-14.1800"), + currency = Currency.getInstance("USD"), + toBase = -14.18, + categoryId = 315295L, + categoryName = "Health, Medical", + categoryGroupId = 315357, + categoryGroupName = "Personal", + isIncome = false, + excludeFromBudget = false, + excludeFromTotals = false, + createdAt = Instant.parse("2023-11-30T22:10:57.820Z"), + updatedAt = Instant.parse("2023-11-30T23:59:56.587Z"), status = LunchmoneyTransactionStatus.CLEARED, + isPending = false, + notes = null, + originalName = "Walmart", + recurringId = null, + recurringPayee = null, + recurringDescription = null, + recurringCadence = null, + recurringType = null, + recurringAmount = null, + recurringCurrency = null, parentId = null, + hasChildren = null, + groupId = 481307164, isGroup = false, - groupId = null, - externalId = null, - tags = null, - originalName = "STARBUCKS NW 32804", - type = null, - subtype = null, - fees = null, - price = null, - quantity = null + assetId = null, + assetInstitutionName = null, + assetName = null, + assetDisplayName = null, + assetStatus = null, + plaidAccountId = 54174, + plaidAccountName = "Amex 1002", + plaidAccountMask = 1005, + institutionName = "American Express", + plaidAccountDisplayName = "Amex Plat", + plaidMetadata = "{\"account_id\":\"fMKfypkyRXSXvpJor4vPTg6OP7wD4afmEjv6N\",\"account_owner\":\"1005\",\"amount\":-14.18,\"authorized_date\":\"2023-11-28\",\"authorized_datetime\":null,\"category\":[\"Shops\",\"Supermarkets and Groceries\"],\"category_id\":\"19047000\",\"check_number\":null,\"counterparties\":[{\"confidence_level\":\"VERY_HIGH\",\"entity_id\":\"O5W5j4dN9OR3E6ypQmjdkWZZRoXEzVMz2ByWM\",\"logo_url\":\"https://plaid-merchant-logos.plaid.com/walmart_1100.png\",\"name\":\"Walmart\",\"type\":\"merchant\",\"website\":\"walmart.com\"}],\"date\":\"2023-11-29\",\"datetime\":null,\"iso_currency_code\":\"USD\",\"location\":{\"address\":null,\"city\":null,\"country\":null,\"lat\":null,\"lon\":null,\"postal_code\":null,\"region\":null,\"store_number\":null},\"logo_url\":\"https://plaid-merchant-logos.plaid.com/walmart_1100.png\",\"merchant_entity_id\":\"O5W5j4dN9OR3E6ypQmjdkWZZRoXEzVMz2ByWM\",\"merchant_name\":\"Walmart\",\"name\":\"Walmart\",\"payment_channel\":\"other\",\"payment_meta\":{\"by_order_of\":null,\"payee\":null,\"payer\":null,\"payment_method\":null,\"payment_processor\":null,\"ppd_id\":null,\"reason\":null,\"reference_number\":\"320233330735688096\"},\"pending\":false,\"pending_transaction_id\":null,\"personal_finance_category\":{\"confidence_level\":\"VERY_HIGH\",\"detailed\":\"GENERAL_MERCHANDISE_SUPERSTORES\",\"primary\":\"GENERAL_MERCHANDISE\"},\"personal_finance_category_icon_url\":\"https://plaid-category-icons.plaid.com/PFC_GENERAL_MERCHANDISE.png\",\"transaction_code\":null,\"transaction_id\":\"rmQdnefvAndbfHN5mZ4y703C3vdjk7mozCw1OarL\",\"transaction_type\":\"place\",\"unofficial_currency_code\":null,\"website\":\"walmart.com\"}", + plaidCategory = "GENERAL_MERCHANDISE_SUPERSTORES", + source = LunchmoneyTransactionSource.Plaid, + displayName = "Walmart", + displayNotes = null, + accountDisplayName = "Amex Plat", + tags = emptyList() ) ) } @@ -81,29 +107,53 @@ internal class GetSingleTransactionRequestTest : TestMockServerBase() { assertThat(api.execute(getSingleTransactionRequest).block()) .isEqualTo( LunchmoneyTransaction( - id = 602L, - date = LocalDate.of(2020, 1, 1), - payee = "Starbucks", - amount = BigDecimal("4.5000"), - currency = Currency.getInstance("CAD"), - toBase = 4.5, - notes = "Frappuccino", - categoryId = null, - assetId = null, - recurringId = null, - plaidAccountId = null, + id = 480887173, + date = LocalDate.of(2023, 11, 29), + payee = "Walmart", + amount = BigDecimal("-14.1800"), + currency = Currency.getInstance("USD"), + toBase = -14.18, + categoryId = 315295L, + categoryName = "Health, Medical", + categoryGroupId = 315357, + categoryGroupName = "Personal", + isIncome = false, + excludeFromBudget = false, + excludeFromTotals = false, + createdAt = Instant.parse("2023-11-30T22:10:57.820Z"), + updatedAt = Instant.parse("2023-11-30T23:59:56.587Z"), status = LunchmoneyTransactionStatus.CLEARED, + isPending = false, + notes = null, + originalName = "Walmart", + recurringId = null, + recurringPayee = null, + recurringDescription = null, + recurringCadence = null, + recurringType = null, + recurringAmount = null, + recurringCurrency = null, parentId = null, + hasChildren = null, + groupId = 481307164, isGroup = false, - groupId = null, - externalId = null, - tags = null, - originalName = "STARBUCKS NW 32804", - type = null, - subtype = null, - fees = null, - price = null, - quantity = null + assetId = null, + assetInstitutionName = null, + assetName = null, + assetDisplayName = null, + assetStatus = null, + plaidAccountId = 54174, + plaidAccountName = "Amex 1002", + plaidAccountMask = 1005, + institutionName = "American Express", + plaidAccountDisplayName = "Amex Plat", + plaidMetadata = "{\"account_id\":\"fMKfypkyRXSXvpJor4vPTg6OP7wD4afmEjv6N\",\"account_owner\":\"1005\",\"amount\":-14.18,\"authorized_date\":\"2023-11-28\",\"authorized_datetime\":null,\"category\":[\"Shops\",\"Supermarkets and Groceries\"],\"category_id\":\"19047000\",\"check_number\":null,\"counterparties\":[{\"confidence_level\":\"VERY_HIGH\",\"entity_id\":\"O5W5j4dN9OR3E6ypQmjdkWZZRoXEzVMz2ByWM\",\"logo_url\":\"https://plaid-merchant-logos.plaid.com/walmart_1100.png\",\"name\":\"Walmart\",\"type\":\"merchant\",\"website\":\"walmart.com\"}],\"date\":\"2023-11-29\",\"datetime\":null,\"iso_currency_code\":\"USD\",\"location\":{\"address\":null,\"city\":null,\"country\":null,\"lat\":null,\"lon\":null,\"postal_code\":null,\"region\":null,\"store_number\":null},\"logo_url\":\"https://plaid-merchant-logos.plaid.com/walmart_1100.png\",\"merchant_entity_id\":\"O5W5j4dN9OR3E6ypQmjdkWZZRoXEzVMz2ByWM\",\"merchant_name\":\"Walmart\",\"name\":\"Walmart\",\"payment_channel\":\"other\",\"payment_meta\":{\"by_order_of\":null,\"payee\":null,\"payer\":null,\"payment_method\":null,\"payment_processor\":null,\"ppd_id\":null,\"reason\":null,\"reference_number\":\"320233330735688096\"},\"pending\":false,\"pending_transaction_id\":null,\"personal_finance_category\":{\"confidence_level\":\"VERY_HIGH\",\"detailed\":\"GENERAL_MERCHANDISE_SUPERSTORES\",\"primary\":\"GENERAL_MERCHANDISE\"},\"personal_finance_category_icon_url\":\"https://plaid-category-icons.plaid.com/PFC_GENERAL_MERCHANDISE.png\",\"transaction_code\":null,\"transaction_id\":\"rmQdnefvAndbfHN5mZ4y703C3vdjk7mozCw1OarL\",\"transaction_type\":\"place\",\"unofficial_currency_code\":null,\"website\":\"walmart.com\"}", + plaidCategory = "GENERAL_MERCHANDISE_SUPERSTORES", + source = LunchmoneyTransactionSource.Plaid, + displayName = "Walmart", + displayNotes = null, + accountDisplayName = "Amex Plat", + tags = emptyList() ) ) } diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/transaction/InsertTransactionsRequestTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/transaction/InsertTransactionsRequestTest.kt index 0e944d4..fddbbf8 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/transaction/InsertTransactionsRequestTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/transaction/InsertTransactionsRequestTest.kt @@ -1,5 +1,6 @@ package io.github.smaugfm.lunchmoney.request.transaction +import assertk.assertFailure import assertk.assertThat import assertk.assertions.cause import assertk.assertions.isEqualTo @@ -96,8 +97,7 @@ internal class InsertTransactionsRequestTest : TestMockServerBase() { ) ) - assertThat { api.execute(insertTransactionsRequest).block() } - .isFailure() + assertFailure { api.execute(insertTransactionsRequest).block() } .isInstanceOf(RuntimeException::class) .cause() .isNotNull() diff --git a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/user/GetCurrentUserRequestTest.kt b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/user/GetCurrentUserRequestTest.kt index 8a3d2d7..792e1dc 100644 --- a/src/test/kotlin/io/github/smaugfm/lunchmoney/request/user/GetCurrentUserRequestTest.kt +++ b/src/test/kotlin/io/github/smaugfm/lunchmoney/request/user/GetCurrentUserRequestTest.kt @@ -9,6 +9,7 @@ import org.junit.jupiter.api.Test import org.mockserver.model.HttpRequest.request import org.mockserver.model.HttpResponse.response import org.mockserver.model.MediaType +import java.util.Currency internal class GetCurrentUserRequestTest : TestMockServerBase() { @Test @@ -32,6 +33,7 @@ internal class GetCurrentUserRequestTest : TestMockServerBase() { "dummy@vasa.com", 12345L, "My New Budget - Jan 1", + Currency.getInstance("USD"), null ) ) diff --git a/src/test/resources/response/getAllCategories.json b/src/test/resources/response/getAllCategories.json index 50b26ac..e5d2c15 100644 --- a/src/test/resources/response/getAllCategories.json +++ b/src/test/resources/response/getAllCategories.json @@ -10,7 +10,8 @@ "updated_at": "2023-02-02T14:57:43.447Z", "created_at": "2023-02-02T14:57:43.447Z", "is_group": false, - "group_id": null + "group_id": null, + "order": 0 }, { "id": 427749, @@ -22,7 +23,16 @@ "updated_at": "2023-02-02T14:57:43.459Z", "created_at": "2023-02-02T14:57:43.459Z", "is_group": false, - "group_id": 427758 + "group_id": 427758, + "order": 0, + "children": [ + { + "id": 315162, + "name": "Alcohol, Bars", + "description": null, + "created_at": "2022-03-06T20:11:36.066Z" + } + ] } ] } diff --git a/src/test/resources/response/getAllTags.json b/src/test/resources/response/getAllTags.json index 2eb5a34..d13e587 100644 --- a/src/test/resources/response/getAllTags.json +++ b/src/test/resources/response/getAllTags.json @@ -2,11 +2,13 @@ { "id": 1807, "name": "Wedding", - "description": "All wedding-related expenses" + "description": "All wedding-related expenses", + "archived": false }, { "id": 1808, "name": "Honeymoon", - "description": "All honeymoon-related expenses" + "description": "All honeymoon-related expenses", + "archived": false } ] diff --git a/src/test/resources/response/getAllTransactions.json b/src/test/resources/response/getAllTransactions.json index 18f320c..1fc8438 100644 --- a/src/test/resources/response/getAllTransactions.json +++ b/src/test/resources/response/getAllTransactions.json @@ -1,52 +1,74 @@ { "transactions": [ { - "id": 602, - "date": "2020-01-01", - "payee": "Starbucks", - "amount": "4.5000", - "currency": "cad", - "to_base": 4.5, - "notes": "Frappuccino", - "category_id": null, - "recurring_id": null, - "asset_id": null, - "plaid_account_id": null, - "status": "cleared", - "is_group": false, - "group_id": null, - "parent_id": null, - "external_id": null, - "original_name": "STARBUCKS NW 32804", - "type": null, - "subtype": null, - "fees": null, - "price": null, - "quantity": null - }, - { - "id": 603, - "date": "2020-01-02", - "payee": "Walmart", - "amount": "20.9100", - "to_base": 20.91, + "id": 246946944, + "date": "2023-07-18", + "amount": "53.19", "currency": "usd", + "to_base": 53.19, + "payee": "Amazon", + "category_id": 315172, + "category_name": "Restaurants", + "category_group_id": 315358, + "category_group_name": "Food & Drink", + "is_income": false, + "exclude_from_budget": false, + "exclude_from_totals": false, + "created_at": "2023-09-09T08:43:05.875Z", + "updated_at": "2023-10-09T06:07:03.105Z", + "status": "cleared", + "is_pending": false, "notes": null, - "category_id": null, + "original_name": null, "recurring_id": null, - "asset_id": 153, - "plaid_account_id": null, - "status": "uncleared", - "is_group": false, + "recurring_payee": null, + "recurring_description": null, + "recurring_cadence": null, + "recurring_type": null, + "recurring_amount": null, + "recurring_currency": null, + "parent_id": 225508713, + "has_children": false, "group_id": null, - "parent_id": null, - "external_id": "jf2r3t98o943", - "original_name": "Walmart Superstore ON 39208", - "type": null, - "subtype": null, - "fees": null, - "price": null, - "quantity": null + "is_group": false, + "asset_id": null, + "asset_institution_name": null, + "asset_name": null, + "asset_display_name": null, + "asset_status": null, + "plaid_account_id": 76602, + "plaid_account_name": "Amazon Whole Foods Visa", + "plaid_account_mask": "6299", + "institution_name": "Chase", + "plaid_account_display_name": "Amazon Whole Foods Visa", + "plaid_metadata": null, + "plaid_category": null, + "source": null, + "display_name": "Amazon", + "display_notes": null, + "account_display_name": "Amazon Whole Foods Visa", + "tags": [ + { + "name": "Amazon", + "id": 76543 + } + ], + "external_id": null, + "children": [ + { + "id": 246946948, + "payee": "Child Transaction One", + "amount": "-33.6", + "currency": "cad", + "date": "2023-08-10", + "formatted_date": "2023-09-10", + "notes": null, + "asset_id": 7409, + "plaid_account_id": null, + "to_base": -33.6 + } + ] } - ] + ], + "has_more": true } diff --git a/src/test/resources/response/getCurrentUser.json b/src/test/resources/response/getCurrentUser.json index f54cb4d..7511a4f 100644 --- a/src/test/resources/response/getCurrentUser.json +++ b/src/test/resources/response/getCurrentUser.json @@ -4,5 +4,6 @@ "user_id": 1234, "account_id": 12345, "budget_name": "My New Budget - Jan 1", + "primary_currency": "usd", "api_key_label": null } diff --git a/src/test/resources/response/getSingleTransaction.json b/src/test/resources/response/getSingleTransaction.json index c870809..489a931 100644 --- a/src/test/resources/response/getSingleTransaction.json +++ b/src/test/resources/response/getSingleTransaction.json @@ -1,24 +1,50 @@ { - "id": 602, - "date": "2020-01-01", - "payee": "Starbucks", - "amount": "4.5000", - "currency": "cad", - "to_base": 4.5, - "notes": "Frappuccino", - "category_id": null, - "recurring_id": null, - "asset_id": null, - "plaid_account_id": null, + "id": 480887173, + "date": "2023-11-29", + "amount": "-14.1800", + "currency": "usd", + "to_base": -14.18, + "payee": "Walmart", + "category_id": 315295, + "category_name": "Health, Medical", + "category_group_id": 315357, + "category_group_name": "Personal", + "is_income": false, + "exclude_from_budget": false, + "exclude_from_totals": false, + "created_at": "2023-11-30T22:10:57.820Z", + "updated_at": "2023-11-30T23:59:56.587Z", "status": "cleared", - "is_group": false, - "group_id": null, + "is_pending": false, + "notes": null, + "original_name": "Walmart", + "recurring_id": null, + "recurring_payee": null, + "recurring_description": null, + "recurring_cadence": null, + "recurring_type": null, + "recurring_amount": null, + "recurring_currency": null, "parent_id": null, - "external_id": null, - "original_name": "STARBUCKS NW 32804", - "type": null, - "subtype": null, - "fees": null, - "price": null, - "quantity": null + "has_children": null, + "group_id": 481307164, + "is_group": false, + "asset_id": null, + "asset_institution_name": null, + "asset_name": null, + "asset_display_name": null, + "asset_status": null, + "plaid_account_id": 54174, + "plaid_account_name": "Amex 1002", + "plaid_account_mask": "1005", + "institution_name": "American Express", + "plaid_account_display_name": "Amex Plat", + "plaid_metadata": "{\"account_id\":\"fMKfypkyRXSXvpJor4vPTg6OP7wD4afmEjv6N\",\"account_owner\":\"1005\",\"amount\":-14.18,\"authorized_date\":\"2023-11-28\",\"authorized_datetime\":null,\"category\":[\"Shops\",\"Supermarkets and Groceries\"],\"category_id\":\"19047000\",\"check_number\":null,\"counterparties\":[{\"confidence_level\":\"VERY_HIGH\",\"entity_id\":\"O5W5j4dN9OR3E6ypQmjdkWZZRoXEzVMz2ByWM\",\"logo_url\":\"https://plaid-merchant-logos.plaid.com/walmart_1100.png\",\"name\":\"Walmart\",\"type\":\"merchant\",\"website\":\"walmart.com\"}],\"date\":\"2023-11-29\",\"datetime\":null,\"iso_currency_code\":\"USD\",\"location\":{\"address\":null,\"city\":null,\"country\":null,\"lat\":null,\"lon\":null,\"postal_code\":null,\"region\":null,\"store_number\":null},\"logo_url\":\"https://plaid-merchant-logos.plaid.com/walmart_1100.png\",\"merchant_entity_id\":\"O5W5j4dN9OR3E6ypQmjdkWZZRoXEzVMz2ByWM\",\"merchant_name\":\"Walmart\",\"name\":\"Walmart\",\"payment_channel\":\"other\",\"payment_meta\":{\"by_order_of\":null,\"payee\":null,\"payer\":null,\"payment_method\":null,\"payment_processor\":null,\"ppd_id\":null,\"reason\":null,\"reference_number\":\"320233330735688096\"},\"pending\":false,\"pending_transaction_id\":null,\"personal_finance_category\":{\"confidence_level\":\"VERY_HIGH\",\"detailed\":\"GENERAL_MERCHANDISE_SUPERSTORES\",\"primary\":\"GENERAL_MERCHANDISE\"},\"personal_finance_category_icon_url\":\"https://plaid-category-icons.plaid.com/PFC_GENERAL_MERCHANDISE.png\",\"transaction_code\":null,\"transaction_id\":\"rmQdnefvAndbfHN5mZ4y703C3vdjk7mozCw1OarL\",\"transaction_type\":\"place\",\"unofficial_currency_code\":null,\"website\":\"walmart.com\"}", + "plaid_category": "GENERAL_MERCHANDISE_SUPERSTORES", + "source": "plaid", + "display_name": "Walmart", + "display_notes": null, + "account_display_name": "Amex Plat", + "tags": [], + "external_id": null }