nylas 4.6.6 → 4.6.7

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
  SHA256:
3
- metadata.gz: baebc1d39fd0bc001c952f302dd417ac00399e139f90b6954080479c659d45ca
4
- data.tar.gz: 554cf1807cb4432d1e7b75722c7da6846db751369085583adc08e09b0e1eaa9b
3
+ metadata.gz: 6dd52077bca505902f8fe016a103318a1c426f74f01235a36c27a2463478f101
4
+ data.tar.gz: 91f2addf66e656561881e721402955080f6e040536c3168737f7b62a4b74a9dd
5
5
  SHA512:
6
- metadata.gz: 7e388d554f86e260cba3950dcd2e4ec559009af1e285c0cbc90c9b8111bed522016292dbf6e907b2a0da89dfedf98bd99d7bc67bab552c3368681b4c0224dc76
7
- data.tar.gz: 947425b241a41b35904eba088d71c2ad6bbb2e0221eb36ba01ff215274e42e852db66c587e047076ab3a81e06d86fac0a98e327b799881097ba7a502ea9b939c
6
+ metadata.gz: ed82717d82cdc4b5fed03a09e7ee1553ba16071e4603b8cedce2518871fc44e2b34c8bd0ce5d9e077bb492a1d216de577264da104014c75e9964b44f7a238e52
7
+ data.tar.gz: be58aff204cad1ce196f8fbeb766708d407d135a8247c484292a5a16fd821119727d21ded457b2b80650b58fc9c70d2a07c38dfc4beea94dc143454bc9377136
data/lib/nylas.rb CHANGED
@@ -51,10 +51,13 @@ require_relative "nylas/timespan"
51
51
  require_relative "nylas/web_page"
52
52
  require_relative "nylas/nylas_date"
53
53
  require_relative "nylas/when"
54
+ require_relative "nylas/free_busy"
55
+ require_relative "nylas/time_slot"
54
56
 
55
57
  # Custom collection types
56
58
  require_relative "nylas/search_collection"
57
59
  require_relative "nylas/deltas_collection"
60
+ require_relative "nylas/free_busy_collection"
58
61
 
59
62
  # Models supported by the API
60
63
  require_relative "nylas/account"
@@ -104,4 +107,5 @@ module Nylas
104
107
  Types.registry[:nylas_date] = NylasDateType.new
105
108
  Types.registry[:contact_group] = Types::ModelType.new(model: ContactGroup)
106
109
  Types.registry[:when] = Types::ModelType.new(model: When)
110
+ Types.registry[:time_slot] = Types::ModelType.new(model: TimeSlot)
107
111
  end
data/lib/nylas/api.rb CHANGED
@@ -150,6 +150,15 @@ module Nylas
150
150
  @webhooks ||= Collection.new(model: Webhook, api: as(client.app_secret))
151
151
  end
152
152
 
153
+ def free_busy(emails:, start_time:, end_time:)
154
+ FreeBusyCollection.new(
155
+ api: self,
156
+ emails: emails,
157
+ start_time: start_time.to_i,
158
+ end_time: end_time.to_i
159
+ )
160
+ end
161
+
153
162
  private
154
163
 
155
164
  def prevent_calling_if_missing_access_token(method_name)
@@ -21,7 +21,7 @@ module Nylas
21
21
  end
22
22
 
23
23
  def create(**attributes)
24
- instance = model.new(attributes.merge(api: api))
24
+ instance = model.new(**attributes.merge(api: api))
25
25
  instance.save
26
26
  instance
27
27
  end
@@ -69,7 +69,7 @@ module Nylas
69
69
  return enum_for(:each) unless block_given?
70
70
 
71
71
  execute.each do |result|
72
- yield(model.new(result.merge(api: api)))
72
+ yield(model.new(**result.merge(api: api)))
73
73
  end
74
74
  end
75
75
 
@@ -119,7 +119,7 @@ module Nylas
119
119
  end
120
120
 
121
121
  def find_raw(id)
122
- api.execute(to_be_executed.merge(path: "#{resources_path}/#{id}")).to_s
122
+ api.execute(**to_be_executed.merge(path: "#{resources_path}/#{id}")).to_s
123
123
  end
124
124
 
125
125
  def resources_path
@@ -127,9 +127,13 @@ module Nylas
127
127
  end
128
128
 
129
129
  def find_model(id)
130
- instance = model.from_hash({ id: id }, api: api)
131
- instance.reload
132
- instance
130
+ response = api.execute(
131
+ **to_be_executed.merge(
132
+ path: "#{resources_path}/#{id}",
133
+ query: {}
134
+ )
135
+ )
136
+ model.from_hash(response, api: api)
133
137
  end
134
138
 
135
139
  # @return [Hash] Specification for request to be passed to {API#execute}
@@ -141,7 +145,7 @@ module Nylas
141
145
  # Retrieves the data from the API for the particular constraints
142
146
  # @return [Hash,Array]
143
147
  def execute
144
- api.execute(to_be_executed)
148
+ api.execute(**to_be_executed)
145
149
  end
