nylas 5.10.0 → 5.12.1

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: 8dfc25b74725b0ba024320c432c69a1318f4b5524f550323d493b59aeb70e181
4
- data.tar.gz: 0a50c968682d1b718aecdf7aaacfd32ea324e8d89c8db2c1f9369142189cf350
3
+ metadata.gz: c1e352b09e650aa0cbc5dff7363b8a0997aab35c94e73a5f4a77b5503de70448
4
+ data.tar.gz: a7830ea4cc6a9028669ca6c0e502cba4f2dfc70402a2c00f85cd1f6d315d0594
5
5
  SHA512:
6
- metadata.gz: 439de1cc121378d1438047d4e2399faa5cd3ec3efcf5647a1dbefa4b858191c83bc0d4bcfb58d3795be30cf9627feaa17828b33ed916bb2a310778cbd64c6e91
7
- data.tar.gz: 0a5a619c18eadad1a5a81fa85e528303e172bef906746cbde9bd2baba5647213e2ff0e7f5cab634bdfc9adf9dc8489b18e159618348973df452d2a50aa6295f2
6
+ metadata.gz: 7aeed921859461105491d8394f845b79d6419ecc10a17ae0989f2239382cce8e4ad1fb3936bd7a4cebd730e40bac60b28dafe8e145e63a10d424a9e9b46915f0
7
+ data.tar.gz: 47fdeaa77f5e1037934fc421b7b869edc031f956aad054d2888d29aee0a75ecb537c063e4c89e3c30e4f14f2be2da0860b5ec546e39034590f137773b73ef3cc
data/lib/nylas/api.rb CHANGED
@@ -35,15 +35,19 @@ module Nylas
35
35
  )
36
36
  end
37
37
 
38
- def authentication_url(redirect_uri:, scopes:, response_type: "code", login_hint: nil, state: nil)
38
+ def authentication_url(redirect_uri:, scopes:, response_type: "code", login_hint: nil, state: nil,
39
+ provider: nil, redirect_on_error: nil)
39
40
  params = {
40
41
  client_id: app_id,
41
42
  redirect_uri: redirect_uri,
42
43
  response_type: response_type,
43
44
  login_hint: login_hint
44
45
  }
46
+
45
47
  params[:state] = state if state
46
48
  params[:scopes] = scopes.join(",") if scopes
49
+ params[:provider] = provider if provider
50
+ params[:redirect_on_error] = redirect_on_error if redirect_on_error
47
51
 
48
52
  "#{api_server}/oauth/authorize?#{URI.encode_www_form(params)}"
49
53
  end
@@ -6,8 +6,14 @@ module Nylas
6
6
  class Calendar
7
7
  include Model
8
8
  self.resources_path = "/calendars"
9
- allows_operations(creatable: true, listable: true, filterable: true, showable: true, updatable: true,
10
- destroyable: true)
9
+ self.creatable = true
10
+ self.listable = true
11
+ self.showable = true
12
+ self.filterable = true
13
+ self.updatable = true
14
+ self.destroyable = true
15
+ self.id_listable = true
16
+ self.countable = true
11
17
 
12
18
  attribute :id, :string
13
19
  attribute :account_id, :string
@@ -31,18 +31,21 @@ module Nylas
31
31
  validate_calendars_or_emails(calendars, emails)
32
32
  validate_open_hours(emails, free_busy, open_hours) unless open_hours.empty?
33
33
 
34
- execute_availability("/calendars/availability",
35
- duration_minutes: duration_minutes,
36
- interval_minutes: interval_minutes,
37
- start_time: start_time,
38
- end_time: end_time,
39
- emails: emails,
40
- buffer: buffer,
41
- round_robin: round_robin,
42
- event_collection_id: event_collection_id,
43
- free_busy: free_busy.map(&:to_h),
44
- open_hours: open_hours.map(&:to_h),
45
- calendars: calendars)
34
+ payload = {
35
+ duration_minutes: duration_minutes,
36
+ interval_minutes: interval_minutes,
37
+ start_time: start_time,
38
+ end_time: end_time,
39
+ emails: emails,
40
+ free_busy: free_busy.map(&:to_h),
41
+ open_hours: open_hours.map(&:to_h),
42
+ calendars: calendars
43
+ }
44
+ payload[:buffer] = buffer if buffer
45
+ payload[:round_robin] = round_robin if round_robin
46
+ payload[:event_collection_id] = event_collection_id if event_collection_id
47
+
48
+ execute_availability("/calendars/availability", **payload)
46
49
  end
