mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Make APICall delegate based rather than defining a bunch of protocols.
This commit is contained in:
@@ -14,28 +14,23 @@ public protocol APICallDelegate {
|
||||
|
||||
func apiCallURLRequest(_ call: APICall) -> URLRequest?
|
||||
func apiCall(_ call: APICall, parseReturnedObjectWith: HTTPResult) -> Any?
|
||||
func apiCall(_ call: APICall, handleErrorWith: HTTPResult)
|
||||
func apiCall(_ call: APICall, performActionWith: HTTPResult)
|
||||
func apiCall(_ call: APICall, handleErrorWith: HTTPResult, returnedObject: Any?)
|
||||
func apiCall(_ call: APICall, performActionWith: HTTPResult, returnedObject: Any?)
|
||||
}
|
||||
|
||||
public final class APICall {
|
||||
|
||||
// Create request. Call server. Create result. Create returned object. Run action.
|
||||
public struct APICall {
|
||||
|
||||
public let provider: WebServiceProvider
|
||||
public let url: URL
|
||||
public let credentials: Credentials?
|
||||
public let methodName: String
|
||||
public let identifier: Int
|
||||
private let delegate: APICallDelegate
|
||||
private static var incrementingIdentifier = 0
|
||||
|
||||
init(provider: WebServiceProvider, url: URL, credentials: Credentials?, methodName: String, delegate: APICallDelegate) {
|
||||
init(provider: WebServiceProvider, methodName: String, delegate: APICallDelegate) {
|
||||
|
||||
self.provider = provider
|
||||
self.url = url
|
||||
self.credentials = credentials
|
||||
self.methodName = methodName
|
||||
self.delegate = delegate
|
||||
|
||||
self.identifier = APICall.incrementingIdentifier
|
||||
APICall.incrementingIdentifier += 1
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
//
|
||||
// APIResultParser.swift
|
||||
// RSWeb
|
||||
//
|
||||
// Created by Brent Simmons on 12/9/17.
|
||||
// Copyright © 2017 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol APIResultParser {
|
||||
|
||||
func parsedObject(with: APIResult) -> Any?
|
||||
}
|
||||
Reference in New Issue
Block a user