nylas 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab2bbc150ba9969544a9044e70426435899ce892
4
- data.tar.gz: ef8eaf6732b5dba963c8a6e4fbc238e91de70950
3
+ metadata.gz: 2b7aad2985900008ad55ef583ee07de0df8824af
4
+ data.tar.gz: f20298596c198037982871b67cedbaed0990352a
5
5
  SHA512:
6
- metadata.gz: 05aea3e3090be4f44562970ca4e80eb127825d4fef4565800e1d2a40a2063c250583ffb782f456e7d0ac5d2cb5bc1323879f3703b3fa12b433b6bbe2af723f4a
7
- data.tar.gz: 90ef6270c015fe24d10e968679fbe7b2e33e29cec4d282c561a997708cc011cf260578b4306d59877c691d790ab128c89e2e79c13bb9fee0a3fcf33cc18b9b39
6
+ metadata.gz: 5c68b26ac547aef2a6374d7c553b039dd0784ae5249ede291fd8615c877e29c76183830ce2d824461f1b5d2443634d596915c9e0c859e14d11687f0ccd1eb129
7
+ data.tar.gz: 072212b16cf78f73cb57be9ccda3230c23d2f6352de27a53f2c0269e0e743ec8a1e2d58e7ece89771b2d6670e8960e874b76e072812ae424bb115b146e7f4b6e
@@ -41,8 +41,16 @@ module Nylas
41
41
  end
42
42
  end
43
43
 
44
- def messages
45
- @messages ||= RestfulModelCollection.new(Message, @_api, {:thread_id=>@id})
44
+ def messages(expanded: false)
45
+ @messages ||= Hash.new do |h, is_expanded|
46
+ h[is_expanded] = \
47
+ if is_expanded
48
+ RestfulModelCollection.new(ExpandedMessage, @_api, thread_id: @id, view: 'expanded')
49
+ else
50
+ RestfulModelCollection.new(Message, @_api, thread_id: @id)
51
+ end
52
+ end
53
+ @messages[expanded]
46
54
  end
47
55
 
48
56
  def drafts
@@ -7,6 +7,7 @@ module Nylas
7
7
  parameter :version
8
8
  parameter :reply_to_message_id
9
9
  parameter :file_ids
10
+ parameter :tracking
10
11
 
11
12
  def attach(file)
12
13
  file.save! unless file.id
@@ -0,0 +1,20 @@
1
+ module Nylas
2
+ class ExpandedMessage < Message
3
+ # override inflate because expanded messages have some special parameters
4
+ # like In-Reply-To and Message-Id.
5
+ attr_reader :message_id
6
+ attr_reader :in_reply_to
7
+ attr_reader :references
8
+
9
+ def self.collection_name
10
+ 'messages'
11
+ end
12
+
13
+ def inflate(json)
14
+ super
15
+ @message_id = json['headers']['Message-Id']
16
+ @in_reply_to = json['headers']['In-Reply-To']
17
+ @references = json['headers']['References']
18
+ end
19
+ end
20
+ end
@@ -99,19 +99,4 @@ module Nylas
99
99
 
100
100
  end
101
101
  end
102
-
103
- class ExpandedMessage < Message
104
- # override inflate because expanded messages have some special parameters
105
- # like In-Reply-To and Message-Id.
106
- attr_reader :message_id
107
- attr_reader :in_reply_to
108
- attr_reader :references
109
-
110
- def inflate(json)
111
- super
112
- @message_id = json['headers']['Message-Id']
113
- @in_reply_to = json['headers']['In-Reply-To']
114
- @references = json['headers']['References']
115
- end
116
- end
117
102
  end
@@ -13,6 +13,7 @@ require 'api_thread'
13
13
  require 'calendar'
14
14
  require 'account'
15
15
  require 'message'
16
+ require 'expanded_message'
16
17
  require 'draft'
17
18
  require 'contact'
18
19
  require 'file'
@@ -36,7 +37,7 @@ module Nylas
36
37
  def initialize(type, message, server_error = nil)
37
38
  super(message)
38
39
  self.type = type
39
- self.message = message
40
+ self.message = message
40
41
  self.server_error = server_error
41
42
  end
42
43
  end
@@ -84,7 +85,7 @@ module Nylas
84
85
  raise exc.new(response['type'], response['message'], response.fetch('server_error', nil))
85
86
  end
86
87
  end
87
-
88
+
88
89
  raise UnexpectedResponse.new(result.msg) if result.is_a?(Net::HTTPClientError)
89
90
  raise UnexpectedResponse.new if options[:expected_class] && !response.is_a?(options[:expected_class])
90
91
  response
@@ -170,8 +171,16 @@ module Nylas
170
171
  @threads ||= RestfulModelCollection.new(Thread, self)
171
172
  end
172
173
 
173
- def messages
174
- @messages ||= RestfulModelCollection.new(Message, self)
174
+ def messages(expanded: false)
175
+ @messages ||= Hash.new do |h, is_expanded|
176
+ h[is_expanded] = \
177
+ if is_expanded
178
+ RestfulModelCollection.new(ExpandedMessage, self, view: 'expanded')
179
+ else
180
+ RestfulModelCollection.new(Message, self)
181
+ end
182
+ end
183
+ @messages[expanded]
175
184
  end
176
185
 
177
186
  def files
@@ -368,10 +377,10 @@ module Nylas
368
377
  yield delta["event"], obj
369
378
  end
370
379
  end
371
-
380
+
372
381
  http = EventMachine::HttpRequest.new(path, :connect_timeout => 0, :inactivity_timeout => timeout).get(:keepalive => true)
373
382
 
374
- # set a callback on the HTTP stream that parses incoming chunks as they come in
383
+ # set a callback on the HTTP stream that parses incoming chunks as they come in
375
384
  http.stream do |chunk|
376
385
  parser << chunk
377
386
  end
@@ -379,7 +388,7 @@ module Nylas
379
388
  http.errback do
380
389
  raise UnexpectedResponse.new http.error
381
390
  end
382
-
391
+
383
392
  end
384
393
  end
385
394
  end
@@ -1,3 +1,3 @@
1
1
  module Nylas
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.0"
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: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Gotow
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-11-04 00:00:00.000000000 Z
14
+ date: 2017-05-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rest-client
@@ -256,6 +256,7 @@ files:
256
256
  - lib/contact.rb
257
257
  - lib/draft.rb
258
258
  - lib/event.rb
259
+ - lib/expanded_message.rb
259
260
  - lib/file.rb
260
261
  - lib/folder.rb
261
262
  - lib/label.rb
@@ -287,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
288
  version: '0'
288
289
  requirements: []
289
290
  rubyforge_project:
290
- rubygems_version: 2.6.6
291
+ rubygems_version: 2.6.12
291
292
  signing_key:
292
293
  specification_version: 4
293
294
  summary: Gem for interacting with the Nylas API