47
50
 
48
51
  # Check multiple calendars to find availability for multiple meetings with several participants
@@ -68,16 +71,19 @@ module Nylas
68
71
  validate_calendars_or_emails(emails, calendars)
69
72
  validate_open_hours(emails, free_busy, open_hours) unless open_hours.empty?
70
73
 
71
- execute_availability("/calendars/availability/consecutive",
72
- duration_minutes: duration_minutes,
73
- interval_minutes: interval_minutes,
74
- start_time: start_time,
75
- end_time: end_time,
76
- emails: emails,
77
- buffer: buffer,
78
- free_busy: free_busy.map(&:to_h),
79
- open_hours: open_hours.map(&:to_h),
80
- calendars: calendars)
74
+ payload = {
75
+ duration_minutes: duration_minutes,
76
+ interval_minutes: interval_minutes,
77
+ start_time: start_time,
78
+ end_time: end_time,
79
+ emails: emails,
80
+ free_busy: free_busy.map(&:to_h),
81
+ open_hours: open_hours.map(&:to_h),
82
+ calendars: calendars
83
+ }
84
+ payload[:buffer] = buffer if buffer
85
+
86
+ execute_availability("/calendars/availability/consecutive", **payload)
81
87
  end
82
88
 
83
89
  private
@@ -17,7 +17,7 @@ module Nylas
17
17
 
18
18
  # Instantiates a new model
19
19
  def new(**attributes)
20
- model.new(attributes.merge(api: api))
20
+ model.new(**attributes.merge(api: api))
21
21
  end
22
22
 
23
23
  def create(**attributes)
@@ -51,7 +51,14 @@ module Nylas
51
51
 
52
52
  # @return [Integer]
53
53
  def count
54
- self.class.new(model: model, api: api, constraints: constraints.merge(view: "count")).execute[:count]
54
+ collection = self.class.new(model: model, api: api, constraints: constraints)
55
+
56
+ if model.countable
57
+ collection.constraints = collection.constraints.merge(view: "count")
58
+ collection.execute[:count]
59
+ else
60
+ collection.find_each.map.count
61
+ end
55
62
  end
56
63
 
57
64
  # @return [Collection<Model>]
@@ -61,7 +68,14 @@ module Nylas
61
68
 
62
69
  # @return [Array<String>]
63
70
  def ids
64
- self.class.new(model: model, api: api, constraints: constraints.merge(view: "ids")).execute
71
+ collection = self.class.new(model: model, api: api, constraints: constraints)
72
+
73
+ if model.id_listable
74
+ collection.constraints = collection.constraints.merge(view: "ids")
75
+ collection.execute
76
+ else
77
+ collection.find_each.map(&:id)
78
+ end
65
79
  end
66
80
 
67
81
  # Iterates over a single page of results based upon current pagination settings
@@ -4,8 +4,12 @@ module Nylas
4
4
  # Structure to represent a the Component Schema.
5
5
  class Component
6
6
  include Model
7
- allows_operations(creatable: true, listable: true, filterable: true, showable: true, updatable: true,
8
- destroyable: true)
7
+ self.creatable = true
8
+ self.listable = true
9
+ self.showable = true
10
+ self.filterable = true
11
+ self.updatable = true
12
+ self.destroyable = true
9
13
  self.auth_method = HttpClient::AuthMethod::BASIC
10
14
 
11
15
  attribute :id, :string, read_only: true
data/lib/nylas/deltas.rb CHANGED
@@ -8,7 +8,7 @@ module Nylas
8
8
  class Deltas
