mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-23 00:30:59 +00:00
44 lines
1 KiB
Swift
44 lines
1 KiB
Swift
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
enum AccessTokenEndpoint {
|
|
case oauthToken(
|
|
clientID: String,
|
|
clientSecret: String,
|
|
code: String,
|
|
grantType: String,
|
|
scopes: String,
|
|
redirectURI: String
|
|
)
|
|
}
|
|
|
|
extension AccessTokenEndpoint: MastodonEndpoint {
|
|
typealias ResultType = AccessToken
|
|
|
|
var context: [String] { [] }
|
|
|
|
var pathComponentsInContext: [String] {
|
|
["oauth", "token"]
|
|
}
|
|
|
|
var method: HTTPMethod {
|
|
switch self {
|
|
case .oauthToken: return .post
|
|
}
|
|
}
|
|
|
|
var parameters: [String: Any]? {
|
|
switch self {
|
|
case let .oauthToken(clientID, clientSecret, code, grantType, scopes, redirectURI):
|
|
return [
|
|
"client_id": clientID,
|
|
"client_secret": clientSecret,
|
|
"code": code,
|
|
"grant_type": grantType,
|
|
"scope": scopes,
|
|
"redirect_uri": redirectURI
|
|
]
|
|
}
|
|
}
|
|
}
|