1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-19 13:02:49 +01:00
metatext-app-ios-iphone-ipad/Shared/Networking/Mastodon API/AppAuthorizationEndpoint.swift
Justin Mazzocchi 0755e81ed9
Refactoring
2020-08-02 17:55:23 -07:00

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