You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO: Add tests for these rules
/// The `EngagementRule` enum defines how deep a JSON is to be parsed
/**
{ node:subnode:{node:subnode:...}
*/
/// This is a placeholder for a fearue that we should have in the future
/// case ObjectDetermined // The rules of the Type to be parsed should be used.
/// case Inline // Only the data that you already have
/// case Exhaustive // fetch all sub entities via new service requests
/// case ExhaustiveRecursive // fetch all sub entities of sub entities (nuclear)
public enum EngagementRule: Equatable {
case None // Stop parsing 1 node deep
case All // Parse all
}
public func == (lhs: EngagementRule, rhs: EngagementRule) -> Bool {
switch lhs {
case .None:
switch rhs {
case .None:
return true
default:
return false
}
case .All:
switch rhs {
case .All:
return true
default:
return false
}
}
}
And change Order to
publicenumMethod:String{case GET, POST, PUT, DELETE, PATCH
}publicclassOrder{publictypealiasRules=[(nodeKey:String, rule:EngagementRule)]publicletpath:Stringpublicletmethod:Method
/// The rules for the nodes that should be fetched.
publicletrulesOfEngagement:Rules?publicinit(path:String, method:Method=.GET, rulesOfEngagement:Rules?=nil){public init(path: String, method: Method =.GET){self.path = path
self.method = method
self.rulesOfEngagement = rulesOfEngagement
}
public func request(withConfiguration configuration:Configuration)->NSURLRequest?{letmutableRequest=NSMutableURLRequest(URL:NSURL(string:"\(configuration.baseURL)/\(path)")!, cachePolicy:.ReloadIgnoringLocalAndRemoteCacheData, timeoutInterval:10.0)
mutableRequest.HTTPMethod = method.rawValue
return mutableRequest
}
public func collectionRequestForConfiguration(configuration:Configuration)->NSURLRequest?{returnnil}
/// Parse sub nodes or not
public func engagementRuleForNodeKey(nodeKey:String)->EngagementRule{guardlet rulesOfEngagement = rulesOfEngagement else{return.None
}iflet rule =(rulesOfEngagement.filter{ $0.nodeKey == nodeKey }).first {return rule.rule
}else{return.None
}}
// TODO: #60 Add ability to paginate
}
// TODO: Add tests for these rules /// The `EngagementRule` enum defines how deep a JSON is to be parsed /**{ node:subnode:{node:subnode:...}
And change
Orderto