9
9
  include Model
10
10
  self.resources_path = "/delta"
11
- allows_operations(filterable: true)
11
+ self.filterable = true
12
12
  has_n_of_attribute :deltas, :delta
13
13
  attribute :cursor_start, :string
14
14
  attribute :cursor_end, :string
data/lib/nylas/draft.rb CHANGED
@@ -6,7 +6,13 @@ module Nylas
6
6
  class Draft
7
7
  include Model
8
8
  self.resources_path = "/drafts"
9
- allows_operations(creatable: true, showable: true, listable: true, updatable: true, destroyable: true)
9
+ self.creatable = true
10
+ self.listable = true
11
+ self.showable = true
12
+ self.updatable = true
13
+ self.destroyable = true
14
+ self.id_listable = true
15
+ self.countable = true
10
16
 
11
17
  attribute :id, :string
12
18
  attribute :object, :string
data/lib/nylas/event.rb CHANGED
@@ -6,8 +6,14 @@ module Nylas
6
6
  class Event
7
7
  include Model
8
8
  self.resources_path = "/events"
9
- allows_operations(creatable: true, listable: true, filterable: true, showable: true, updatable: true,
10
- destroyable: true)
9
+ self.creatable = true
10
+ self.listable = true
11
+ self.showable = true
12
+ self.filterable = true
13
+ self.updatable = true
14
+ self.destroyable = true
15
+ self.id_listable = true
16
+ self.countable = true
11
17
 
12
18
  attribute :id, :string, read_only: true
13
19
  attribute :object, :string, read_only: true
@@ -34,6 +40,8 @@ module Nylas
34
40
  has_n_of_attribute :notifications, :event_notification
35
41
  has_n_of_attribute :round_robin_order, :string
36
42
  attribute :original_start_time, :unix_timestamp
43
+ attribute :reminder_minutes, :string
44
+ attribute :reminder_method, :string
37
45
  attribute :job_status_id, :string, read_only: true
38
46
 
39
47
  attr_accessor :notify_participants
@@ -48,6 +56,7 @@ module Nylas
48
56
 
49
57
  def save
50
58
  validate
59
+ format_reminder_minutes
51
60
 
52
61
  super
53
62
  end
@@ -111,6 +120,13 @@ module Nylas
111
120
  payload
112
121
  end
113
122
 
123
+ # Formats the reminder minute field to match the API format: "[%d]"
124
+ def format_reminder_minutes
125
+ return if reminder_minutes.nil? || reminder_minutes.empty? || reminder_minutes.match(/\[\d+\]/)
126
+
127
+ self.reminder_minutes = "[#{reminder_minutes}]"
128
+ end
129
+
114
130
  def query_params
115
131
  if notify_participants.nil?
116
132
  {}
data/lib/nylas/file.rb CHANGED
@@ -6,7 +6,13 @@ 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, destroyable: true)
9
+ self.creatable = true
10
+ self.listable = true
11
+ self.showable = true
12
+ self.filterable = true
13
+ self.destroyable = true
14
+ self.id_listable = true
15
+ self.countable = true
10
16
 
11
17
  attribute :id, :string
12
18
  attribute :account_id, :string
data/lib/nylas/folder.rb CHANGED
@@ -12,6 +12,8 @@ module Nylas
12
12
  self.filterable = false
13
13
  self.updatable = true
14
14
  self.destroyable = true
15
+ self.id_listable = true
16
+ self.countable = true
15
17
 
16
18
  attribute :id, :string, read_only: true
17
19
  attribute :account_id, :string, read_only: true
@@ -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
@@ -6,7 +6,7 @@ module Nylas
6
6
  class JobStatus
7
7
  include Model
8
8
  self.resources_path = "/job-statuses"
9
- allows_operations(listable: true)
9
+ self.listable = true
10
10
 
11
11
  attribute :id, :string, read_only: true
12
12
  attribute :account_id, :string, read_only: true
