Impressia/Vernissage/Extensions/MastodonClientAuthenticated...

22 lines
612 B
Swift
Raw Normal View History

2023-01-04 20:56:26 +01:00
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the MIT License.
//
import Foundation
import MastodonSwift
extension MastodonClientAuthenticated {
func getAccount(for accountId: String) async throws -> Account {
let request = try Self.request(
for: baseURL,
target: Mastodon.Account.account(accountId),
withBearerToken: token
)
let (data, _) = try await urlSession.data(for: request)
return try JSONDecoder().decode(Account.self, from: data)
}
}