{"action":"created","comment":{"url":"https://api.github.com/repos/cloudant/swift-cloudant/pulls/comments/76037003","id":76037003,"diff_hunk":"@@ -0,0 +1,532 @@\n+//\n+//  ViewPaging.swift\n+//  SwiftCloudant\n+//\n+//  Created by Rhys Short on 01/08/2016.\n+//\n+//  Copyright (c) 2016 IBM Corp.\n+//\n+//  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file\n+//  except in compliance with the License. You may obtain a copy of the License at\n+//    http://www.apache.org/licenses/LICENSE-2.0\n+//  Unless required by applicable law or agreed to in writing, software distributed under the\n+//  License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n+//  either express or implied. See the License for the specific language governing permissions\n+//  and limitations under the License.\n+//\n+\n+\n+import Foundation\n+\n+public class ViewPage {\n+    \n+    public struct Token {\n+        \n+        fileprivate let state: ViewPage.State\n+        \n+        fileprivate let descending: Bool?\n+        fileprivate let startKey: Any?\n+        fileprivate let startKeyDocumentID:String?\n+        fileprivate let endKey: Any?\n+        fileprivate let endKeyDocumentID: String?\n+        fileprivate let inclusiveEnd:Bool?\n+        fileprivate let key:Any?\n+        fileprivate let keys:[Any]?\n+        fileprivate let includeDocs:Bool?\n+        fileprivate let conflicts:Bool?\n+        fileprivate let stale:Stale?\n+        fileprivate let includeLastUpdateSequenceNumber: Bool?\n+        \n+        fileprivate let name: String\n+        fileprivate let designDocumentID: String\n+        fileprivate let databaseName:String\n+        fileprivate let pageSize:UInt\n+        \n+        fileprivate let client: CouchDBClient\n+        \n+        public func seralised() throws -> String {\n+            \n+            var dict:[String: Any] = [\"name\": name,\n+                                            \"ddoc\": designDocumentID,\n+                                            \"db\": databaseName,\n+                                            \"page_size\": pageSize]\n+            \n+            \n+            if let descending = descending {\n+                dict[\"descending\"] = descending\n+            }\n+            if let startKey = startKey {\n+                dict[\"startkey\"] = startKey\n+            }\n+            \n+            if let startKeyDocumentID = startKeyDocumentID {\n+                dict[\"startkey_docid\"] = startKeyDocumentID\n+            }\n+            \n+            if let endKey = endKey {\n+                 dict[\"endkey\"] = endKey\n+            }\n+            \n+            if let endKeyDocumentID = endKeyDocumentID {\n+                dict[\"endkey_docid\"] = endKeyDocumentID\n+            }\n+            \n+            if let inclusiveEnd = inclusiveEnd {\n+                dict[\"inclusive_end\"] = inclusiveEnd\n+            }\n+            \n+            if let key = key {\n+                dict[\"key\"] = key\n+            }\n+            \n+            if let keys = keys {\n+                dict[\"keys\"] = keys\n+            }\n+            \n+            if let includeDocs = includeDocs {\n+                dict[\"include_docs\" ] = includeDocs\n+            }\n+            \n+            if let conflicts = conflicts {\n+                dict[\"conflicts\"] = conflicts\n+            }\n+            \n+            if let stale = stale {\n+                dict[\"stale\" ] = \"\\(stale)\"\n+            }\n+            \n+            if let includeLastUpdateSequenceNumber = includeLastUpdateSequenceNumber {\n+                dict[\"update_seq\"] = includeLastUpdateSequenceNumber\n+            }\n+            \n+            dict[\"state\"] = state.dictionary\n+\n+            \n+            let data = try JSONSerialization.data(withJSONObject: dict)\n+            if let token =  String(data: data, encoding: .utf8) {","path":"Source/ViewPaging.swift","position":null,"original_position":106,"commit_id":"3d2eda701a2c7b99991a89b3f807cdd7c15a6d6b","original_commit_id":"64a011942abc550c6236cb8cdb0d4794bd36ff3b","user":{"login":"rhyshort","id":1616727,"avatar_url":"https://avatars.githubusercontent.com/u/1616727?v=3","gravatar_id":"","url":"https://api.github.com/users/rhyshort","html_url":"https://github.com/rhyshort","followers_url":"https://api.github.com/users/rhyshort/followers","following_url":"https://api.github.com/users/rhyshort/following{/other_user}","gists_url":"https://api.github.com/users/rhyshort/gists{/gist_id}","starred_url":"https://api.github.com/users/rhyshort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhyshort/subscriptions","organizations_url":"https://api.github.com/users/rhyshort/orgs","repos_url":"https://api.github.com/users/rhyshort/repos","events_url":"https://api.github.com/users/rhyshort/events{/privacy}","received_events_url":"https://api.github.com/users/rhyshort/received_events","type":"User","site_admin":false},"body":"Done, from 3d2eda7 token strings are now Base64 encoded.","created_at":"2016-08-24T11:06:33Z","updated_at":"2016-08-24T11:06:33Z","html_url":"https://github.com/cloudant/swift-cloudant/pull/118#discussion_r76037003","pull_request_url":"https://api.github.com/repos/cloudant/swift-cloudant/pulls/118","_links":{"self":{"href":"https://api.github.com/repos/cloudant/swift-cloudant/pulls/comments/76037003"},"html":{"href":"https://github.com/cloudant/swift-cloudant/pull/118#discussion_r76037003"},"pull_request":{"href":"https://api.github.com/repos/cloudant/swift-cloudant/pulls/118"}}},"pull_request":{"url":"https://api.github.com/repos/cloudant/swift-cloudant/pulls/118","id":82168189,"html_url":"https://github.com/cloudant/swift-cloudant/pull/118","diff_url":"https://github.com/cloudant/swift-cloudant/pull/118.diff","patch_url":"https://github.com/cloudant/swift-cloudant/pull/118.patch","issue_url":"https://api.github.com/repos/cloudant/swift-cloudant/issues/118","number":118,"state":"open","locked":false,"title":"Add the ability to page through views","user":{"login":"rhyshort","id":1616727,"avatar_url":"https://avatars.githubusercontent.com/u/1616727?v=3","gravatar_id":"","url":"https://api.github.com/users/rhyshort","html_url":"https://github.com/rhyshort","followers_url":"https://api.github.com/users/rhyshort/followers","following_url":"https://api.github.com/users/rhyshort/following{/other_user}","gists_url":"https://api.github.com/users/rhyshort/gists{/gist_id}","starred_url":"https://api.github.com/users/rhyshort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhyshort/subscriptions","organizations_url":"https://api.github.com/users/rhyshort/orgs","repos_url":"https://api.github.com/users/rhyshort/repos","events_url":"https://api.github.com/users/rhyshort/events{/privacy}","received_events_url":"https://api.github.com/users/rhyshort/received_events","type":"User","site_admin":false},"body":"## What\r\n\r\nAdded support to page through views.\r\n\r\n## How\r\n\r\nCreated a new class `ViewPage` which handles the requests to correctly page, this can either be one page after another using the block, or later using the token.\r\n\r\n## Testing\r\n\r\nAdded new tests to ViewPageTests.\r\n\r\n## Issues\r\n\r\nResolves #62\r\n\r\n\r\n## Notes\r\nThere isn't any API doc yet, I want to get some feedback on the API etc before documenting it.","created_at":"2016-08-22T10:36:05Z","updated_at":"2016-08-24T11:06:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"57fb80a74a30cba5efd8eb961463798689c535aa","assignee":{"login":"ricellis","id":10698320,"avatar_url":"https://avatars.githubusercontent.com/u/10698320?v=3","gravatar_id":"","url":"https://api.github.com/users/ricellis","html_url":"https://github.com/ricellis","followers_url":"https://api.github.com/users/ricellis/followers","following_url":"https://api.github.com/users/ricellis/following{/other_user}","gists_url":"https://api.github.com/users/ricellis/gists{/gist_id}","starred_url":"https://api.github.com/users/ricellis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ricellis/subscriptions","organizations_url":"https://api.github.com/users/ricellis/orgs","repos_url":"https://api.github.com/users/ricellis/repos","events_url":"https://api.github.com/users/ricellis/events{/privacy}","received_events_url":"https://api.github.com/users/ricellis/received_events","type":"User","site_admin":false},"assignees":[{"login":"ricellis","id":10698320,"avatar_url":"https://avatars.githubusercontent.com/u/10698320?v=3","gravatar_id":"","url":"https://api.github.com/users/ricellis","html_url":"https://github.com/ricellis","followers_url":"https://api.github.com/users/ricellis/followers","following_url":"https://api.github.com/users/ricellis/following{/other_user}","gists_url":"https://api.github.com/users/ricellis/gists{/gist_id}","starred_url":"https://api.github.com/users/ricellis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ricellis/subscriptions","organizations_url":"https://api.github.com/users/ricellis/orgs","repos_url":"https://api.github.com/users/ricellis/repos","events_url":"https://api.github.com/users/ricellis/events{/privacy}","received_events_url":"https://api.github.com/users/ricellis/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/cloudant/swift-cloudant/pulls/118/commits","review_comments_url":"https://api.github.com/repos/cloudant/swift-cloudant/pulls/118/comments","review_comment_url":"https://api.github.com/repos/cloudant/swift-cloudant/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudant/swift-cloudant/issues/118/comments","statuses_url":"https://api.github.com/repos/cloudant/swift-cloudant/statuses/3d2eda701a2c7b99991a89b3f807cdd7c15a6d6b","head":{"label":"cloudant:view-paging","ref":"view-paging","sha":"3d2eda701a2c7b99991a89b3f807cdd7c15a6d6b","user":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"repo":{"id":55980905,"name":"swift-cloudant","full_name":"cloudant/swift-cloudant","owner":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudant/swift-cloudant","description":"A Swift Lang client for Cloudant and CouchDB","fork":false,"url":"https://api.github.com/repos/cloudant/swift-cloudant","forks_url":"https://api.github.com/repos/cloudant/swift-cloudant/forks","keys_url":"https://api.github.com/repos/cloudant/swift-cloudant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudant/swift-cloudant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudant/swift-cloudant/teams","hooks_url":"https://api.github.com/repos/cloudant/swift-cloudant/hooks","issue_events_url":"https://api.github.com/repos/cloudant/swift-cloudant/issues/events{/number}","events_url":"https://api.github.com/repos/cloudant/swift-cloudant/events","assignees_url":"https://api.github.com/repos/cloudant/swift-cloudant/assignees{/user}","branches_url":"https://api.github.com/repos/cloudant/swift-cloudant/branches{/branch}","tags_url":"https://api.github.com/repos/cloudant/swift-cloudant/tags","blobs_url":"https://api.github.com/repos/cloudant/swift-cloudant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudant/swift-cloudant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudant/swift-cloudant/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudant/swift-cloudant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudant/swift-cloudant/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudant/swift-cloudant/languages","stargazers_url":"https://api.github.com/repos/cloudant/swift-cloudant/stargazers","contributors_url":"https://api.github.com/repos/cloudant/swift-cloudant/contributors","subscribers_url":"https://api.github.com/repos/cloudant/swift-cloudant/subscribers","subscription_url":"https://api.github.com/repos/cloudant/swift-cloudant/subscription","commits_url":"https://api.github.com/repos/cloudant/swift-cloudant/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudant/swift-cloudant/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudant/swift-cloudant/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudant/swift-cloudant/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudant/swift-cloudant/contents/{+path}","compare_url":"https://api.github.com/repos/cloudant/swift-cloudant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudant/swift-cloudant/merges","archive_url":"https://api.github.com/repos/cloudant/swift-cloudant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudant/swift-cloudant/downloads","issues_url":"https://api.github.com/repos/cloudant/swift-cloudant/issues{/number}","pulls_url":"https://api.github.com/repos/cloudant/swift-cloudant/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudant/swift-cloudant/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudant/swift-cloudant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudant/swift-cloudant/labels{/name}","releases_url":"https://api.github.com/repos/cloudant/swift-cloudant/releases{/id}","deployments_url":"https://api.github.com/repos/cloudant/swift-cloudant/deployments","created_at":"2016-04-11T14:47:54Z","updated_at":"2016-08-02T07:49:36Z","pushed_at":"2016-08-24T11:05:29Z","git_url":"git://github.com/cloudant/swift-cloudant.git","ssh_url":"git@github.com:cloudant/swift-cloudant.git","clone_url":"https://github.com/cloudant/swift-cloudant.git","svn_url":"https://github.com/cloudant/swift-cloudant","homepage":null,"size":562,"stargazers_count":7,"watchers_count":7,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":19,"forks":3,"open_issues":19,"watchers":7,"default_branch":"master"}},"base":{"label":"cloudant:master","ref":"master","sha":"f5cfd4eb6886183b288c52bd44964c7fd4ef87de","user":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"repo":{"id":55980905,"name":"swift-cloudant","full_name":"cloudant/swift-cloudant","owner":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudant/swift-cloudant","description":"A Swift Lang client for Cloudant and CouchDB","fork":false,"url":"https://api.github.com/repos/cloudant/swift-cloudant","forks_url":"https://api.github.com/repos/cloudant/swift-cloudant/forks","keys_url":"https://api.github.com/repos/cloudant/swift-cloudant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudant/swift-cloudant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudant/swift-cloudant/teams","hooks_url":"https://api.github.com/repos/cloudant/swift-cloudant/hooks","issue_events_url":"https://api.github.com/repos/cloudant/swift-cloudant/issues/events{/number}","events_url":"https://api.github.com/repos/cloudant/swift-cloudant/events","assignees_url":"https://api.github.com/repos/cloudant/swift-cloudant/assignees{/user}","branches_url":"https://api.github.com/repos/cloudant/swift-cloudant/branches{/branch}","tags_url":"https://api.github.com/repos/cloudant/swift-cloudant/tags","blobs_url":"https://api.github.com/repos/cloudant/swift-cloudant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudant/swift-cloudant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudant/swift-cloudant/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudant/swift-cloudant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudant/swift-cloudant/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudant/swift-cloudant/languages","stargazers_url":"https://api.github.com/repos/cloudant/swift-cloudant/stargazers","contributors_url":"https://api.github.com/repos/cloudant/swift-cloudant/contributors","subscribers_url":"https://api.github.com/repos/cloudant/swift-cloudant/subscribers","subscription_url":"https://api.github.com/repos/cloudant/swift-cloudant/subscription","commits_url":"https://api.github.com/repos/cloudant/swift-cloudant/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudant/swift-cloudant/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudant/swift-cloudant/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudant/swift-cloudant/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudant/swift-cloudant/contents/{+path}","compare_url":"https://api.github.com/repos/cloudant/swift-cloudant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudant/swift-cloudant/merges","archive_url":"https://api.github.com/repos/cloudant/swift-cloudant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudant/swift-cloudant/downloads","issues_url":"https://api.github.com/repos/cloudant/swift-cloudant/issues{/number}","pulls_url":"https://api.github.com/repos/cloudant/swift-cloudant/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudant/swift-cloudant/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudant/swift-cloudant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudant/swift-cloudant/labels{/name}","releases_url":"https://api.github.com/repos/cloudant/swift-cloudant/releases{/id}","deployments_url":"https://api.github.com/repos/cloudant/swift-cloudant/deployments","created_at":"2016-04-11T14:47:54Z","updated_at":"2016-08-02T07:49:36Z","pushed_at":"2016-08-24T11:05:29Z","git_url":"git://github.com/cloudant/swift-cloudant.git","ssh_url":"git@github.com:cloudant/swift-cloudant.git","clone_url":"https://github.com/cloudant/swift-cloudant.git","svn_url":"https://github.com/cloudant/swift-cloudant","homepage":null,"size":562,"stargazers_count":7,"watchers_count":7,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":19,"forks":3,"open_issues":19,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudant/swift-cloudant/pulls/118"},"html":{"href":"https://github.com/cloudant/swift-cloudant/pull/118"},"issue":{"href":"https://api.github.com/repos/cloudant/swift-cloudant/issues/118"},"comments":{"href":"https://api.github.com/repos/cloudant/swift-cloudant/issues/118/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudant/swift-cloudant/pulls/118/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudant/swift-cloudant/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudant/swift-cloudant/pulls/118/commits"},"statuses":{"href":"https://api.github.com/repos/cloudant/swift-cloudant/statuses/3d2eda701a2c7b99991a89b3f807cdd7c15a6d6b"}}}}
{"actor":{"display_login":"rhyshort"}}