146
150
  end
147
151
  end
@@ -34,7 +34,7 @@ module Nylas
34
34
  # Retrieves the data from the API for the particular constraints
35
35
  # @return [Detlas]
36
36
  def execute
37
- self.deltas ||= Deltas.new(api.execute(to_be_executed))
37
+ self.deltas ||= Deltas.new(**api.execute(**to_be_executed))
38
38
  end
39
39
  end
40
40
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Query free/busy information for a calendar during a certain time period
5
+ # @see https://docs.nylas.com/reference#calendars-free-busy
6
+ class FreeBusy
7
+ include Model::Attributable
8
+
9
+ attribute :email, :string
10
+ attribute :object, :string
11
+ has_n_of_attribute :time_slots, :time_slot
12
+ end
13
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Helper to get and build `FreeBusy` objects
5
+ class FreeBusyCollection
6
+ extend Forwardable
7
+ def_delegators :each, :map, :select, :reject, :to_a, :take
8
+ def_delegators :to_a, :first, :last, :[]
9
+
10
+ def initialize(emails:, start_time:, end_time:, api:)
11
+ @api = api
12
+ @emails = emails
13
+ @start_time = start_time
14
+ @end_time = end_time
15
+ end
16
+
17
+ def each
18
+ return enum_for(:each) unless block_given?
19
+
20
+ execute.each do |result|
21
+ yield(FreeBusy.new(**result))
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :api, :emails, :start_time, :end_time
28
+
29
+ PATH = "/calendars/free-busy"
30
+ private_constant :PATH
31
+
32
+ def execute
33
+ api.execute(
34
+ method: :post,
35
+ path: PATH,
36
+ payload: payload
37
+ )
38
+ end
39
+
40
+ def payload
41
+ JSON.dump(
42
+ emails: emails,
43
+ start_time: start_time,
44
+ end_time: end_time
45
+ )
46
+ end
47
+ end
48
+ end
data/lib/nylas/message.rb CHANGED
@@ -56,7 +56,7 @@ module Nylas
56
56
  allowed_attributes: UPDATABLE_ATTRIBUTES
57
57
  ).check
58
58
 
59
- super(payload)
59
+ super(**payload)
60
60
  end
61
61
 
62
62
  def update_folder(folder_id)
@@ -66,7 +66,7 @@ module Nylas
66
66
  def expanded
67
67
  return self unless headers.nil?
68
68
 
69
- assign(api.execute(method: :get, path: resource_path, query: { view: "expanded" }))
69
+ assign(**api.execute(method: :get, path: resource_path, query: { view: "expanded" }))
70
70
  self
71
71
  end
72
72
 
data/lib/nylas/model.rb CHANGED
@@ -70,7 +70,7 @@ module Nylas
70
70
  end
71
71
 
72
72
  def reload
73
- assign(execute(method: :get, path: resource_path))
73
+ assign(**execute(method: :get, path: resource_path))
74
74
  true
75
75
  end
76
76
 
data/lib/nylas/thread.rb CHANGED
@@ -42,7 +42,7 @@ module Nylas
42
42
  raise ArgumentError, "Cannot update #{unupdatable_attributes} only " \
43
43
  "#{UPDATABLE_ATTRIBUTES} are updatable"
44
44
  end
45
- super(data)
45
+ super(**data)
46
46
  end
47
47
 
48
48
  def update_folder(folder_id)
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Query free/busy information for a calendar during a certain time period
5
+ # @see https://docs.nylas.com/reference#calendars-free-busy
6
+ class TimeSlot
7
+ include Model::Attributable
8
+
9
+ attribute :object, :string
10
+ attribute :status, :string
11
+ attribute :start_time, :unix_timestamp
12
+ attribute :end_time, :unix_timestamp
13
+ end
14
+ end
data/lib/nylas/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nylas
4
- VERSION = "4.6.6"
4
+ VERSION = "4.6.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nylas
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.6
4
+ version: 4.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nylas, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-06 00:00:00.000000000 Z
11
+ date: 2021-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.3.0
27
- - !ruby/object:Gem::Dependency
28
- name: jeweler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2.1'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.1'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: yard
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -300,6 +286,8 @@ files:
300
286
  - lib/nylas/file.rb
301
287
  - lib/nylas/filter_attributes.rb
302
288
  - lib/nylas/folder.rb
289
+ - lib/nylas/free_busy.rb
290
+ - lib/nylas/free_busy_collection.rb
303
291
  - lib/nylas/http_client.rb
304
292
  - lib/nylas/im_address.rb
305
293
  - lib/nylas/label.rb
@@ -325,6 +313,7 @@ files:
325
313
  - lib/nylas/rsvp.rb
326
314
  - lib/nylas/search_collection.rb
327
315
  - lib/nylas/thread.rb
316
+ - lib/nylas/time_slot.rb
328
317
  - lib/nylas/timespan.rb
329
318
  - lib/nylas/types.rb
330
319
  - lib/nylas/version.rb