nylas 5.4.1 → 5.5.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
  SHA256:
3
- metadata.gz: 29f07de83f9f9129d2604b28ad5efd02d21cdc81075e92b16129d6ebfb3509fc
4
- data.tar.gz: f1259c4907de58f04082c6c2e0a80a7d2d50b99a13efc70714f7370ead25d420
3
+ metadata.gz: 23edacaacec01d7cfd4c182647c30287d27b6ef790ec4abb7a83f98afa17782a
4
+ data.tar.gz: 3303d603caaf9a5be367fd5983f5350a61460575ddd7978c475c7eaf8be88727
5
5
  SHA512:
6
- metadata.gz: 9117a61ff796ee58ee596d2ce7f1d41874a0f79f452d678f66dc768e8cf7db59580085f069946e4d4a634b47a85ebd4696f59b59960ecdec805c0244575bbc7a
7
- data.tar.gz: b53cedb0c8c2334da1f6e092819eea787ec4c856eafdb606ce29713605eed834044e780dfd6ed6fafc0ee47c6c1bfd48d947237dc4dd9a6d84d531c4c5cc1daf
6
+ metadata.gz: af4b7703eb190cbebcc2dac2777ea8cc3a9dbc77dc07604ffd11b3d5aaf4b8085afe60512cca8698bae58f1729c6adee6dd3fe03ae68bb0139ce0c0f208f91cb
7
+ data.tar.gz: f2060e79d3fe69ba18cb7fc35647504b4f5c66c0ba7c8e41d861b058991e109c5c2a0ec3c1a505eb9ec11d45c8ee9f359f988ade593685af5bf6a157b1029833
data/lib/nylas/api.rb CHANGED
@@ -83,7 +83,7 @@ module Nylas
83
83
 
84
84
  # @return [Collection<Calendar>] A queryable collection of {Calendar}s
85
85
  def calendars
86
- @calendars ||= Collection.new(model: Calendar, api: self)
86
+ @calendars ||= CalendarCollection.new(model: Calendar, api: self)
87
87
  end
88
88
 
89
89
  # @return [DeltasCollection<Delta>] A queryable collection of Deltas, which are themselves a collection.
@@ -126,11 +126,24 @@ module Nylas
126
126
  @room_resources ||= Collection.new(model: RoomResource, api: self)
127
127
  end
128
128
 
129
+ # @return[Collection<Scheduler>] A queryable collection of {Scheduler} objects
130
+ def scheduler
131
+ # Make a deep copy of the API as the scheduler API uses a different base URL
132
+ scheduler_api = Marshal.load(Marshal.dump(self))
133
+ scheduler_api.client.api_server = "https://api.schedule.nylas.com"
134
+ @scheduler ||= Collection.new(model: Scheduler, api: scheduler_api)
135
+ end
136
+
129
137
  # @return[Neural] A {Neural} object that provides
130
138
  def neural
131
139
  @neural ||= Neural.new(api: self)
132
140
  end
133
141
 
142
+ # @return [Collection<Component>] A queryable collection of {Component}s
143
+ def components
144
+ @components ||= ComponentCollection.new(model: Component, api: as(client.app_secret))
145
+ end
146
+
134
147
  # Revokes access to the Nylas API for the given access token
135
148
  # @return [Boolean]
136
149
  def revoke(access_token)
@@ -171,6 +184,7 @@ module Nylas
171
184
  @webhooks ||= Collection.new(model: Webhook, api: as(client.app_secret))
172
185
  end
173
186
 
187
+ # TODO: Move this into calendar collection
174
188
  def free_busy(emails:, start_time:, end_time:)