@@ -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
data/lib/nylas/label.rb CHANGED
@@ -12,6 +12,8 @@ module Nylas
12
12
  self.filterable = false
13
13
  self.updatable = true
14
14
  self.destroyable = true
15
+ self.id_listable = true
16
+ self.countable = true
15
17
 
16
18
  attribute :id, :string
17
19
  attribute :account_id, :string
data/lib/nylas/message.rb CHANGED
@@ -7,7 +7,13 @@ module Nylas
7
7
  include Model
8
8
  self.raw_mime_type = "message/rfc822"
9
9
  self.resources_path = "/messages"
10
- allows_operations(showable: true, listable: true, filterable: true, searchable: true, updatable: true)
10
+ self.listable = true
11
+ self.showable = true
12
+ self.filterable = true
13
+ self.updatable = true
14
+ self.searchable = true
15
+ self.id_listable = true
16
+ self.countable = true
11
17
  UPDATABLE_ATTRIBUTES = %i[label_ids folder_id starred unread metadata].freeze
12
18
 
13
19
  attribute :id, :string
@@ -37,6 +43,7 @@ module Nylas
37
43
  attribute :folder, :folder
38
44
  attribute :folder_id, :string
39
45
  attribute :metadata, :hash
46
+ attribute :reply_to_message_id, :string, read_only: true
40
47
  attribute :job_status_id, :string, read_only: true
41
48
 
42
49
  has_n_of_attribute :labels, :label, read_only: true
data/lib/nylas/model.rb CHANGED
@@ -20,8 +20,8 @@ module Nylas
20
20
  model.extend(ClassMethods)
21
21
  model.extend(Forwardable)
22
22
  model.def_delegators :model_class, :creatable?, :filterable?, :listable?, :searchable?, :showable?,
23
- :updatable?, :destroyable?
24
- model.allows_operations
23
+ :updatable?, :destroyable?, :id_listable?, :countable?
24
+ model.init_operations
25
25
  end
26
26
 
27
27
  def save
@@ -141,19 +141,19 @@ module Nylas
141
141
  # Allows you to narrow in exactly what kind of model you're working with
142
142
  module ClassMethods
143
143
  attr_accessor :raw_mime_type, :creatable, :showable, :filterable, :searchable, :listable, :updatable,
144
- :destroyable
144
+ :destroyable, :id_listable, :countable
145
145
  attr_writer :resources_path, :auth_method
146
146
 
147
- def allows_operations(creatable: false, showable: false, listable: false, filterable: false,
148
- searchable: false, updatable: false, destroyable: false)
149
-
150
- self.creatable ||= creatable
151
- self.showable ||= showable
152
- self.listable ||= listable
153
- self.filterable ||= filterable
154
- self.searchable ||= searchable
155
- self.updatable ||= updatable
156
- self.destroyable ||= destroyable
147
+ def init_operations
148
+ self.creatable = false
149
+ self.showable = false
150
+ self.listable = false
151
+ self.filterable = false
152
+ self.searchable = false
153
+ self.updatable = false
154
+ self.destroyable = false
155
+ self.id_listable = false
156
+ self.countable = false
157
157
  end
158
158
 
159
159
  def creatable?
@@ -184,6 +184,14 @@ module Nylas
184
184
  destroyable
185
185
  end
186
186
 
187
+ def id_listable?
188
+ id_listable
189
+ end
190
+
191
+ def countable?
192
+ countable
193
+ end
194
+
187
195
  def resources_path(*)
188
196
  @resources_path
189
197
  end
@@ -6,7 +6,7 @@ module Nylas
6
6
  class NeuralCategorizer < Message
7
7
  include Model
8
8
  self.resources_path = "/neural/categorize"
9
- allows_operations(listable: true)
9
+ self.listable = true
10
10
 
11
11
  attribute :categorizer, :categorize
12
12
  # Overrides Message's label attribute as currently categorize returns
@@ -6,7 +6,7 @@ module Nylas
6
6
  class NeuralCleanConversation < Message
7
7
  include Model
8
8
  self.resources_path = "/neural/conversation"
