nylas 5.6.1 → 5.7.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: 54c46b764fd777bee7eb27539bd6dc54ad253b76a242db3cfa9c969e128c05e4
4
- data.tar.gz: 2c0876d20db34b5796ec2d6c21c487de8d661cd6041a899604b6dcf594ffa8f1
3
+ metadata.gz: 4d8d9639941076724b3e9ae95b85a2e4a48c8f663a35b03f5f26473c5c87b208
4
+ data.tar.gz: 4b2733e86538a6dd7ac3069dc5738997ea8db1b7be13b1a8de9bef5c868ec1d5
5
5
  SHA512:
6
- metadata.gz: f70e5d14160b41bb0b50fddc2a17141fd16405fc9f0460a0fbdeaf7ac9ff356332a0400167322c63e7c0a1d0673a1b234a57e1427d9682c8bf88e59e0ca2a5c6
7
- data.tar.gz: f4494a94a6bf17fc43be9af8961ce9ceb0ce9b97e76b06e598bf4214934d81561378f3519c3715a536d2b8703194bfe6ba047496e1ab425b3bdb99b18e46bc90
6
+ metadata.gz: 56b9216d9e5f37a0c449d999891a76a06e1ed8dd8925efe5186d8d59d16105da76ea3b8a5599d88a9e8e83bd2862bc71cc7491957ac8c8da8718a825af2a2a2a
7
+ data.tar.gz: 5fa04ae09e9692f0c954926ae8e7d541388597a12a154dd8bf82b78c40e91b7b9b73508c5d39b6a2c604ed5d53f5eec86379687dc9b79da81b4a8571d0500460
data/lib/nylas/account.rb CHANGED
@@ -8,6 +8,7 @@ module Nylas
8
8
  self.listable = true
9
9
  self.showable = true
10
10
  self.updatable = true
11
+ self.destroyable = true
11
12
 
12
13
  attribute :id, :string, read_only: true
13
14
  attribute :account_id, :string, read_only: true
@@ -36,6 +37,15 @@ module Nylas
36
37
  response[:success]
37
38
  end
38
39
 
40
+ # Return information about an account's access token
41
+ # @param access_token [String] The access token to inquire about
42
+ # @return [TokenInfo] The access token information
43
+ def token_info(access_token)
44
+ payload = JSON.dump(access_token: access_token)
45
+ response = execute(method: :post, path: "#{resource_path}/token-info", payload: payload)
46
+ TokenInfo.new(**response)
47
+ end
48
+
39
49
  def self.resources_path(api:)
40
50
  "/a/#{api.app_id}/accounts"
41
51
  end
data/lib/nylas/api.rb CHANGED
@@ -130,6 +130,11 @@ module Nylas
130
130
  @room_resources ||= Collection.new(model: RoomResource, api: self)
131
131
  end
132
132
 
133
+ # @return[Collection<JobStatus>] A queryable collection of {JobStatus} objects
134
+ def job_statuses
135
+ @job_statuses ||= Collection.new(model: JobStatus, api: self)
136
+ end
137
+
133
138
  # @return[SchedulerCollection<Scheduler>] A queryable collection of {Scheduler} objects
134
139
  def scheduler
135
140
  # Make a deep copy of the API as the scheduler API uses a different base URL
@@ -155,6 +160,25 @@ module Nylas
155
160
  response.code == 200 && response.empty?
156
161
  end
157
162
 
163
+ # Returns the application details
164
+ # @return [ApplicationDetail] The application details
165
+ def application_details
166
+ response = client.as(client.app_secret).execute(method: :get, path: "/a/#{app_id}")
167
+ ApplicationDetail.new(**response)
168
+ end
169
+
170
+ # Updates the application details
171
+ # @param application_details [ApplicationDetail] The updated application details
172
+ # @return [ApplicationDetails] The updated application details, returned from the server
173
+ def update_application_details(application_details)
174
+ response = client.as(client.app_secret).execute(
175
+ method: :put,
176
+ path: "/a/#{app_id}",
177
+ payload: JSON.dump(application_details.to_h)
178
+ )
179
+ ApplicationDetail.new(**response)
180
+ end
181
+
158
182
  # Returns list of IP addresses
159
183
  # @return [Hash]
160
184
  # hash has keys of :updated_at (unix timestamp) and :ip_addresses (array of strings)
@@ -172,7 +196,7 @@ module Nylas
172
196
  end
173
197
 
174
198
  # Allows you to get an API that acts as a different user but otherwise has the same settings
175
- # @param [String] Oauth Access token or app secret used to authenticate with the API
199
+ # @param access_token [String] Oauth Access token or app secret used to authenticate with the API
176
200
  # @return [API]