175
189
  FreeBusyCollection.new(
176
190
  api: self,
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Additional methods for some of Calendar's other functionality
5
+ # @see https://developer.nylas.com/docs/connectivity/calendar
6
+ class CalendarCollection < Collection
7
+ def availability(duration_minutes:,
8
+ interval:,
9
+ start_time:,
10
+ end_time:,
11
+ emails:,
12
+ buffer: nil,
13
+ round_robin: nil,
14
+ free_busy: [],
15
+ open_hours: [])
16
+ validate_open_hours(emails, free_busy, open_hours) unless open_hours.empty?
17
+
18
+ execute_availability("/calendars/availability",
19
+ duration_minutes: duration_minutes,
20
+ interval: interval,
21
+ start_time: start_time,
22
+ end_time: end_time,
23
+ emails: emails,
24
+ buffer: buffer,
25
+ round_robin: round_robin,
26
+ free_busy: free_busy,
27
+ open_hours: open_hours)
28
+ end
29
+
30
+ def consecutive_availability(duration_minutes:,
31
+ interval:,
32
+ start_time:,
33
+ end_time:,
34
+ emails:,
35
+ buffer: nil,
36
+ free_busy: [],
37
+ open_hours: [])
38
+ validate_open_hours(emails, free_busy, open_hours) unless open_hours.empty?
39
+
40
+ execute_availability("/calendars/availability/consecutive",
41
+ duration_minutes: duration_minutes,
42
+ interval: interval,
43
+ start_time: start_time,
44
+ end_time: end_time,
45
+ emails: emails,
46
+ buffer: buffer,
47
+ free_busy: free_busy,
48
+ open_hours: open_hours)
49
+ end
50
+
51
+ private
52
+
53
+ def execute_availability(path, **payload)
54
+ api.execute(
55
+ method: :post,
56
+ path: path,
57
+ payload: JSON.dump(payload)
58
+ )
59
+ end
60
+
61
+ def validate_open_hours(emails, free_busy, open_hours)
62
+ raise TypeError, "open_hours' must be an array." unless open_hours.is_a?(Array)
63
+
64
+ open_hours_emails = map_open_hours_emails(open_hours)
65
+ free_busy_emails = map_free_busy_emails(free_busy)
66
+ emails = merge_arrays(emails) if emails[0].is_a?(Array)
67
+
68
+ open_hours_emails.each do |email|
69
+ next if emails.include?(email) || free_busy_emails.include?(email)
70
+
71
+ raise ArgumentError, "Open Hours cannot contain an email not present in the main email list or
72
+ the free busy email list."
73
+ end
74
+ end
75
+
76
+ def map_open_hours_emails(open_hours)
77
+ open_hours_emails = []
78
+ open_hours.map do |oh|
79
+ open_hours_emails += oh.emails
80
+ end
81
+ open_hours_emails
82
+ end
83
+
84
+ def map_free_busy_emails(free_busy)
85
+ free_busy_emails = []
86
+ free_busy.map do |fb|
87
+ free_busy_emails.append(fb.email)
88
+ end
89
+ free_busy_emails
90
+ end
91
+
92
+ def merge_arrays(array)
93
+ list = []
94
+ array.each do |x|
95
+ list += x
96
+ end
97
+ list
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Structure to represent a the Component Schema.
5
+ class Component
6
+ include Model
7
+ allows_operations(creatable: true, listable: true, filterable: true, showable: true, updatable: true,
8
+ destroyable: true)
9
+
10
+ attribute :id, :string, read_only: true
11
+ attribute :account_id, :string
12
+ attribute :name, :string
13
+ attribute :type, :string
14
+ attribute :action, :integer
15
+ attribute :active, :boolean
16
+ attribute :settings, :hash
17
+ attribute :public_account_id, :string
18
+ attribute :public_token_id, :string
19
+ attribute :public_application_id, :string, read_only: true
20
+ attribute :access_token, :string
21
+ attribute :created_at, :date, read_only: true
22
+ attribute :updated_at, :date, read_only: true
23
+
24
+ has_n_of_attribute :allowed_domains, :string
25
+
26
+ def resources_path(*)
27
+ "/component/#{api.client.app_id}"
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Additional configuration for the Component CRUD API
5
+ class ComponentCollection < Collection
6
+ def resources_path
7
+ "/component/#{api.client.app_id}"
8
+ end
9
+ end
10
+ end
data/lib/nylas/draft.rb CHANGED
@@ -86,7 +86,7 @@ module Nylas
86
86
  def extract_file_ids!
87
87
  files = self.files || []
88
88
 
89
- self.file_ids = files.map(&:id)
89
+ self.file_ids ||= files.map(&:id)
90
90
  end
91
91
  end
92
92
  end
data/lib/nylas/file.rb CHANGED
@@ -6,7 +6,7 @@ module Nylas
6
6
  class File
7
7
  include Model
8
8
  self.resources_path = "/files"
9
- allows_operations(listable: true, showable: true, filterable: true, creatable: true)
9
+ allows_operations(listable: true, showable: true, filterable: true, creatable: true, destroyable: true)
10
10
 
11
11
  attribute :id, :string
12
12
  attribute :account_id, :string
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Additional times email accounts are available
5
+ # @see https://developer.nylas.com/docs/api/#post/calendars/availability
6
+ class OpenHours
7
+ include Model::Attributable
8
+
9
+ attribute :timezone, :string
10
+ attribute :start, :string
11
+ attribute :end, :string
12
+ has_n_of_attribute :emails, :string
13
+ has_n_of_attribute :days, :integer
14
+ end
15
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Ruby representation of a the Nylas Scheduler API
5
+ # @see https://developer.nylas.com/docs/api/scheduler/#overview
6
+ class Scheduler
7
+ include Model
8
+ self.resources_path = "/manage/pages"
9
+ allows_operations(creatable: true, listable: true, filterable: true, showable: true, updatable: true,
10
+ destroyable: true)
11
+
12
+ attribute :id, :integer, read_only: true
13
+ attribute :app_client_id, :string
14
+ attribute :app_organization_id, :integer
15
+ attribute :config, :scheduler_config
16
+ attribute :edit_token, :string
17
+ attribute :name, :string
18
+ attribute :slug, :string
19
+ attribute :created_at, :date
20
+ attribute :modified_at, :date
21
+
22
+ has_n_of_attribute :access_tokens, :string
23
+
24
+ def get_available_calendars
25
+ raise ArgumentError, "Cannot get calendars for a page without an ID." if id.nil?
26
+
27
+ api.execute(
28
+ method: :get,
29
+ path: "/manage/pages/#{id}/calendars"
30
+ )
31
+ end
32
+
33
+ def upload_image(content_type:, object_name:)
34
+ raise ArgumentError, "Cannot upload an image to a page without an ID." if id.nil?
35
+
36
+ payload = {
37
+ contentType: content_type,
38
+ objectName: object_name
39
+ }
40
+ api.execute(
41
+ method: :put,
42
+ path: "/manage/pages/#{id}/upload-image",
43
+ payload: JSON.dump(payload)
44
+ )
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Configuration settings for a Scheduler page
5
+ # @see https://developer.nylas.com/docs/api/scheduler
6
+ class SchedulerConfig
7
+ include Model::Attributable
8
+
9
+ attribute :appearance, :hash
10
+ attribute :booking, :hash
11
+ attribute :calendar_ids, :hash
12
+ attribute :event, :hash
13
+ attribute :expire_after, :hash
14
+ attribute :locale, :string
15
+ attribute :locale_for_guests, :string
16
+ attribute :timezone, :string
17
+
18
+ has_n_of_attribute :reminders, :hash
19
+ end
20
+ 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 = "5.4.1"
4
+ VERSION = "5.5.0"
5
5
  end
data/lib/nylas.rb CHANGED
@@ -35,7 +35,6 @@ require_relative "nylas/model"
35
35
  # Attribute types supported by the API
36
36
  require_relative "nylas/email_address"
37
37
  require_relative "nylas/event"
38
- require_relative "nylas/event_collection"
39
38
  require_relative "nylas/file"
40
39
  require_relative "nylas/folder"
41
40
  require_relative "nylas/im_address"
@@ -53,14 +52,19 @@ require_relative "nylas/nylas_date"
53
52
  require_relative "nylas/when"
54
53
  require_relative "nylas/free_busy"
55
54
  require_relative "nylas/time_slot"
55
+ require_relative "nylas/open_hours"
56
56
  require_relative "nylas/event_conferencing"
57
57
  require_relative "nylas/event_conferencing_details"
58
58
  require_relative "nylas/event_conferencing_autocreate"
59
+ require_relative "nylas/component"
59
60
 
60
61
  # Custom collection types
62
+ require_relative "nylas/event_collection"
61
63
  require_relative "nylas/search_collection"
62
64
  require_relative "nylas/deltas_collection"
63
65
  require_relative "nylas/free_busy_collection"
66
+ require_relative "nylas/calendar_collection"
67
+ require_relative "nylas/component_collection"
64
68
 
65
69
  # Models supported by the API
66
70
  require_relative "nylas/account"
@@ -77,6 +81,7 @@ require_relative "nylas/new_message"
77
81
  require_relative "nylas/raw_message"
78
82
  require_relative "nylas/thread"
79
83
  require_relative "nylas/webhook"
84
+ require_relative "nylas/scheduler"
80
85
 
81
86
  # Neural specific types
82
87
  require_relative "nylas/neural"
@@ -90,6 +95,7 @@ require_relative "nylas/neural_signature_contact"
90
95
  require_relative "nylas/neural_signature_extraction"
91
96
  require_relative "nylas/neural_message_options"
92
97
  require_relative "nylas/categorize"
98
+ require_relative "nylas/scheduler_config"
93
99
 
94
100
  require_relative "nylas/native_authentication"
95
101
 
@@ -134,4 +140,5 @@ module Nylas
134
140
  Types.registry[:neural_signature_contact] = Types::ModelType.new(model: NeuralSignatureContact)
135
141
  Types.registry[:neural_contact_link] = Types::ModelType.new(model: NeuralContactLink)
136
142
  Types.registry[:neural_contact_name] = Types::ModelType.new(model: NeuralContactName)
143
+ Types.registry[:scheduler_config] = Types::ModelType.new(model: SchedulerConfig)
137
144
  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: 5.4.1
4
+ version: 5.5.0
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-09-27 00:00:00.000000000 Z
11
+ date: 2021-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -270,8 +270,11 @@ files:
270
270
  - lib/nylas/account.rb
271
271
  - lib/nylas/api.rb
272
272
  - lib/nylas/calendar.rb
273
+ - lib/nylas/calendar_collection.rb
273
274
  - lib/nylas/categorize.rb
274
275
  - lib/nylas/collection.rb
276
+ - lib/nylas/component.rb
277
+ - lib/nylas/component_collection.rb
275
278
  - lib/nylas/constraints.rb
276
279
  - lib/nylas/contact.rb
277
280
  - lib/nylas/contact_group.rb
@@ -318,6 +321,7 @@ files:
318
321
  - lib/nylas/neural_signature_extraction.rb
319
322
  - lib/nylas/new_message.rb
320
323
  - lib/nylas/nylas_date.rb
324
+ - lib/nylas/open_hours.rb
321
325
  - lib/nylas/participant.rb
322
326
  - lib/nylas/phone_number.rb
323
327
  - lib/nylas/physical_address.rb
@@ -326,6 +330,8 @@ files:
326
330
  - lib/nylas/registry.rb
327
331
  - lib/nylas/room_resource.rb
328
332
  - lib/nylas/rsvp.rb
333
+ - lib/nylas/scheduler.rb
334
+ - lib/nylas/scheduler_config.rb
329
335
  - lib/nylas/search_collection.rb
330
336
  - lib/nylas/thread.rb
331
337
  - lib/nylas/time_slot.rb
@@ -360,7 +366,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
360
366
  - !ruby/object:Gem::Version
361
367
  version: '0'
362
368
  requirements: []
363
- rubygems_version: 3.1.6
369
+ rubygems_version: 3.2.17
364
370
  signing_key:
365
371
  specification_version: 4
366
372
  summary: Gem for interacting with the Nylas API