nylas 5.1.0 → 5.2.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: d2f677958900566f6aeb941f450e9bbe3b4dfd54f57c4cf4b87bb403f968f731
4
- data.tar.gz: 5f4eb58cf5835a43a4034229d506d7662923fa110c4fe5e352f9d867ac69b295
3
+ metadata.gz: c6b0265bb93198dcc5494a819c68a5261703a143a4fe320a4662cc6c65aa2e94
4
+ data.tar.gz: ee107c7cacfb2b7e2b099fd675c20c02700def063e1ccdd6b46923448da9e25b
5
5
  SHA512:
6
- metadata.gz: c727f58c5ecaeaca411d346b23d2176f8114f1cc441347326c8c26239f3ef78626007a443f89932fc955c68c295229d238a647cb7f42234f11d31fc0d02ec7e9
7
- data.tar.gz: e1ce86d59fcdc7c7193688faf95833978e106fb5e0ea5166f009f9f06234e9a724e363b21133b6636c14398e4dcc177853347b13a5c821af765deaf5900a0cc4
6
+ metadata.gz: 4e7aca3de25b0e2847011c4b190960405a214e8905429ba2743f9d3bd068d41e60cb36ad7365d298f685eb47979c30df0397996212d784c26e20e54f32b874aa
7
+ data.tar.gz: 8fc30003aa6609694e5f2a7aedf2c949e2f191c45a0edea6045669d918c3ff88cdfc837046ec409815f67c255b7a1184586532878988166cd39865c8517f00fe
data/lib/nylas.rb CHANGED
@@ -69,6 +69,7 @@ require_relative "nylas/deltas"
69
69
  require_relative "nylas/delta"
70
70
  require_relative "nylas/draft"
71
71
  require_relative "nylas/message"
72
+ require_relative "nylas/room_resource"
72
73
  require_relative "nylas/new_message"
73
74
  require_relative "nylas/raw_message"
74
75
  require_relative "nylas/thread"
@@ -94,6 +95,7 @@ module Nylas
94
95
  Types.registry[:folder] = Types::ModelType.new(model: Folder)
95
96
  Types.registry[:im_address] = Types::ModelType.new(model: IMAddress)
96
97
  Types.registry[:label] = Types::ModelType.new(model: Label)
98
+ Types.registry[:room_resource] = Types::ModelType.new(model: RoomResource)
97
99
  Types.registry[:message] = Types::ModelType.new(model: Message)
98
100
  Types.registry[:message_headers] = MessageHeadersType.new
99
101
  Types.registry[:message_tracking] = Types::ModelType.new(model: MessageTracking)
data/lib/nylas/api.rb CHANGED
@@ -16,13 +16,11 @@ module Nylas
16
16
  # @param access_token [String] (Optional) Your users access token.
17
17
  # @param api_server [String] (Optional) Which Nylas API Server to connect to. Only change this if
18
18
  # you're using a self-hosted Nylas instance.
19
- # @param service_domain [String] (Optional) Host you are authenticating OAuth against.
20
19
  # @return [Nylas::API]
21
20
  def initialize(client: nil, app_id: nil, app_secret: nil, access_token: nil,
22
- api_server: "https://api.nylas.com", service_domain: "api.nylas.com")
21
+ api_server: "https://api.nylas.com")
23
22
  self.client = client || HttpClient.new(app_id: app_id, app_secret: app_secret,
24
- access_token: access_token, api_server: api_server,
25
- service_domain: service_domain)
23
+ access_token: access_token, api_server: api_server)
26
24
  end
27
25
 
28
26
  # @return [String] A Nylas access token for that particular user.
@@ -123,6 +121,11 @@ module Nylas
123
121
  @messages ||= Collection.new(model: Message, api: self)
124
122
  end
125
123
 
124
+ # @return[Collection<RoomResource>] A queryable collection of {RoomResource} objects
125
+ def room_resources
126
+ @room_resources ||= Collection.new(model: RoomResource, api: self)
127
+ end
128
+
126
129
  # Revokes access to the Nylas API for the given access token
127
130
  # @return [Boolean]
128
131
  def revoke(access_token)
@@ -5,6 +5,8 @@ module Nylas
5
5
 
6
6
  # Plain HTTP client that can be used to interact with the Nylas API sans any type casting.
