mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-25 17:50:59 +00:00
38 lines
905 B
Swift
38 lines
905 B
Swift
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
enum AppAuthorizationEndpoint {
|
|
case apps(clientName: String, redirectURI: String, scopes: String, website: URL?)
|
|
}
|
|
|
|
extension AppAuthorizationEndpoint: MastodonEndpoint {
|
|
typealias ResultType = AppAuthorization
|
|
|
|
var pathComponentsInContext: [String] {
|
|
switch self {
|
|
case .apps: return ["apps"]
|
|
}
|
|
}
|
|
|
|
var method: HTTPMethod {
|
|
switch self {
|
|
case .apps: return .post
|
|
}
|
|
}
|
|
|
|
var parameters: [String: Any]? {
|
|
switch self {
|
|
case let .apps(clientName, redirectURI, scopes, website):
|
|
var params = [
|
|
"client_name": clientName,
|
|
"redirect_uris": redirectURI,
|
|
"scopes": scopes
|
|
]
|
|
|
|
params["website"] = website?.absoluteString
|
|
|
|
return params
|
|
}
|
|
}
|
|
}
|