nylas 5.12.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: 3e5d0a27634342959eaddf47669543e1140fa7651b4e0a62bc438bfd0cfff4d0
4
- data.tar.gz: 18cd209379fc280946c1c5c1d07a5b5b1d430fda3cee0859bc72cc71a7108e60
3
+ metadata.gz: c1e352b09e650aa0cbc5dff7363b8a0997aab35c94e73a5f4a77b5503de70448
4
+ data.tar.gz: a7830ea4cc6a9028669ca6c0e502cba4f2dfc70402a2c00f85cd1f6d315d0594
5
5
  SHA512:
6
- metadata.gz: a8ad67acdb82c2e08cc988859bef6205677019619c3abaac63d3157b67d57eb491b5562c83ea80f8851749e028c827aa44e34be8d947de07002f89c2ea3e0a90
7
- data.tar.gz: 68511185782d9586bd3530fccd6e3c5e1a8744f6662f5f369040abce1a9c664ec08ae0a2ffeed94c5a086f7fef56369d8cca917e1be85c726a4241cf7b0f19b2
6
+ metadata.gz: 7aeed921859461105491d8394f845b79d6419ecc10a17ae0989f2239382cce8e4ad1fb3936bd7a4cebd730e40bac60b28dafe8e145e63a10d424a9e9b46915f0
7
+ data.tar.gz: 47fdeaa77f5e1037934fc421b7b869edc031f956aad054d2888d29aee0a75ecb537c063e4c89e3c30e4f14f2be2da0860b5ec546e39034590f137773b73ef3cc
@@ -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
@@ -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
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
@@ -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
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
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.12.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.12.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-07-29 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