177
201
  def as(access_token)
178
202
  API.new(client: client.as(access_token))
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Structure to represent a Nylas Application Detail object.
5
+ # @see https://developer.nylas.com/docs/api/#get/a/client_id
6
+ class ApplicationDetail
7
+ include Model::Attributable
8
+
9
+ attribute :application_name, :string
10
+ attribute :icon_url, :string
11
+ has_n_of_attribute :redirect_uris, :string
12
+ end
13
+ end
@@ -22,6 +22,7 @@ module Nylas
22
22
 
23
23
  attribute :read_only, :boolean
24
24
  attribute :metadata, :hash
25
+ attribute :job_status_id, :string, read_only: true
25
26
 
26
27
  def read_only?
27
28
  read_only == true
data/lib/nylas/contact.rb CHANGED
@@ -30,6 +30,7 @@ module Nylas
30
30
  attribute :office_location, :string
31
31
  attribute :notes, :string
32
32
  attribute :source, :string
33
+ attribute :job_status_id, :string, read_only: true
33
34
 
34
35
  has_n_of_attribute :groups, :contact_group
35
36
  has_n_of_attribute :emails, :email_address
data/lib/nylas/draft.rb CHANGED
@@ -36,6 +36,7 @@ module Nylas
36
36
  has_n_of_attribute :labels, :label
37
37
 
38
38
  attribute :tracking, :message_tracking
39
+ attribute :job_status_id, :string, read_only: true
39
40
 
40
41
  transfer :api, to: %i[events files folder labels]
41
42
 
data/lib/nylas/event.rb CHANGED
@@ -31,6 +31,7 @@ module Nylas
31
31
  attribute :conferencing, :event_conferencing
32
32
  has_n_of_attribute :notifications, :event_notification
33
33
  attribute :original_start_time, :unix_timestamp
34
+ attribute :job_status_id, :string, read_only: true
34
35
 
35
36
  attr_accessor :notify_participants
36
37
 
@@ -59,8 +60,47 @@ module Nylas
59
60
  rsvp.save
60
61
  end
61
62
 
63
+ # Generate an ICS file server-side, from an Event
64
+ # @param ical_uid [String] Unique identifier used events across calendaring systems
65
+ # @param method [String] Description of invitation and response methods for attendees
66
+ # @param prodid [String] Company-specific unique product identifier
67
+ # @return [String] String for writing directly into an ICS file
68
+ def generate_ics(ical_uid: nil, method: nil, prodid: nil)
69
+ raise ArgumentError, "Cannot generate an ICS file for an event without a Calendar ID or when set" unless
70
+ calendar_id && self.when
71
+
72
+ payload = build_ics_event_payload(ical_uid, method, prodid)
73
+ response = api.execute(
74
+ method: :post,
75
+ path: "#{resources_path}/to-ics",
76
+ payload: JSON.dump(payload)
77
+ )
78
+
79
+ response[:ics]
80
+ end
81
+
62
82
  private
63
83
 
84
+ def build_ics_event_payload(ical_uid, method, prodid)
85
+ payload = {}
86
+ if id
87
+ payload[:event_id] = id
88
+ else
89
+ payload = to_h(enforce_read_only: true)
90
+ end
91
+ ics_options = build_ics_options_payload(ical_uid, method, prodid)
92
+ payload["ics_options"] = ics_options unless ics_options.empty?
93
+ payload
94
+ end
95
+
96
+ def build_ics_options_payload(ical_uid, method, prodid)
97
+ payload = {}
98
+ payload["ical_uid"] = ical_uid if ical_uid
99
+ payload["method"] = method if method
100
+ payload["prodid"] = prodid if prodid
101
+ payload
102
+ end
103
+
64
104
  def query_params
65
105
  if notify_participants.nil?
66
106
  {}
data/lib/nylas/folder.rb CHANGED
@@ -13,12 +13,12 @@ module Nylas
13
13
  self.updatable = true
14
14
  self.destroyable = true
15
15
 
16
- attribute :id, :string
17
- attribute :account_id, :string
18
-
19
- attribute :object, :string
16
+ attribute :id, :string, read_only: true
17
+ attribute :account_id, :string, read_only: true
18
+ attribute :object, :string, read_only: true
20
19
 
21
20
  attribute :name, :string
22
21
  attribute :display_name, :string
22
+ attribute :job_status_id, :string, read_only: true
23
23
  end
