nylas 5.9.1 → 5.11.0

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: c62ff2cfcd6e73840a14c281b0d46da494dcea2d49f42da51eb94a30080307e8
4
- data.tar.gz: 957a04e0146a2cea58a2fe064d11814462a7aae36c88fee38d2c4b71ad5c3d97
3
+ metadata.gz: 5f59eea98b61cf99f73b87277cf360310f9fa8584a4164297d58faa2ef2575cd
4
+ data.tar.gz: 1afd54d9481f76af4330d8e12a2f90b8fe667628247e455453211425b198f470
5
5
  SHA512:
6
- metadata.gz: 8316f1b5ebb2470a0154c1a8c33bfcd23ede0318555546e8fcf3f23b19fb5a84f052621d1150b38d10893db07c98c71a6ba997487b8bae9a1562d58dd95f1f25
7
- data.tar.gz: da299c0110d2755b5514dc6e604b6ad3ecf3fecffca0998fc61ab417ffb096f52c775a360728724487688cada34c3bef4f7285cc1d9e09633b278a2dc91ab4dc
6
+ metadata.gz: ebf09713be0037d694e9d43c3aa5b3c3c4a5557296593773bbd792f21f281662ef96fb2079ca34d1325a0c43b4810f0805a80e963de29eef0b0762b805a74581
7
+ data.tar.gz: cb2c8c558dd67b36aa446d7b92a91902978b0e41af1f1a24e3629c833817ad3038fa71f2c1c42f0e79f3ab32c8bb02f836fc10f1481eaf0fb9f78ed021fbb44e
data/lib/nylas/account.rb CHANGED
@@ -9,6 +9,7 @@ module Nylas
9
9
  self.showable = true
10
10
  self.updatable = true
11
11
  self.destroyable = true
12
+ self.filterable = true
12
13
  self.auth_method = HttpClient::AuthMethod::BASIC
13
14
 
14
15
  attribute :id, :string, read_only: true
@@ -4,6 +4,19 @@ module Nylas
4
4
  # Additional methods for some of Calendar's other functionality
5
5
  # @see https://developer.nylas.com/docs/connectivity/calendar
6
6
  class CalendarCollection < Collection
7
+ # Check multiple calendars to find available time slots for a single meeting
8
+ # @param duration_minutes [Integer] The total number of minutes the event should last
9
+ # @param interval_minutes [Integer] How many minutes it should check for availability
10
+ # @param start_time [Integer] The timestamp for the beginning of the event
11
+ # @param end_time [Integer] The timestamp for the end of the event
12
+ # @param emails [Array<String>] Emails on the same domain to check
13
+ # @param buffer [Integer] The amount of buffer time in minutes that you want around existing meetings
14
+ # @param round_robin [String] Finds available meeting times in a round-robin style
15
+ # @param event_collection_id [String] Unique identifier for a collection of events that are created
16
+ # @param free_busy [Array<Nylas::FreeBusy>] A list of free-busy data for users not in your organization
17
+ # @param open_hours [Array<Nylas::OpenHours>] Additional times email accounts are available
18
+ # @param calendars [Array] Check account and calendar IDs for free/busy status
19
+ # @return [Hash] The availability information; a list of time slots where all participants are available
7
20
  def availability(duration_minutes:,
8
21
  interval_minutes:,
9
22
  start_time:,
@@ -11,6 +24,7 @@ module Nylas
11
24
  emails: [],
12
25
  buffer: nil,
13
26
  round_robin: nil,
27
+ event_collection_id: nil,
14
28
  free_busy: [],
15
29
  open_hours: [],
16
30
  calendars: [])
@@ -25,11 +39,23 @@ module Nylas
25
39
  emails: emails,
26
40
  buffer: buffer,
27
41
  round_robin: round_robin,
28
- free_busy: free_busy,
29
- open_hours: open_hours,
42
+ event_collection_id: event_collection_id,
43
+ free_busy: free_busy.map(&:to_h),
44
+ open_hours: open_hours.map(&:to_h),
30
45
  calendars: calendars)
