inbox 0.17.3 → 0.17.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70c2c8822c460f75a72323535a4f9494410e5a1c
4
- data.tar.gz: 15a62798f4553d58b7c29cdd7b89957537a73d90
3
+ metadata.gz: b479b25409cbfee3adfba4c174e2619088a996cf
4
+ data.tar.gz: 3a5ee526204580120da8bd7ac82ccf2047193b7e
5
5
  SHA512:
6
- metadata.gz: 826daef856721dbcdcd7df25daa12d722cb0b5d334b4f3518cb95c6668c28ac7b20a231220a92308759d6a99e6fecd0a3f0cc6f45473ecf5d727e109b8742dd4
7
- data.tar.gz: 143b7591126fb7e68ab8f882b84be4261241ef123771c1f5eeacb6c580215b2b64b84b52953811f1e9459ebd6f73820d96ad3339b2f9860022c625d265088774
6
+ metadata.gz: 32511f5b1ad87c4e12445ac16f0b280a6ff7f33972450f7e9b7419382501c9a2804ccd337de4f2dc5796ef191105b4d3aef529354238488b73f41ed8e56343ad
7
+ data.tar.gz: 391330668237711328401b0b55a77baea4ae7eaeb9cee503a195202855dca28845af54ee96d7826ae47379011e539e9166a963c77939588702bf7194c2e4b32e
data/README.md CHANGED
@@ -173,24 +173,11 @@ thread.mark_as_read!
173
173
  # Archive
174
174
  thread.archive!
175
175
 
176
- # Add or remove arbitrary tags (DEPRECATED --- you should use the new labels and folders API)
176
+ # Add or remove arbitrary tags
177
177
  tagsToAdd = ['inbox', 'cfa1233ef123acd12']
178
178
  tagsToRemove = []
179
179
  thread.update_tags!(tagsToAdd, tagsToRemove)
180
180
 
181
- # Add a new label to a message
182
-
183
- important = nil
184
- ns.labels.each do |label|
185
- if label.display_name == 'Important'
186
- important = label
187
- end
188
- end
189
-
190
- thread = ns.threads.where(:from => "helena@nylas.com").first
191
- thread.labels.push(important)
192
- thread.save!
193
-
194
181
  # List messages
195
182
  thread.messages.each do |message|
196
183
  puts message.subject
@@ -211,37 +198,6 @@ file = namespace.files.build(:file => File.new("./public/favicon.ico", 'rb'))
211
198
  file.save!