9
- allows_operations(listable: true)
9
+ self.listable = true
10
10
  IMAGE_REGEX = /[(']cid:(.*?)[)']/.freeze
11
11
 
12
12
  attribute :conversation, :string
@@ -6,7 +6,7 @@ module Nylas
6
6
  class NeuralOcr < File
7
7
  include Model
8
8
  self.resources_path = "/neural/ocr"
9
- allows_operations(listable: true)
9
+ self.listable = true
10
10
 
11
11
  has_n_of_attribute :ocr, :string
12
12
  attribute :processed_pages, :integer
@@ -6,7 +6,7 @@ module Nylas
6
6
  class NeuralSentimentAnalysis
7
7
  include Model
8
8
  self.resources_path = "/neural/sentiment"
9
- allows_operations(listable: true)
9
+ self.listable = true
10
10
 
11
11
  attribute :account_id, :string
12
12
  attribute :sentiment, :string
@@ -6,7 +6,7 @@ module Nylas
6
6
  class RoomResource
7
7
  include Model
8
8
  self.resources_path = "/resources"
9
- allows_operations(listable: true)
9
+ self.listable = true
10
10
 
11
11
  attribute :object, :string, read_only: true
12
12
  attribute :email, :string, read_only: true
data/lib/nylas/rsvp.rb CHANGED
@@ -5,7 +5,7 @@ module Nylas
5
5
  # @see https://docs.nylas.com/reference#rsvping-to-invitations
6
6
  class Rsvp
7
7
  include Model
8
- allows_operations(creatable: true)
8
+ self.creatable = true
9
9
 
10
10
  attribute :account_id, :string
11
11
  attribute :event_id, :string
@@ -6,8 +6,12 @@ module Nylas
6
6
  class Scheduler
7
7
  include Model
8
8
  self.resources_path = "/manage/pages"
9
- allows_operations(creatable: true, listable: true, filterable: true, showable: true, updatable: true,
10
- destroyable: true)
9
+ self.creatable = true
10
+ self.listable = true
11
+ self.showable = true
12
+ self.filterable = true
13
+ self.updatable = true
14
+ self.destroyable = true
11
15
 
12
16
  attribute :id, :integer, read_only: true
13
17
  attribute :app_client_id, :string
data/lib/nylas/thread.rb CHANGED
@@ -5,7 +5,12 @@ module Nylas
5
5
  # @see https://docs.nylas.com/reference#threads
6
6
  class Thread
7
7
  include Model
8
- allows_operations(searchable: true, filterable: true, listable: true, updatable: true)
8
+ self.searchable = true
9
+ self.listable = true
10
+ self.filterable = true
11
+ self.updatable = true
12
+ self.id_listable = true
13
+ self.countable = true
9
14
 
10
15
  self.resources_path = "/threads"
11
16
 
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.10.0"
4
+ VERSION = "5.12.1"
5
5
  end
data/lib/nylas/webhook.rb CHANGED
@@ -41,8 +41,11 @@ module Nylas
41
41
  # @see https://docs.nylas.com/reference#webhooks
42
42
  class Webhook
43
43
  include Model
44
- allows_operations(creatable: true, listable: true, showable: true, updatable: true,
45
- destroyable: true)
44
+ self.creatable = true
45
+ self.listable = true
46
+ self.showable = true
47
+ self.updatable = true
48
+ self.destroyable = true
46
49
  self.auth_method = HttpClient::AuthMethod::BASIC
47
50
  attribute :id, :string, read_only: true
48
51
  attribute :application_id, :string, read_only: true
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.10.0
4
+ version: 5.12.1
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-05-10 00:00:00.000000000 Z
11
+ date: 2022-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -380,7 +380,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
380
380
  - !ruby/object:Gem::Version
381
381
  version: '0'
382
382
  requirements: []
383
- rubygems_version: 3.3.3
383
+ rubygems_version: 3.3.7
384
384
  signing_key:
385
385
  specification_version: 4
386
386
  summary: Gem for interacting with the Nylas API