31
46
  end
32
47
 
48
+ # Check multiple calendars to find availability for multiple meetings with several participants
49
+ # @param duration_minutes [Integer] The total number of minutes the event should last
50
+ # @param interval_minutes [Integer] How many minutes it should check for availability
51
+ # @param start_time [Integer] The timestamp for the beginning of the event
52
+ # @param end_time [Integer] The timestamp for the end of the event
53
+ # @param emails [Array<Array<String>>] Emails on the same domain to check
54
+ # @param buffer [Integer] The amount of buffer time in minutes that you want around existing meetings
55
+ # @param free_busy [Array<Nylas::FreeBusy>] A list of free-busy data for users not in your organization
56
+ # @param open_hours [Array<Nylas::OpenHours>] Additional times email accounts are available
57
+ # @param calendars [Array] Check account and calendar IDs for free/busy status
58
+ # @return [Hash] The availability information; a list of all possible groupings that share time slots
33
59
  def consecutive_availability(duration_minutes:,
34
60
  interval_minutes:,
35
61
  start_time:,
@@ -49,8 +75,8 @@ module Nylas
49
75
  end_time: end_time,
50
76
  emails: emails,
51
77
  buffer: buffer,
52
- free_busy: free_busy,
53
- open_hours: open_hours,
78
+ free_busy: free_busy.map(&:to_h),
79
+ open_hours: open_hours.map(&:to_h),
54
80
  calendars: calendars)
55
81
  end
56
82
 
data/lib/nylas/event.rb CHANGED
@@ -16,7 +16,9 @@ module Nylas
16
16
  attribute :master_event_id, :string
17
17
  attribute :message_id, :string
18
18
  attribute :ical_uid, :string
19
+ attribute :event_collection_id, :string
19
20
 
21
+ attribute :capacity, :integer
20
22
  attribute :busy, :boolean
21
23
  attribute :description, :string
22
24
  attribute :location, :string
@@ -30,7 +32,10 @@ module Nylas
30
32
  attribute :metadata, :hash
31
33
  attribute :conferencing, :event_conferencing
32
34
  has_n_of_attribute :notifications, :event_notification
35
+ has_n_of_attribute :round_robin_order, :string
33
36
  attribute :original_start_time, :unix_timestamp
37
+ attribute :reminder_minutes, :string
38
+ attribute :reminder_method, :string
34
39
  attribute :job_status_id, :string, read_only: true
35
40
 
36
41
  attr_accessor :notify_participants
@@ -44,12 +49,8 @@ module Nylas
44
49
  end
45
50
 
46
51
  def save
47
- if conferencing
48
- body = to_h
49
- if body.dig(:conferencing, :details) && body.dig(:conferencing, :autocreate)
50
- raise ArgumentError, "Cannot set both 'details' and 'autocreate' in conferencing object."
51
- end
52
- end
52
+ validate
53
+ format_reminder_minutes
53
54
 
54
55
  super
55
56
  end
@@ -81,6 +82,18 @@ module Nylas
81
82
 
82
83
  private
83
84
 
85
+ def validate
86
+ if conferencing
87
+ body = to_h
88
+ if body.dig(:conferencing, :details) && body.dig(:conferencing, :autocreate)
89
+ raise ArgumentError, "Cannot set both 'details' and 'autocreate' in conferencing object."
90
+ end
91
+ end
92
+ return unless capacity && capacity != -1 && participants && participants.length > capacity
93
+
94
+ raise ArgumentError, "The number of participants in the event exceeds the set capacity."
95
+ end
96
+
84
97
  def build_ics_event_payload(ical_uid, method, prodid)
85
98
  payload = {}
86
99
  if id
@@ -101,6 +114,13 @@ module Nylas
101
114
  payload
102
115
  end
103
116
 
