iOS/Sources/Shared/API/Webhook/Networking/WebhookResponseUnhandled.swift
Zac West 640cca884b
Add SwiftFormat to project (#1463)
Adds new fastlane lanes:
- `fastlane lint` which checks the linters
- `fastlane autocorrect` which applies the linters which can autocorrect (Rubocop, SwiftFormat)

Adds a build step to the Codegen abstract target which runs SwiftFormat in lint mode, pointing out what it's going to change when run.

Applies SwiftFormat to nearly all code -- exempts a few externally-sourced files and generated code.
2021-02-05 22:06:25 -08:00

27 lines
812 B
Swift

import Foundation
import PromiseKit
public extension WebhookResponseIdentifier {
static var unhandled: Self { .init(rawValue: "unhandled") }
}
struct WebhookResponseUnhandled: WebhookResponseHandler {
init(api: HomeAssistantAPI) {}
static func shouldReplace(request current: WebhookRequest, with proposed: WebhookRequest) -> Bool {
// the unhandled variant never replaces requests. to customize, create another implementation.
false
}
func handle(
request: Promise<WebhookRequest>,
result: Promise<Any>
) -> Guarantee<WebhookResponseHandlerResult> {
result.then { _ in
Guarantee.value(WebhookResponseHandlerResult.default)
}.recover { _ in
Guarantee.value(WebhookResponseHandlerResult.default)
}
}
}