Vernissage/PixelfedKit/Sources/PixelfedKit/PixelfedClient+Tags.swift

41 lines
1.1 KiB
Swift
Raw Normal View History

2023-01-25 15:39:04 +01:00
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
2023-03-28 10:35:38 +02:00
// Licensed under the Apache License 2.0.
2023-01-25 15:39:04 +01:00
//
import Foundation
2023-02-19 10:43:37 +01:00
public extension PixelfedClientAuthenticated {
2023-01-25 15:39:04 +01:00
func tag(hashtag: String) async throws -> Tag {
let request = try Self.request(
for: baseURL,
2023-02-19 10:43:37 +01:00
target: Pixelfed.Tags.tag(hashtag),
2023-01-25 15:39:04 +01:00
withBearerToken: token
)
return try await downloadJson(Tag.self, request: request)
}
func follow(hashtag: String) async throws -> Tag {
let request = try Self.request(
for: baseURL,
2023-02-19 10:43:37 +01:00
target: Pixelfed.Tags.follow(hashtag),
2023-01-25 15:39:04 +01:00
withBearerToken: token
)
return try await downloadJson(Tag.self, request: request)
}
func unfollow(hashtag: String) async throws -> Tag {
let request = try Self.request(
for: baseURL,
2023-02-19 10:43:37 +01:00
target: Pixelfed.Tags.unfollow(hashtag),
2023-01-25 15:39:04 +01:00
withBearerToken: token
)
return try await downloadJson(Tag.self, request: request)
}
}