2019-05-03 01:17:52 +02:00
|
|
|
//
|
|
|
|
// FeedbinAPICaller.swift
|
|
|
|
// Account
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 5/2/19.
|
|
|
|
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import RSWeb
|
|
|
|
|
|
|
|
final class FeedbinAPICaller: NSObject {
|
|
|
|
|
2019-05-04 15:54:07 +02:00
|
|
|
private let feedbinBaseURL = URL(string: "https://api.feedbin.com/v2/")!
|
|
|
|
private var transport: Transport!
|
2019-05-03 01:17:52 +02:00
|
|
|
|
2019-05-04 15:54:07 +02:00
|
|
|
init(transport: Transport) {
|
2019-05-03 01:17:52 +02:00
|
|
|
super.init()
|
2019-05-04 15:54:07 +02:00
|
|
|
self.transport = transport
|
|
|
|
}
|
|
|
|
|
|
|
|
func validateCredentials(username: String, password: String, completionHandler handler: @escaping (Result<Bool, Error>) -> Void) {
|
2019-05-03 01:17:52 +02:00
|
|
|
|
2019-05-04 15:54:07 +02:00
|
|
|
let callURL = feedbinBaseURL.appendingPathComponent("authentication.json")
|
|
|
|
let request = URLRequest(url: callURL, username: username, password: password)
|
2019-05-03 01:17:52 +02:00
|
|
|
|
2019-05-04 15:54:07 +02:00
|
|
|
transport.send(request: request) { result in
|
|
|
|
switch result {
|
|
|
|
case .success:
|
|
|
|
handler(.success(true))
|
|
|
|
case .failure:
|
|
|
|
handler(.success(false))
|
|
|
|
}
|
2019-05-03 01:17:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|