nylas 5.5.0 → 5.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nylas/account.rb +9 -7
- data/lib/nylas/api.rb +11 -7
- data/lib/nylas/calendar.rb +3 -1
- data/lib/nylas/draft.rb +3 -3
- data/lib/nylas/event.rb +1 -0
- data/lib/nylas/event_notification.rb +17 -0
- data/lib/nylas/message.rb +4 -7
- data/lib/nylas/model.rb +1 -9
- data/lib/nylas/scheduler_booking_confirmation.rb +24 -0
- data/lib/nylas/scheduler_booking_request.rb +17 -0
- data/lib/nylas/scheduler_collection.rb +104 -0
- data/lib/nylas/scheduler_time_slot.rb +14 -0
- data/lib/nylas/version.rb +1 -1
- data/lib/nylas.rb +7 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bcbd7a865f3b26271776f6e5358647e8e8d9d92d29b9e33f1e942bb0153ea80
|
4
|
+
data.tar.gz: 8a16ead2bc3cccb8f29dcdcf97cbb128722f0f68acf843a96788426c440fbe6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2678a4be307e3870b12d605f5cac42878a884ac97e562ce9cb372d2db54135d9f12ebec4422910efff329e81f4beffa59fe485192f8974832a8d8957cf622431
|
7
|
+
data.tar.gz: 8f77887a487ee85104aae6557bbdf6a39f2fd96bd5fc5265f68e7923655fed39eb2269d9a59d6fc0209ead37cc3cc8b272fbe496ad08e027e64f2c5ab841ed6e
|
data/lib/nylas/account.rb
CHANGED
@@ -7,15 +7,17 @@ module Nylas
|
|
7
7
|
include Model
|
8
8
|
self.listable = true
|
9
9
|
self.showable = true
|
10
|
+
self.updatable = true
|
10
11
|
|
11
|
-
attribute :id, :string
|
12
|
-
attribute :account_id, :string
|
13
|
-
attribute :billing_state, :string
|
14
|
-
attribute :sync_state, :string
|
15
|
-
attribute :provider, :string
|
12
|
+
attribute :id, :string, read_only: true
|
13
|
+
attribute :account_id, :string, read_only: true
|
14
|
+
attribute :billing_state, :string, read_only: true
|
15
|
+
attribute :sync_state, :string, read_only: true
|
16
|
+
attribute :provider, :string, read_only: true
|
16
17
|
|
17
|
-
attribute :email, :string
|
18
|
-
attribute :trial, :boolean
|
18
|
+
attribute :email, :string, read_only: true
|
19
|
+
attribute :trial, :boolean, read_only: true
|
20
|
+
attribute :metadata, :hash
|
19
21
|
|
20
22
|
def upgrade
|
21
23
|
response = execute(method: :post, path: "#{resource_path}/upgrade")
|
data/lib/nylas/api.rb
CHANGED
@@ -48,7 +48,11 @@ module Nylas
|
|
48
48
|
"#{api_server}/oauth/authorize?#{URI.encode_www_form(params)}"
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
# Exchanges an authorization code for an access token
|
52
|
+
# @param code [String] The authorization code to exchange
|
53
|
+
# @param return_full_response [Boolean] If true, returns the full response body instead of just the token
|
54
|
+
# @return [String | Hash] Returns just the access token as a string, or the full response as a hash
|
55
|
+
def exchange_code_for_token(code, return_full_response: false)
|
52
56
|
data = {
|
53
57
|
"client_id" => app_id,
|
54
58
|
"client_secret" => client.app_secret,
|
@@ -56,8 +60,8 @@ module Nylas
|
|
56
60
|
"code" => code
|
57
61
|
}
|
58
62
|
|
59
|
-
|
60
|
-
|
63
|
+
response = execute(method: :post, path: "/oauth/token", payload: data)
|
64
|
+
return_full_response ? response : response[:access_token]
|
61
65
|
end
|
62
66
|
|
63
67
|
# @return [Collection<Contact>] A queryable collection of Contacts
|
@@ -81,7 +85,7 @@ module Nylas
|
|
81
85
|
@accounts ||= Collection.new(model: Account, api: as(client.app_secret))
|
82
86
|
end
|
83
87
|
|
84
|
-
# @return [
|
88
|
+
# @return [CalendarCollection<Calendar>] A queryable collection of {Calendar}s
|
85
89
|
def calendars
|
86
90
|
@calendars ||= CalendarCollection.new(model: Calendar, api: self)
|
87
91
|
end
|
@@ -96,7 +100,7 @@ module Nylas
|
|
96
100
|
@drafts ||= Collection.new(model: Draft, api: self)
|
97
101
|
end
|
98
102
|
|
99
|
-
# @return [
|
103
|
+
# @return [EventCollection<Event>] A queryable collection of {Event}s
|
100
104
|
def events
|
101
105
|
@events ||= EventCollection.new(model: Event, api: self)
|
102
106
|
end
|
@@ -126,12 +130,12 @@ module Nylas
|
|
126
130
|
@room_resources ||= Collection.new(model: RoomResource, api: self)
|
127
131
|
end
|
128
132
|
|
129
|
-
# @return[
|
133
|
+
# @return[SchedulerCollection<Scheduler>] A queryable collection of {Scheduler} objects
|
130
134
|
def scheduler
|
131
135
|
# Make a deep copy of the API as the scheduler API uses a different base URL
|
132
136
|
scheduler_api = Marshal.load(Marshal.dump(self))
|
133
137
|
scheduler_api.client.api_server = "https://api.schedule.nylas.com"
|
134
|
-
@scheduler ||=
|
138
|
+
@scheduler ||= SchedulerCollection.new(model: Scheduler, api: scheduler_api)
|
135
139
|
end
|
136
140
|
|
137
141
|
# @return[Neural] A {Neural} object that provides
|
data/lib/nylas/calendar.rb
CHANGED
@@ -6,7 +6,8 @@ module Nylas
|
|
6
6
|
class Calendar
|
7
7
|
include Model
|
8
8
|
self.resources_path = "/calendars"
|
9
|
-
allows_operations(listable: true, filterable: true, showable: true
|
9
|
+
allows_operations(creatable: true, listable: true, filterable: true, showable: true, updatable: true,
|
10
|
+
destroyable: true)
|
10
11
|
|
11
12
|
attribute :id, :string
|
12
13
|
attribute :account_id, :string
|
@@ -20,6 +21,7 @@ module Nylas
|
|
20
21
|
attribute :timezone, :string
|
21
22
|
|
22
23
|
attribute :read_only, :boolean
|
24
|
+
attribute :metadata, :hash
|
23
25
|
|
24
26
|
def read_only?
|
25
27
|
read_only == true
|
data/lib/nylas/draft.rb
CHANGED
@@ -75,14 +75,14 @@ module Nylas
|
|
75
75
|
execute(method: :delete, path: resource_path, payload: attributes.serialize_for_api(keys: [:version]))
|
76
76
|
end
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
def save_call
|
78
|
+
def save
|
81
79
|
extract_file_ids!
|
82
80
|
|
83
81
|
super
|
84
82
|
end
|
85
83
|
|
84
|
+
private
|
85
|
+
|
86
86
|
def extract_file_ids!
|
87
87
|
files = self.files || []
|
88
88
|
|
data/lib/nylas/event.rb
CHANGED
@@ -29,6 +29,7 @@ module Nylas
|
|
29
29
|
attribute :when, :when
|
30
30
|
attribute :metadata, :hash
|
31
31
|
attribute :conferencing, :event_conferencing
|
32
|
+
has_n_of_attribute :notifications, :event_notification
|
32
33
|
attribute :original_start_time, :unix_timestamp
|
33
34
|
|
34
35
|
attr_accessor :notify_participants
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nylas
|
4
|
+
# Structure to represent the Event Notification object
|
5
|
+
# @see https://developer.nylas.com/docs/connectivity/calendar/event-notifications
|
6
|
+
class EventNotification
|
7
|
+
include Model::Attributable
|
8
|
+
|
9
|
+
attribute :type, :string
|
10
|
+
attribute :minutes_before_event, :integer
|
11
|
+
attribute :url, :string
|
12
|
+
attribute :payload, :string
|
13
|
+
attribute :subject, :string
|
14
|
+
attribute :body, :string
|
15
|
+
attribute :message, :string
|
16
|
+
end
|
17
|
+
end
|
data/lib/nylas/message.rb
CHANGED
@@ -8,7 +8,7 @@ module Nylas
|
|
8
8
|
self.raw_mime_type = "message/rfc822"
|
9
9
|
self.resources_path = "/messages"
|
10
10
|
allows_operations(showable: true, listable: true, filterable: true, searchable: true, updatable: true)
|
11
|
-
UPDATABLE_ATTRIBUTES = %i[label_ids folder_id starred unread].freeze
|
11
|
+
UPDATABLE_ATTRIBUTES = %i[label_ids folder_id starred unread metadata].freeze
|
12
12
|
|
13
13
|
attribute :id, :string
|
14
14
|
attribute :object, :string
|
@@ -36,6 +36,7 @@ module Nylas
|
|
36
36
|
has_n_of_attribute :files, :file
|
37
37
|
attribute :folder, :folder
|
38
38
|
attribute :folder_id, :string
|
39
|
+
attribute :metadata, :hash
|
39
40
|
|
40
41
|
has_n_of_attribute :labels, :label, read_only: true
|
41
42
|
has_n_of_attribute :label_ids, :string
|
@@ -72,14 +73,10 @@ module Nylas
|
|
72
73
|
self
|
73
74
|
end
|
74
75
|
|
75
|
-
def
|
76
|
+
def save
|
76
77
|
handle_folder
|
77
78
|
|
78
|
-
|
79
|
-
method: :put,
|
80
|
-
payload: attributes.serialize_for_api,
|
81
|
-
path: resource_path
|
82
|
-
)
|
79
|
+
super
|
83
80
|
end
|
84
81
|
|
85
82
|
def handle_folder
|
data/lib/nylas/model.rb
CHANGED
@@ -28,7 +28,7 @@ module Nylas
|
|
28
28
|
result = if persisted?
|
29
29
|
raise ModelNotUpdatableError, self unless updatable?
|
30
30
|
|
31
|
-
|
31
|
+
update_call(attributes.serialize_for_api)
|
32
32
|
else
|
33
33
|
create
|
34
34
|
end
|
@@ -120,14 +120,6 @@ module Nylas
|
|
120
120
|
|
121
121
|
private
|
122
122
|
|
123
|
-
def save_call
|
124
|
-
execute(
|
125
|
-
method: :put,
|
126
|
-
payload: attributes.serialize_for_api,
|
127
|
-
path: resource_path
|
128
|
-
)
|
129
|
-
end
|
130
|
-
|
131
123
|
def update_call(payload)
|
132
124
|
result = execute(
|
133
125
|
method: :put,
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nylas
|
4
|
+
# Structure to represent the booking response returned from the Scheduler API
|
5
|
+
class SchedulerBookingConfirmation
|
6
|
+
include Model::Attributable
|
7
|
+
attribute :id, :integer
|
8
|
+
attribute :account_id, :string
|
9
|
+
attribute :calendar_event_id, :string
|
10
|
+
attribute :calendar_id, :string
|
11
|
+
attribute :edit_hash, :string
|
12
|
+
attribute :location, :string
|
13
|
+
attribute :title, :string
|
14
|
+
attribute :recipient_email, :string
|
15
|
+
attribute :recipient_locale, :string
|
16
|
+
attribute :recipient_name, :string
|
17
|
+
attribute :recipient_tz, :string
|
18
|
+
attribute :additional_field_values, :hash
|
19
|
+
attribute :is_confirmed, :boolean
|
20
|
+
attribute :start_time, :unix_timestamp
|
21
|
+
attribute :end_time, :unix_timestamp
|
22
|
+
has_n_of_attribute :additional_emails, :string
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nylas
|
4
|
+
# Structure to represent the booking request used for the Scheduler API
|
5
|
+
class SchedulerBookingRequest
|
6
|
+
include Model::Attributable
|
7
|
+
attribute :additional_values, :hash
|
8
|
+
attribute :email, :string
|
9
|
+
attribute :locale, :string
|
10
|
+
attribute :name, :string
|
11
|
+
attribute :page_hostname, :string
|
12
|
+
attribute :replaces_booking_hash, :string
|
13
|
+
attribute :timezone, :string
|
14
|
+
attribute :slot, :scheduler_time_slot
|
15
|
+
has_n_of_attribute :additional_emails, :string
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nylas
|
4
|
+
# Additional methods for some of Scheduler's other functionality
|
5
|
+
# @see https://developer.nylas.com/docs/api/scheduler#overview
|
6
|
+
class SchedulerCollection < Collection
|
7
|
+
# Retrieve Google availability
|
8
|
+
# @return [Hash] Returns the availability
|
9
|
+
def get_google_availability
|
10
|
+
execute_provider_availability("google")
|
11
|
+
end
|
12
|
+
|
13
|
+
# Retrieve Office 365 availability
|
14
|
+
# @return [Hash] Returns the availability
|
15
|
+
def get_office_365_availability
|
16
|
+
execute_provider_availability("o365")
|
17
|
+
end
|
18
|
+
|
19
|
+
# Retrieve public config for a scheduling page
|
20
|
+
# @param slug [String] The Scheduler page slug
|
21
|
+
# @return [Scheduler] Returns the Scheduler object representing the page configuration
|
22
|
+
def get_page_slug(slug)
|
23
|
+
page_response = api.execute(
|
24
|
+
method: :get,
|
25
|
+
path: "/schedule/#{slug}/info"
|
26
|
+
)
|
27
|
+
|
28
|
+
Scheduler.new(**page_response.merge(api: api))
|
29
|
+
end
|
30
|
+
|
31
|
+
# Retrieve available time slots
|
32
|
+
# @param slug [String] The Scheduler page slug
|
33
|
+
# @return [Array<SchedulerTimeSlot>] Returns the list of available timeslots
|
34
|
+
def get_available_time_slots(slug)
|
35
|
+
response = api.execute(
|
36
|
+
method: :get,
|
37
|
+
path: "/schedule/#{slug}/timeslots"
|
38
|
+
)
|
39
|
+
|
40
|
+
timeslots = []
|
41
|
+
response.each do |available_slot|
|
42
|
+
timeslots.push(SchedulerTimeSlot.new(**available_slot.merge(api: api)))
|
43
|
+
end
|
44
|
+
timeslots
|
45
|
+
end
|
46
|
+
|
47
|
+
# Book a time slot
|
48
|
+
# @param slug [String] The Scheduler page slug
|
49
|
+
# @param timeslot [SchedulerBookingRequest] The time slot booking request
|
50
|
+
# @return [SchedulerBookingConfirmation] Returns the booking confirmation
|
51
|
+
def book_time_slot(slug, timeslot)
|
52
|
+
payload = timeslot.to_h
|
53
|
+
# The booking endpoint requires additional_values and additional_emails
|
54
|
+
# to exist regardless if they are empty or not
|
55
|
+
payload[:additional_values] = {} unless payload[:additional_values]
|
56
|
+
payload[:additional_emails] = [] unless payload[:additional_emails]
|
57
|
+
booking_response = api.execute(
|
58
|
+
method: :post,
|
59
|
+
path: "/schedule/#{slug}/timeslots",
|
60
|
+
payload: JSON.dump(payload)
|
61
|
+
)
|
62
|
+
|
63
|
+
SchedulerBookingConfirmation.new(**booking_response.merge(api: api))
|
64
|
+
end
|
65
|
+
|
66
|
+
# Cancel a booking
|
67
|
+
# @param slug [String] The Scheduler page slug
|
68
|
+
# @param edit_hash [String] The token used for editing the booked time slot
|
69
|
+
# @param reason [String] The reason for cancelling the booking
|
70
|
+
# @return [Hash] Returns a hash of a boolean representing success of cancellation
|
71
|
+
def cancel_booking(slug, edit_hash, reason)
|
72
|
+
api.execute(
|
73
|
+
method: :post,
|
74
|
+
path: "/schedule/#{slug}/#{edit_hash}/cancel",
|
75
|
+
payload: JSON.dump(reason: reason)
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Confirm a booking
|
80
|
+
# @param slug [String] The Scheduler page slug
|
81
|
+
# @param edit_hash [String] The token used for editing the booked time slot
|
82
|
+
# @return [SchedulerBookingConfirmation] Returns the confirmed booking confirmation
|
83
|
+
def confirm_booking(slug, edit_hash)
|
84
|
+
booking_response = api.execute(
|
85
|
+
method: :post,
|
86
|
+
path: "/schedule/#{slug}/#{edit_hash}/confirm",
|
87
|
+
payload: {}
|
88
|
+
)
|
89
|
+
|
90
|
+
SchedulerBookingConfirmation.new(**booking_response.merge(api: api))
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
# Retrieve provider availability
|
96
|
+
# @return [Hash] Returns the availability
|
97
|
+
def execute_provider_availability(provider)
|
98
|
+
api.execute(
|
99
|
+
method: :get,
|
100
|
+
path: "/schedule/availability/#{provider}"
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nylas
|
4
|
+
# Structure to represent the time slot object from the Scheduler API
|
5
|
+
class SchedulerTimeSlot
|
6
|
+
include Model::Attributable
|
7
|
+
attribute :account_id, :string
|
8
|
+
attribute :calendar_id, :string
|
9
|
+
attribute :host_name, :string
|
10
|
+
attribute :start, :unix_timestamp
|
11
|
+
attribute :end, :unix_timestamp
|
12
|
+
has_n_of_attribute :emails, :string
|
13
|
+
end
|
14
|
+
end
|
data/lib/nylas/version.rb
CHANGED
data/lib/nylas.rb
CHANGED
@@ -56,6 +56,7 @@ require_relative "nylas/open_hours"
|
|
56
56
|
require_relative "nylas/event_conferencing"
|
57
57
|
require_relative "nylas/event_conferencing_details"
|
58
58
|
require_relative "nylas/event_conferencing_autocreate"
|
59
|
+
require_relative "nylas/event_notification"
|
59
60
|
require_relative "nylas/component"
|
60
61
|
|
61
62
|
# Custom collection types
|
@@ -65,6 +66,7 @@ require_relative "nylas/deltas_collection"
|
|
65
66
|
require_relative "nylas/free_busy_collection"
|
66
67
|
require_relative "nylas/calendar_collection"
|
67
68
|
require_relative "nylas/component_collection"
|
69
|
+
require_relative "nylas/scheduler_collection"
|
68
70
|
|
69
71
|
# Models supported by the API
|
70
72
|
require_relative "nylas/account"
|
@@ -96,6 +98,9 @@ require_relative "nylas/neural_signature_extraction"
|
|
96
98
|
require_relative "nylas/neural_message_options"
|
97
99
|
require_relative "nylas/categorize"
|
98
100
|
require_relative "nylas/scheduler_config"
|
101
|
+
require_relative "nylas/scheduler_time_slot"
|
102
|
+
require_relative "nylas/scheduler_booking_request"
|
103
|
+
require_relative "nylas/scheduler_booking_confirmation"
|
99
104
|
|
100
105
|
require_relative "nylas/native_authentication"
|
101
106
|
|
@@ -135,10 +140,12 @@ module Nylas
|
|
135
140
|
Types.registry[:event_conferencing] = Types::ModelType.new(model: EventConferencing)
|
136
141
|
Types.registry[:event_conferencing_details] = Types::ModelType.new(model: EventConferencingDetails)
|
137
142
|
Types.registry[:event_conferencing_autocreate] = Types::ModelType.new(model: EventConferencingAutocreate)
|
143
|
+
Types.registry[:event_notification] = Types::ModelType.new(model: EventNotification)
|
138
144
|
Types.registry[:neural] = Types::ModelType.new(model: Neural)
|
139
145
|
Types.registry[:categorize] = Types::ModelType.new(model: Categorize)
|
140
146
|
Types.registry[:neural_signature_contact] = Types::ModelType.new(model: NeuralSignatureContact)
|
141
147
|
Types.registry[:neural_contact_link] = Types::ModelType.new(model: NeuralContactLink)
|
142
148
|
Types.registry[:neural_contact_name] = Types::ModelType.new(model: NeuralContactName)
|
143
149
|
Types.registry[:scheduler_config] = Types::ModelType.new(model: SchedulerConfig)
|
150
|
+
Types.registry[:scheduler_time_slot] = Types::ModelType.new(model: SchedulerTimeSlot)
|
144
151
|
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.
|
4
|
+
version: 5.6.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-
|
11
|
+
date: 2021-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -290,6 +290,7 @@ files:
|
|
290
290
|
- lib/nylas/event_conferencing.rb
|
291
291
|
- lib/nylas/event_conferencing_autocreate.rb
|
292
292
|
- lib/nylas/event_conferencing_details.rb
|
293
|
+
- lib/nylas/event_notification.rb
|
293
294
|
- lib/nylas/file.rb
|
294
295
|
- lib/nylas/filter_attributes.rb
|
295
296
|
- lib/nylas/folder.rb
|
@@ -331,7 +332,11 @@ files:
|
|
331
332
|
- lib/nylas/room_resource.rb
|
332
333
|
- lib/nylas/rsvp.rb
|
333
334
|
- lib/nylas/scheduler.rb
|
335
|
+
- lib/nylas/scheduler_booking_confirmation.rb
|
336
|
+
- lib/nylas/scheduler_booking_request.rb
|
337
|
+
- lib/nylas/scheduler_collection.rb
|
334
338
|
- lib/nylas/scheduler_config.rb
|
339
|
+
- lib/nylas/scheduler_time_slot.rb
|
335
340
|
- lib/nylas/search_collection.rb
|
336
341
|
- lib/nylas/thread.rb
|
337
342
|
- lib/nylas/time_slot.rb
|