{"action":"created","comment":{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/comments/50567346","id":50567346,"diff_hunk":"@@ -0,0 +1,70 @@\n+import CoreData\n+import WordPressComAnalytics\n+\n+public extension Blog\n+{\n+    /// Only WordPress.com hosted sites we administer may be deleted\n+    func supportsDeleteSiteServices() -> Bool {\n+        return isHostedAtWPcom && isAdmin\n+    }\n+}\n+\n+/// DeleteSiteService handles deletion of a user's site.\n+\n+public class DeleteSiteService : LocalCoreDataService\n+{\n+    /**\n+     Deletes the WordPress.com site for the specified Blog.\n+     \n+     - parameter blog:    The Blog whose site to delete\n+     - parameter success: Optional success block with no parameters\n+     - parameter failure: Optional failure block with NSError parameter\n+     */\n+    public func deleteSiteForBlog(blog: Blog, success: (() -> ())?, failure: (NSError -> ())?) {\n+        let blogObjectID = blog.objectID\n+        let remote = deleteSiteServiceRemoteForBlog(blog)\n+        remote.deleteSite(blog.dotComID,\n+            success: {\n+                self.removeBlogWithObjectID(blogObjectID, success: success)\n+            },\n+            failure: { error in\n+                failure?(error)\n+            })\n+    }\n+    \n+    /**\n+     Removes Blog with the specified ID from Core Data.\n+     \n+     - parameter objectID: Core Data ID of the Blog to remove\n+     - parameter success:  Optional success block with no parameters\n+     */\n+    public func removeBlogWithObjectID(objectID: NSManagedObjectID, success: (() -> ())?) {","path":"WordPress/Classes/Services/DeleteSiteService.swift","position":41,"original_position":41,"commit_id":"faaa92a32c972332c699c39432a205ad1a5b90c7","original_commit_id":"faaa92a32c972332c699c39432a205ad1a5b90c7","user":{"login":"alexcurylo","id":872697,"avatar_url":"https://avatars.githubusercontent.com/u/872697?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcurylo","html_url":"https://github.com/alexcurylo","followers_url":"https://api.github.com/users/alexcurylo/followers","following_url":"https://api.github.com/users/alexcurylo/following{/other_user}","gists_url":"https://api.github.com/users/alexcurylo/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcurylo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcurylo/subscriptions","organizations_url":"https://api.github.com/users/alexcurylo/orgs","repos_url":"https://api.github.com/users/alexcurylo/repos","events_url":"https://api.github.com/users/alexcurylo/events{/privacy}","received_events_url":"https://api.github.com/users/alexcurylo/received_events","type":"User","site_admin":false},"body":"Supporting the 'Remove Site' functionality from here instead of BlogService seems natural to me.","created_at":"2016-01-22T17:48:02Z","updated_at":"2016-01-22T17:48:02Z","html_url":"https://github.com/wordpress-mobile/WordPress-iOS/pull/4723#discussion_r50567346","pull_request_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/4723","_links":{"self":{"href":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/comments/50567346"},"html":{"href":"https://github.com/wordpress-mobile/WordPress-iOS/pull/4723#discussion_r50567346"},"pull_request":{"href":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/4723"}}},"pull_request":{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/4723","id":56827906,"html_url":"https://github.com/wordpress-mobile/WordPress-iOS/pull/4723","diff_url":"https://github.com/wordpress-mobile/WordPress-iOS/pull/4723.diff","patch_url":"https://github.com/wordpress-mobile/WordPress-iOS/pull/4723.patch","issue_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/4723","number":4723,"state":"open","locked":false,"title":"Delete Site service layer","user":{"login":"alexcurylo","id":872697,"avatar_url":"https://avatars.githubusercontent.com/u/872697?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcurylo","html_url":"https://github.com/alexcurylo","followers_url":"https://api.github.com/users/alexcurylo/followers","following_url":"https://api.github.com/users/alexcurylo/following{/other_user}","gists_url":"https://api.github.com/users/alexcurylo/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcurylo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcurylo/subscriptions","organizations_url":"https://api.github.com/users/alexcurylo/orgs","repos_url":"https://api.github.com/users/alexcurylo/repos","events_url":"https://api.github.com/users/alexcurylo/events{/privacy}","received_events_url":"https://api.github.com/users/alexcurylo/received_events","type":"User","site_admin":false},"body":"Adds a Delete Site service layer with methods for deleting a site from WordPress.com and cleanly removing it from Core Data.\r\n\r\n**Test:** Ensure unit tests in DeleteSiteServiceTests and DeleteSiteServiceRemoteTests succeed. Settings UI for live testing will follow as #4570 tasks are punched.\r\n\r\nNeeds Review: @aerych ","created_at":"2016-01-21T23:51:18Z","updated_at":"2016-01-22T17:48:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2b567f620876b4c85549c75375e8fdc798462b61","assignee":null,"milestone":{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/milestones/51","html_url":"https://github.com/wordpress-mobile/WordPress-iOS/milestones/6.0","labels_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/milestones/51/labels","id":1465750,"number":51,"title":"6.0","description":null,"creator":{"login":"jleandroperez","id":1195260,"avatar_url":"https://avatars.githubusercontent.com/u/1195260?v=3","gravatar_id":"","url":"https://api.github.com/users/jleandroperez","html_url":"https://github.com/jleandroperez","followers_url":"https://api.github.com/users/jleandroperez/followers","following_url":"https://api.github.com/users/jleandroperez/following{/other_user}","gists_url":"https://api.github.com/users/jleandroperez/gists{/gist_id}","starred_url":"https://api.github.com/users/jleandroperez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jleandroperez/subscriptions","organizations_url":"https://api.github.com/users/jleandroperez/orgs","repos_url":"https://api.github.com/users/jleandroperez/repos","events_url":"https://api.github.com/users/jleandroperez/events{/privacy}","received_events_url":"https://api.github.com/users/jleandroperez/received_events","type":"User","site_admin":false},"open_issues":18,"closed_issues":79,"state":"open","created_at":"2015-12-17T21:05:13Z","updated_at":"2016-01-22T16:33:09Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/4723/commits","review_comments_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/4723/comments","review_comment_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/4723/comments","statuses_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/statuses/faaa92a32c972332c699c39432a205ad1a5b90c7","head":{"label":"wordpress-mobile:feature/4570-delete-site-service-layer","ref":"feature/4570-delete-site-service-layer","sha":"faaa92a32c972332c699c39432a205ad1a5b90c7","user":{"login":"wordpress-mobile","id":1306301,"avatar_url":"https://avatars.githubusercontent.com/u/1306301?v=3","gravatar_id":"","url":"https://api.github.com/users/wordpress-mobile","html_url":"https://github.com/wordpress-mobile","followers_url":"https://api.github.com/users/wordpress-mobile/followers","following_url":"https://api.github.com/users/wordpress-mobile/following{/other_user}","gists_url":"https://api.github.com/users/wordpress-mobile/gists{/gist_id}","starred_url":"https://api.github.com/users/wordpress-mobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wordpress-mobile/subscriptions","organizations_url":"https://api.github.com/users/wordpress-mobile/orgs","repos_url":"https://api.github.com/users/wordpress-mobile/repos","events_url":"https://api.github.com/users/wordpress-mobile/events{/privacy}","received_events_url":"https://api.github.com/users/wordpress-mobile/received_events","type":"Organization","site_admin":false},"repo":{"id":8859285,"name":"WordPress-iOS","full_name":"wordpress-mobile/WordPress-iOS","owner":{"login":"wordpress-mobile","id":1306301,"avatar_url":"https://avatars.githubusercontent.com/u/1306301?v=3","gravatar_id":"","url":"https://api.github.com/users/wordpress-mobile","html_url":"https://github.com/wordpress-mobile","followers_url":"https://api.github.com/users/wordpress-mobile/followers","following_url":"https://api.github.com/users/wordpress-mobile/following{/other_user}","gists_url":"https://api.github.com/users/wordpress-mobile/gists{/gist_id}","starred_url":"https://api.github.com/users/wordpress-mobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wordpress-mobile/subscriptions","organizations_url":"https://api.github.com/users/wordpress-mobile/orgs","repos_url":"https://api.github.com/users/wordpress-mobile/repos","events_url":"https://api.github.com/users/wordpress-mobile/events{/privacy}","received_events_url":"https://api.github.com/users/wordpress-mobile/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wordpress-mobile/WordPress-iOS","description":"WordPress for iOS - Official repository","fork":false,"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS","forks_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/forks","keys_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/teams","hooks_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/hooks","issue_events_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/events{/number}","events_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/events","assignees_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/assignees{/user}","branches_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/branches{/branch}","tags_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/tags","blobs_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/git/refs{/sha}","trees_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/statuses/{sha}","languages_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/languages","stargazers_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/stargazers","contributors_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/contributors","subscribers_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/subscribers","subscription_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/subscription","commits_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/commits{/sha}","git_commits_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/git/commits{/sha}","comments_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/comments{/number}","issue_comment_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/comments{/number}","contents_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/contents/{+path}","compare_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/merges","archive_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/downloads","issues_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues{/number}","pulls_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls{/number}","milestones_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/milestones{/number}","notifications_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/labels{/name}","releases_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/releases{/id}","deployments_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/deployments","created_at":"2013-03-18T16:59:33Z","updated_at":"2016-01-22T11:29:02Z","pushed_at":"2016-01-22T17:43:37Z","git_url":"git://github.com/wordpress-mobile/WordPress-iOS.git","ssh_url":"git@github.com:wordpress-mobile/WordPress-iOS.git","clone_url":"https://github.com/wordpress-mobile/WordPress-iOS.git","svn_url":"https://github.com/wordpress-mobile/WordPress-iOS","homepage":"http://ios.wordpress.org/","size":286390,"stargazers_count":842,"watchers_count":842,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":400,"mirror_url":null,"open_issues_count":335,"forks":400,"open_issues":335,"watchers":842,"default_branch":"develop"}},"base":{"label":"wordpress-mobile:develop","ref":"develop","sha":"dcda6881ea4c1c9468ee95088166766e5a0bf9bf","user":{"login":"wordpress-mobile","id":1306301,"avatar_url":"https://avatars.githubusercontent.com/u/1306301?v=3","gravatar_id":"","url":"https://api.github.com/users/wordpress-mobile","html_url":"https://github.com/wordpress-mobile","followers_url":"https://api.github.com/users/wordpress-mobile/followers","following_url":"https://api.github.com/users/wordpress-mobile/following{/other_user}","gists_url":"https://api.github.com/users/wordpress-mobile/gists{/gist_id}","starred_url":"https://api.github.com/users/wordpress-mobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wordpress-mobile/subscriptions","organizations_url":"https://api.github.com/users/wordpress-mobile/orgs","repos_url":"https://api.github.com/users/wordpress-mobile/repos","events_url":"https://api.github.com/users/wordpress-mobile/events{/privacy}","received_events_url":"https://api.github.com/users/wordpress-mobile/received_events","type":"Organization","site_admin":false},"repo":{"id":8859285,"name":"WordPress-iOS","full_name":"wordpress-mobile/WordPress-iOS","owner":{"login":"wordpress-mobile","id":1306301,"avatar_url":"https://avatars.githubusercontent.com/u/1306301?v=3","gravatar_id":"","url":"https://api.github.com/users/wordpress-mobile","html_url":"https://github.com/wordpress-mobile","followers_url":"https://api.github.com/users/wordpress-mobile/followers","following_url":"https://api.github.com/users/wordpress-mobile/following{/other_user}","gists_url":"https://api.github.com/users/wordpress-mobile/gists{/gist_id}","starred_url":"https://api.github.com/users/wordpress-mobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wordpress-mobile/subscriptions","organizations_url":"https://api.github.com/users/wordpress-mobile/orgs","repos_url":"https://api.github.com/users/wordpress-mobile/repos","events_url":"https://api.github.com/users/wordpress-mobile/events{/privacy}","received_events_url":"https://api.github.com/users/wordpress-mobile/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wordpress-mobile/WordPress-iOS","description":"WordPress for iOS - Official repository","fork":false,"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS","forks_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/forks","keys_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/teams","hooks_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/hooks","issue_events_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/events{/number}","events_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/events","assignees_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/assignees{/user}","branches_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/branches{/branch}","tags_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/tags","blobs_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/git/refs{/sha}","trees_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/statuses/{sha}","languages_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/languages","stargazers_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/stargazers","contributors_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/contributors","subscribers_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/subscribers","subscription_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/subscription","commits_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/commits{/sha}","git_commits_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/git/commits{/sha}","comments_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/comments{/number}","issue_comment_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/comments{/number}","contents_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/contents/{+path}","compare_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/merges","archive_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/downloads","issues_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues{/number}","pulls_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls{/number}","milestones_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/milestones{/number}","notifications_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/labels{/name}","releases_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/releases{/id}","deployments_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/deployments","created_at":"2013-03-18T16:59:33Z","updated_at":"2016-01-22T11:29:02Z","pushed_at":"2016-01-22T17:43:37Z","git_url":"git://github.com/wordpress-mobile/WordPress-iOS.git","ssh_url":"git@github.com:wordpress-mobile/WordPress-iOS.git","clone_url":"https://github.com/wordpress-mobile/WordPress-iOS.git","svn_url":"https://github.com/wordpress-mobile/WordPress-iOS","homepage":"http://ios.wordpress.org/","size":286390,"stargazers_count":842,"watchers_count":842,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":400,"mirror_url":null,"open_issues_count":335,"forks":400,"open_issues":335,"watchers":842,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/4723"},"html":{"href":"https://github.com/wordpress-mobile/WordPress-iOS/pull/4723"},"issue":{"href":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/4723"},"comments":{"href":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/4723/comments"},"review_comments":{"href":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/4723/comments"},"review_comment":{"href":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/4723/commits"},"statuses":{"href":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/statuses/faaa92a32c972332c699c39432a205ad1a5b90c7"}}}}