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 +4 -4
- data/lib/api_thread.rb +11 -3
- data/lib/message.rb +3 -3
- data/lib/restful_model_collection.rb +13 -17
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccf84356618303aac11fbe3a42e849cf12c39523
|
4
|
+
data.tar.gz: 61186e74226ef63f22a636cad9ada12ef9ba15ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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["
|
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["
|
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["
|
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["
|
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
|
-
|
19
|
-
|
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
|
-
|
28
|
-
finished = results.length <
|
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
|
-
|
69
|
-
|
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
|
-
|
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
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.
|
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-
|
13
|
+
date: 2016-02-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|