diff --git a/DB/Sources/DB/Content/StoredStatus.swift b/DB/Sources/DB/Content/StoredStatus.swift index 50ed866..ca7f893 100644 --- a/DB/Sources/DB/Content/StoredStatus.swift +++ b/DB/Sources/DB/Content/StoredStatus.swift @@ -38,11 +38,11 @@ struct StoredStatus: Codable, Hashable { extension StoredStatus: FetchableRecord, PersistableRecord { static func databaseJSONDecoder(for column: String) -> JSONDecoder { - APIDecoder() + MastodonDecoder() } static func databaseJSONEncoder(for column: String) -> JSONEncoder { - APIEncoder() + MastodonEncoder() } } diff --git a/DB/Sources/DB/Extensions/Account+Extensions.swift b/DB/Sources/DB/Extensions/Account+Extensions.swift index 448fb46..74fdd29 100644 --- a/DB/Sources/DB/Extensions/Account+Extensions.swift +++ b/DB/Sources/DB/Extensions/Account+Extensions.swift @@ -6,10 +6,10 @@ import Mastodon extension Account: FetchableRecord, PersistableRecord { public static func databaseJSONDecoder(for column: String) -> JSONDecoder { - APIDecoder() + MastodonDecoder() } public static func databaseJSONEncoder(for column: String) -> JSONEncoder { - APIEncoder() + MastodonEncoder() } } diff --git a/DB/Sources/DB/Extensions/Filter+Extensions.swift b/DB/Sources/DB/Extensions/Filter+Extensions.swift index 7606ec9..df83167 100644 --- a/DB/Sources/DB/Extensions/Filter+Extensions.swift +++ b/DB/Sources/DB/Extensions/Filter+Extensions.swift @@ -6,10 +6,10 @@ import Mastodon extension Filter: FetchableRecord, PersistableRecord { public static func databaseJSONDecoder(for column: String) -> JSONDecoder { - APIDecoder() + MastodonDecoder() } public static func databaseJSONEncoder(for column: String) -> JSONEncoder { - APIEncoder() + MastodonEncoder() } } diff --git a/Mastodon/Package.swift b/Mastodon/Package.swift index 063a654..313b818 100644 --- a/Mastodon/Package.swift +++ b/Mastodon/Package.swift @@ -11,24 +11,13 @@ let package = Package( products: [ .library( name: "Mastodon", - targets: ["Mastodon"]), - .library( - name: "MastodonStubs", - targets: ["MastodonStubs"]) - ], - dependencies: [ - .package(path: "HTTP") + targets: ["Mastodon"]) ], + dependencies: [], targets: [ - .target( - name: "Mastodon", - dependencies: ["HTTP"]), - .target( - name: "MastodonStubs", - dependencies: ["Mastodon", .product(name: "Stubbing", package: "HTTP")], - resources: [.process("Resources")]), + .target(name: "Mastodon"), .testTarget( name: "MastodonTests", - dependencies: ["MastodonStubs"]) + dependencies: ["Mastodon"]) ] ) diff --git a/Mastodon/Sources/Mastodon/API/APIDecoder.swift b/Mastodon/Sources/Mastodon/Coding/MastodonDecoder.swift similarity index 87% rename from Mastodon/Sources/Mastodon/API/APIDecoder.swift rename to Mastodon/Sources/Mastodon/Coding/MastodonDecoder.swift index 61860f0..3ff3d9a 100644 --- a/Mastodon/Sources/Mastodon/API/APIDecoder.swift +++ b/Mastodon/Sources/Mastodon/Coding/MastodonDecoder.swift @@ -2,7 +2,7 @@ import Foundation -public final class APIDecoder: JSONDecoder { +public final class MastodonDecoder: JSONDecoder { public override init() { super.init() diff --git a/Mastodon/Sources/Mastodon/API/APIEncoder.swift b/Mastodon/Sources/Mastodon/Coding/MastodonEncoder.swift similarity index 88% rename from Mastodon/Sources/Mastodon/API/APIEncoder.swift rename to Mastodon/Sources/Mastodon/Coding/MastodonEncoder.swift index c0c338f..5c7c331 100644 --- a/Mastodon/Sources/Mastodon/API/APIEncoder.swift +++ b/Mastodon/Sources/Mastodon/Coding/MastodonEncoder.swift @@ -2,7 +2,7 @@ import Foundation -public final class APIEncoder: JSONEncoder { +public final class MastodonEncoder: JSONEncoder { public override init() { super.init() diff --git a/Mastodon/Sources/Mastodon/Entities/Timeline.swift b/Mastodon/Sources/Mastodon/Entities/Timeline.swift index 8ea3a45..9b7f822 100644 --- a/Mastodon/Sources/Mastodon/Entities/Timeline.swift +++ b/Mastodon/Sources/Mastodon/Entities/Timeline.swift @@ -12,21 +12,6 @@ public enum Timeline: Hashable { public extension Timeline { static let nonLists: [Timeline] = [.home, .local, .federated] - - var endpoint: TimelinesEndpoint { - switch self { - case .home: - return .home - case .local: - return .public(local: true) - case .federated: - return .public(local: false) - case let .list(list): - return .list(id: list.id) - case let .tag(tag): - return .tag(tag) - } - } } extension Timeline: Identifiable { diff --git a/MastodonAPI/.gitignore b/MastodonAPI/.gitignore new file mode 100644 index 0000000..95c4320 --- /dev/null +++ b/MastodonAPI/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ diff --git a/MastodonAPI/Package.swift b/MastodonAPI/Package.swift new file mode 100644 index 0000000..88f8c46 --- /dev/null +++ b/MastodonAPI/Package.swift @@ -0,0 +1,35 @@ +// swift-tools-version:5.3 + +import PackageDescription + +let package = Package( + name: "MastodonAPI", + platforms: [ + .iOS(.v14), + .macOS(.v11) + ], + products: [ + .library( + name: "MastodonAPI", + targets: ["MastodonAPI"]), + .library( + name: "MastodonAPIStubs", + targets: ["MastodonAPIStubs"]) + ], + dependencies: [ + .package(path: "HTTP"), + .package(path: "Mastodon") + ], + targets: [ + .target( + name: "MastodonAPI", + dependencies: ["HTTP", "Mastodon"]), + .target( + name: "MastodonAPIStubs", + dependencies: ["MastodonAPI", .product(name: "Stubbing", package: "HTTP")], + resources: [.process("Resources")]), + .testTarget( + name: "MastodonAPITests", + dependencies: ["MastodonAPIStubs"]) + ] +) diff --git a/Mastodon/Sources/Mastodon/API/Endpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoint.swift similarity index 100% rename from Mastodon/Sources/Mastodon/API/Endpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoint.swift diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/AccessTokenEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/AccessTokenEndpoint.swift similarity index 98% rename from Mastodon/Sources/Mastodon/API/Endpoints/AccessTokenEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/AccessTokenEndpoint.swift index 09b02df..4202aa6 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/AccessTokenEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/AccessTokenEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum AccessTokenEndpoint { case oauthToken( diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/AccountEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/AccountEndpoint.swift similarity index 97% rename from Mastodon/Sources/Mastodon/API/Endpoints/AccountEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/AccountEndpoint.swift index 5e39071..19f2170 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/AccountEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/AccountEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum AccountEndpoint { case verifyCredentials diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/AppAuthorizationEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/AppAuthorizationEndpoint.swift similarity index 98% rename from Mastodon/Sources/Mastodon/API/Endpoints/AppAuthorizationEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/AppAuthorizationEndpoint.swift index 92621de..ed0bc8b 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/AppAuthorizationEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/AppAuthorizationEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum AppAuthorizationEndpoint { case apps(clientName: String, redirectURI: String, scopes: String, website: URL?) diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/ContextEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/ContextEndpoint.swift similarity index 96% rename from Mastodon/Sources/Mastodon/API/Endpoints/ContextEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/ContextEndpoint.swift index 7b96eb1..4e12465 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/ContextEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/ContextEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum ContextEndpoint { case context(id: String) diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/DeletionEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/DeletionEndpoint.swift similarity index 98% rename from Mastodon/Sources/Mastodon/API/Endpoints/DeletionEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/DeletionEndpoint.swift index 7b77c31..46eec07 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/DeletionEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/DeletionEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum DeletionEndpoint { case oauthRevoke(token: String, clientID: String, clientSecret: String) diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/FilterEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/FilterEndpoint.swift similarity index 99% rename from Mastodon/Sources/Mastodon/API/Endpoints/FilterEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/FilterEndpoint.swift index 5d96900..351f7b2 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/FilterEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/FilterEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum FilterEndpoint { case create( diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/FiltersEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/FiltersEndpoint.swift similarity index 97% rename from Mastodon/Sources/Mastodon/API/Endpoints/FiltersEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/FiltersEndpoint.swift index aa46320..fbe3281 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/FiltersEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/FiltersEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum FiltersEndpoint { case filters diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/InstanceEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/InstanceEndpoint.swift similarity index 96% rename from Mastodon/Sources/Mastodon/API/Endpoints/InstanceEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/InstanceEndpoint.swift index 8ebd3c2..e8998b7 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/InstanceEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/InstanceEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum InstanceEndpoint { case instance diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/ListEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/ListEndpoint.swift similarity index 97% rename from Mastodon/Sources/Mastodon/API/Endpoints/ListEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/ListEndpoint.swift index 793f056..c918339 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/ListEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/ListEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum ListEndpoint { case create(title: String) diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/ListsEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/ListsEndpoint.swift similarity index 95% rename from Mastodon/Sources/Mastodon/API/Endpoints/ListsEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/ListsEndpoint.swift index f67d578..b9894fb 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/ListsEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/ListsEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum ListsEndpoint { case lists diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/Paged.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/Paged.swift similarity index 98% rename from Mastodon/Sources/Mastodon/API/Endpoints/Paged.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/Paged.swift index 9824c97..1fde781 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/Paged.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/Paged.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public struct Paged { public let endpoint: T diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/PreferencesEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/PreferencesEndpoint.swift similarity index 96% rename from Mastodon/Sources/Mastodon/API/Endpoints/PreferencesEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/PreferencesEndpoint.swift index 11d45f3..8b05a8c 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/PreferencesEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/PreferencesEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum PreferencesEndpoint { case preferences diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/PushSubscriptionEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/PushSubscriptionEndpoint.swift similarity index 99% rename from Mastodon/Sources/Mastodon/API/Endpoints/PushSubscriptionEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/PushSubscriptionEndpoint.swift index 950e487..a93194d 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/PushSubscriptionEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/PushSubscriptionEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum PushSubscriptionEndpoint { case create( diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/StatusEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/StatusEndpoint.swift similarity index 98% rename from Mastodon/Sources/Mastodon/API/Endpoints/StatusEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/StatusEndpoint.swift index 09a2478..bd1f2e6 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/StatusEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/StatusEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum StatusEndpoint { case status(id: String) diff --git a/Mastodon/Sources/Mastodon/API/Endpoints/TimelinesEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/TimelinesEndpoint.swift similarity index 98% rename from Mastodon/Sources/Mastodon/API/Endpoints/TimelinesEndpoint.swift rename to MastodonAPI/Sources/MastodonAPI/Endpoints/TimelinesEndpoint.swift index 3d6a3b2..f61079c 100644 --- a/Mastodon/Sources/Mastodon/API/Endpoints/TimelinesEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/TimelinesEndpoint.swift @@ -2,6 +2,7 @@ import Foundation import HTTP +import Mastodon public enum TimelinesEndpoint { case `public`(local: Bool) diff --git a/MastodonAPI/Sources/MastodonAPI/Extensions/Timeline+Extensions.swift b/MastodonAPI/Sources/MastodonAPI/Extensions/Timeline+Extensions.swift new file mode 100644 index 0000000..e957043 --- /dev/null +++ b/MastodonAPI/Sources/MastodonAPI/Extensions/Timeline+Extensions.swift @@ -0,0 +1,21 @@ +// Copyright © 2020 Metabolist. All rights reserved. + +import Foundation +import Mastodon + +public extension Timeline { + var endpoint: TimelinesEndpoint { + switch self { + case .home: + return .home + case .local: + return .public(local: true) + case .federated: + return .public(local: false) + case let .list(list): + return .list(id: list.id) + case let .tag(tag): + return .tag(tag) + } + } +} diff --git a/Mastodon/Sources/Mastodon/API/APIClient.swift b/MastodonAPI/Sources/MastodonAPI/MastodonAPIClient.swift similarity index 73% rename from Mastodon/Sources/Mastodon/API/APIClient.swift rename to MastodonAPI/Sources/MastodonAPI/MastodonAPIClient.swift index 6cc3276..d50942d 100644 --- a/Mastodon/Sources/Mastodon/API/APIClient.swift +++ b/MastodonAPI/Sources/MastodonAPI/MastodonAPIClient.swift @@ -3,13 +3,14 @@ import Foundation import Combine import HTTP +import Mastodon -public final class APIClient: Client { +public final class MastodonAPIClient: Client { public var instanceURL: URL? public var accessToken: String? public required init(session: Session) { - super.init(session: session, decoder: APIDecoder()) + super.init(session: session, decoder: MastodonDecoder()) } public override func request(_ target: T) -> AnyPublisher { @@ -17,14 +18,14 @@ public final class APIClient: Client { } } -extension APIClient { +extension MastodonAPIClient { public func request(_ endpoint: E) -> AnyPublisher { guard let instanceURL = instanceURL else { return Fail(error: URLError(.badURL)).eraseToAnyPublisher() } return super.request( - APITarget(baseURL: instanceURL, endpoint: endpoint, accessToken: accessToken), + MastodonAPITarget(baseURL: instanceURL, endpoint: endpoint, accessToken: accessToken), decodeErrorsAs: APIError.self) } } diff --git a/Mastodon/Sources/Mastodon/API/APITarget.swift b/MastodonAPI/Sources/MastodonAPI/MastodonAPITarget.swift similarity index 91% rename from Mastodon/Sources/Mastodon/API/APITarget.swift rename to MastodonAPI/Sources/MastodonAPI/MastodonAPITarget.swift index 839cc46..115d1fd 100644 --- a/Mastodon/Sources/Mastodon/API/APITarget.swift +++ b/MastodonAPI/Sources/MastodonAPI/MastodonAPITarget.swift @@ -3,7 +3,7 @@ import Foundation import HTTP -public struct APITarget { +public struct MastodonAPITarget { public let baseURL: URL public let endpoint: E public let accessToken: String? @@ -15,7 +15,7 @@ public struct APITarget { } } -extension APITarget: DecodableTarget { +extension MastodonAPITarget: DecodableTarget { public typealias ResultType = E.ResultType public var pathComponents: [String] { endpoint.pathComponents } diff --git a/Mastodon/Sources/MastodonStubs/AccessTokenEndpoint+Stubbing.swift b/MastodonAPI/Sources/MastodonAPIStubs/AccessTokenEndpoint+Stubbing.swift similarity index 96% rename from Mastodon/Sources/MastodonStubs/AccessTokenEndpoint+Stubbing.swift rename to MastodonAPI/Sources/MastodonAPIStubs/AccessTokenEndpoint+Stubbing.swift index aa8a440..4cd70b6 100644 --- a/Mastodon/Sources/MastodonStubs/AccessTokenEndpoint+Stubbing.swift +++ b/MastodonAPI/Sources/MastodonAPIStubs/AccessTokenEndpoint+Stubbing.swift @@ -1,7 +1,7 @@ // Copyright © 2020 Metabolist. All rights reserved. import Foundation -import Mastodon +import MastodonAPI import Stubbing extension AccessTokenEndpoint: Stubbing { diff --git a/Mastodon/Sources/MastodonStubs/AccountEndpoint+Stubbing.swift b/MastodonAPI/Sources/MastodonAPIStubs/AccountEndpoint+Stubbing.swift similarity index 95% rename from Mastodon/Sources/MastodonStubs/AccountEndpoint+Stubbing.swift rename to MastodonAPI/Sources/MastodonAPIStubs/AccountEndpoint+Stubbing.swift index c8fbd59..160bbb1 100644 --- a/Mastodon/Sources/MastodonStubs/AccountEndpoint+Stubbing.swift +++ b/MastodonAPI/Sources/MastodonAPIStubs/AccountEndpoint+Stubbing.swift @@ -1,7 +1,7 @@ // Copyright © 2020 Metabolist. All rights reserved. import Foundation -import Mastodon +import MastodonAPI import Stubbing extension AccountEndpoint: Stubbing { diff --git a/Mastodon/Sources/MastodonStubs/AppAuthorizationEndpoint+Stubbing.swift b/MastodonAPI/Sources/MastodonAPIStubs/AppAuthorizationEndpoint+Stubbing.swift similarity index 97% rename from Mastodon/Sources/MastodonStubs/AppAuthorizationEndpoint+Stubbing.swift rename to MastodonAPI/Sources/MastodonAPIStubs/AppAuthorizationEndpoint+Stubbing.swift index cb95ee5..e216e04 100644 --- a/Mastodon/Sources/MastodonStubs/AppAuthorizationEndpoint+Stubbing.swift +++ b/MastodonAPI/Sources/MastodonAPIStubs/AppAuthorizationEndpoint+Stubbing.swift @@ -1,7 +1,7 @@ // Copyright © 2020 Metabolist. All rights reserved. import Foundation -import Mastodon +import MastodonAPI import Stubbing extension AppAuthorizationEndpoint: Stubbing { diff --git a/Mastodon/Sources/MastodonStubs/ContextEndpoint+Stubbing.swift b/MastodonAPI/Sources/MastodonAPIStubs/ContextEndpoint+Stubbing.swift similarity index 95% rename from Mastodon/Sources/MastodonStubs/ContextEndpoint+Stubbing.swift rename to MastodonAPI/Sources/MastodonAPIStubs/ContextEndpoint+Stubbing.swift index 68e0935..b1b6828 100644 --- a/Mastodon/Sources/MastodonStubs/ContextEndpoint+Stubbing.swift +++ b/MastodonAPI/Sources/MastodonAPIStubs/ContextEndpoint+Stubbing.swift @@ -1,7 +1,7 @@ // Copyright © 2020 Metabolist. All rights reserved. import Foundation -import Mastodon +import MastodonAPI import Stubbing extension ContextEndpoint: Stubbing { diff --git a/Mastodon/Sources/MastodonStubs/InstanceEndpoint+Stubbing.swift b/MastodonAPI/Sources/MastodonAPIStubs/InstanceEndpoint+Stubbing.swift similarity index 94% rename from Mastodon/Sources/MastodonStubs/InstanceEndpoint+Stubbing.swift rename to MastodonAPI/Sources/MastodonAPIStubs/InstanceEndpoint+Stubbing.swift index a2ac529..06ea80c 100644 --- a/Mastodon/Sources/MastodonStubs/InstanceEndpoint+Stubbing.swift +++ b/MastodonAPI/Sources/MastodonAPIStubs/InstanceEndpoint+Stubbing.swift @@ -1,7 +1,7 @@ // Copyright © 2020 Metabolist. All rights reserved. import Foundation -import Mastodon +import MastodonAPI import Stubbing extension InstanceEndpoint: Stubbing { diff --git a/Mastodon/Sources/MastodonStubs/MastodonTarget+Stubbing.swift b/MastodonAPI/Sources/MastodonAPIStubs/MastodonTarget+Stubbing.swift similarity index 89% rename from Mastodon/Sources/MastodonStubs/MastodonTarget+Stubbing.swift rename to MastodonAPI/Sources/MastodonAPIStubs/MastodonTarget+Stubbing.swift index ac09eb6..d1dcd98 100644 --- a/Mastodon/Sources/MastodonStubs/MastodonTarget+Stubbing.swift +++ b/MastodonAPI/Sources/MastodonAPIStubs/MastodonTarget+Stubbing.swift @@ -1,10 +1,10 @@ // Copyright © 2020 Metabolist. All rights reserved. import Foundation -import Mastodon +import MastodonAPI import Stubbing -extension APITarget: Stubbing { +extension MastodonAPITarget: Stubbing { public func stub(url: URL) -> HTTPStub? { (endpoint as? Stubbing)?.stub(url: url) } diff --git a/Mastodon/Sources/MastodonStubs/Paged+Stubbing.swift b/MastodonAPI/Sources/MastodonAPIStubs/Paged+Stubbing.swift similarity index 91% rename from Mastodon/Sources/MastodonStubs/Paged+Stubbing.swift rename to MastodonAPI/Sources/MastodonAPIStubs/Paged+Stubbing.swift index dd390d9..5ba31d3 100644 --- a/Mastodon/Sources/MastodonStubs/Paged+Stubbing.swift +++ b/MastodonAPI/Sources/MastodonAPIStubs/Paged+Stubbing.swift @@ -1,7 +1,7 @@ // Copyright © 2020 Metabolist. All rights reserved. import Foundation -import Mastodon +import MastodonAPI import Stubbing extension Paged: Stubbing where T: Stubbing { diff --git a/Mastodon/Sources/MastodonStubs/PreferencesEndpoint+Stubbing.swift b/MastodonAPI/Sources/MastodonAPIStubs/PreferencesEndpoint+Stubbing.swift similarity index 96% rename from Mastodon/Sources/MastodonStubs/PreferencesEndpoint+Stubbing.swift rename to MastodonAPI/Sources/MastodonAPIStubs/PreferencesEndpoint+Stubbing.swift index 1af6143..80cc514 100644 --- a/Mastodon/Sources/MastodonStubs/PreferencesEndpoint+Stubbing.swift +++ b/MastodonAPI/Sources/MastodonAPIStubs/PreferencesEndpoint+Stubbing.swift @@ -1,7 +1,7 @@ // Copyright © 2020 Metabolist. All rights reserved. import Foundation -import Mastodon +import MastodonAPI import Stubbing extension PreferencesEndpoint: Stubbing { diff --git a/Mastodon/Sources/MastodonStubs/Resources/account.json b/MastodonAPI/Sources/MastodonAPIStubs/Resources/account.json similarity index 100% rename from Mastodon/Sources/MastodonStubs/Resources/account.json rename to MastodonAPI/Sources/MastodonAPIStubs/Resources/account.json diff --git a/Mastodon/Sources/MastodonStubs/Resources/instance.json b/MastodonAPI/Sources/MastodonAPIStubs/Resources/instance.json similarity index 100% rename from Mastodon/Sources/MastodonStubs/Resources/instance.json rename to MastodonAPI/Sources/MastodonAPIStubs/Resources/instance.json diff --git a/Mastodon/Sources/MastodonStubs/Resources/timeline.json b/MastodonAPI/Sources/MastodonAPIStubs/Resources/timeline.json similarity index 100% rename from Mastodon/Sources/MastodonStubs/Resources/timeline.json rename to MastodonAPI/Sources/MastodonAPIStubs/Resources/timeline.json diff --git a/Mastodon/Sources/MastodonStubs/TimelinesEndpoint+Stubbing.swift b/MastodonAPI/Sources/MastodonAPIStubs/TimelinesEndpoint+Stubbing.swift similarity index 93% rename from Mastodon/Sources/MastodonStubs/TimelinesEndpoint+Stubbing.swift rename to MastodonAPI/Sources/MastodonAPIStubs/TimelinesEndpoint+Stubbing.swift index 73d7cc9..2d9efe4 100644 --- a/Mastodon/Sources/MastodonStubs/TimelinesEndpoint+Stubbing.swift +++ b/MastodonAPI/Sources/MastodonAPIStubs/TimelinesEndpoint+Stubbing.swift @@ -1,7 +1,7 @@ // Copyright © 2020 Metabolist. All rights reserved. import Foundation -import Mastodon +import MastodonAPI import Stubbing extension TimelinesEndpoint: Stubbing { diff --git a/MastodonAPI/Tests/MastodonAPITests/MastodonAPITests.swift b/MastodonAPI/Tests/MastodonAPITests/MastodonAPITests.swift new file mode 100644 index 0000000..bb31e5e --- /dev/null +++ b/MastodonAPI/Tests/MastodonAPITests/MastodonAPITests.swift @@ -0,0 +1,10 @@ +import XCTest +@testable import MastodonAPI + +final class MastodonAPITests: XCTestCase { + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + } +} diff --git a/Metatext.xcodeproj/project.pbxproj b/Metatext.xcodeproj/project.pbxproj index 720675b..5158511 100644 --- a/Metatext.xcodeproj/project.pbxproj +++ b/Metatext.xcodeproj/project.pbxproj @@ -95,6 +95,7 @@ D0BEB21024FA2A90001B0F04 /* EditFilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditFilterView.swift; sourceTree = ""; }; D0BECB952501B3DD002C1B13 /* Keychain */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Keychain; sourceTree = ""; }; D0BECB962501BCE0002C1B13 /* Secrets */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Secrets; sourceTree = ""; }; + D0BECB9D2501CBC3002C1B13 /* MastodonAPI */ = {isa = PBXFileReference; lastKnownFileType = folder; path = MastodonAPI; sourceTree = ""; }; D0BFDAF524FC7C5300C86618 /* HTTP */ = {isa = PBXFileReference; lastKnownFileType = folder; path = HTTP; sourceTree = ""; }; D0C7D41E24F76169001EBDBB /* Metatext.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Metatext.entitlements; sourceTree = ""; }; D0C7D41F24F76169001EBDBB /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -188,6 +189,7 @@ D0BECB952501B3DD002C1B13 /* Keychain */, D0C7D45624F76169001EBDBB /* Localizations */, D0E0F1E424FC49FC002C04BF /* Mastodon */, + D0BECB9D2501CBC3002C1B13 /* MastodonAPI */, D0E5361A24E3EB4D00FB1CE1 /* Notification Service Extension */, D047FA8D24C3E21200AF17C5 /* Products */, D0BECB962501BCE0002C1B13 /* Secrets */, diff --git a/Notification Service Extension/NotificationService.swift b/Notification Service Extension/NotificationService.swift index c256046..c88195a 100644 --- a/Notification Service Extension/NotificationService.swift +++ b/Notification Service Extension/NotificationService.swift @@ -24,7 +24,7 @@ class NotificationService: UNNotificationServiceExtension { do { let decryptedJSON = try Self.extractAndDecrypt(userInfo: request.content.userInfo) - pushNotification = try APIDecoder().decode(PushNotification.self, from: decryptedJSON) + pushNotification = try MastodonDecoder().decode(PushNotification.self, from: decryptedJSON) } catch { contentHandler(bestAttemptContent) diff --git a/ServiceLayer/Package.swift b/ServiceLayer/Package.swift index 4d06236..810ccce 100644 --- a/ServiceLayer/Package.swift +++ b/ServiceLayer/Package.swift @@ -20,18 +20,18 @@ let package = Package( .package(url: "https://github.com/groue/CombineExpectations.git", .upToNextMajor(from: "0.5.0")), .package(path: "DB"), .package(path: "Keychain"), - .package(path: "Mastodon"), + .package(path: "MastodonAPI"), .package(path: "Secrets") ], targets: [ .target( name: "ServiceLayer", - dependencies: ["DB", "Secrets"]), + dependencies: ["DB", "MastodonAPI", "Secrets"]), .target( name: "ServiceLayerMocks", dependencies: [ "ServiceLayer", - .product(name: "MastodonStubs", package: "Mastodon"), + .product(name: "MastodonAPIStubs", package: "MastodonAPI"), .product(name: "MockKeychain", package: "Keychain")]), .testTarget( name: "ServiceLayerTests", diff --git a/ServiceLayer/Sources/ServiceLayer/AllIdentitiesService.swift b/ServiceLayer/Sources/ServiceLayer/Services/AllIdentitiesService.swift similarity index 94% rename from ServiceLayer/Sources/ServiceLayer/AllIdentitiesService.swift rename to ServiceLayer/Sources/ServiceLayer/Services/AllIdentitiesService.swift index 62f2454..d2cc953 100644 --- a/ServiceLayer/Sources/ServiceLayer/AllIdentitiesService.swift +++ b/ServiceLayer/Sources/ServiceLayer/Services/AllIdentitiesService.swift @@ -4,6 +4,7 @@ import DB import Foundation import Combine import Mastodon +import MastodonAPI import Secrets public struct AllIdentitiesService { @@ -53,9 +54,9 @@ public extension AllIdentitiesService { func deleteIdentity(_ identity: Identity) -> AnyPublisher { let secrets = Secrets(identityID: identity.id, keychain: environment.keychain) - let networkClient = APIClient(session: environment.session) + let mastodonAPIClient = MastodonAPIClient(session: environment.session) - networkClient.instanceURL = identity.url + mastodonAPIClient.instanceURL = identity.url return identityDatabase.deleteIdentity(id: identity.id) .collect() @@ -65,7 +66,7 @@ public extension AllIdentitiesService { clientID: try secrets.item(.clientID), clientSecret: try secrets.item(.clientSecret)) } - .flatMap(networkClient.request) + .flatMap(mastodonAPIClient.request) .collect() .tryMap { _ in try secrets.deleteAllItems() diff --git a/ServiceLayer/Sources/ServiceLayer/AuthenticationService.swift b/ServiceLayer/Sources/ServiceLayer/Services/AuthenticationService.swift similarity index 89% rename from ServiceLayer/Sources/ServiceLayer/AuthenticationService.swift rename to ServiceLayer/Sources/ServiceLayer/Services/AuthenticationService.swift index dee2f5f..53e9285 100644 --- a/ServiceLayer/Sources/ServiceLayer/AuthenticationService.swift +++ b/ServiceLayer/Sources/ServiceLayer/Services/AuthenticationService.swift @@ -3,14 +3,15 @@ import Foundation import Combine import Mastodon +import MastodonAPI public struct AuthenticationService { - private let networkClient: APIClient + private let mastodonAPIClient: MastodonAPIClient private let webAuthSessionType: WebAuthSession.Type private let webAuthSessionContextProvider = WebAuthSessionContextProvider() public init(environment: AppEnvironment) { - networkClient = APIClient(session: environment.session) + mastodonAPIClient = MastodonAPIClient(session: environment.session) webAuthSessionType = environment.webAuthSessionType } } @@ -22,9 +23,9 @@ public extension AuthenticationService { redirectURI: OAuth.callbackURL.absoluteString, scopes: OAuth.scopes, website: OAuth.website) - let target = APITarget(baseURL: instanceURL, endpoint: endpoint, accessToken: nil) + let target = MastodonAPITarget(baseURL: instanceURL, endpoint: endpoint, accessToken: nil) - return networkClient.request(target) + return mastodonAPIClient.request(target) } func authenticate(instanceURL: URL, appAuthorization: AppAuthorization) -> AnyPublisher { @@ -63,9 +64,9 @@ public extension AuthenticationService { grantType: OAuth.grantType, scopes: OAuth.scopes, redirectURI: OAuth.callbackURL.absoluteString) - let target = APITarget(baseURL: instanceURL, endpoint: endpoint, accessToken: nil) + let target = MastodonAPITarget(baseURL: instanceURL, endpoint: endpoint, accessToken: nil) - return networkClient.request(target) + return mastodonAPIClient.request(target) } .eraseToAnyPublisher() } diff --git a/ServiceLayer/Sources/ServiceLayer/IdentityService.swift b/ServiceLayer/Sources/ServiceLayer/Services/IdentityService.swift similarity index 85% rename from ServiceLayer/Sources/ServiceLayer/IdentityService.swift rename to ServiceLayer/Sources/ServiceLayer/Services/IdentityService.swift index 1494548..2a23b35 100644 --- a/ServiceLayer/Sources/ServiceLayer/IdentityService.swift +++ b/ServiceLayer/Sources/ServiceLayer/Services/IdentityService.swift @@ -4,6 +4,7 @@ import DB import Foundation import Combine import Mastodon +import MastodonAPI import Secrets public class IdentityService { @@ -13,7 +14,7 @@ public class IdentityService { private let identityDatabase: IdentityDatabase private let contentDatabase: ContentDatabase private let environment: AppEnvironment - private let networkClient: APIClient + private let mastodonAPIClient: MastodonAPIClient private let secrets: Secrets private let observationErrorsInput = PassthroughSubject() @@ -37,9 +38,9 @@ public class IdentityService { secrets = Secrets( identityID: identityID, keychain: environment.keychain) - networkClient = APIClient(session: environment.session) - networkClient.instanceURL = identity.url - networkClient.accessToken = try? secrets.item(.accessToken) + mastodonAPIClient = MastodonAPIClient(session: environment.session) + mastodonAPIClient.instanceURL = identity.url + mastodonAPIClient.accessToken = try? secrets.item(.accessToken) contentDatabase = try ContentDatabase(identityID: identityID, inMemory: environment.inMemoryContent) @@ -53,21 +54,21 @@ public class IdentityService { } public extension IdentityService { - var isAuthorized: Bool { networkClient.accessToken != nil } + var isAuthorized: Bool { mastodonAPIClient.accessToken != nil } func updateLastUse() -> AnyPublisher { identityDatabase.updateLastUsedAt(identityID: identity.id) } func verifyCredentials() -> AnyPublisher { - networkClient.request(AccountEndpoint.verifyCredentials) + mastodonAPIClient.request(AccountEndpoint.verifyCredentials) .zip(Just(identity.id).first().setFailureType(to: Error.self)) .flatMap(identityDatabase.updateAccount) .eraseToAnyPublisher() } func refreshServerPreferences() -> AnyPublisher { - networkClient.request(PreferencesEndpoint.preferences) + mastodonAPIClient.request(PreferencesEndpoint.preferences) .zip(Just(self).first().setFailureType(to: Error.self)) .map { ($1.identity.preferences.updated(from: $0), $1.identity.id) } .flatMap(identityDatabase.updatePreferences) @@ -75,7 +76,7 @@ public extension IdentityService { } func refreshInstance() -> AnyPublisher { - networkClient.request(InstanceEndpoint.instance) + mastodonAPIClient.request(InstanceEndpoint.instance) .zip(Just(identity.id).first().setFailureType(to: Error.self)) .flatMap(identityDatabase.updateInstance) .eraseToAnyPublisher() @@ -90,19 +91,19 @@ public extension IdentityService { } func refreshLists() -> AnyPublisher { - networkClient.request(ListsEndpoint.lists) + mastodonAPIClient.request(ListsEndpoint.lists) .flatMap(contentDatabase.setLists(_:)) .eraseToAnyPublisher() } func createList(title: String) -> AnyPublisher { - networkClient.request(ListEndpoint.create(title: title)) + mastodonAPIClient.request(ListEndpoint.create(title: title)) .flatMap(contentDatabase.createList(_:)) .eraseToAnyPublisher() } func deleteList(id: String) -> AnyPublisher { - networkClient.request(DeletionEndpoint.list(id: id)) + mastodonAPIClient.request(DeletionEndpoint.list(id: id)) .map { _ in id } .flatMap(contentDatabase.deleteList(id:)) .eraseToAnyPublisher() @@ -113,13 +114,13 @@ public extension IdentityService { } func refreshFilters() -> AnyPublisher { - networkClient.request(FiltersEndpoint.filters) + mastodonAPIClient.request(FiltersEndpoint.filters) .flatMap(contentDatabase.setFilters(_:)) .eraseToAnyPublisher() } func createFilter(_ filter: Filter) -> AnyPublisher { - networkClient.request(FilterEndpoint.create(phrase: filter.phrase, + mastodonAPIClient.request(FilterEndpoint.create(phrase: filter.phrase, context: filter.context, irreversible: filter.irreversible, wholeWord: filter.wholeWord, @@ -129,7 +130,7 @@ public extension IdentityService { } func updateFilter(_ filter: Filter) -> AnyPublisher { - networkClient.request(FilterEndpoint.update(id: filter.id, + mastodonAPIClient.request(FilterEndpoint.update(id: filter.id, phrase: filter.phrase, context: filter.context, irreversible: filter.irreversible, @@ -140,7 +141,7 @@ public extension IdentityService { } func deleteFilter(id: String) -> AnyPublisher { - networkClient.request(DeletionEndpoint.filter(id: id)) + mastodonAPIClient.request(DeletionEndpoint.filter(id: id)) .map { _ in id } .flatMap(contentDatabase.deleteFilter(id:)) .eraseToAnyPublisher() @@ -180,7 +181,7 @@ public extension IdentityService { .appendingPathComponent(deviceToken) .appendingPathComponent(identityID.uuidString) - return networkClient.request( + return mastodonAPIClient.request( PushSubscriptionEndpoint.create( endpoint: endpoint, publicKey: publicKey, @@ -194,14 +195,14 @@ public extension IdentityService { func updatePushSubscription(alerts: PushSubscription.Alerts) -> AnyPublisher { let identityID = identity.id - return networkClient.request(PushSubscriptionEndpoint.update(alerts: alerts)) + return mastodonAPIClient.request(PushSubscriptionEndpoint.update(alerts: alerts)) .map { ($0.alerts, nil, identityID) } .flatMap(identityDatabase.updatePushSubscription(alerts:deviceToken:forIdentityID:)) .eraseToAnyPublisher() } func service(timeline: Timeline) -> StatusListService { - StatusListService(timeline: timeline, networkClient: networkClient, contentDatabase: contentDatabase) + StatusListService(timeline: timeline, mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase) } } diff --git a/ServiceLayer/Sources/ServiceLayer/StatusListService.swift b/ServiceLayer/Sources/ServiceLayer/Services/StatusListService.swift similarity index 77% rename from ServiceLayer/Sources/ServiceLayer/StatusListService.swift rename to ServiceLayer/Sources/ServiceLayer/Services/StatusListService.swift index 2ce0123..3d639f6 100644 --- a/ServiceLayer/Sources/ServiceLayer/StatusListService.swift +++ b/ServiceLayer/Sources/ServiceLayer/Services/StatusListService.swift @@ -4,6 +4,7 @@ import Combine import DB import Foundation import Mastodon +import MastodonAPI public struct StatusListService { public let statusSections: AnyPublisher<[[Status]], Error> @@ -11,13 +12,13 @@ public struct StatusListService { public let contextParentID: String? private let filterContext: Filter.Context - private let networkClient: APIClient + private let mastodonAPIClient: MastodonAPIClient private let contentDatabase: ContentDatabase private let requestClosure: (_ maxID: String?, _ minID: String?) -> AnyPublisher } extension StatusListService { - init(timeline: Timeline, networkClient: APIClient, contentDatabase: ContentDatabase) { + init(timeline: Timeline, mastodonAPIClient: MastodonAPIClient, contentDatabase: ContentDatabase) { let filterContext: Filter.Context switch timeline { @@ -31,9 +32,9 @@ extension StatusListService { paginates: true, contextParentID: nil, filterContext: filterContext, - networkClient: networkClient, + mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase) { maxID, minID in - networkClient.request(Paged(timeline.endpoint, maxID: maxID, minID: minID)) + mastodonAPIClient.request(Paged(timeline.endpoint, maxID: maxID, minID: minID)) .flatMap { contentDatabase.insert(statuses: $0, timeline: timeline) } .eraseToAnyPublisher() } @@ -50,7 +51,7 @@ public extension StatusListService { } func statusService(status: Status) -> StatusService { - StatusService(status: status, networkClient: networkClient, contentDatabase: contentDatabase) + StatusService(status: status, networkClient: mastodonAPIClient, contentDatabase: contentDatabase) } func contextService(statusID: String) -> Self { @@ -58,13 +59,13 @@ public extension StatusListService { paginates: false, contextParentID: statusID, filterContext: .thread, - networkClient: networkClient, + mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase) { _, _ in Publishers.Merge( - networkClient.request(StatusEndpoint.status(id: statusID)) + mastodonAPIClient.request(StatusEndpoint.status(id: statusID)) .flatMap(contentDatabase.insert(status:)) .eraseToAnyPublisher(), - networkClient.request(ContextEndpoint.context(id: statusID)) + mastodonAPIClient.request(ContextEndpoint.context(id: statusID)) .flatMap { contentDatabase.insert(context: $0, parentID: statusID) } .eraseToAnyPublisher()) .eraseToAnyPublisher() diff --git a/ServiceLayer/Sources/ServiceLayer/StatusService.swift b/ServiceLayer/Sources/ServiceLayer/Services/StatusService.swift similarity index 51% rename from ServiceLayer/Sources/ServiceLayer/StatusService.swift rename to ServiceLayer/Sources/ServiceLayer/Services/StatusService.swift index cef4b26..3601feb 100644 --- a/ServiceLayer/Sources/ServiceLayer/StatusService.swift +++ b/ServiceLayer/Sources/ServiceLayer/Services/StatusService.swift @@ -4,24 +4,25 @@ import Foundation import Combine import DB import Mastodon +import MastodonAPI public struct StatusService { public let status: Status - private let networkClient: APIClient + private let mastodonAPIClient: MastodonAPIClient private let contentDatabase: ContentDatabase - init(status: Status, networkClient: APIClient, contentDatabase: ContentDatabase) { + init(status: Status, networkClient: MastodonAPIClient, contentDatabase: ContentDatabase) { self.status = status - self.networkClient = networkClient + self.mastodonAPIClient = networkClient self.contentDatabase = contentDatabase } } public extension StatusService { func toggleFavorited() -> AnyPublisher { - networkClient.request(status.displayStatus.favourited - ? StatusEndpoint.unfavourite(id: status.displayStatus.id) - : StatusEndpoint.favourite(id: status.displayStatus.id)) + mastodonAPIClient.request(status.displayStatus.favourited + ? StatusEndpoint.unfavourite(id: status.displayStatus.id) + : StatusEndpoint.favourite(id: status.displayStatus.id)) .flatMap(contentDatabase.insert(status:)) .eraseToAnyPublisher() } diff --git a/ServiceLayer/Sources/ServiceLayer/UserNotificationService.swift b/ServiceLayer/Sources/ServiceLayer/Services/UserNotificationService.swift similarity index 100% rename from ServiceLayer/Sources/ServiceLayer/UserNotificationService.swift rename to ServiceLayer/Sources/ServiceLayer/Services/UserNotificationService.swift diff --git a/ServiceLayer/Sources/ServiceLayer/Entities/UserNotificationClient.swift b/ServiceLayer/Sources/ServiceLayer/Utilities/UserNotificationClient.swift similarity index 100% rename from ServiceLayer/Sources/ServiceLayer/Entities/UserNotificationClient.swift rename to ServiceLayer/Sources/ServiceLayer/Utilities/UserNotificationClient.swift diff --git a/ServiceLayer/Sources/ServiceLayer/Entities/WebAuthSession.swift b/ServiceLayer/Sources/ServiceLayer/Utilities/WebAuthSession.swift similarity index 100% rename from ServiceLayer/Sources/ServiceLayer/Entities/WebAuthSession.swift rename to ServiceLayer/Sources/ServiceLayer/Utilities/WebAuthSession.swift diff --git a/ViewModels/Sources/PreviewViewModels/ViewModelMocks.swift b/ViewModels/Sources/PreviewViewModels/ViewModelMocks.swift index 780aae6..bbeaab2 100644 --- a/ViewModels/Sources/PreviewViewModels/ViewModelMocks.swift +++ b/ViewModels/Sources/PreviewViewModels/ViewModelMocks.swift @@ -4,12 +4,13 @@ import Foundation import Combine import HTTP import Mastodon -import MastodonStubs +import MastodonAPI +import MastodonAPIStubs import ServiceLayer import ServiceLayerMocks import ViewModels -private let decoder = APIDecoder() +private let decoder = MastodonDecoder() private let devInstanceURL = URL(string: "https://mastodon.social")! // swiftlint:disable force_try