Merge pull request #13 from paulcastro/master

Issue #12, add URL used when verboseReplies is true
diff --git a/OpenWhisk/OpenWhiskSDK.swift b/OpenWhisk/OpenWhiskSDK.swift
index e37c6d8..9dd6449 100644
--- a/OpenWhisk/OpenWhiskSDK.swift
+++ b/OpenWhisk/OpenWhiskSDK.swift
@@ -45,7 +45,7 @@
 
 /* Error types for Whisk calls */
 public enum WhiskError: ErrorType {
-    case HTTPError(description: String, statusCode: Int) // something went wrong with the http call
+    case HTTPError(description: String, statusCode: Int, url: String) // something went wrong with the http call
     case JsonError(description: String) // json wasn't right
     case CredentialError(description: String) // something is wrong with the whisk credentials
     case QualifiedNameFormat(description: String) // something is wrong in qualified name
@@ -204,7 +204,7 @@
         
         // get base URL
         guard let actionURL = baseURL != nil ? baseURL : Config.getHostAndPath(type: typeStr) else {
-            callback(reply: nil, error: WhiskError.HTTPError(description: "Base URL not set, try using whisk.baseUrl setting", statusCode: 400))
+            callback(reply: nil, error: WhiskError.HTTPError(description: "Base URL not set, try using whisk.baseUrl setting", statusCode: 400, url: "Undefined"))
             return
         }
         
@@ -232,8 +232,11 @@
             syncName += "?blocking=true"
         }
         
+        // use this for verbose replies
+        let restCall = actionURL+syncName
+        
         guard let encodedPath = syncName.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet()) else {
-            callback(reply: nil, error: WhiskError.HTTPError(description: "URL Encode error \(syncName)", statusCode: 400))
+            callback(reply: nil, error: WhiskError.HTTPError(description: "URL Encode error \(syncName)", statusCode: 400, url: restCall))
             return
         }
         
@@ -243,7 +246,7 @@
         guard let url = NSURL(string:actionURL+syncName) else {
             // send back error on main queue
             
-            callback(reply: nil, error: WhiskError.HTTPError(description: "Malformed url \(actionURL+syncName)", statusCode: 400))
+            callback(reply: nil, error: WhiskError.HTTPError(description: "Malformed url", statusCode: 400, url: restCall))
             
             return
             
@@ -299,7 +302,7 @@
                 }
                 // return network transport error call on main queue
                 dispatch_async(dispatch_get_main_queue()) {
-                    callback(reply: nil, error: WhiskError.HTTPError(description: "\(error.localizedDescription)", statusCode: statusCode))
+                    callback(reply: nil, error: WhiskError.HTTPError(description: "\(error.localizedDescription)", statusCode: statusCode, url: restCall))
                 }
                 
                 return
@@ -338,6 +341,15 @@
                                     
                                     if self.verboseReplies == true {
                                         whiskReply = jsonDict
+                                        
+                                        // add the rest call made to verbose replies for debugging
+                                        switch type {
+                                        case .Action:
+                                            whiskReply["actionUrl"] = restCall
+                                        case .Trigger:
+                                            whiskReply["triggerUrl"] = restCall
+                                        }
+                                        
                                     } else {
                                         let reply = jsonDict
                                         whiskReply["activationId"] = reply["activationId"]
@@ -389,7 +401,7 @@
                             }
                         } else {
                             dispatch_async(dispatch_get_main_queue()) {
-                                callback(reply: nil, error: WhiskError.HTTPError(description: "Whisk returned HTTP error code", statusCode: statusCode))
+                                callback(reply: nil, error: WhiskError.HTTPError(description: "Whisk returned HTTP error code", statusCode: statusCode, url:restCall))
                             }
                         }
                         
diff --git a/README.md b/README.md
index 5514895..200c088 100644
--- a/README.md
+++ b/README.md
@@ -150,7 +150,7 @@
     print("Error \(error)")
 }
 ```
-By default, the SDK will only return the activationId and any result produced by the invoked action.  To get metadata of the entire response object, which includes the HTTP response status code, use this setting:
+By default, the SDK will only return the activationId and any result produced by the invoked action.  To get metadata of the entire response object, which includes the HTTP response status code and the REST API URL the SDK tried to call, use this setting:
 
 ```
 whisk.verboseReplies = true