nylas 3.1.1 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nylas.rb +15 -20
- data/lib/restful_model_collection.rb +30 -32
- data/lib/version.rb +1 -1
- metadata +26 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9418683f9825515764e97bf23b26d8221583c9ca
|
4
|
+
data.tar.gz: 0b6b65e34c35da57205f4b58de3f2e27ded1ae36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75d304cd89b172f67956a4b942ded7fa25c40cb6b330fa3e7123a5daf3ae1e8c132217fd236925db6898f3870c0fc41a0b611db8dfc013433708525cdeeb7954
|
7
|
+
data.tar.gz: 97d3c77893776e5d6d8aa6b5590179db2a97e50300d2b1488d7e0f03b59f9e2b001203ed925287ce64252e133440a8d043e567a32665225611468f6559a1acdb
|
data/lib/nylas.rb
CHANGED
@@ -268,32 +268,30 @@ module Nylas
|
|
268
268
|
"message" => Nylas::ExpandedMessage,
|
269
269
|
}
|
270
270
|
|
271
|
-
def
|
272
|
-
|
271
|
+
def _build_types_filter_string(filter, types)
|
272
|
+
return "" if types.empty?
|
273
|
+
query_string = "&#{filter}_types="
|
273
274
|
|
274
|
-
|
275
|
+
types.each do |value|
|
275
276
|
count = 0
|
276
277
|
if OBJECTS_TABLE.has_value?(value)
|
277
278
|
param_name = OBJECTS_TABLE.key(value)
|
278
|
-
|
279
|
+
query_string += "#{param_name},"
|
279
280
|
end
|
280
281
|
end
|
281
282
|
|
282
|
-
|
283
|
+
query_string = query_string[0..-2]
|
283
284
|
end
|
284
285
|
|
285
|
-
def deltas(cursor, exclude_types=[], expanded_view=false)
|
286
|
-
return enum_for(:deltas, cursor, exclude_types, expanded_view) unless block_given?
|
286
|
+
def deltas(cursor, exclude_types=[], expanded_view=false, include_types=[])
|
287
|
+
return enum_for(:deltas, cursor, exclude_types, expanded_view, include_types) unless block_given?
|
287
288
|
|
288
|
-
exclude_string =
|
289
|
-
|
290
|
-
if exclude_types.any?
|
291
|
-
exclude_string = _build_exclude_types(exclude_types)
|
292
|
-
end
|
289
|
+
exclude_string = _build_types_filter_string(:exclude, exclude_types)
|
290
|
+
include_string = _build_types_filter_string(:include, include_types)
|
293
291
|
|
294
292
|
# loop and yield deltas until we've come to the end.
|
295
293
|
loop do
|
296
|
-
path = self.url_for_path("/delta?exclude_folders=false&cursor=#{cursor}#{exclude_string}")
|
294
|
+
path = self.url_for_path("/delta?exclude_folders=false&cursor=#{cursor}#{exclude_string}#{include_string}")
|
297
295
|
if expanded_view
|
298
296
|
path += '&view=expanded'
|
299
297
|
end
|
@@ -336,17 +334,14 @@ module Nylas
|
|
336
334
|
end
|
337
335
|
end
|
338
336
|
|
339
|
-
def delta_stream(cursor, exclude_types=[], timeout=0, expanded_view=false)
|
337
|
+
def delta_stream(cursor, exclude_types=[], timeout=0, expanded_view=false, include_types=[])
|
340
338
|
raise 'Please provide a block for receiving the delta objects' if !block_given?
|
341
339
|
|
342
|
-
exclude_string =
|
343
|
-
|
344
|
-
if exclude_types.any?
|
345
|
-
exclude_string = _build_exclude_types(exclude_types)
|
346
|
-
end
|
340
|
+
exclude_string = _build_types_filter_string(:exclude, exclude_types)
|
341
|
+
include_string = _build_types_filter_string(:include, include_types)
|
347
342
|
|
348
343
|
# loop and yield deltas indefinitely.
|
349
|
-
path = self.url_for_path("/delta/streaming?exclude_folders=false&cursor=#{cursor}#{exclude_string}")
|
344
|
+
path = self.url_for_path("/delta/streaming?exclude_folders=false&cursor=#{cursor}#{exclude_string}#{include_string}")
|
350
345
|
if expanded_view
|
351
346
|
path += '&view=expanded'
|
352
347
|
end
|
@@ -15,16 +15,10 @@ module Nylas
|
|
15
15
|
def each
|
16
16
|
return enum_for(:each) unless block_given?
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
finished = false
|
21
|
-
while (!finished) do
|
22
|
-
results = get_model_collection(offset, chunk_size)
|
23
|
-
results.each { |item|
|
18
|
+
get_model_collection do |items|
|
19
|
+
items.each do |item|
|
24
20
|
yield item
|
25
|
-
|
26
|
-
offset += results.length
|
27
|
-
finished = results.length < chunk_size
|
21
|
+
end
|
28
22
|
end
|
29
23
|
end
|
30
24
|
|
@@ -60,21 +54,8 @@ module Nylas
|
|
60
54
|
end
|
61
55
|
|
62
56
|
def range(offset = 0, limit = 100)
|
63
|
-
accumulated = []
|
64
|
-
finished = false
|
65
|
-
chunk_size = 100
|
66
|
-
|
67
|
-
if limit < chunk_size
|
68
|
-
chunk_size = limit
|
69
|
-
end
|
70
|
-
|
71
|
-
while (!finished && accumulated.length < limit) do
|
72
|
-
results = get_model_collection(offset + accumulated.length, chunk_size)
|
73
|
-
accumulated = accumulated.concat(results)
|
74
57
|
|
75
|
-
|
76
|
-
finished = accumulated.length >= limit || results.length == 0 || (results.length % chunk_size != 0)
|
77
|
-
end
|
58
|
+
accumulated = get_model_collection(offset, limit)
|
78
59
|
|
79
60
|
accumulated = accumulated[0..limit] if limit < Float::INFINITY
|
80
61
|
accumulated
|
@@ -136,21 +117,38 @@ module Nylas
|
|
136
117
|
model
|
137
118
|
end
|
138
119
|
|
139
|
-
def get_model_collection(offset =
|
120
|
+
def get_model_collection(offset = nil, limit = nil, pagination_options = { per_page: 100 })
|
140
121
|
filters = @filters.clone
|
141
|
-
filters[:offset] = offset
|
142
|
-
filters[:limit] = limit
|
143
|
-
models = []
|
122
|
+
filters[:offset] = offset || filters[:offset] || 0
|
123
|
+
filters[:limit] = limit || filters[:limit] || 100
|
144
124
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
125
|
+
accumulated = []
|
126
|
+
|
127
|
+
finished = false
|
128
|
+
|
129
|
+
current_calls_filters = filters.clone
|
130
|
+
while (!finished) do
|
131
|
+
current_calls_filters[:limit] = pagination_options[:per_page] > filters[:limit] ? filters[:limit] : pagination_options[:per_page]
|
132
|
+
RestClient.get(url, :params => current_calls_filters) do |response, request, result|
|
133
|
+
items = Nylas.interpret_response(result, response, { :expected_class => Array })
|
134
|
+
new_items = inflate_collection(items)
|
135
|
+
yield new_items if block_given?
|
136
|
+
accumulated = accumulated.concat(new_items)
|
137
|
+
finished = no_more_pages?(accumulated, items, filters, pagination_options)
|
138
|
+
end
|
139
|
+
|
140
|
+
current_calls_filters[:offset] += pagination_options[:per_page]
|
141
|
+
end
|
142
|
+
|
143
|
+
accumulated
|
150
144
|
end
|
151
145
|
|
146
|
+
def no_more_pages?(accumulated, items, filters, pagination_options)
|
147
|
+
accumulated.length >= filters[:limit] || items.length < pagination_options[:per_page]
|
148
|
+
end
|
152
149
|
end
|
153
150
|
|
151
|
+
|
154
152
|
# a ManagementModelCollection is similar to a RestfulModelCollection except
|
155
153
|
# it's used by models under the /a/<app_id> namespace (mostly account status
|
156
154
|
# and billing methods).
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,72 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nylas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
- Karim Hamidou
|
9
|
-
- Jennie Lees
|
10
|
-
- Michael Pfister
|
7
|
+
- Nylas, Inc.
|
11
8
|
autorequire:
|
12
9
|
bindir: bin
|
13
10
|
cert_chain: []
|
14
|
-
date: 2017-
|
11
|
+
date: 2017-11-17 00:00:00.000000000 Z
|
15
12
|
dependencies:
|
16
13
|
- !ruby/object:Gem::Dependency
|
17
14
|
name: rest-client
|
18
15
|
requirement: !ruby/object:Gem::Requirement
|
19
16
|
requirements:
|
20
|
-
- - "
|
17
|
+
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '1.6'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.6'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: yajl-ruby
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
30
|
requirements:
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 1.2.1
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
33
|
version: '1.2'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.2.1
|
40
37
|
type: :runtime
|
41
38
|
prerelease: false
|
42
39
|
version_requirements: !ruby/object:Gem::Requirement
|
43
40
|
requirements:
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 1.2.1
|
47
41
|
- - "~>"
|
48
42
|
- !ruby/object:Gem::Version
|
49
43
|
version: '1.2'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.2.1
|
50
47
|
- !ruby/object:Gem::Dependency
|
51
48
|
name: em-http-request
|
52
49
|
requirement: !ruby/object:Gem::Requirement
|
53
50
|
requirements:
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 1.1.3
|
57
51
|
- - "~>"
|
58
52
|
- !ruby/object:Gem::Version
|
59
53
|
version: '1.1'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.1.3
|
60
57
|
type: :runtime
|
61
58
|
prerelease: false
|
62
59
|
version_requirements: !ruby/object:Gem::Requirement
|
63
60
|
requirements:
|
64
|
-
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 1.1.3
|
67
61
|
- - "~>"
|
68
62
|
- !ruby/object:Gem::Version
|
69
63
|
version: '1.1'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.1.3
|
70
67
|
- !ruby/object:Gem::Dependency
|
71
68
|
name: rspec
|
72
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,9 +71,6 @@ dependencies:
|
|
74
71
|
- - ">="
|
75
72
|
- !ruby/object:Gem::Version
|
76
73
|
version: 3.5.0
|
77
|
-
- - "~>"
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: '3.5'
|
80
74
|
type: :development
|
81
75
|
prerelease: false
|
82
76
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -84,9 +78,6 @@ dependencies:
|
|
84
78
|
- - ">="
|
85
79
|
- !ruby/object:Gem::Version
|
86
80
|
version: 3.5.0
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '3.5'
|
90
81
|
- !ruby/object:Gem::Dependency
|
91
82
|
name: shoulda
|
92
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,9 +85,6 @@ dependencies:
|
|
94
85
|
- - ">="
|
95
86
|
- !ruby/object:Gem::Version
|
96
87
|
version: 3.4.0
|
97
|
-
- - "~>"
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: '3.5'
|
100
88
|
type: :development
|
101
89
|
prerelease: false
|
102
90
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -104,21 +92,18 @@ dependencies:
|
|
104
92
|
- - ">="
|
105
93
|
- !ruby/object:Gem::Version
|
106
94
|
version: 3.4.0
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '3.5'
|
110
95
|
- !ruby/object:Gem::Dependency
|
111
96
|
name: rdoc
|
112
97
|
requirement: !ruby/object:Gem::Requirement
|
113
98
|
requirements:
|
114
|
-
- - "
|
99
|
+
- - ">="
|
115
100
|
- !ruby/object:Gem::Version
|
116
101
|
version: '3.12'
|
117
102
|
type: :development
|
118
103
|
prerelease: false
|
119
104
|
version_requirements: !ruby/object:Gem::Requirement
|
120
105
|
requirements:
|
121
|
-
- - "
|
106
|
+
- - ">="
|
122
107
|
- !ruby/object:Gem::Version
|
123
108
|
version: '3.12'
|
124
109
|
- !ruby/object:Gem::Dependency
|
@@ -128,9 +113,6 @@ dependencies:
|
|
128
113
|
- - ">="
|
129
114
|
- !ruby/object:Gem::Version
|
130
115
|
version: 1.3.5
|
131
|
-
- - "~>"
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '1.3'
|
134
116
|
type: :development
|
135
117
|
prerelease: false
|
136
118
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -138,9 +120,6 @@ dependencies:
|
|
138
120
|
- - ">="
|
139
121
|
- !ruby/object:Gem::Version
|
140
122
|
version: 1.3.5
|
141
|
-
- - "~>"
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: '1.3'
|
144
123
|
- !ruby/object:Gem::Dependency
|
145
124
|
name: jeweler
|
146
125
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,9 +127,6 @@ dependencies:
|
|
148
127
|
- - ">="
|
149
128
|
- !ruby/object:Gem::Version
|
150
129
|
version: 2.1.2
|
151
|
-
- - "~>"
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
version: '2.1'
|
154
130
|
type: :development
|
155
131
|
prerelease: false
|
156
132
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -158,49 +134,46 @@ dependencies:
|
|
158
134
|
- - ">="
|
159
135
|
- !ruby/object:Gem::Version
|
160
136
|
version: 2.1.2
|
161
|
-
- - "~>"
|
162
|
-
- !ruby/object:Gem::Version
|
163
|
-
version: '2.1'
|
164
137
|
- !ruby/object:Gem::Dependency
|
165
138
|
name: pry
|
166
139
|
requirement: !ruby/object:Gem::Requirement
|
167
140
|
requirements:
|
168
|
-
- - "
|
141
|
+
- - ">="
|
169
142
|
- !ruby/object:Gem::Version
|
170
143
|
version: 0.10.4
|
171
144
|
type: :development
|
172
145
|
prerelease: false
|
173
146
|
version_requirements: !ruby/object:Gem::Requirement
|
174
147
|
requirements:
|
175
|
-
- - "
|
148
|
+
- - ">="
|
176
149
|
- !ruby/object:Gem::Version
|
177
150
|
version: 0.10.4
|
178
151
|
- !ruby/object:Gem::Dependency
|
179
152
|
name: pry-nav
|
180
153
|
requirement: !ruby/object:Gem::Requirement
|
181
154
|
requirements:
|
182
|
-
- - "
|
155
|
+
- - ">="
|
183
156
|
- !ruby/object:Gem::Version
|
184
157
|
version: 0.2.4
|
185
158
|
type: :development
|
186
159
|
prerelease: false
|
187
160
|
version_requirements: !ruby/object:Gem::Requirement
|
188
161
|
requirements:
|
189
|
-
- - "
|
162
|
+
- - ">="
|
190
163
|
- !ruby/object:Gem::Version
|
191
164
|
version: 0.2.4
|
192
165
|
- !ruby/object:Gem::Dependency
|
193
166
|
name: pry-stack_explorer
|
194
167
|
requirement: !ruby/object:Gem::Requirement
|
195
168
|
requirements:
|
196
|
-
- - "
|
169
|
+
- - ">="
|
197
170
|
- !ruby/object:Gem::Version
|
198
171
|
version: 0.4.9.2
|
199
172
|
type: :development
|
200
173
|
prerelease: false
|
201
174
|
version_requirements: !ruby/object:Gem::Requirement
|
202
175
|
requirements:
|
203
|
-
- - "
|
176
|
+
- - ">="
|
204
177
|
- !ruby/object:Gem::Version
|
205
178
|
version: 0.4.9.2
|
206
179
|
- !ruby/object:Gem::Dependency
|
@@ -210,9 +183,6 @@ dependencies:
|
|
210
183
|
- - ">="
|
211
184
|
- !ruby/object:Gem::Version
|
212
185
|
version: 2.1.0
|
213
|
-
- - "~>"
|
214
|
-
- !ruby/object:Gem::Version
|
215
|
-
version: '2.1'
|
216
186
|
type: :development
|
217
187
|
prerelease: false
|
218
188
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -220,9 +190,6 @@ dependencies:
|
|
220
190
|
- - ">="
|
221
191
|
- !ruby/object:Gem::Version
|
222
192
|
version: 2.1.0
|
223
|
-
- - "~>"
|
224
|
-
- !ruby/object:Gem::Version
|
225
|
-
version: '2.1'
|
226
193
|
- !ruby/object:Gem::Dependency
|
227
194
|
name: sinatra
|
228
195
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,9 +197,6 @@ dependencies:
|
|
230
197
|
- - ">="
|
231
198
|
- !ruby/object:Gem::Version
|
232
199
|
version: 1.4.7
|
233
|
-
- - "~>"
|
234
|
-
- !ruby/object:Gem::Version
|
235
|
-
version: '1.4'
|
236
200
|
type: :development
|
237
201
|
prerelease: false
|
238
202
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -240,9 +204,6 @@ dependencies:
|
|
240
204
|
- - ">="
|
241
205
|
- !ruby/object:Gem::Version
|
242
206
|
version: 1.4.7
|
243
|
-
- - "~>"
|
244
|
-
- !ruby/object:Gem::Version
|
245
|
-
version: '1.4'
|
246
207
|
description: Gem for interacting with the Nylas API.
|
247
208
|
email: support@nylas.com
|
248
209
|
executables: []
|
@@ -288,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
288
249
|
version: '0'
|
289
250
|
requirements: []
|
290
251
|
rubyforge_project:
|
291
|
-
rubygems_version: 2.6.
|
252
|
+
rubygems_version: 2.6.13
|
292
253
|
signing_key:
|
293
254
|
specification_version: 4
|
294
255
|
summary: Gem for interacting with the Nylas API
|