117
+ # Formats the reminder minute field to match the API format: "[%d]"
118
+ def format_reminder_minutes
119
+ return if reminder_minutes.nil? || reminder_minutes.empty? || reminder_minutes.match(/\[\d+\]/)
120
+
121
+ self.reminder_minutes = "[#{reminder_minutes}]"
122
+ end
123
+
104
124
  def query_params
105
125
  if notify_participants.nil?
106
126
  {}
@@ -5,7 +5,7 @@ module Nylas
5
5
  require "base64"
6
6
 
7
7
  # Plain HTTP client that can be used to interact with the Nylas API sans any type casting.
8
- class HttpClient # rubocop:disable Metrics/ClassLength
8
+ class HttpClient
9
9
  module AuthMethod
10
10
  BEARER = 1
11
11
  BASIC = 2
@@ -16,6 +16,7 @@ module Nylas
16
16
  attribute :status, :string, read_only: true
17
17
  attribute :created_at, :unix_timestamp, read_only: true
18
18
  attribute :reason, :string, read_only: true
19
+ attribute :metadata, :hash, read_only: true
19
20
 
20
21
  # Returns the status of a job as a boolean
21
22
  # @return [Boolean] If the job was successful
@@ -10,5 +10,7 @@ module Nylas
10
10
  attribute :status, :string
11
11
  attribute :start_time, :unix_timestamp
12
12
  attribute :end_time, :unix_timestamp
13
+ attribute :capacity, :time_slot_capacity
14
+ has_n_of_attribute :emails, :string
13
15
  end
14
16
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Capacity values for a timeslot
5
+ # @see https://docs.nylas.com/reference#calendars-free-busy
6
+ class TimeSlotCapacity
7
+ include Model::Attributable
8
+
9
+ attribute :event_id, :string
10
+ attribute :current_capacity, :integer
11
+ attribute :max_capacity, :integer
12
+ end
13
+ 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.9.1"
4
+ VERSION = "5.11.0"
5
5
  end
data/lib/nylas.rb CHANGED
@@ -54,6 +54,7 @@ require_relative "nylas/nylas_date"
54
54
  require_relative "nylas/when"
55
55
  require_relative "nylas/free_busy"
56
56
  require_relative "nylas/time_slot"
57
+ require_relative "nylas/time_slot_capacity"
57
58
  require_relative "nylas/open_hours"
58
59
  require_relative "nylas/event_conferencing"
59
60
  require_relative "nylas/event_conferencing_details"
@@ -144,6 +145,7 @@ module Nylas
144
145
  Types.registry[:contact_group] = Types::ModelType.new(model: ContactGroup)
145
146
  Types.registry[:when] = Types::ModelType.new(model: When)
146
147
  Types.registry[:time_slot] = Types::ModelType.new(model: TimeSlot)
148
+ Types.registry[:time_slot_capacity] = Types::ModelType.new(model: TimeSlotCapacity)
147
149
  Types.registry[:event_conferencing] = Types::ModelType.new(model: EventConferencing)
148
150
  Types.registry[:event_conferencing_details] = Types::ModelType.new(model: EventConferencingDetails)
149
151
  Types.registry[:event_conferencing_autocreate] = Types::ModelType.new(model: EventConferencingAutocreate)
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.9.1
4
+ version: 5.11.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: 2022-04-20 00:00:00.000000000 Z
11
+ date: 2022-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -347,6 +347,7 @@ files:
347
347
  - lib/nylas/send_grid_verified_status.rb
348
348
  - lib/nylas/thread.rb
349
349
  - lib/nylas/time_slot.rb
350
+ - lib/nylas/time_slot_capacity.rb
350
351
  - lib/nylas/timespan.rb
351
352
  - lib/nylas/token_info.rb
352
353
  - lib/nylas/types.rb
@@ -379,7 +380,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
379
380
  - !ruby/object:Gem::Version
380
381
  version: '0'
381
382
  requirements: []
382
- rubygems_version: 3.3.3
383
+ rubygems_version: 3.3.11
383
384
  signing_key:
384
385
  specification_version: 4
385
386
  summary: Gem for interacting with the Nylas API