README.md in inbox-0.14.1 vs README.md in inbox-0.15.0
- old
+ new
@@ -41,11 +41,11 @@
Generally, you should store your App ID and Secret into environment variables to avoid adding them to source control. That said, in the example project and code snippets below, the values were added to `config/environments/development.rb` for convenience.
### Authentication
-The Nilas REST API uses server-side (three-legged) OAuth, and the Ruby gem provides convenience methods that simplify the OAuth process. For more information about authenticating with Nilas, visit the [Developer Documentation](https://www.nilas.com/docs/gettingstarted-hosted#authenticating).
+The Nilas REST API uses server-side (three-legged) OAuth, and the Ruby gem provides convenience methods that simplify the OAuth process. For more information about authenticating with Nilas, visit the [Developer Documentation](https://www.nilas.com/docs/knowledgebase#authentication).
**Step 1: Redirect the user to Nilas:**
```ruby
require 'inbox'
@@ -259,9 +259,53 @@
new_event.when = {:start_time => 1407542195, :end_time => 1407543195}
# Persist the event --- it's automatically synced back to the Google or Exchange calendar
new_event.save!
```
+
+## Using the Delta sync API
+
+The delta sync API allows fetching all the changes that occured since a specified time. [Read this](https://nilas.com/docs/api#sync-protocol) for more details about the API.
+
+````ruby
+# Get all the messages starting from timestamp
+#
+# we first need to get a cursor object a cursor is simply the id of
+# an individual change.
+cursor = inbox.namespaces.first.get_cursor(1407543195)
+
+last_cursor = nil
+inbox.namespaces.first.deltas(cursor) do |event, object|
+ if event == "create" or event == "modify"
+ if object.is_a?(Inbox::Contact)
+ puts "#{object.name} - #{object.email}"
+ elsif object.is_a?(Inbox::Event)
+ puts "Event!"
+ end
+ elsif event == "delete"
+ # In the case of a deletion, the API only returns the ID of the object.
+ # In this case, the Ruby SDK returns a dummy object with only the id field
+ # set.
+ puts "Deleting from collection #{object.class.name}, id: #{object}"
+ end
+ last_cursor = object.cursor
+end
+
+# Don't forget to save the last cursor so that we can pick up changes
+# from where we left.
+save_to_db(last_cursor)
+```
+
+### Exclude changes from a specific type --- get only messages
+inbox.namespaces.first.deltas(cursor, exclude=[Inbox::Contact,
+ Inbox::Event,
+ Inbox::File,
+ Inbox::Tag,
+ Inbox::Thread]) do |event, object|
+if event == 'create' or event == 'modify"
+ puts object.subject
+ end
+end
### Handling Errors
The Nilas API uses conventional HTTP response codes to indicate success or failure of an API request. The ruby gem raises these as native exceptions.
Code | Error Type | Description