README.md in inbox-0.17.4 vs README.md in inbox-0.18.0
- old
+ new
@@ -171,15 +171,28 @@
thread.mark_as_read!
# Archive
thread.archive!
-# Add or remove arbitrary tags
+# Add or remove arbitrary tags (DEPRECATED --- you should use the new labels and folders API)
tagsToAdd = ['inbox', 'cfa1233ef123acd12']
tagsToRemove = []
thread.update_tags!(tagsToAdd, tagsToRemove)
+# Add a new label to a message
+
+important = nil
+ns.labels.each do |label|
+ if label.display_name == 'Important'
+ important = label
+ end
+end
+
+thread = ns.threads.where(:from => "helena@nylas.com").first
+thread.labels.push(important)
+thread.save!
+
# List messages
thread.messages.each do |message|
puts message.subject
end
```
@@ -196,10 +209,41 @@
# Create a new file
file = namespace.files.build(:file => File.new("./public/favicon.ico", 'rb'))
file.save!
```
+### Working with Labels/Folder
+
+The new folders and labels API replaces the now deprecated Tags API. It allows you to apply Gmail labels to whole threads or individual messages and, for providers other than Gmail, to move threads and messages between folders.
+
+```ruby
+
+# List labels
+namespace.labels.each do |label|
+ puts label.display_name, label.id
+end
+
+# Create a label
+label = ns.folders.build(:display_name => 'Test label', :name => 'test name')
+label.save!
+
+# Create a folder
+#
+# Note that Folders and Labels are absolutely identical from the standpoint of the SDK.
+# The only difference is that a message can have many labels but only a single folder.
+fld = ns.folders.build(:display_name => 'Test folder', :name => 'test name')
+fld.save!
+
+# Rename a folder
+#
+# Note that you can not rename folders like INBOX, Trash, etc.
+fld = ns.folders.first
+fld.display_name = 'Renamed folder'
+fld.save!
+
+```
+
### Working with Messages, Contacts, etc.
Each of the primary collections (contacts, messages, etc.) behave the same way as `threads`. For example, finding messages with a filter is similar to finding threads:
```ruby
@@ -253,9 +297,16 @@
# Dates are expressed by the Inbox API as UTC timestamps
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!
+
+# Send an invite/update message to the participants
+new_event.save!(:notify_participants => true)
+
+# RSVP to an invite (Note: this only works for the events in the 'Emailed events' calendar)
+# possible statuses are 'yes', 'no' and 'maybe'.
+emailed_invite.rsvp!(status='yes', comment='I will come')
```
## Using the Delta sync API
The delta sync API allows fetching all the changes that occured since a specified time. [Read this](https://nylas.com/docs/api#sync-protocol) for more details about the API.