7
7
  class HttpClient # rubocop:disable Metrics/ClassLength
8
+ HTTP_SUCCESS_CODES = [200, 302].freeze
9
+
8
10
  HTTP_CODE_TO_EXCEPTIONS = {
9
11
  400 => InvalidRequest,
10
12
  401 => UnauthorizedRequest,
@@ -34,7 +36,7 @@ module Nylas
34
36
  SUPPORTED_API_VERSION = "2.2"
35
37
 
36
38
  include Logging
37
- attr_accessor :api_server, :service_domain
39
+ attr_accessor :api_server
38
40
  attr_writer :default_headers
39
41
  attr_reader :access_token
40
42
  attr_reader :app_id
@@ -45,10 +47,8 @@ module Nylas
45
47
  # @param access_token [String] (Optional) Your users access token.
46
48
  # @param api_server [String] (Optional) Which Nylas API Server to connect to. Only change this if
47
49
  # you're using a self-hosted Nylas instance.
48
- # @param service_domain [String] (Optional) Host you are authenticating OAuth against.
49
50
  # @return [Nylas::HttpClient]
50
- def initialize(app_id:, app_secret:, access_token: nil, api_server: "https://api.nylas.com",
51
- service_domain: "api.nylas.com")
51
+ def initialize(app_id:, app_secret:, access_token: nil, api_server: "https://api.nylas.com")
52
52
  unless api_server.include?("://")
53
53
  raise "When overriding the Nylas API server address, you must include https://"
54
54
  end
@@ -57,13 +57,12 @@ module Nylas
57
57
  @access_token = access_token
58
58
  @app_secret = app_secret
59
59
  @app_id = app_id
60
- @service_domain = service_domain
61
60
  end
62
61
 
63
62
  # @return [Nylas::HttpClient[]
64
63
  def as(access_token)
65
64
  HttpClient.new(app_id: app_id, access_token: access_token,
66
- app_secret: app_secret, api_server: api_server, service_domain: service_domain)
65
+ app_secret: app_secret, api_server: api_server)
67
66
  end
68
67
 
69
68
  # Sends a request to the Nylas API and rai
@@ -177,7 +176,7 @@ module Nylas
177
176
  end
178
177
 
179
178
  def handle_anticipated_failure_mode(http_code:, response:)
180
- return if http_code == 200
179
+ return if HTTP_SUCCESS_CODES.include?(http_code)
181
180
 
182
181
  exception = HTTP_CODE_TO_EXCEPTIONS.fetch(http_code, APIError)
183
182
  parsed_response = parse_response(response)
data/lib/nylas/message.rb CHANGED
@@ -67,6 +67,8 @@ module Nylas
67
67
  return self unless headers.nil?
68
68
 
69
69
  assign(**api.execute(method: :get, path: resource_path, query: { view: "expanded" }))
70
+ # Transfer reference to the API to attributes that need it
71
+ transfer_attributes
70
72
  self
71
73
  end
72
74
 
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Ruby representation of a Nylas Room Resource object
5
+ # @see https://developer.nylas.com/docs/api/#tag--Room-Resources
6
+ class RoomResource
7
+ include Model
8
+ self.resources_path = "/resources"
9
+ allows_operations(listable: true)
10
+
11
+ attribute :object, :string, read_only: true
12
+ attribute :email, :string, read_only: true
13
+ attribute :name, :string, read_only: true
14
+ attribute :capacity, :string, read_only: true
15
+ attribute :building, :string, read_only: true
16
+ attribute :floor_name, :string, read_only: true
17
+ attribute :floor_number, :string, read_only: true
18
+ end
19
+ 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.1.0"
4
+ VERSION = "5.2.0"
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: 5.1.0
4
+ version: 5.2.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-06-07 00:00:00.000000000 Z
11
+ date: 2021-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -310,6 +310,7 @@ files:
310
310
  - lib/nylas/raw_message.rb
311
311
  - lib/nylas/recurrence.rb
312
312
  - lib/nylas/registry.rb
313
+ - lib/nylas/room_resource.rb
313
314
  - lib/nylas/rsvp.rb
314
315
  - lib/nylas/search_collection.rb
315
316
  - lib/nylas/thread.rb