nylas 2.0.0 → 2.0.1

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: 1b60f55a392bfe4d0f3c6e0ecc37e783752add29
4
- data.tar.gz: 1a6af142d7458455dd49ed9c45e3f3b18d93cb59
3
+ metadata.gz: ccf84356618303aac11fbe3a42e849cf12c39523
4
+ data.tar.gz: 61186e74226ef63f22a636cad9ada12ef9ba15ee
5
5
  SHA512:
6
- metadata.gz: a0ed44667ecb4975213ceb7fa746d821d0e5cc01752fce9b1e7dde670559fec3c001b52a34fc20bf92f208a2fb32644107494c8866f8a24003f42d7f57e165f4
7
- data.tar.gz: 8e4d7ef85607a1f9011017198ff5c1e65bb52abf1be5cf98f9caddb542df5685f5e1391cf542f4fd104172804e77153d456a8b79bcfa12757c6c8063bd87e608
6
+ metadata.gz: 0bd236ce1d002c37a428e68e5268c1e006bd5ec598b242f4d3f032acef6e04564b829f52cd60efa988b3af35d0fbb3e0eca27a674e5964db31f7c6ddbc56b1bc
7
+ data.tar.gz: 2fb547cd6fe80d29b14af51164e95755934214ff1a53d2f916673db10e9a08b4f4ad0804f98f21d1b9c2fea8f15bfc02e375c0f2cf9f59eed26e06e7de346a91
data/lib/api_thread.rb CHANGED
@@ -34,7 +34,7 @@ module Inbox
34
34
  label
35
35
  end
36
36
 
37
- if not folder.nil?
37
+ if not folder.nil? and folder.is_a?(Hash)
38
38
  folder = Folder.new(@_api)
39
39
  folder.inflate(@folder)
40
40
  @folder = folder
@@ -52,14 +52,22 @@ module Inbox
52
52
  def as_json(options = {})
53
53
  hash = {}
54
54
 
55
+ if not @unread.nil?
56
+ hash["unread"] = @unread
57
+ end
58
+
59
+ if not @starred.nil?
60
+ hash["starred"] = @starred
61
+ end
62
+
55
63
  if not @labels.nil? and @labels != []
56
- hash["labels"] = @labels.map do |label|
64
+ hash["label_ids"] = @labels.map do |label|
57
65
  label.id
58
66
  end
59
67
  end
60
68
 
61
69
  if not @folder.nil?
62
- hash["folder"] = @folder.id
70
+ hash["folder_id"] = @folder.id
63
71
  end
64
72
 
65
73
  hash
data/lib/message.rb CHANGED
@@ -38,7 +38,7 @@ module Inbox
38
38
  label
39
39
  end
40
40
 
41
- if not folder.nil?
41
+ if not folder.nil? and folder.is_a?(Hash)
42
42
  folder = Folder.new(@_api)
43
43
  folder.inflate(@folder)
44
44
  @folder = folder
@@ -59,13 +59,13 @@ module Inbox
59
59
  end
60
60
 
61
61
  if not @labels.nil? and @labels != []
62
- hash["labels"] = @labels.map do |label|
62
+ hash["label_ids"] = @labels.map do |label|
63
63
  label.id
64
64
  end
65
65
  end
66
66
 
67
67
  if not @folder.nil?
68
- hash["folder"] = @folder.id
68
+ hash["folder_id"] = @folder.id
69
69
  end
70
70
 
71
71
  hash
@@ -15,17 +15,16 @@ module Inbox
15
15
  def each
16
16
  return enum_for(:each) unless block_given?
17
17
 
18
- @filters[:offset] = 0 unless @filters.key?(:offset)
19
- @filters[:limit] = 100 unless @filters.key?(:limit)
20
-
18
+ offset = 0
19
+ chunk_size = 100
21
20
  finished = false
22
21
  while (!finished) do
23
- results = get_model_collection()
22
+ results = get_model_collection(offset, chunk_size)
24
23
  results.each { |item|
25
24
  yield item
26
25
  }
27
- @filters[:offset] += results.length
28
- finished = results.length < @filters[:limit]
26
+ offset += results.length
27
+ finished = results.length < chunk_size
29
28
  end
30
29
  end
31
30
 
@@ -65,17 +64,12 @@ module Inbox
65
64
  finished = false
66
65
  chunk_size = 100
67
66
 
68
- while (!finished && accumulated.length < limit) do
69
- @filters[:offset] = offset + accumulated.length
70
-
71
- # if the total items we want, minus how many we already have, is fewer than we plan to grab...
72
- remaining = limit - accumulated.length
73
- if remaining < chunk_size
74
- chunk_size = remaining
75
- end
76
- @filters[:limit] = chunk_size
67
+ if limit < chunk_size
68
+ chunk_size = limit
69
+ end
77
70
 
78
- results = get_model_collection()
71
+ while (!finished && accumulated.length < limit) do
72
+ results = get_model_collection(offset + accumulated.length, chunk_size)
79
73
  accumulated = accumulated.concat(results)
80
74
 
81
75
  # we're done if we have more than 'limit' items, or if we asked for 50 and got less than 50...
@@ -142,8 +136,10 @@ module Inbox
142
136
  model
143
137
  end
144
138
 
145
- def get_model_collection
139
+ def get_model_collection(offset = 0, limit = 100)
146
140
  filters = @filters.clone
141
+ filters[:offset] = offset
142
+ filters[:limit] = limit
147
143
  models = []
148
144
 
149
145
  RestClient.get(url, :params => filters){ |response,request,result|
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Inbox
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nylas
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Gotow
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-02-06 00:00:00.000000000 Z
13
+ date: 2016-02-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client