 
 /// Defines stub response for a matching API path
 public struct ServiceStub {
+    /// A stubbed request
     public let request:ServiceStubRequest
+    
+    /// The type of stubbing we want to do, either a success or a failure
     public let stubType:ServiceStubType
+    
+    /// The behavior for this stub, if we want the request to come back sync or async
     public let stubBehavior:ServiceStubBehavior
+    
+    /// The type of case we want when the request gets executed, either authenticated with a token or unauthenticated
     public let stubCase:ServiceStubCase
     
     public init(execute request:ServiceStubRequest,
                 with type:ServiceStubType,
-                when stubCase:ServiceStubCase = .unauthenticated,
-                react behavior:ServiceStubBehavior = .immediate)
+                when stubCase:ServiceStubCase,
+                react behavior:ServiceStubBehavior)
     {
         self.request = request
         self.stubType = type

    case delayed(seconds: TimeInterval)
}

/// Used for stubbing responses.
public enum ServiceStubType {
    
    /// The network returned a response, including status code and response.
    case success(code:Int, response:[String:Any]?)

        self.stubCase = stubCase
    }
}

extension JSONSerialization
{
    
    /// Builds a JSON Dictionary from a bundled json file
    ///
    /// - Parameter fileName: the name of the json file
    /// - Returns: returns a JSON dictionary
    public class func JSONObjectWithFileName(fileName:String) -> [String:Any]?
    {
        if let path = Bundle.currentTestBundle?.path(forResource: fileName, ofType: "json"),
            let jsonData = NSData(contentsOfFile: path),
            let jsonResult = try! JSONSerialization.jsonObject(with: jsonData as Data, options: ReadingOptions.mutableContainers) as? [String:Any]
        {
            return jsonResult
        }
        return nil
    }
}

extension Bundle {
    
    /// Locates the first bundle with a '.xctest' file extension.
    internal static var currentTestBundle: Bundle? {
        return allBundles.first { $0.bundlePath.hasSuffix(".xctest") }
    }
    
}
