{"action":"created","issue":{"url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/issues/319","repository_url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk","labels_url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/issues/319/labels{/name}","comments_url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/issues/319/comments","events_url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/issues/319/events","html_url":"https://github.com/watson-developer-cloud/ios-sdk/issues/319","id":159241238,"number":319,"title":"[alchemy-language] Weird structure of different document types as method parameters","user":{"login":"thomaspaulmann","id":12066405,"avatar_url":"https://avatars.githubusercontent.com/u/12066405?v=3","gravatar_id":"","url":"https://api.github.com/users/thomaspaulmann","html_url":"https://github.com/thomaspaulmann","followers_url":"https://api.github.com/users/thomaspaulmann/followers","following_url":"https://api.github.com/users/thomaspaulmann/following{/other_user}","gists_url":"https://api.github.com/users/thomaspaulmann/gists{/gist_id}","starred_url":"https://api.github.com/users/thomaspaulmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomaspaulmann/subscriptions","organizations_url":"https://api.github.com/users/thomaspaulmann/orgs","repos_url":"https://api.github.com/users/thomaspaulmann/repos","events_url":"https://api.github.com/users/thomaspaulmann/events{/privacy}","received_events_url":"https://api.github.com/users/thomaspaulmann/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-06-08T18:40:02Z","updated_at":"2016-06-09T08:31:43Z","closed_at":null,"body":"I've seen that the method parameters of the alchemy language are weird for different document types. Here is an example:\r\n\r\n```\r\npublic func getAuthorsHtml(\r\n  html: NSURL,\r\n  url: String? = nil,\r\n  failure: (NSError -> Void)? = nil,\r\n  success: DocumentAuthors -> Void) { }\r\n\r\npublic func getAuthorsURL(\r\n  url: String,\r\n  failure: (NSError -> Void)? = nil,\r\n  success: DocumentAuthors -> Void) { }\r\n```\r\nIs it supposed to be so? Especially that the paramter `url` is of the type `String`? I've dived a little bit into the code behind the scenes and it looks that it doesn't matter if it's `NSURL` or `String`.\r\nThis looks like an inconsistent API. Furthermore there are more inconsistency if you look to other methods like the API for emotion extraction:\r\n```\r\npublic func getEmotionURL(\r\n  url: NSURL,\r\n  failure: (NSError -> Void)? = nil,\r\n  success: DocumentEmotion -> Void) { }\r\n\r\npublic func getEmotionHtml(\r\n  html: String,\r\n  url: String? = nil,\r\n  failure: (NSError -> Void)? = nil,\r\n  success: DocumentEmotion -> Void) { }\r\n\r\npublic func getEmotionText(\r\n  text: String,\r\n  failure: (NSError -> Void)? = nil,\r\n  success: DocumentEmotion -> Void) { }\r\n```\r\nWhat about synchronising all this methods in a similar way. I would also make it a little _swiftier_. My suggestion would be something like this:\r\n```\r\npublic func getEmotion(\r\n  forUrl url: NSURL,\r\n  failure: (NSError -> Void)? = nil,\r\n  success: DocumentEmotion -> Void) { }\r\n\r\npublic func getEmotion(\r\n  forHtml html: String,\r\n  failure: (NSError -> Void)? = nil,\r\n  success: DocumentEmotion -> Void) { }\r\n\r\npublic func getEmotion(\r\n  forText text: String,\r\n  failure: (NSError -> Void)? = nil,\r\n  success: DocumentEmotion -> Void) { }\r\n```\r\nWhat do you think about the solution? Furthermore we can extend this to the whole Alchemy Language API. I guess this gives more transparency to the developer. \r\n\r\nI would love to help with the refactoring and would contribute it."},"comment":{"url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/issues/comments/224832196","html_url":"https://github.com/watson-developer-cloud/ios-sdk/issues/319#issuecomment-224832196","issue_url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/issues/319","id":224832196,"user":{"login":"thomaspaulmann","id":12066405,"avatar_url":"https://avatars.githubusercontent.com/u/12066405?v=3","gravatar_id":"","url":"https://api.github.com/users/thomaspaulmann","html_url":"https://github.com/thomaspaulmann","followers_url":"https://api.github.com/users/thomaspaulmann/followers","following_url":"https://api.github.com/users/thomaspaulmann/following{/other_user}","gists_url":"https://api.github.com/users/thomaspaulmann/gists{/gist_id}","starred_url":"https://api.github.com/users/thomaspaulmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomaspaulmann/subscriptions","organizations_url":"https://api.github.com/users/thomaspaulmann/orgs","repos_url":"https://api.github.com/users/thomaspaulmann/repos","events_url":"https://api.github.com/users/thomaspaulmann/events{/privacy}","received_events_url":"https://api.github.com/users/thomaspaulmann/received_events","type":"User","site_admin":false},"created_at":"2016-06-09T08:31:43Z","updated_at":"2016-06-09T08:31:43Z","body":"@Hsaylor Ok, now I see that you want to load a text document. What about a pure text from an input field? Probably that is also an use case. So maybe we should extend the functionality and add another method:\r\n```\r\npublic func getEmotion(\r\n  forText text: String,\r\n  failure: (NSError -> Void)? = nil,\r\n  success: DocumentEmotion -> Void) { }\r\n\r\npublic func getEmotion(\r\n  forTextDocument text: NSURL,\r\n  failure: (NSError -> Void)? = nil,\r\n  success: DocumentEmotion -> Void) { }\r\n```\r\nThis solution gives the developer the freedom of choice. If it's ok for you, I would integrate this as well."}}
{"actor":{"display_login":"thomaspaulmann"}}