Repository: andregasser/bigbone (kotlin)

Issue:
Add attribution_domains attribute to Account
According to [Trunks & Tidbits January 2025](https://blog.joinmastodon.org/2025/02/trunk-tidbits-january-2025/), an `attributions_domains` attribute has been added to `Account`. See https://docs.joinmastodon.org/entities/Account/#attribution_domains

Pull request description:
# Description

attribution_domains is a new attribute of CredentialAccounts since Mastodon 4.4.0.

Adds test to check for proper deserialization of `CredentialAccount` JSON data.

Closes #556.

# Type of Change

- New feature

# Mandatory Checklist

- [x] I ran `gradle check` and there were no errors reported
- [x] I have performed a self-review of my code
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] All tests pass locally with my changes
- [x] I have added KDoc documentation to all public methods

Patch:
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/entity/CredentialAccount.kt b/bigbone/src/main/kotlin/social/bigbone/api/entity/CredentialAccount.kt
index bf4c0bdf0..91bdcd3b9 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/entity/CredentialAccount.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/entity/CredentialAccount.kt
@@ -180,6 +180,13 @@ data class CredentialAccount(
     @SerialName("following_count")
     val followingCount: Long = 0,
 
+    /**
+     * Domains of websites allowed to credit the account.
+     * @since Mastodon 4.4.0
+     */
+    @SerialName("attribution_domains")
+    val attributionDomains: List<String> = emptyList(),
+
     /**
      * An extra attribute that contains source values
      * to be used with API methods that [AccountMethods.verifyCredentials] and [AccountMethods.updateCredentials].


Test patch:
diff --git a/bigbone/src/test/assets/credential_account.json b/bigbone/src/test/assets/credential_account.json
index af6dc943a..d83f99171 100644
--- a/bigbone/src/test/assets/credential_account.json
+++ b/bigbone/src/test/assets/credential_account.json
@@ -14,6 +14,7 @@
   "avatar_static": "test",
   "header": "test",
   "header_static": "test",
+  "attribution_domains": ["example.com", "example.net"],
   "source": {
     "privacy": "public",
     "sensitive": false,
diff --git a/bigbone/src/test/kotlin/social/bigbone/api/entity/AccountsTest.kt b/bigbone/src/test/kotlin/social/bigbone/api/entity/AccountsTest.kt
index b966f07ff..6deb5d69d 100644
--- a/bigbone/src/test/kotlin/social/bigbone/api/entity/AccountsTest.kt
+++ b/bigbone/src/test/kotlin/social/bigbone/api/entity/AccountsTest.kt
@@ -5,6 +5,7 @@ import org.amshove.kluent.shouldBeInstanceOf
 import org.junit.jupiter.api.Test
 import social.bigbone.JSON_SERIALIZER
 import social.bigbone.PrecisionDateTime
+import social.bigbone.api.entity.data.Visibility
 import social.bigbone.testtool.AssetsUtil
 
 class AccountsTest {
@@ -37,6 +38,22 @@ class AccountsTest {
         list[2].muteExpiresAt shouldBeInstanceOf PrecisionDateTime.InvalidPrecisionDateTime.Unavailable::class
     }
 
+    @Test
+    fun deserializeCredentialAccount() {
+        // given a JSON string containing valid CredentialAccount data
+        val json = AssetsUtil.readFromAssets("credential_account.json")
+
+        // when parsing as a CredentialAccount
+        val credentialAccount: CredentialAccount = JSON_SERIALIZER.decodeFromString(json)
+
+        // then retrieving CredentialAccount data should be possible
+        credentialAccount.attributionDomains.size shouldBeEqualTo 2
+        credentialAccount.attributionDomains.first() shouldBeEqualTo "example.com"
+        credentialAccount.source.note.startsWith("Lorem ipsum dolor sit amet") shouldBeEqualTo true
+        credentialAccount.source.privacy shouldBeEqualTo Visibility.PUBLIC
+        credentialAccount.source.fields.first().name shouldBeEqualTo "Website"
+    }
+
     @Test
     fun muteAccountsToAccounts() {
         // given a JSON string containing valid MutedAccount data