metatext/Networking/Mastodon API/Endpoints/AppAuthorizationEndpoint.swift
2020-08-26 21:04:06 -07:00

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
}
}
}