diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/AccountMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/AccountMethods.kt
index 0b5569cf0..501552a30 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/AccountMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/AccountMethods.kt
@@ -18,6 +18,9 @@ import java.time.Duration
* @see Mastodon accounts API methods
*/
class AccountMethods(private val client: MastodonClient) {
+
+ private val endpoint = "api/v1/accounts"
+
/**
* Register an account.
* @param username The desired username for the account
@@ -38,7 +41,7 @@ class AccountMethods(private val client: MastodonClient) {
reason: String?
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/accounts",
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("username", username)
@@ -58,7 +61,7 @@ class AccountMethods(private val client: MastodonClient) {
*/
fun getAccount(accountId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/accounts/$accountId",
+ endpoint = "$endpoint/$accountId",
method = MastodonClient.Method.GET
)
}
@@ -69,7 +72,7 @@ class AccountMethods(private val client: MastodonClient) {
*/
fun verifyCredentials(): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/accounts/verify_credentials",
+ endpoint = "$endpoint/verify_credentials",
method = MastodonClient.Method.GET
)
}
@@ -167,7 +170,7 @@ class AccountMethods(private val client: MastodonClient) {
defaultLanguage: String?
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/accounts/update_credentials",
+ endpoint = "$endpoint/update_credentials",
method = MastodonClient.Method.PATCH,
parameters = Parameters().apply {
displayName?.let { append("display_name", displayName) }
@@ -199,7 +202,7 @@ class AccountMethods(private val client: MastodonClient) {
@JvmOverloads
fun getFollowers(accountId: String, range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/accounts/$accountId/followers",
+ endpoint = "$endpoint/$accountId/followers",
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -214,7 +217,7 @@ class AccountMethods(private val client: MastodonClient) {
@JvmOverloads
fun getFollowing(accountId: String, range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/accounts/$accountId/following",
+ endpoint = "$endpoint/$accountId/following",
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -244,7 +247,7 @@ class AccountMethods(private val client: MastodonClient) {
range: Range = Range()
): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/accounts/$accountId/statuses",
+ endpoint = "$endpoint/$accountId/statuses",
method = MastodonClient.Method.GET,
parameters = range.toParameters().apply {
if (onlyMedia) append("only_media", true)
@@ -275,7 +278,7 @@ class AccountMethods(private val client: MastodonClient) {
filterForLanguages: List? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/accounts/$accountId/follow",
+ endpoint = "$endpoint/$accountId/follow",
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
includeReblogs?.let { append("reblogs", includeReblogs) }
@@ -292,7 +295,7 @@ class AccountMethods(private val client: MastodonClient) {
*/
fun unfollowAccount(accountId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/accounts/$accountId/unfollow",
+ endpoint = "$endpoint/$accountId/unfollow",
method = MastodonClient.Method.POST
)
}
@@ -304,7 +307,7 @@ class AccountMethods(private val client: MastodonClient) {
*/
fun blockAccount(accountId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/accounts/$accountId/block",
+ endpoint = "$endpoint/$accountId/block",
method = MastodonClient.Method.POST
)
}
@@ -316,7 +319,7 @@ class AccountMethods(private val client: MastodonClient) {
*/
fun unblockAccount(accountId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/accounts/$accountId/unblock",
+ endpoint = "$endpoint/$accountId/unblock",
method = MastodonClient.Method.POST
)
}
@@ -338,7 +341,7 @@ class AccountMethods(private val client: MastodonClient) {
muteDuration: Duration? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/accounts/$accountId/mute",
+ endpoint = "$endpoint/$accountId/mute",
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
muteNotifications?.let { append("notifications", muteNotifications) }
@@ -354,7 +357,7 @@ class AccountMethods(private val client: MastodonClient) {
*/
fun unmuteAccount(accountId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/accounts/$accountId/unmute",
+ endpoint = "$endpoint/$accountId/unmute",
method = MastodonClient.Method.POST
)
}
@@ -373,7 +376,7 @@ class AccountMethods(private val client: MastodonClient) {
includeSuspended: Boolean? = null
): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "api/v1/accounts/relationships",
+ endpoint = "$endpoint/relationships",
method = MastodonClient.Method.GET,
parameters = Parameters().apply {
append("id", accountIds)
@@ -402,7 +405,7 @@ class AccountMethods(private val client: MastodonClient) {
attemptWebFingerLookup: Boolean? = null
): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "api/v1/accounts/search",
+ endpoint = "$endpoint/search",
method = MastodonClient.Method.GET,
parameters = Parameters().apply {
append("q", query)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/AnnouncementMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/AnnouncementMethods.kt
index c7a07767f..cfe444b8b 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/AnnouncementMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/AnnouncementMethods.kt
@@ -12,7 +12,7 @@ import social.bigbone.api.exception.BigBoneRequestException
*/
class AnnouncementMethods(private val client: MastodonClient) {
- private val announcementsEndpoint = "api/v1/announcements"
+ private val endpoint = "api/v1/announcements"
/**
* See all currently active announcements set by admins.
@@ -24,7 +24,7 @@ class AnnouncementMethods(private val client: MastodonClient) {
withDismissed: Boolean = false
): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = announcementsEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = Parameters()
.append("with_dismissed", withDismissed)
@@ -39,7 +39,7 @@ class AnnouncementMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun dismissAnnouncement(announcementId: String) {
client.performAction(
- endpoint = "$announcementsEndpoint/$announcementId/dismiss",
+ endpoint = "$endpoint/$announcementId/dismiss",
method = MastodonClient.Method.POST
)
}
@@ -56,7 +56,7 @@ class AnnouncementMethods(private val client: MastodonClient) {
announcementId: String
) {
client.performAction(
- endpoint = "$announcementsEndpoint/$announcementId/reactions/$emojiName",
+ endpoint = "$endpoint/$announcementId/reactions/$emojiName",
method = MastodonClient.Method.PUT
)
}
@@ -73,7 +73,7 @@ class AnnouncementMethods(private val client: MastodonClient) {
announcementId: String
) {
client.performAction(
- endpoint = "$announcementsEndpoint/$announcementId/reactions/$emojiName",
+ endpoint = "$endpoint/$announcementId/reactions/$emojiName",
method = MastodonClient.Method.DELETE
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/AppMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/AppMethods.kt
index 4f80558ed..03e51581e 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/AppMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/AppMethods.kt
@@ -11,6 +11,9 @@ import social.bigbone.api.entity.Application
* @see Mastodon apps API methods
*/
class AppMethods(private val client: MastodonClient) {
+
+ private val endpoint = "api/v1/apps"
+
/**
* Create a new application to obtain OAuth2 credentials.
* @param clientName A name for your application
@@ -27,7 +30,7 @@ class AppMethods(private val client: MastodonClient) {
scope: Scope? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/apps",
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("client_name", clientName)
@@ -50,7 +53,7 @@ class AppMethods(private val client: MastodonClient) {
*/
fun verifyCredentials(): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/apps/verify_credentials",
+ endpoint = "$endpoint/verify_credentials",
method = MastodonClient.Method.GET
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/BlockMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/BlockMethods.kt
index 0e57acdc5..aff12bdf1 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/BlockMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/BlockMethods.kt
@@ -11,6 +11,9 @@ import social.bigbone.api.entity.Account
* @see Mastodon blocks API methods
*/
class BlockMethods(private val client: MastodonClient) {
+
+ private val endpoint = "api/v1/blocks"
+
/**
* View your blocks. Blocking and unblocking is achieved via accounts methods.
* @param range optional Range for the pageable return value
@@ -19,7 +22,7 @@ class BlockMethods(private val client: MastodonClient) {
@JvmOverloads
fun getBlocks(range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/blocks",
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/BookmarkMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/BookmarkMethods.kt
index 349b67ce9..e9c9a187a 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/BookmarkMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/BookmarkMethods.kt
@@ -11,6 +11,9 @@ import social.bigbone.api.entity.Status
* @see Mastodon bookmarks API methods
*/
class BookmarkMethods(private val client: MastodonClient) {
+
+ private val endpoint = "api/v1/bookmarks"
+
/**
* View bookmarked statuses.
* @param range optional Range for the pageable return value
@@ -19,7 +22,7 @@ class BookmarkMethods(private val client: MastodonClient) {
@JvmOverloads
fun getBookmarks(range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/bookmarks",
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/ConversationMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/ConversationMethods.kt
index 2338fcc4f..9ec872c2d 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/ConversationMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/ConversationMethods.kt
@@ -11,6 +11,9 @@ import social.bigbone.api.entity.Conversation
* @see Mastodon conversations API methods
*/
class ConversationMethods(private val client: MastodonClient) {
+
+ private val endpoint = "api/v1/conversations"
+
/**
* View your direct conversations with other participants.
* @param range optional Range for the pageable return value
@@ -19,7 +22,7 @@ class ConversationMethods(private val client: MastodonClient) {
@JvmOverloads
fun getConversations(range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/conversations",
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -32,7 +35,7 @@ class ConversationMethods(private val client: MastodonClient) {
*/
fun deleteConversation(conversationId: String) {
client.performAction(
- endpoint = "api/v1/conversations/$conversationId",
+ endpoint = "$endpoint/$conversationId",
method = MastodonClient.Method.DELETE
)
}
@@ -44,7 +47,7 @@ class ConversationMethods(private val client: MastodonClient) {
*/
fun markConversationAsRead(conversationId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/conversations/$conversationId/read",
+ endpoint = "$endpoint/$conversationId/read",
method = MastodonClient.Method.POST
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/CustomEmojiMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/CustomEmojiMethods.kt
index a69037608..663d249d6 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/CustomEmojiMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/CustomEmojiMethods.kt
@@ -11,7 +11,7 @@ import social.bigbone.api.entity.CustomEmoji
*/
class CustomEmojiMethods(private val client: MastodonClient) {
- private val customEmojisEndpoint = "api/v1/custom_emojis"
+ private val endpoint = "api/v1/custom_emojis"
/**
* Returns custom emojis that are available on the server.
@@ -19,7 +19,7 @@ class CustomEmojiMethods(private val client: MastodonClient) {
*/
fun getAllCustomEmojis(): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = customEmojisEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/DirectoryMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/DirectoryMethods.kt
index 3c7cea022..59c4aa7a1 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/DirectoryMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/DirectoryMethods.kt
@@ -11,6 +11,8 @@ import social.bigbone.api.entity.Account
*/
class DirectoryMethods(private val client: MastodonClient) {
+ private val endpoint = "api/v1/directory"
+
/**
* When listing, use [AccountOrder.ACTIVE] to sort by most recently posted statuses or [AccountOrder.NEW] to sort
* by most recently created profiles.
@@ -37,7 +39,7 @@ class DirectoryMethods(private val client: MastodonClient) {
limit: Int? = null
): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "api/v1/directory",
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = Parameters().apply {
append("local", local)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/DomainBlockMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/DomainBlockMethods.kt
index 28bbb4577..b5947ee42 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/DomainBlockMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/DomainBlockMethods.kt
@@ -11,7 +11,7 @@ import social.bigbone.api.Range
*/
class DomainBlockMethods(private val client: MastodonClient) {
- private val domainBlocksEndpoint = "/api/v1/domain_blocks"
+ private val endpoint = "api/v1/domain_blocks"
/**
* View domains the user has blocked.
@@ -24,7 +24,7 @@ class DomainBlockMethods(private val client: MastodonClient) {
range: Range = Range()
): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = domainBlocksEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -46,7 +46,7 @@ class DomainBlockMethods(private val client: MastodonClient) {
require(!domain.contains(' ')) { "domain must not contain spaces" }
return client.performAction(
- endpoint = domainBlocksEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.POST
)
}
@@ -66,7 +66,7 @@ class DomainBlockMethods(private val client: MastodonClient) {
require(!domain.contains(' ')) { "domain must not contain spaces" }
return client.performAction(
- endpoint = domainBlocksEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.DELETE
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/EmailMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/EmailMethods.kt
index c4e8ec31e..3fa3bb152 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/EmailMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/EmailMethods.kt
@@ -9,7 +9,7 @@ import social.bigbone.Parameters
*/
class EmailMethods(private val client: MastodonClient) {
- private val emailsEndpoint = "api/v1/emails"
+ private val endpoint = "api/v1/emails"
/**
* Request a new confirmation email for an unconfirmed user, potentially to a new email address.
@@ -23,7 +23,7 @@ class EmailMethods(private val client: MastodonClient) {
@JvmOverloads
fun resendConfirmationEmail(emailAddress: String? = null) {
client.performAction(
- endpoint = "$emailsEndpoint/confirmations",
+ endpoint = "$endpoint/confirmations",
method = MastodonClient.Method.POST,
parameters = emailAddress?.let { Parameters().append("email", emailAddress) }
)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/EndorsementMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/EndorsementMethods.kt
index ed647310d..4c6b3260e 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/EndorsementMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/EndorsementMethods.kt
@@ -12,7 +12,7 @@ import social.bigbone.api.entity.Account
*/
class EndorsementMethods(private val client: MastodonClient) {
- private val endorsementsEndpoint = "/api/v1/endorsements"
+ private val endpoint = "api/v1/endorsements"
/**
* Accounts that the user is currently featuring on their profile.
@@ -25,7 +25,7 @@ class EndorsementMethods(private val client: MastodonClient) {
range: Range = Range()
): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = endorsementsEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/FavouriteMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/FavouriteMethods.kt
index 1469333d7..9cce737f1 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/FavouriteMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/FavouriteMethods.kt
@@ -12,6 +12,8 @@ import social.bigbone.api.entity.Status
*/
class FavouriteMethods(private val client: MastodonClient) {
+ private val endpoint = "api/v1/favourites"
+
/**
* View your favourites. Favouring and unfavouring is achieved via statuses methods.
* @param range optional Range for the pageable return value
@@ -20,7 +22,7 @@ class FavouriteMethods(private val client: MastodonClient) {
@JvmOverloads
fun getFavourites(range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/favourites",
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/FeaturedTagMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/FeaturedTagMethods.kt
index 306570b6b..3e5ee9d91 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/FeaturedTagMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/FeaturedTagMethods.kt
@@ -13,7 +13,7 @@ import social.bigbone.api.exception.BigBoneRequestException
*/
class FeaturedTagMethods(private val client: MastodonClient) {
- private val featuredTagsEndpoint = "api/v1/featured_tags"
+ private val endpoint = "api/v1/featured_tags"
/**
* List all hashtags featured on your profile.
@@ -21,7 +21,7 @@ class FeaturedTagMethods(private val client: MastodonClient) {
*/
fun getFeaturedTags(): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = featuredTagsEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET
)
}
@@ -37,7 +37,7 @@ class FeaturedTagMethods(private val client: MastodonClient) {
require(!tagName.contains('#')) { "Tag name to be featured must not contain '#'" }
return client.getMastodonRequest(
- endpoint = featuredTagsEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().append("name", tagName)
)
@@ -54,7 +54,7 @@ class FeaturedTagMethods(private val client: MastodonClient) {
require(tagId.isNotBlank()) { "Tag ID must not be blank" }
client.performAction(
- endpoint = featuredTagsEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.DELETE,
parameters = Parameters().append("id", tagId)
)
@@ -66,7 +66,7 @@ class FeaturedTagMethods(private val client: MastodonClient) {
*/
fun getSuggestedTags(): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "$featuredTagsEndpoint/suggestions",
+ endpoint = "$endpoint/suggestions",
method = MastodonClient.Method.GET
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/FilterMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/FilterMethods.kt
index 2e6226bfb..44cbbe4f2 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/FilterMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/FilterMethods.kt
@@ -13,6 +13,9 @@ import social.bigbone.api.exception.BigBoneRequestException
* @see Mastodon filters API methods
*/
class FilterMethods(private val client: MastodonClient) {
+
+ private val endpoint = "api/v2/filters"
+
/**
* Obtain a list of all filter groups for the current user.
* @see Mastodon API documentation: methods/filters/#get
@@ -20,7 +23,7 @@ class FilterMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun listFilters(): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "api/v2/filters",
+ endpoint = endpoint,
method = MastodonClient.Method.GET
)
}
@@ -57,7 +60,7 @@ class FilterMethods(private val client: MastodonClient) {
filterAction: Filter.FilterAction = Filter.FilterAction.WARN
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v2/filters",
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("title", title)
@@ -104,7 +107,7 @@ class FilterMethods(private val client: MastodonClient) {
keywordsToRemove: List? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v2/filters/$filterId",
+ endpoint = "$endpoint/$filterId",
method = MastodonClient.Method.PUT,
parameters = Parameters().apply {
title?.let {
@@ -153,7 +156,7 @@ class FilterMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun deleteFilter(filterId: String) {
client.performAction(
- endpoint = "api/v2/filters/$filterId",
+ endpoint = "$endpoint/$filterId",
method = MastodonClient.Method.DELETE
)
}
@@ -166,7 +169,7 @@ class FilterMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun listKeywords(filterId: String): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "api/v2/filters/$filterId/keywords",
+ endpoint = "$endpoint/$filterId/keywords",
method = MastodonClient.Method.GET
)
}
@@ -180,7 +183,7 @@ class FilterMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun addKeyword(filterId: String, filterKeyword: FilterKeyword): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v2/filters/$filterId/keywords",
+ endpoint = "$endpoint/$filterId/keywords",
method = MastodonClient.Method.POST,
Parameters().apply {
append("keyword", filterKeyword.keyword)
@@ -197,7 +200,7 @@ class FilterMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun viewKeyword(keywordId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v2/filters/keywords/$keywordId",
+ endpoint = "$endpoint/keywords/$keywordId",
method = MastodonClient.Method.GET
)
}
@@ -210,7 +213,7 @@ class FilterMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun updateKeyword(filterKeyword: FilterKeyword): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v2/filters/keywords/${filterKeyword.id}",
+ endpoint = "$endpoint/keywords/${filterKeyword.id}",
method = MastodonClient.Method.PUT,
Parameters().apply {
append("keyword", filterKeyword.keyword)
@@ -227,7 +230,7 @@ class FilterMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun deleteKeyword(keywordId: String) {
client.performAction(
- endpoint = "api/v2/filters/keywords/$keywordId",
+ endpoint = "$endpoint/keywords/$keywordId",
method = MastodonClient.Method.DELETE
)
}
@@ -240,7 +243,7 @@ class FilterMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun listStatusFilters(filterId: String): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "api/v2/filters/$filterId/statuses",
+ endpoint = "$endpoint/$filterId/statuses",
method = MastodonClient.Method.GET
)
}
@@ -252,7 +255,7 @@ class FilterMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun addStatusToFilter(filterId: String, statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v2/filters/$filterId/statuses",
+ endpoint = "$endpoint/$filterId/statuses",
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("status_id", statusId)
@@ -268,7 +271,7 @@ class FilterMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun viewStatusFilter(filterStatusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v2/filters/statuses/$filterStatusId",
+ endpoint = "$endpoint/statuses/$filterStatusId",
method = MastodonClient.Method.GET
)
}
@@ -281,7 +284,7 @@ class FilterMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun removeStatusFromFilter(filterStatusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v2/filters/statuses/$filterStatusId",
+ endpoint = "$endpoint/statuses/$filterStatusId",
method = MastodonClient.Method.DELETE
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/FollowRequestMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/FollowRequestMethods.kt
index 074558682..28d74a8b6 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/FollowRequestMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/FollowRequestMethods.kt
@@ -14,6 +14,8 @@ import social.bigbone.api.exception.BigBoneRequestException
*/
class FollowRequestMethods(private val client: MastodonClient) {
+ private val endpoint = "api/v1/follow_requests"
+
/**
* View pending follow requests.
* @param range optional Range for the pageable return value
@@ -22,7 +24,7 @@ class FollowRequestMethods(private val client: MastodonClient) {
@JvmOverloads
fun getFollowRequests(range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/follow_requests",
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -36,7 +38,7 @@ class FollowRequestMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun authorizeFollowRequest(accountId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/follow_requests/$accountId/authorize",
+ endpoint = "$endpoint/$accountId/authorize",
method = MastodonClient.Method.POST
)
}
@@ -49,7 +51,7 @@ class FollowRequestMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun rejectFollowRequest(accountId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/follow_requests/$accountId/reject",
+ endpoint = "$endpoint/$accountId/reject",
method = MastodonClient.Method.POST
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/FollowedTagMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/FollowedTagMethods.kt
index 3ddcf8cbd..dde0403f4 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/FollowedTagMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/FollowedTagMethods.kt
@@ -13,7 +13,7 @@ import social.bigbone.api.entity.Tag
*/
class FollowedTagMethods(private val client: MastodonClient) {
- private val followedTagsEndpoint = "api/v1/followed_tags"
+ private val endpoint = "api/v1/followed_tags"
/**
* View your followed hashtags.
@@ -24,7 +24,7 @@ class FollowedTagMethods(private val client: MastodonClient) {
@JvmOverloads
fun viewAllFollowedTags(range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = followedTagsEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/InstanceMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/InstanceMethods.kt
index dd44e2292..b5069a897 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/InstanceMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/InstanceMethods.kt
@@ -16,8 +16,8 @@ import social.bigbone.api.entity.Rule
*/
class InstanceMethods(private val client: MastodonClient) {
- private val instanceEndpointV1 = "/api/v1/instance"
- private val instanceEndpointV2 = "/api/v2/instance"
+ private val endpointV1 = "api/v1/instance"
+ private val endpointV2 = "api/v2/instance"
/**
* Obtain general information about the server.
@@ -25,7 +25,7 @@ class InstanceMethods(private val client: MastodonClient) {
*/
fun getInstance(): MastodonRequest {
return client.getMastodonRequest(
- endpoint = instanceEndpointV2,
+ endpoint = endpointV2,
method = MastodonClient.Method.GET
)
}
@@ -41,7 +41,7 @@ class InstanceMethods(private val client: MastodonClient) {
)
fun getInstanceV1(): MastodonRequest {
return client.getMastodonRequest(
- endpoint = instanceEndpointV1,
+ endpoint = endpointV1,
method = MastodonClient.Method.GET
)
}
@@ -52,7 +52,7 @@ class InstanceMethods(private val client: MastodonClient) {
*/
fun getPeers(): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "$instanceEndpointV1/peers",
+ endpoint = "$endpointV1/peers",
method = MastodonClient.Method.GET
)
}
@@ -63,7 +63,7 @@ class InstanceMethods(private val client: MastodonClient) {
*/
fun getActivity(): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "$instanceEndpointV1/activity",
+ endpoint = "$endpointV1/activity",
method = MastodonClient.Method.GET
)
}
@@ -74,7 +74,7 @@ class InstanceMethods(private val client: MastodonClient) {
*/
fun getRules(): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "$instanceEndpointV1/rules",
+ endpoint = "$endpointV1/rules",
method = MastodonClient.Method.GET
)
}
@@ -86,7 +86,7 @@ class InstanceMethods(private val client: MastodonClient) {
*/
fun getBlockedDomains(): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "$instanceEndpointV1/domain_blocks",
+ endpoint = "$endpointV1/domain_blocks",
method = MastodonClient.Method.GET
)
}
@@ -98,7 +98,7 @@ class InstanceMethods(private val client: MastodonClient) {
*/
fun getExtendedDescription(): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$instanceEndpointV1/extended_description",
+ endpoint = "$endpointV1/extended_description",
method = MastodonClient.Method.GET
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/ListMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/ListMethods.kt
index 5f2cb85fb..c9d04b37f 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/ListMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/ListMethods.kt
@@ -14,13 +14,15 @@ import social.bigbone.api.entity.MastodonList
*/
class ListMethods(private val client: MastodonClient) {
+ private val endpoint = "api/v1/lists"
+
/**
* Fetch all lists that the user owns.
* @see Mastodon API documentation: methods/lists/#get
*/
fun getLists(): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "api/v1/lists",
+ endpoint = endpoint,
method = MastodonClient.Method.GET
)
}
@@ -32,7 +34,7 @@ class ListMethods(private val client: MastodonClient) {
*/
fun getList(listId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/lists/$listId",
+ endpoint = "$endpoint/$listId",
method = MastodonClient.Method.GET
)
}
@@ -40,7 +42,7 @@ class ListMethods(private val client: MastodonClient) {
/**
* Create a new list.
* @param title The title of the list to be created.
- * @param repliesPolicy One of [MastodonList.RepliesPolicy], defaults to [MastodonList.RepliesPolicy.List].
+ * @param repliesPolicy One of [MastodonList.RepliesPolicy], defaults to [MastodonList.RepliesPolicy.LIST].
* @param exclusive Whether members of this list need to get removed from the “Home” feed.
* @see Mastodon API documentation: methods/lists/#create
*/
@@ -51,7 +53,7 @@ class ListMethods(private val client: MastodonClient) {
exclusive: Boolean? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/lists",
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("title", title)
@@ -74,7 +76,7 @@ class ListMethods(private val client: MastodonClient) {
repliesPolicy: MastodonList.RepliesPolicy
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/lists/$listId",
+ endpoint = "$endpoint/$listId",
method = MastodonClient.Method.PUT,
parameters = Parameters().apply {
append("title", title)
@@ -90,7 +92,7 @@ class ListMethods(private val client: MastodonClient) {
*/
fun deleteList(listId: String) {
client.performAction(
- endpoint = "api/v1/lists/$listId",
+ endpoint = "$endpoint/$listId",
method = MastodonClient.Method.DELETE
)
}
@@ -104,7 +106,7 @@ class ListMethods(private val client: MastodonClient) {
@JvmOverloads
fun getAccountsInList(listId: String, range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/lists/$listId/accounts",
+ endpoint = "$endpoint/$listId/accounts",
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -118,7 +120,7 @@ class ListMethods(private val client: MastodonClient) {
*/
fun addAccountsToList(listId: String, accountIds: List) {
client.performAction(
- endpoint = "api/v1/lists/$listId/accounts",
+ endpoint = "$endpoint/$listId/accounts",
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("account_ids", accountIds)
@@ -134,7 +136,7 @@ class ListMethods(private val client: MastodonClient) {
*/
fun deleteAccountsFromList(listId: String, accountIds: List) {
client.performAction(
- endpoint = "api/v1/lists/$listId/accounts",
+ endpoint = "$endpoint/$listId/accounts",
method = MastodonClient.Method.DELETE,
parameters = Parameters().apply {
append("account_ids", accountIds)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/MarkerMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/MarkerMethods.kt
index 935033a2a..65be6121f 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/MarkerMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/MarkerMethods.kt
@@ -12,6 +12,9 @@ import social.bigbone.api.exception.BigBoneRequestException
* @see Mastodon markers API methods
*/
class MarkerMethods(private val client: MastodonClient) {
+
+ private val endpoint = "api/v1/markers"
+
/**
* Get saved timeline positions.
* @param timeline specifies for which timelines the position markers should be returned. This value
@@ -22,7 +25,7 @@ class MarkerMethods(private val client: MastodonClient) {
@JvmOverloads
fun getMarkers(timeline: Timeline? = null): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/markers",
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = Parameters().apply {
timeline?.let {
@@ -51,7 +54,7 @@ class MarkerMethods(private val client: MastodonClient) {
lastReadId: Int
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/markers",
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
when (timeline) {
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/MuteMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/MuteMethods.kt
index a155db946..3ae75c0b5 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/MuteMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/MuteMethods.kt
@@ -12,6 +12,8 @@ import social.bigbone.api.entity.Account
*/
class MuteMethods(private val client: MastodonClient) {
+ private val endpoint = "api/v1/mutes"
+
/**
* Accounts the user has muted.
* @param range optional Range for the pageable return value
@@ -20,7 +22,7 @@ class MuteMethods(private val client: MastodonClient) {
@JvmOverloads
fun getMutes(range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/mutes",
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/NotificationMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/NotificationMethods.kt
index 04cea3dcb..c7556e83d 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/NotificationMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/NotificationMethods.kt
@@ -13,7 +13,7 @@ import social.bigbone.api.exception.BigBoneRequestException
*/
class NotificationMethods(private val client: MastodonClient) {
- private val notificationsEndpoint = "api/v1/notifications"
+ private val endpoint = "api/v1/notifications"
/**
* Notifications concerning the user.
@@ -31,7 +31,7 @@ class NotificationMethods(private val client: MastodonClient) {
range: Range = Range()
): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = notificationsEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters().apply {
includeTypes?.let {
@@ -52,7 +52,7 @@ class NotificationMethods(private val client: MastodonClient) {
*/
fun getNotification(id: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$notificationsEndpoint/$id",
+ endpoint = "$endpoint/$id",
method = MastodonClient.Method.GET
)
}
@@ -64,7 +64,7 @@ class NotificationMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun dismissAllNotifications() {
client.performAction(
- endpoint = "$notificationsEndpoint/clear",
+ endpoint = "$endpoint/clear",
method = MastodonClient.Method.POST
)
}
@@ -77,7 +77,7 @@ class NotificationMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun dismissNotification(notificationId: String) {
client.performAction(
- endpoint = "$notificationsEndpoint/$notificationId/dismiss",
+ endpoint = "$endpoint/$notificationId/dismiss",
method = MastodonClient.Method.POST
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/OAuthMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/OAuthMethods.kt
index c93c73b72..8d4dd0a05 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/OAuthMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/OAuthMethods.kt
@@ -12,6 +12,8 @@ import social.bigbone.api.entity.Token
*/
class OAuthMethods(private val client: MastodonClient) {
+ private val endpoint = "oauth"
+
/**
* Returns a URL that can be used to display an authorization form to the user. If approved,
* it will create and return an authorization code, then redirect to the desired redirectUri,
@@ -32,7 +34,7 @@ class OAuthMethods(private val client: MastodonClient) {
forceLogin: Boolean? = null,
languageCode: String? = null
): String {
- val endpoint = "oauth/authorize"
+ val endpoint = "$endpoint/authorize"
val params = Parameters().apply {
append("client_id", clientId)
append("redirect_uri", redirectUri)
@@ -72,7 +74,7 @@ class OAuthMethods(private val client: MastodonClient) {
scope: Scope? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "oauth/token",
+ endpoint = "$endpoint/token",
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("client_id", clientId)
@@ -103,7 +105,7 @@ class OAuthMethods(private val client: MastodonClient) {
scope: Scope? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "oauth/token",
+ endpoint = "$endpoint/token",
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("client_id", clientId)
@@ -139,7 +141,7 @@ class OAuthMethods(private val client: MastodonClient) {
scope: Scope? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "oauth/token",
+ endpoint = "$endpoint/token",
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("client_id", clientId)
@@ -167,7 +169,7 @@ class OAuthMethods(private val client: MastodonClient) {
token: String
) {
client.performAction(
- endpoint = "oauth/revoke",
+ endpoint = "$endpoint/revoke",
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("client_id", clientId)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/OEmbedMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/OEmbedMethods.kt
index fb539b26d..e8ef5e1c1 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/OEmbedMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/OEmbedMethods.kt
@@ -11,7 +11,7 @@ import social.bigbone.api.entity.OEmbedMetadata
*/
class OEmbedMethods(private val mastodonClient: MastodonClient) {
- private val oEmbedEndpoint = "api/oembed"
+ private val endpoint = "api/oembed"
/**
* Get oEmbed info as JSON.
@@ -27,7 +27,7 @@ class OEmbedMethods(private val mastodonClient: MastodonClient) {
maxHeight: Int? = null
): MastodonRequest {
return mastodonClient.getMastodonRequest(
- endpoint = oEmbedEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = Parameters().apply {
append("url", urlOfStatus)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/PollMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/PollMethods.kt
index d816500a8..9eccbbc52 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/PollMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/PollMethods.kt
@@ -12,6 +12,8 @@ import social.bigbone.api.exception.BigBoneRequestException
*/
class PollMethods(private val client: MastodonClient) {
+ private val endpoint = "api/v1/polls"
+
/**
* View a poll attached to a status. To discover poll ID, you will need to GET a Status first and then check for
* a poll property.
@@ -21,7 +23,7 @@ class PollMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun viewPoll(pollId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/polls/$pollId",
+ endpoint = "$endpoint/$pollId",
method = MastodonClient.Method.GET
)
}
@@ -36,7 +38,7 @@ class PollMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun voteOnPoll(pollId: String, choices: List): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/polls/$pollId/votes",
+ endpoint = "$endpoint/$pollId/votes",
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
appendInts("choices", choices)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/PreferenceMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/PreferenceMethods.kt
index ce12a7c34..aef15254e 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/PreferenceMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/PreferenceMethods.kt
@@ -11,7 +11,7 @@ import social.bigbone.api.exception.BigBoneRequestException
*/
class PreferenceMethods(private val client: MastodonClient) {
- private val preferencesEndpoint = "api/v1/preferences"
+ private val endpoint = "api/v1/preferences"
/**
* Get preferences about an account.
@@ -20,7 +20,7 @@ class PreferenceMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun getPreferences(): MastodonRequest {
return client.getMastodonRequest(
- endpoint = preferencesEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/PushNotificationMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/PushNotificationMethods.kt
index 88b57c9c3..a62ba0faf 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/PushNotificationMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/PushNotificationMethods.kt
@@ -12,7 +12,7 @@ import social.bigbone.api.exception.BigBoneRequestException
*/
class PushNotificationMethods(private val client: MastodonClient) {
- private val pushEndpoint = "/api/v1/push/subscription"
+ private val endpoint = "api/v1/push/subscription"
/**
* Specify whether to receive push notifications from all, followed, follower, or none users.
@@ -59,7 +59,7 @@ class PushNotificationMethods(private val client: MastodonClient) {
policy: PushDataPolicy? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = pushEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("subscription[endpoint]", endpoint)
@@ -112,7 +112,7 @@ class PushNotificationMethods(private val client: MastodonClient) {
policy: PushDataPolicy? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = pushEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.PUT,
parameters = Parameters().apply {
mention?.let { append("data[alerts][mention]", it) }
@@ -137,7 +137,7 @@ class PushNotificationMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun getPushNotification(): MastodonRequest {
return client.getMastodonRequest(
- endpoint = pushEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET
)
}
@@ -149,7 +149,7 @@ class PushNotificationMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun removePushSubscription() {
client.performAction(
- endpoint = pushEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.DELETE
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/ReportMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/ReportMethods.kt
index 3de5f0f0b..27ea04b4d 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/ReportMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/ReportMethods.kt
@@ -13,6 +13,8 @@ import social.bigbone.api.exception.BigBoneRequestException
*/
class ReportMethods(private val client: MastodonClient) {
+ private val endpoint = "api/v1/reports"
+
/**
* File a report.
* @param accountId The ID of the account to report
@@ -34,7 +36,7 @@ class ReportMethods(private val client: MastodonClient) {
category: ReportCategory? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/reports",
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = buildParameters(accountId, statusIds, comment, forward, ruleIds, category)
)
@@ -64,7 +66,10 @@ class ReportMethods(private val client: MastodonClient) {
}
}
- private fun setCategoryCorrectly(ruleIds: List? = emptyList(), category: ReportCategory? = null): ReportCategory {
+ private fun setCategoryCorrectly(
+ ruleIds: List? = emptyList(),
+ category: ReportCategory? = null
+ ): ReportCategory {
return when {
!ruleIds.isNullOrEmpty() -> ReportCategory.VIOLATION
category == null -> ReportCategory.OTHER
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/SearchMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/SearchMethods.kt
index 31d900466..6a6d41f97 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/SearchMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/SearchMethods.kt
@@ -14,6 +14,8 @@ import social.bigbone.api.entity.Search
*/
class SearchMethods(private val client: MastodonClient) {
+ private val endpoint = "api/v2/search"
+
/**
* Specify whether to search for only accounts, hashtags, statuses.
*/
@@ -61,7 +63,7 @@ class SearchMethods(private val client: MastodonClient) {
offset: Int? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v2/search",
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = buildParameters(
query = query,
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/StatusMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/StatusMethods.kt
index 7774c6c07..eb0e67f01 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/StatusMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/StatusMethods.kt
@@ -29,6 +29,8 @@ private val SCHEDULED_AT_MIN_AHEAD: Duration = Duration.ofMinutes(5)
*/
class StatusMethods(private val client: MastodonClient) {
+ private val endpoint = "api/v1/statuses"
+
/**
* Obtain information about a status.
* @param statusId ID of the status.
@@ -37,7 +39,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun getStatus(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId",
+ endpoint = "$endpoint/$statusId",
method = MastodonClient.Method.GET
)
}
@@ -50,7 +52,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun getContext(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/context",
+ endpoint = "$endpoint/$statusId/context",
method = MastodonClient.Method.GET
)
}
@@ -65,7 +67,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun translateStatus(statusId: String, language: String? = null): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/translate",
+ endpoint = "$endpoint/$statusId/translate",
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
language?.let { append("lang", it) }
@@ -83,7 +85,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun getRebloggedBy(statusId: String, range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/reblogged_by",
+ endpoint = "$endpoint/$statusId/reblogged_by",
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -99,7 +101,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun getFavouritedBy(statusId: String, range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/favourited_by",
+ endpoint = "$endpoint/$statusId/favourited_by",
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -133,7 +135,7 @@ class StatusMethods(private val client: MastodonClient) {
addIdempotencyKey: Boolean = true
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses",
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("status", status)
@@ -175,7 +177,7 @@ class StatusMethods(private val client: MastodonClient) {
addIdempotencyKey: Boolean = true
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses",
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("status", status)
@@ -227,7 +229,7 @@ class StatusMethods(private val client: MastodonClient) {
}
return client.getMastodonRequest(
- endpoint = "api/v1/statuses",
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("status", status)
@@ -276,7 +278,7 @@ class StatusMethods(private val client: MastodonClient) {
}
return client.getMastodonRequest(
- endpoint = "api/v1/statuses",
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("status", status)
@@ -303,7 +305,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun deleteStatus(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId",
+ endpoint = "$endpoint/$statusId",
method = MastodonClient.Method.DELETE
)
}
@@ -325,7 +327,7 @@ class StatusMethods(private val client: MastodonClient) {
throw BigBoneRequestException("Visibility must be one of: public, unlisted, private when reblogging.")
}
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/reblog",
+ endpoint = "$endpoint/$statusId/reblog",
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("visibility", visibility.apiName)
@@ -341,7 +343,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun unreblogStatus(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/unreblog",
+ endpoint = "$endpoint/$statusId/unreblog",
method = MastodonClient.Method.POST
)
}
@@ -354,7 +356,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun favouriteStatus(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/favourite",
+ endpoint = "$endpoint/$statusId/favourite",
method = MastodonClient.Method.POST
)
}
@@ -367,7 +369,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun unfavouriteStatus(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/unfavourite",
+ endpoint = "$endpoint/$statusId/unfavourite",
method = MastodonClient.Method.POST
)
}
@@ -380,7 +382,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun bookmarkStatus(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/bookmark",
+ endpoint = "$endpoint/$statusId/bookmark",
method = MastodonClient.Method.POST
)
}
@@ -393,7 +395,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun unbookmarkStatus(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/unbookmark",
+ endpoint = "$endpoint/$statusId/unbookmark",
method = MastodonClient.Method.POST
)
}
@@ -406,7 +408,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun muteConversation(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/mute",
+ endpoint = "$endpoint/$statusId/mute",
method = MastodonClient.Method.POST
)
}
@@ -419,7 +421,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun unmuteConversation(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/unmute",
+ endpoint = "$endpoint/$statusId/unmute",
method = MastodonClient.Method.POST
)
}
@@ -432,7 +434,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun pinStatus(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/pin",
+ endpoint = "$endpoint/$statusId/pin",
method = MastodonClient.Method.POST
)
}
@@ -445,7 +447,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun unpinStatus(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/unpin",
+ endpoint = "$endpoint/$statusId/unpin",
method = MastodonClient.Method.POST
)
}
@@ -473,7 +475,7 @@ class StatusMethods(private val client: MastodonClient) {
language: String? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId",
+ endpoint = "$endpoint/$statusId",
method = MastodonClient.Method.PUT,
parameters = Parameters().apply {
append("status", status)
@@ -508,7 +510,7 @@ class StatusMethods(private val client: MastodonClient) {
language: String? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId",
+ endpoint = "$endpoint/$statusId",
method = MastodonClient.Method.PUT,
parameters = Parameters().apply {
append("status", status)
@@ -531,7 +533,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun getEditHistory(statusId: String): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "api/v1/statuses/$statusId/history",
+ endpoint = "$endpoint/$statusId/history",
method = MastodonClient.Method.GET
)
}
@@ -544,7 +546,7 @@ class StatusMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun getStatusSource(statusId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/statuses/$statusId/source",
+ endpoint = "$endpoint/$statusId/source",
method = MastodonClient.Method.GET
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/StreamingMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/StreamingMethods.kt
index bc4c28ddd..ebbe907b7 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/StreamingMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/StreamingMethods.kt
@@ -26,6 +26,8 @@ import java.io.Closeable
*/
class StreamingMethods(private val client: MastodonClient) {
+ private val endpoint = "api/v1/streaming"
+
private fun stream(
streamType: StreamType,
callback: WebSocketCallback,
@@ -77,7 +79,7 @@ class StreamingMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun checkServerHealth() {
client.performAction(
- endpoint = "api/v1/streaming/health",
+ endpoint = "$endpoint/health",
method = MastodonClient.Method.GET
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/SuggestionMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/SuggestionMethods.kt
index 19a2ad37a..2680505cd 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/SuggestionMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/SuggestionMethods.kt
@@ -11,8 +11,8 @@ import social.bigbone.api.entity.Suggestion
*/
class SuggestionMethods(private val client: MastodonClient) {
- private val suggestionsEndpointV2 = "/api/v2/suggestions"
- private val suggestionsEndpointV1 = "/api/v1/suggestions"
+ private val endpointV2 = "api/v2/suggestions"
+ private val endpointV1 = "api/v1/suggestions"
/**
* Accounts that are promoted by staff, or that the user has had past positive interactions with, but is not yet following.
@@ -21,7 +21,7 @@ class SuggestionMethods(private val client: MastodonClient) {
*/
fun getSuggestions(limit: Int? = null): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = suggestionsEndpointV2,
+ endpoint = endpointV2,
method = MastodonClient.Method.GET,
parameters = Parameters().apply {
append("limit", limit ?: 40)
@@ -36,7 +36,7 @@ class SuggestionMethods(private val client: MastodonClient) {
*/
fun removeSuggestion(accountId: String) {
client.performAction(
- endpoint = "$suggestionsEndpointV1/$accountId",
+ endpoint = "$endpointV1/$accountId",
method = MastodonClient.Method.DELETE
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/TagMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/TagMethods.kt
index a8d6c7c2b..f1e4102d8 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/TagMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/TagMethods.kt
@@ -10,6 +10,8 @@ import social.bigbone.api.entity.Tag
*/
class TagMethods(private val client: MastodonClient) {
+ private val endpoint = "api/v1/tags"
+
/**
* Show a hashtag and its associated information.
* @param tagId The name of the hashtag
@@ -17,7 +19,7 @@ class TagMethods(private val client: MastodonClient) {
*/
fun getTag(tagId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/tags/$tagId",
+ endpoint = "$endpoint/$tagId",
method = MastodonClient.Method.GET
)
}
@@ -29,7 +31,7 @@ class TagMethods(private val client: MastodonClient) {
*/
fun followTag(tagId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/tags/$tagId/follow",
+ endpoint = "$endpoint/$tagId/follow",
method = MastodonClient.Method.POST
)
}
@@ -41,7 +43,7 @@ class TagMethods(private val client: MastodonClient) {
*/
fun unfollowTag(tagId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "api/v1/tags/$tagId/unfollow",
+ endpoint = "$endpoint/$tagId/unfollow",
method = MastodonClient.Method.POST
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/TimelineMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/TimelineMethods.kt
index 97d0965ab..420d7fdc8 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/TimelineMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/TimelineMethods.kt
@@ -12,6 +12,9 @@ import social.bigbone.api.exception.BigBoneRequestException
* @see Mastodon timelines API methods
*/
class TimelineMethods(private val client: MastodonClient) {
+
+ private val endpoint = "api/v1/timelines"
+
/**
* Public timelines can consist of only local statuses, only remote (=federated) statuses, or a combination of both.
*/
@@ -30,7 +33,7 @@ class TimelineMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun getHomeTimeline(range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/timelines/home",
+ endpoint = "$endpoint/home",
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -46,7 +49,7 @@ class TimelineMethods(private val client: MastodonClient) {
@Throws(BigBoneRequestException::class)
fun getListTimeline(listId: String, range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/timelines/list/$listId",
+ endpoint = "$endpoint/list/$listId",
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -67,7 +70,7 @@ class TimelineMethods(private val client: MastodonClient) {
range: Range = Range()
): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/timelines/public",
+ endpoint = "$endpoint/public",
method = MastodonClient.Method.GET,
parameters = range.toParameters().apply {
when (statusOrigin) {
@@ -104,7 +107,7 @@ class TimelineMethods(private val client: MastodonClient) {
onlyMedia: Boolean? = null
): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = "api/v1/timelines/tag/$tag",
+ endpoint = "$endpoint/tag/$tag",
method = MastodonClient.Method.GET,
parameters = range.toParameters().apply {
when (statusOrigin) {
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/TrendMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/TrendMethods.kt
index a18e394b6..71bcdce9f 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/TrendMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/TrendMethods.kt
@@ -13,7 +13,7 @@ import social.bigbone.api.entity.TrendsLink
*/
class TrendMethods(private val client: MastodonClient) {
- private val trendsEndpoint = "api/v1/trends"
+ private val endpoint = "api/v1/trends"
/**
* Tags that are being used more frequently within the past week.
@@ -28,7 +28,7 @@ class TrendMethods(private val client: MastodonClient) {
limit: Int = 10
): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "$trendsEndpoint/tags",
+ endpoint = "$endpoint/tags",
method = MastodonClient.Method.GET,
parameters = Parameters().apply {
append("limit", limit)
@@ -49,7 +49,7 @@ class TrendMethods(private val client: MastodonClient) {
limit: Int = 20
): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "$trendsEndpoint/statuses",
+ endpoint = "$endpoint/statuses",
method = MastodonClient.Method.GET,
parameters = Parameters().apply {
append("limit", limit)
@@ -71,7 +71,7 @@ class TrendMethods(private val client: MastodonClient) {
limit: Int = 10
): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "$trendsEndpoint/links",
+ endpoint = "$endpoint/links",
method = MastodonClient.Method.GET,
parameters = Parameters().apply {
append("limit", limit)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminAccountMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminAccountMethods.kt
index a84ee2076..07a7cec16 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminAccountMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminAccountMethods.kt
@@ -18,8 +18,8 @@ import social.bigbone.api.entity.admin.AdminAccount
*/
class AdminAccountMethods(private val client: MastodonClient) {
- private val adminAccountsEndpointV1 = "api/v1/admin/accounts"
- private val adminAccountsEndpointV2 = "api/v2/admin/accounts"
+ private val endpointV1 = "api/v1/admin/accounts"
+ private val endpointV2 = "api/v2/admin/accounts"
/**
* View all accounts, optionally matching certain criteria for filtering, up to 100 at a time.
@@ -53,7 +53,7 @@ class AdminAccountMethods(private val client: MastodonClient) {
ipAddress: String? = null
): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = adminAccountsEndpointV2,
+ endpoint = endpointV2,
method = Method.GET,
parameters = Parameters().apply {
range.toParameters(parameters = this)
@@ -81,7 +81,7 @@ class AdminAccountMethods(private val client: MastodonClient) {
*/
fun viewAccount(withId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$adminAccountsEndpointV1/$withId",
+ endpoint = "$endpointV1/$withId",
method = Method.GET
)
}
@@ -95,7 +95,7 @@ class AdminAccountMethods(private val client: MastodonClient) {
*/
fun approvePendingAccount(withId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$adminAccountsEndpointV1/$withId/approve",
+ endpoint = "$endpointV1/$withId/approve",
method = Method.POST
)
}
@@ -109,7 +109,7 @@ class AdminAccountMethods(private val client: MastodonClient) {
*/
fun rejectPendingAccount(withId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$adminAccountsEndpointV1/$withId/reject",
+ endpoint = "$endpointV1/$withId/reject",
method = Method.POST
)
}
@@ -123,7 +123,7 @@ class AdminAccountMethods(private val client: MastodonClient) {
*/
fun deleteAccount(withId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$adminAccountsEndpointV1/$withId",
+ endpoint = "$endpointV1/$withId",
method = Method.DELETE
)
}
@@ -151,7 +151,7 @@ class AdminAccountMethods(private val client: MastodonClient) {
sendEmailNotification: Boolean? = null
) {
return client.performAction(
- endpoint = "$adminAccountsEndpointV1/$withId/action",
+ endpoint = "$endpointV1/$withId/action",
method = Method.POST,
parameters = Parameters().apply {
append("type", type.apiName())
@@ -171,7 +171,7 @@ class AdminAccountMethods(private val client: MastodonClient) {
*/
fun enableDisabledAccount(withId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$adminAccountsEndpointV1/$withId/enable",
+ endpoint = "$endpointV1/$withId/enable",
method = Method.POST
)
}
@@ -183,7 +183,7 @@ class AdminAccountMethods(private val client: MastodonClient) {
*/
fun unsilenceAccount(withId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$adminAccountsEndpointV1/$withId/unsilence",
+ endpoint = "$endpointV1/$withId/unsilence",
method = Method.POST
)
}
@@ -195,7 +195,7 @@ class AdminAccountMethods(private val client: MastodonClient) {
*/
fun unsuspendAccount(withId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$adminAccountsEndpointV1/$withId/unsuspend",
+ endpoint = "$endpointV1/$withId/unsuspend",
method = Method.POST
)
}
@@ -207,7 +207,7 @@ class AdminAccountMethods(private val client: MastodonClient) {
*/
fun unmarkAccountAsSensitive(withId: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$adminAccountsEndpointV1/$withId/unsensitive",
+ endpoint = "$endpointV1/$withId/unsensitive",
method = Method.POST
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminCanonicalEmailBlockMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminCanonicalEmailBlockMethods.kt
index 557b31e37..f0c65fae1 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminCanonicalEmailBlockMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminCanonicalEmailBlockMethods.kt
@@ -15,7 +15,7 @@ import social.bigbone.api.entity.admin.BlockCanonicalEmailVariant
*/
class AdminCanonicalEmailBlockMethods(private val client: MastodonClient) {
- private val adminCanonicalEmailBlockEndpoint = "api/v1/admin/canonical_email_blocks"
+ private val endpoint = "api/v1/admin/canonical_email_blocks"
/**
* List all canonical email blocks.
@@ -28,7 +28,7 @@ class AdminCanonicalEmailBlockMethods(private val client: MastodonClient) {
@JvmOverloads
fun getAllCanonicalEmailBlocks(range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = adminCanonicalEmailBlockEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -44,7 +44,7 @@ class AdminCanonicalEmailBlockMethods(private val client: MastodonClient) {
*/
fun getCanonicalEmailBlock(id: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$adminCanonicalEmailBlockEndpoint/$id",
+ endpoint = "$endpoint/$id",
method = MastodonClient.Method.GET
)
}
@@ -59,7 +59,7 @@ class AdminCanonicalEmailBlockMethods(private val client: MastodonClient) {
*/
fun blockCanonicalEmail(variant: BlockCanonicalEmailVariant): MastodonRequest {
return client.getMastodonRequest(
- endpoint = adminCanonicalEmailBlockEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = variant.appendToParameters()
)
@@ -75,7 +75,7 @@ class AdminCanonicalEmailBlockMethods(private val client: MastodonClient) {
*/
fun removeCanonicalEmailBlock(id: String) {
client.performAction(
- endpoint = "$adminCanonicalEmailBlockEndpoint/$id",
+ endpoint = "$endpoint/$id",
method = MastodonClient.Method.DELETE
)
}
@@ -91,7 +91,7 @@ class AdminCanonicalEmailBlockMethods(private val client: MastodonClient) {
*/
fun canonicalizeAndHashEmailAddress(emailAddress: String): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = "$adminCanonicalEmailBlockEndpoint/test",
+ endpoint = "$endpoint/test",
method = MastodonClient.Method.POST,
parameters = Parameters().append("email", emailAddress)
)
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminDimensionMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminDimensionMethods.kt
index 09767cf44..3970cc7cb 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminDimensionMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminDimensionMethods.kt
@@ -13,7 +13,7 @@ import java.time.Instant
*/
class AdminDimensionMethods(private val client: MastodonClient) {
- private val adminDimensionsEndpoint = "api/v1/admin/dimensions"
+ private val endpoint = "api/v1/admin/dimensions"
/**
* Obtain information about popularity of certain accounts, servers, languages, etc.
@@ -31,7 +31,7 @@ class AdminDimensionMethods(private val client: MastodonClient) {
endAt: Instant
): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = adminDimensionsEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
dimensions
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminEmailDomainBlockMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminEmailDomainBlockMethods.kt
index 00973bff5..a1b7be5df 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminEmailDomainBlockMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminEmailDomainBlockMethods.kt
@@ -14,7 +14,7 @@ import social.bigbone.api.entity.admin.AdminEmailDomainBlock
*/
class AdminEmailDomainBlockMethods(private val client: MastodonClient) {
- private val adminEmailDomainBlockEndpoint = "api/v1/admin/email_domain_blocks"
+ private val endpoint = "api/v1/admin/email_domain_blocks"
/**
* Show information about all email domains blocked from signing up.
@@ -26,7 +26,7 @@ class AdminEmailDomainBlockMethods(private val client: MastodonClient) {
@JvmOverloads
fun getAllEmailDomainBlocks(range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = adminEmailDomainBlockEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -41,7 +41,7 @@ class AdminEmailDomainBlockMethods(private val client: MastodonClient) {
*/
fun getEmailDomainBlock(id: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$adminEmailDomainBlockEndpoint/$id",
+ endpoint = "$endpoint/$id",
method = MastodonClient.Method.GET
)
}
@@ -54,7 +54,7 @@ class AdminEmailDomainBlockMethods(private val client: MastodonClient) {
*/
fun blockEmailDomain(domain: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = adminEmailDomainBlockEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().append("domain", domain)
)
@@ -69,7 +69,7 @@ class AdminEmailDomainBlockMethods(private val client: MastodonClient) {
*/
fun removeEmailDomainBlock(id: String) {
client.performAction(
- endpoint = "$adminEmailDomainBlockEndpoint/$id",
+ endpoint = "$endpoint/$id",
method = MastodonClient.Method.DELETE
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminIpBlockMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminIpBlockMethods.kt
index 9199b8e66..1ab88fa58 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminIpBlockMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminIpBlockMethods.kt
@@ -13,7 +13,7 @@ import social.bigbone.api.entity.admin.AdminIpBlock
*/
class AdminIpBlockMethods(private val client: MastodonClient) {
- private val adminIpBlockEndpoint = "/api/v1/admin/ip_blocks"
+ private val endpoint = "api/v1/admin/ip_blocks"
/**
* Show information about all blocked IP ranges.
@@ -23,7 +23,7 @@ class AdminIpBlockMethods(private val client: MastodonClient) {
@JvmOverloads
fun getAllIpBlocks(range: Range = Range()): MastodonRequest> {
return client.getPageableMastodonRequest(
- endpoint = adminIpBlockEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.GET,
parameters = range.toParameters()
)
@@ -36,7 +36,7 @@ class AdminIpBlockMethods(private val client: MastodonClient) {
*/
fun getBlockedIpRange(id: String): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$adminIpBlockEndpoint/$id",
+ endpoint = "$endpoint/$id",
method = MastodonClient.Method.GET
)
}
@@ -57,7 +57,7 @@ class AdminIpBlockMethods(private val client: MastodonClient) {
expiresInSeconds: Int? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = adminIpBlockEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("ip", ipAddress)
@@ -86,7 +86,7 @@ class AdminIpBlockMethods(private val client: MastodonClient) {
expiresInSeconds: Int? = null
): MastodonRequest {
return client.getMastodonRequest(
- endpoint = "$adminIpBlockEndpoint/$id",
+ endpoint = "$endpoint/$id",
method = MastodonClient.Method.PUT,
parameters = Parameters().apply {
append("ip", ipAddress)
@@ -104,7 +104,7 @@ class AdminIpBlockMethods(private val client: MastodonClient) {
*/
fun removeIpBlock(id: String) {
client.performAction(
- endpoint = "$adminIpBlockEndpoint/$id",
+ endpoint = "$endpoint/$id",
method = MastodonClient.Method.DELETE
)
}
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminMeasureMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminMeasureMethods.kt
index d56d99aef..55a6557e1 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminMeasureMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminMeasureMethods.kt
@@ -13,7 +13,7 @@ import java.time.Instant
*/
class AdminMeasureMethods(private val client: MastodonClient) {
- private val adminMeasuresEndpoint = "api/v1/admin/measures"
+ private val endpoint = "api/v1/admin/measures"
/**
* Obtain statistical measures for your server.
@@ -30,7 +30,7 @@ class AdminMeasureMethods(private val client: MastodonClient) {
endAt: Instant
): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = adminMeasuresEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
measures
diff --git a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminRetentionMethods.kt b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminRetentionMethods.kt
index b2d57de1d..2c3490b7a 100644
--- a/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminRetentionMethods.kt
+++ b/bigbone/src/main/kotlin/social/bigbone/api/method/admin/AdminRetentionMethods.kt
@@ -13,7 +13,7 @@ import java.time.Instant
*/
class AdminRetentionMethods(private val client: MastodonClient) {
- private val adminRetentionEndpoint = "api/v1/admin/retention"
+ private val endpoint = "api/v1/admin/retention"
/**
* Generate a retention data report for a given time period and bucket.
@@ -29,7 +29,7 @@ class AdminRetentionMethods(private val client: MastodonClient) {
frequency: FrequencyOneOf
): MastodonRequest> {
return client.getMastodonRequestForList(
- endpoint = adminRetentionEndpoint,
+ endpoint = endpoint,
method = MastodonClient.Method.POST,
parameters = Parameters().apply {
append("start_at", startAt.toString())
diff --git a/bigbone/src/test/kotlin/social/bigbone/api/method/DomainBlockMethodsTest.kt b/bigbone/src/test/kotlin/social/bigbone/api/method/DomainBlockMethodsTest.kt
index 107f19fd7..7a2dbed40 100644
--- a/bigbone/src/test/kotlin/social/bigbone/api/method/DomainBlockMethodsTest.kt
+++ b/bigbone/src/test/kotlin/social/bigbone/api/method/DomainBlockMethodsTest.kt
@@ -29,7 +29,7 @@ class DomainBlockMethodsTest {
verify {
client.get(
- path = "/api/v1/domain_blocks",
+ path = "api/v1/domain_blocks",
query = any()
)
}
@@ -57,7 +57,7 @@ class DomainBlockMethodsTest {
verify {
client.performAction(
- endpoint = "/api/v1/domain_blocks",
+ endpoint = "api/v1/domain_blocks",
method = MastodonClient.Method.POST
)
}
@@ -103,7 +103,7 @@ class DomainBlockMethodsTest {
verify {
client.performAction(
- endpoint = "/api/v1/domain_blocks",
+ endpoint = "api/v1/domain_blocks",
method = MastodonClient.Method.DELETE
)
}
diff --git a/bigbone/src/test/kotlin/social/bigbone/api/method/InstanceMethodsTest.kt b/bigbone/src/test/kotlin/social/bigbone/api/method/InstanceMethodsTest.kt
index 374b169e7..9f84df544 100644
--- a/bigbone/src/test/kotlin/social/bigbone/api/method/InstanceMethodsTest.kt
+++ b/bigbone/src/test/kotlin/social/bigbone/api/method/InstanceMethodsTest.kt
@@ -35,7 +35,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v2/instance",
+ path = "api/v2/instance",
query = null
)
}
@@ -115,7 +115,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v2/instance",
+ path = "api/v2/instance",
query = null
)
}
@@ -173,7 +173,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v1/instance",
+ path = "api/v1/instance",
query = null
)
}
@@ -214,7 +214,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v2/instance",
+ path = "api/v2/instance",
query = null
)
}
@@ -231,7 +231,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v2/instance",
+ path = "api/v2/instance",
query = null
)
}
@@ -251,7 +251,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v1/instance/peers",
+ path = "api/v1/instance/peers",
query = null
)
}
@@ -271,7 +271,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v1/instance/peers",
+ path = "api/v1/instance/peers",
query = null
)
}
@@ -293,7 +293,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v1/instance/activity",
+ path = "api/v1/instance/activity",
query = null
)
}
@@ -313,7 +313,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v1/instance/activity",
+ path = "api/v1/instance/activity",
query = null
)
}
@@ -333,7 +333,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v1/instance/rules",
+ path = "api/v1/instance/rules",
query = null
)
}
@@ -355,7 +355,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v1/instance/domain_blocks",
+ path = "api/v1/instance/domain_blocks",
query = null
)
}
@@ -375,7 +375,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v1/instance/domain_blocks",
+ path = "api/v1/instance/domain_blocks",
query = null
)
}
@@ -394,7 +394,7 @@ class InstanceMethodsTest {
verify {
client.get(
- path = "/api/v1/instance/extended_description",
+ path = "api/v1/instance/extended_description",
query = null
)
}
diff --git a/bigbone/src/test/kotlin/social/bigbone/api/method/admin/AdminIpBlockMethodsTest.kt b/bigbone/src/test/kotlin/social/bigbone/api/method/admin/AdminIpBlockMethodsTest.kt
index d9e8f3885..4d1dcf2f4 100644
--- a/bigbone/src/test/kotlin/social/bigbone/api/method/admin/AdminIpBlockMethodsTest.kt
+++ b/bigbone/src/test/kotlin/social/bigbone/api/method/admin/AdminIpBlockMethodsTest.kt
@@ -16,7 +16,7 @@ import java.net.URLEncoder
class AdminIpBlockMethodsTest {
- private val adminIpBlockEndpoint = "/api/v1/admin/ip_blocks"
+ private val adminIpBlockEndpoint = "api/v1/admin/ip_blocks"
@Test
fun `Given client returning success, when getting all blocked ip addresses, then return list of ip addresses`() {