24
24
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Ruby representation of a Nylas Job Status object
5
+ # @see https://developer.nylas.com/docs/api/#tag--Job-Status
6
+ class JobStatus
7
+ include Model
8
+ self.resources_path = "/job-statuses"
9
+ allows_operations(listable: true)
10
+
11
+ attribute :id, :string, read_only: true
12
+ attribute :account_id, :string, read_only: true
13
+ attribute :job_status_id, :string, read_only: true
14
+ attribute :action, :string, read_only: true
15
+ attribute :object, :string, read_only: true
16
+ attribute :status, :string, read_only: true
17
+ attribute :created_at, :unix_timestamp, read_only: true
18
+ attribute :original_data, :message, read_only: true
19
+
20
+ # Returns the status of a job as a boolean
21
+ # @return [Boolean] If the job was successful
22
+ def successful?
23
+ status == "successful"
24
+ end
25
+ end
26
+ end
data/lib/nylas/label.rb CHANGED
@@ -20,5 +20,6 @@ module Nylas
20
20
 
21
21
  attribute :name, :string
22
22
  attribute :display_name, :string
23
+ attribute :job_status_id, :string, read_only: true
23
24
  end
24
25
  end
data/lib/nylas/message.rb CHANGED
@@ -37,6 +37,7 @@ module Nylas
37
37
  attribute :folder, :folder
38
38
  attribute :folder_id, :string
39
39
  attribute :metadata, :hash
40
+ attribute :job_status_id, :string, read_only: true
40
41
 
41
42
  has_n_of_attribute :labels, :label, read_only: true
42
43
  has_n_of_attribute :label_ids, :string
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # Structure to represent information about a Nylas access token.
5
+ # @see https://developer.nylas.com/docs/api/#post/a/client_id/accounts/id/token-info
6
+ class TokenInfo
7
+ include Model::Attributable
8
+
9
+ attribute :scopes, :string
10
+ attribute :state, :string
11
+ attribute :created_at, :unix_timestamp
12
+ attribute :updated_at, :unix_timestamp
13
+
14
+ # Returns the state of the token as a boolean
15
+ # @return [Boolean] If the token is active
16
+ def valid?
17
+ state == "valid"
18
+ end
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.6.1"
4
+ VERSION = "5.7.0"
5
5
  end
data/lib/nylas.rb CHANGED
@@ -84,6 +84,9 @@ require_relative "nylas/raw_message"
84
84
  require_relative "nylas/thread"
85
85
  require_relative "nylas/webhook"
86
86
  require_relative "nylas/scheduler"
87
+ require_relative "nylas/job_status"
88
+ require_relative "nylas/token_info"
89
+ require_relative "nylas/application_details"
87
90
 
88
91
  # Neural specific types
89
92
  require_relative "nylas/neural"
@@ -148,4 +151,5 @@ module Nylas
148
151
  Types.registry[:neural_contact_name] = Types::ModelType.new(model: NeuralContactName)
149
152
  Types.registry[:scheduler_config] = Types::ModelType.new(model: SchedulerConfig)
150
153
  Types.registry[:scheduler_time_slot] = Types::ModelType.new(model: SchedulerTimeSlot)
154
+ Types.registry[:job_status] = Types::ModelType.new(model: JobStatus)
151
155
  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.6.1
4
+ version: 5.7.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-12-13 00:00:00.000000000 Z
11
+ date: 2022-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.52.0
61
+ version: 1.24.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.52.0
68
+ version: 1.24.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop-rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.20.1
75
+ version: 2.7.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.20.1
82
+ version: 2.7.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: overcommit
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -269,6 +269,7 @@ files:
269
269
  - lib/nylas.rb
270
270
  - lib/nylas/account.rb
271
271
  - lib/nylas/api.rb
272
+ - lib/nylas/application_details.rb
272
273
  - lib/nylas/calendar.rb
273
274
  - lib/nylas/calendar_collection.rb
274
275
  - lib/nylas/categorize.rb
@@ -298,6 +299,7 @@ files:
298
299
  - lib/nylas/free_busy_collection.rb
299
300
  - lib/nylas/http_client.rb
300
301
  - lib/nylas/im_address.rb
302
+ - lib/nylas/job_status.rb
301
303
  - lib/nylas/label.rb
302
304
  - lib/nylas/logging.rb
303
305
  - lib/nylas/message.rb
@@ -341,6 +343,7 @@ files:
341
343
  - lib/nylas/thread.rb
342
344
  - lib/nylas/time_slot.rb
343
345
  - lib/nylas/timespan.rb
346
+ - lib/nylas/token_info.rb
344
347
  - lib/nylas/types.rb
345
348
  - lib/nylas/version.rb
346
349
  - lib/nylas/web_page.rb