212
199
  ```
213
200
 
214
- ### Working with Labels/Folder
215
-
216
- 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.
217
-
218
- ```ruby
219
-
220
- # List labels
221
- namespace.labels.each do |label|
222
- puts label.display_name, label.id
223
- end
224
-
225
- # Create a label
226
- label = ns.folders.build(:display_name => 'Test label', :name => 'test name')
227
- label.save!
228
-
229
- # Create a folder
230
- #
231
- # Note that Folders and Labels are absolutely identical from the standpoint of the SDK.
232
- # The only difference is that a message can have many labels but only a single folder.
233
- fld = ns.folders.build(:display_name => 'Test folder', :name => 'test name')
234
- fld.save!
235
-
236
- # Rename a folder
237
- #
238
- # Note that you can not rename folders like INBOX, Trash, etc.
239
- fld = ns.folders.first
240
- fld.display_name = 'Renamed folder'
241
- fld.save!
242
-
243
- ```
244
-
245
201
  ### Working with Messages, Contacts, etc.
246
202
 
247
203
  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:
data/lib/api_thread.rb CHANGED
@@ -11,31 +11,9 @@ module Inbox
11
11
  parameter :tags
12
12
  parameter :message_ids
13
13
  parameter :draft_ids
14
- parameter :labels
15
- parameter :folder
16
14
  time_attr_accessor :last_message_timestamp
17
15
  time_attr_accessor :first_message_timestamp
18
16
 
19
- def inflate(json)
20
- super
21
- @labels ||= []
22
- @folder ||= nil
23
-
24
- # This is a special case --- we receive label data from the API
25
- # as JSON but we want it to behave like an API object.
26
- @labels.map! do |label_json|
27
- label = Label.new(@_api)
28
- label.inflate(label_json)
29
- label
30
- end
31
-
32
- if not folder.nil?
33
- folder = folder.new(@_api)
34
- folder.inflate(@folder)
35
- @folder = folder
36
- end
37
- end
38
-
39
17
  def messages
40
18
  @messages ||= RestfulModelCollection.new(Message, @_api, @namespace_id, {:thread_id=>@id})
41
19
  end
@@ -74,22 +52,5 @@ module Inbox
74
52
  def unstar!
75
53
  update_tags!([], ['starred'])
76
54
  end
77
-
78
- def as_json(options = {})
79
- hash = {}
80
-
81
- if not @labels.nil? and @labels != []
82
- hash["labels"] = @labels.map do |label|
83
- label.id
84
- end
85
- end
86
-
87
- if not @folder.nil?
88
- hash["folder"] = @folder.id
89
- end
90
-
91
- hash
92
- end
93
-
94
55
  end
95
- end
56
+ end
data/lib/message.rb CHANGED
@@ -15,57 +15,12 @@ module Inbox
15
15
  parameter :thread_id
16
16
  parameter :body
17
17
  parameter :unread
18
- parameter :starred
19
- parameter :folder
20
- parameter :labels
21
18
 
22
19
  def inflate(json)
23
20
  super
24
21
  @to ||= []
25
22
  @cc ||= []
26
23
  @bcc ||= []
27
- @labels ||= []
28
- @folder ||= nil
29
-
30
- # This is a special case --- we receive label data from the API
31
- # as JSON but we want it to behave like an API object.
32
- @labels.map! do |label_json|
33
- label = Label.new(@_api)
34
- label.inflate(label_json)
35
- label
36
- end
37
-
38
- if not folder.nil?
39
- folder = folder.new(@_api)
40
- folder.inflate(@folder)
41
- @folder = folder
42
- end
43
- end
44
-
45
- def as_json(options = {})
46
- hash = {}
47
-
48
- # unread, starred and labels/folder are the only attribute
49
- # you can modify.
50
- if not @unread.nil?
51
- hash["unread"] = @unread
52
- end
53
-
54
- if not @starred.nil?
55
- hash["starred"] = @starred
56
- end
57
-
58
- if not @labels.nil? and @labels != []
59
- hash["labels"] = @labels.map do |label|
60
- label.id
61
- end
62
- end
63
-
64
- if not @folder.nil?
65
- hash["folder"] = @folder.id
66
- end
67
-
68
- hash
69
24
  end
70
25
 
71
26
  def files
data/lib/namespace.rb CHANGED
@@ -7,7 +7,6 @@ require 'contact'
7
7
  require 'file'
8
8
  require 'calendar'
9
9
  require 'event'
10
- require 'folder'
11
10
  require 'yajl'
12
11
  require 'em-http'
13
12
  require 'ostruct'
@@ -63,14 +62,6 @@ module Inbox
63
62
  @events ||= RestfulModelCollection.new(Event, @_api, @id)
64
63
  end
65
64
 
66
- def folders
67
- @folders ||= RestfulModelCollection.new(Folder, @_api, @id)
68
- end
69
-
70
- def labels
71
- @labels ||= RestfulModelCollection.new(Label, @_api, @id)
72
- end
73
-
74
65
  def get_cursor(timestamp)
75
66
  # Get the cursor corresponding to a specific timestamp.
76
67
  path = @_api.url_for_path("/n/#{@namespace_id}/delta/generate_cursor")
@@ -97,8 +88,6 @@ module Inbox
97
88
  "message" => Inbox::Message,
98
89
  "namespace" => Inbox::Namespace,
99
90
  "tag" => Inbox::Tag,
100
- "folder" => Inbox::Folder,
101
- "label" => Inbox::Label,
102
91
  }
103
92
 
104
93
  def _build_exclude_types(exclude_types)
@@ -136,6 +125,10 @@ module Inbox
136
125
  end_cursor = json["cursor_end"]
137
126
 
138
127
  json["deltas"].each do |delta|
128
+ if not OBJECTS_TABLE.has_key?(delta['object'])
129
+ next
130
+ end
131
+
139
132
  cls = OBJECTS_TABLE[delta['object']]
140
133
  obj = cls.new(@_api, @namespace_id)
141
134
 
@@ -172,6 +165,10 @@ module Inbox
172
165
  parser.on_parse_complete = proc do |data|
173
166
  delta = Inbox.interpret_response(OpenStruct.new(:code => '200'), data, {:expected_class => Object, :result_parsed => true})
174
167
 
168
+ if not OBJECTS_TABLE.has_key?(delta['object'])
169
+ next
170
+ end
171
+
175
172
  cls = OBJECTS_TABLE[delta['object']]
176
173
  obj = cls.new(@_api, @namespace_id)
177
174
 
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Inbox
2
- VERSION = "0.17.2"
2
+ VERSION = "0.17.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.3
4
+ version: 0.17.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Gotow