nylas_v2 5.14.2
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 +7 -0
- data/lib/nylas_v2/account.rb +56 -0
- data/lib/nylas_v2/api.rb +244 -0
- data/lib/nylas_v2/application_details.rb +13 -0
- data/lib/nylas_v2/calendar.rb +46 -0
- data/lib/nylas_v2/calendar_collection.rb +144 -0
- data/lib/nylas_v2/categorize.rb +14 -0
- data/lib/nylas_v2/collection.rb +175 -0
- data/lib/nylas_v2/component.rb +35 -0
- data/lib/nylas_v2/component_collection.rb +10 -0
- data/lib/nylas_v2/constraints.rb +56 -0
- data/lib/nylas_v2/contact.rb +53 -0
- data/lib/nylas_v2/contact_group.rb +23 -0
- data/lib/nylas_v2/current_account.rb +23 -0
- data/lib/nylas_v2/delta.rb +56 -0
- data/lib/nylas_v2/deltas.rb +19 -0
- data/lib/nylas_v2/deltas_collection.rb +40 -0
- data/lib/nylas_v2/draft.rb +100 -0
- data/lib/nylas_v2/email_address.rb +12 -0
- data/lib/nylas_v2/errors.rb +111 -0
- data/lib/nylas_v2/event.rb +141 -0
- data/lib/nylas_v2/event_collection.rb +15 -0
- data/lib/nylas_v2/event_conferencing.rb +12 -0
- data/lib/nylas_v2/event_conferencing_autocreate.rb +10 -0
- data/lib/nylas_v2/event_conferencing_details.rb +14 -0
- data/lib/nylas_v2/event_notification.rb +17 -0
- data/lib/nylas_v2/file.rb +75 -0
- data/lib/nylas_v2/filter_attributes.rb +25 -0
- data/lib/nylas_v2/folder.rb +26 -0
- data/lib/nylas_v2/free_busy.rb +13 -0
- data/lib/nylas_v2/free_busy_collection.rb +48 -0
- data/lib/nylas_v2/http_client.rb +279 -0
- data/lib/nylas_v2/im_address.rb +11 -0
- data/lib/nylas_v2/job_status.rb +27 -0
- data/lib/nylas_v2/job_status_collection.rb +21 -0
- data/lib/nylas_v2/label.rb +27 -0
- data/lib/nylas_v2/logging.rb +41 -0
- data/lib/nylas_v2/message.rb +98 -0
- data/lib/nylas_v2/message_headers.rb +27 -0
- data/lib/nylas_v2/message_tracking.rb +13 -0
- data/lib/nylas_v2/model/attributable.rb +89 -0
- data/lib/nylas_v2/model/attribute_definition.rb +24 -0
- data/lib/nylas_v2/model/attributes.rb +97 -0
- data/lib/nylas_v2/model/list_attribute_definition.rb +39 -0
- data/lib/nylas_v2/model/transferable.rb +53 -0
- data/lib/nylas_v2/model.rb +217 -0
- data/lib/nylas_v2/native_authentication.rb +39 -0
- data/lib/nylas_v2/neural.rb +87 -0
- data/lib/nylas_v2/neural_categorizer.rb +29 -0
- data/lib/nylas_v2/neural_clean_conversation.rb +33 -0
- data/lib/nylas_v2/neural_contact_link.rb +11 -0
- data/lib/nylas_v2/neural_contact_name.rb +11 -0
- data/lib/nylas_v2/neural_message_options.rb +35 -0
- data/lib/nylas_v2/neural_ocr.rb +16 -0
- data/lib/nylas_v2/neural_sentiment_analysis.rb +17 -0
- data/lib/nylas_v2/neural_signature_contact.rb +81 -0
- data/lib/nylas_v2/neural_signature_extraction.rb +18 -0
- data/lib/nylas_v2/new_message.rb +39 -0
- data/lib/nylas_v2/nylas_date.rb +25 -0
- data/lib/nylas_v2/open_hours.rb +15 -0
- data/lib/nylas_v2/outbox.rb +116 -0
- data/lib/nylas_v2/outbox_job_status.rb +19 -0
- data/lib/nylas_v2/outbox_message.rb +17 -0
- data/lib/nylas_v2/participant.rb +13 -0
- data/lib/nylas_v2/phone_number.rb +11 -0
- data/lib/nylas_v2/physical_address.rb +17 -0
- data/lib/nylas_v2/raw_message.rb +25 -0
- data/lib/nylas_v2/recurrence.rb +11 -0
- data/lib/nylas_v2/registry.rb +42 -0
- data/lib/nylas_v2/room_resource.rb +19 -0
- data/lib/nylas_v2/rsvp.rb +24 -0
- data/lib/nylas_v2/scheduler.rb +51 -0
- data/lib/nylas_v2/scheduler_booking_confirmation.rb +24 -0
- data/lib/nylas_v2/scheduler_booking_request.rb +17 -0
- data/lib/nylas_v2/scheduler_collection.rb +104 -0
- data/lib/nylas_v2/scheduler_config.rb +20 -0
- data/lib/nylas_v2/scheduler_time_slot.rb +14 -0
- data/lib/nylas_v2/search_collection.rb +10 -0
- data/lib/nylas_v2/send_grid_verified_status.rb +12 -0
- data/lib/nylas_v2/thread.rb +66 -0
- data/lib/nylas_v2/time_slot.rb +16 -0
- data/lib/nylas_v2/time_slot_capacity.rb +13 -0
- data/lib/nylas_v2/timespan.rb +20 -0
- data/lib/nylas_v2/token_info.rb +20 -0
- data/lib/nylas_v2/types.rb +168 -0
- data/lib/nylas_v2/version.rb +5 -0
- data/lib/nylas_v2/web_page.rb +11 -0
- data/lib/nylas_v2/webhook.rb +98 -0
- data/lib/nylas_v2/when.rb +75 -0
- data/lib/nylas_v2.rb +162 -0
- metadata +415 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Structure to represent the Neural API's Signature Extraction Contact object
|
|
5
|
+
# @see https://developer.nylas.com/docs/intelligence/signature-extraction/#parse-signature-response
|
|
6
|
+
class NeuralSignatureContact
|
|
7
|
+
include Model::Attributable
|
|
8
|
+
has_n_of_attribute :job_titles, :string
|
|
9
|
+
has_n_of_attribute :links, :neural_contact_link
|
|
10
|
+
has_n_of_attribute :phone_numbers, :string
|
|
11
|
+
has_n_of_attribute :emails, :string
|
|
12
|
+
has_n_of_attribute :names, :neural_contact_name
|
|
13
|
+
|
|
14
|
+
attr_accessor :api
|
|
15
|
+
|
|
16
|
+
# Creates a Nylas contact object compatible with the contact endpoints.
|
|
17
|
+
# Please note if multiple names or multiple job titles were parsed only
|
|
18
|
+
# the first set are used.
|
|
19
|
+
def to_contact_object
|
|
20
|
+
contact = merge_multiple_hashes([convert_names, convert_emails, convert_phone_numbers, convert_links])
|
|
21
|
+
contact[:job_title] = job_titles[0] unless job_titles.nil?
|
|
22
|
+
Contact.new(**contact.merge(api: api))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def convert_names
|
|
28
|
+
return {} if names.empty?
|
|
29
|
+
|
|
30
|
+
contact = {}
|
|
31
|
+
contact[:given_name] = names[0].first_name if names[0].first_name
|
|
32
|
+
contact[:surname] = names[0].last_name if names[0].last_name
|
|
33
|
+
contact
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def convert_emails
|
|
37
|
+
return {} if emails.empty?
|
|
38
|
+
|
|
39
|
+
contact = {}
|
|
40
|
+
contact[:emails] = []
|
|
41
|
+
emails.each do |e|
|
|
42
|
+
contact[:emails].push(type: "personal", email: e)
|
|
43
|
+
end
|
|
44
|
+
contact
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def convert_phone_numbers
|
|
48
|
+
return {} if phone_numbers.empty?
|
|
49
|
+
|
|
50
|
+
contact = {}
|
|
51
|
+
contact[:phone_numbers] = []
|
|
52
|
+
phone_numbers.each do |number|
|
|
53
|
+
contact[:phone_numbers].push(type: "mobile", number: number)
|
|
54
|
+
end
|
|
55
|
+
contact
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def convert_links
|
|
59
|
+
return {} if links.empty?
|
|
60
|
+
|
|
61
|
+
contact = {}
|
|
62
|
+
contact[:web_pages] = []
|
|
63
|
+
links.each do |link|
|
|
64
|
+
type = "homepage"
|
|
65
|
+
type = link.description unless link.description.empty?
|
|
66
|
+
contact[:web_pages].push(type: type, url: link.url)
|
|
67
|
+
end
|
|
68
|
+
contact
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# For Ruby 2.5 support as it doesn't support multiple hashes to merge at once
|
|
72
|
+
def merge_multiple_hashes(hashes_to_merge)
|
|
73
|
+
hash = {}
|
|
74
|
+
hashes_to_merge.each do |new_hash|
|
|
75
|
+
hash = hash.merge(new_hash)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
hash
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Structure to represent a the Signature Extraction Schema.
|
|
5
|
+
# @see https://developer.nylas.com/docs/intelligence/signature-extraction/#signature-feedback-response
|
|
6
|
+
class NeuralSignatureExtraction < Message
|
|
7
|
+
include Model
|
|
8
|
+
self.resources_path = "/neural/signature"
|
|
9
|
+
|
|
10
|
+
attribute :signature, :string
|
|
11
|
+
attribute :model_version, :string
|
|
12
|
+
attribute :contacts, :neural_signature_contact
|
|
13
|
+
|
|
14
|
+
inherit_attributes
|
|
15
|
+
|
|
16
|
+
transfer :api, to: %i[contacts]
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Data structure for sending a message via the Nylas API
|
|
5
|
+
class NewMessage
|
|
6
|
+
include Model
|
|
7
|
+
self.creatable = false
|
|
8
|
+
self.showable = false
|
|
9
|
+
self.listable = false
|
|
10
|
+
self.filterable = false
|
|
11
|
+
self.updatable = false
|
|
12
|
+
self.destroyable = false
|
|
13
|
+
|
|
14
|
+
has_n_of_attribute :to, :email_address
|
|
15
|
+
has_n_of_attribute :from, :email_address
|
|
16
|
+
has_n_of_attribute :cc, :email_address
|
|
17
|
+
has_n_of_attribute :bcc, :email_address
|
|
18
|
+
has_n_of_attribute :reply_to, :email_address
|
|
19
|
+
|
|
20
|
+
attribute :subject, :string
|
|
21
|
+
attribute :body, :string
|
|
22
|
+
attribute :reply_to_message_id, :string
|
|
23
|
+
attribute :metadata, :hash
|
|
24
|
+
|
|
25
|
+
has_n_of_attribute :file_ids, :string
|
|
26
|
+
|
|
27
|
+
attribute :tracking, :message_tracking
|
|
28
|
+
|
|
29
|
+
# Sends the new message
|
|
30
|
+
# @return [Message] The sent message
|
|
31
|
+
# @raise [RuntimeError] if the API response data was not a hash
|
|
32
|
+
def send!
|
|
33
|
+
message_data = api.execute(method: :post, path: "/send", payload: to_json)
|
|
34
|
+
raise "Unexpected response from the server, data received not a Message" unless message_data.is_a?(Hash)
|
|
35
|
+
|
|
36
|
+
Message.from_hash(message_data, api: api)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Structure to represent Nylas's more complex Date Schema
|
|
5
|
+
# @see https://docs.nylas.com/reference#contactsid
|
|
6
|
+
class NylasDate
|
|
7
|
+
extend Forwardable
|
|
8
|
+
def_delegators :date, :===, :==, :<=>, :eql?, :equal?
|
|
9
|
+
|
|
10
|
+
include Model::Attributable
|
|
11
|
+
attribute :object, :string
|
|
12
|
+
attribute :date, :date
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Serializes, Deserializes between {NylasDate} objects and a {Hash}
|
|
16
|
+
class NylasDateType < Types::ModelType
|
|
17
|
+
def initialize
|
|
18
|
+
super(model: NylasDate)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def cast(value)
|
|
22
|
+
value.is_a?(String) ? super({ object: "date", date: value }) : super
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Additional times email accounts are available
|
|
5
|
+
# @see https://developer.nylas.com/docs/api/#post/calendars/availability
|
|
6
|
+
class OpenHours
|
|
7
|
+
include Model::Attributable
|
|
8
|
+
|
|
9
|
+
attribute :timezone, :string
|
|
10
|
+
attribute :start, :string
|
|
11
|
+
attribute :end, :string
|
|
12
|
+
has_n_of_attribute :emails, :string
|
|
13
|
+
has_n_of_attribute :days, :integer
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Methods for Outbox functionality
|
|
5
|
+
# @see https://developer.nylas.com/docs/api/#tag--Outbox
|
|
6
|
+
class Outbox
|
|
7
|
+
attr_accessor :api
|
|
8
|
+
|
|
9
|
+
def initialize(api:)
|
|
10
|
+
self.api = api
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def outbox_path
|
|
14
|
+
@outbox_path ||= "/v2/outbox"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# rubocop:disable Layout/LineLength
|
|
18
|
+
# Send a message via Outbox
|
|
19
|
+
# @param draft [Draft, OutboxMessage] The message to send
|
|
20
|
+
# @param send_at [Numeric] The date and time to send the message. If not set, Outbox will send this message immediately.
|
|
21
|
+
# @param retry_limit_datetime [Numeric] The date and time to stop retry attempts for a message. If not set, it defaults to 24 hours after send_at.
|
|
22
|
+
# @return [OutboxJobStatus] The outbox job status status and message data
|
|
23
|
+
# rubocop:enable Layout/LineLength
|
|
24
|
+
def send(draft, send_at: nil, retry_limit_datetime: nil)
|
|
25
|
+
message = draft.to_h(enforce_read_only: true)
|
|
26
|
+
message.merge!(validate_set_date_time(send_at, retry_limit_datetime))
|
|
27
|
+
outbox_response = api.execute(
|
|
28
|
+
method: :post,
|
|
29
|
+
path: outbox_path,
|
|
30
|
+
payload: JSON.dump(message)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
OutboxJobStatus.new(**outbox_response)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# rubocop:disable Layout/LineLength
|
|
37
|
+
# Update a scheduled Outbox message
|
|
38
|
+
# @param job_status_id [String] The ID of the outbox job status
|
|
39
|
+
# @param message [Draft, OutboxMessage] The message object with updated values
|
|
40
|
+
# @param send_at [Numeric] The date and time to send the message. If not set, Outbox will send this message immediately.
|
|
41
|
+
# @param retry_limit_datetime [Numeric] The date and time to stop retry attempts for a message. If not set, it defaults to 24 hours after send_at.
|
|
42
|
+
# @return [OutboxJobStatus] The updated outbox job status status and message data
|
|
43
|
+
# rubocop:enable Layout/LineLength
|
|
44
|
+
def update(job_status_id, message: nil, send_at: nil, retry_limit_datetime: nil)
|
|
45
|
+
payload = {}
|
|
46
|
+
payload.merge!(message.to_h(enforce_read_only: true)) if message
|
|
47
|
+
payload.merge!(validate_set_date_time(send_at, retry_limit_datetime))
|
|
48
|
+
outbox_response = api.execute(
|
|
49
|
+
method: :patch,
|
|
50
|
+
path: "#{outbox_path}/#{job_status_id}",
|
|
51
|
+
payload: JSON.dump(payload)
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
OutboxJobStatus.new(**outbox_response)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Delete a scheduled Outbox message
|
|
58
|
+
# @param job_status_id [String] The ID of the outbox job status to delete
|
|
59
|
+
# @return [void]
|
|
60
|
+
def delete(job_status_id)
|
|
61
|
+
api.execute(
|
|
62
|
+
method: :delete,
|
|
63
|
+
path: "#{outbox_path}/#{job_status_id}"
|
|
64
|
+
)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# SendGrid - Check Authentication and Verification Status
|
|
68
|
+
# @return [SendGridVerifiedStatus] The SendGrid Authentication and Verification Status
|
|
69
|
+
def send_grid_verification_status
|
|
70
|
+
response = api.execute(
|
|
71
|
+
method: :get,
|
|
72
|
+
path: "#{outbox_path}/onboard/verified_status"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
raise "Verification status not present in response" if response.key?("results")
|
|
76
|
+
|
|
77
|
+
SendGridVerifiedStatus.new(**response[:results])
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# SendGrid - Delete SendGrid Subuser and UAS Grant
|
|
81
|
+
# @param email [String] Email address for SendGrid subuser to delete
|
|
82
|
+
# @return [void]
|
|
83
|
+
def delete_send_grid_sub_user(email)
|
|
84
|
+
api.execute(
|
|
85
|
+
method: :delete,
|
|
86
|
+
path: "#{outbox_path}/onboard/subuser",
|
|
87
|
+
payload: JSON.dump({ email: email })
|
|
88
|
+
)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
def validate_set_date_time(send_at, retry_limit_datetime)
|
|
94
|
+
hash = {}
|
|
95
|
+
hash[:send_at] = validate_send_at(send_at) if send_at
|
|
96
|
+
if retry_limit_datetime
|
|
97
|
+
hash[:retry_limit_datetime] = validate_retry_limit_datetime(send_at, retry_limit_datetime)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
hash
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def validate_send_at(send_at)
|
|
104
|
+
return send_at unless send_at != 0 && (send_at < Time.now.to_i)
|
|
105
|
+
|
|
106
|
+
raise ArgumentError, "Cannot set message to be sent at a time before the current time."
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def validate_retry_limit_datetime(send_at, retry_limit_datetime)
|
|
110
|
+
valid_send_at = send_at && send_at != 0 ? send_at : Time.now.to_i
|
|
111
|
+
return retry_limit_datetime unless retry_limit_datetime != 0 && (retry_limit_datetime < valid_send_at)
|
|
112
|
+
|
|
113
|
+
raise ArgumentError, "Cannot set message to stop retrying before time to send at."
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Ruby representation of a Nylas Outbox Job Status object
|
|
5
|
+
# @see https://developer.nylas.com/docs/api/#post/v2/outbox
|
|
6
|
+
class OutboxJobStatus < JobStatus
|
|
7
|
+
include Model
|
|
8
|
+
|
|
9
|
+
attribute :send_at, :unix_timestamp
|
|
10
|
+
attribute :original_send_at, :unix_timestamp
|
|
11
|
+
attribute :message_id, :string
|
|
12
|
+
attribute :thread_id, :string
|
|
13
|
+
attribute :original_data, :outbox_message
|
|
14
|
+
|
|
15
|
+
transfer :api, to: %i[original_data]
|
|
16
|
+
|
|
17
|
+
inherit_attributes
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Ruby representation of a Nylas Outbox Message object
|
|
5
|
+
# @see https://developer.nylas.com/docs/api/#post/v2/outbox
|
|
6
|
+
class OutboxMessage < Draft
|
|
7
|
+
include Model
|
|
8
|
+
|
|
9
|
+
attribute :send_at, :unix_timestamp
|
|
10
|
+
attribute :retry_limit_datetime, :unix_timestamp
|
|
11
|
+
attribute :original_send_at, :unix_timestamp, read_only: true
|
|
12
|
+
|
|
13
|
+
transfer :api, to: %i[events files folder labels]
|
|
14
|
+
|
|
15
|
+
inherit_attributes
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Structure to represent the Participant
|
|
5
|
+
class Participant
|
|
6
|
+
include Model::Attributable
|
|
7
|
+
attribute :name, :string
|
|
8
|
+
attribute :email, :string
|
|
9
|
+
attribute :phone_number, :string
|
|
10
|
+
attribute :comment, :string
|
|
11
|
+
attribute :status, :string, read_only: true
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Structure to represent the Phone Number Schema
|
|
5
|
+
# @see https://docs.nylas.com/reference#contactsid
|
|
6
|
+
class PhoneNumber
|
|
7
|
+
include Model::Attributable
|
|
8
|
+
attribute :type, :string
|
|
9
|
+
attribute :number, :string
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Structure to represent the Physical Address schema
|
|
5
|
+
# @see https://docs.nylas.com/reference#contactsid
|
|
6
|
+
class PhysicalAddress
|
|
7
|
+
include Model::Attributable
|
|
8
|
+
attribute :format, :string
|
|
9
|
+
attribute :type, :string
|
|
10
|
+
attribute :street_address, :string
|
|
11
|
+
attribute :postal_code, :string
|
|
12
|
+
attribute :state, :string
|
|
13
|
+
attribute :city, :string
|
|
14
|
+
attribute :country, :string
|
|
15
|
+
attribute :secondary_address, :string
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Allows sending of email with nylas from an rfc822 compatible string
|
|
5
|
+
class RawMessage
|
|
6
|
+
attr_accessor :api, :mime_compatible_string
|
|
7
|
+
|
|
8
|
+
def initialize(mime_compatible_string, api:)
|
|
9
|
+
self.api = api
|
|
10
|
+
self.mime_compatible_string = mime_compatible_string
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def send!
|
|
14
|
+
Message.new(**api.execute(
|
|
15
|
+
method: :post,
|
|
16
|
+
path: "/send",
|
|
17
|
+
payload: mime_compatible_string,
|
|
18
|
+
headers: HEADERS
|
|
19
|
+
).merge(api: api))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
HEADERS = { "Content-type" => "message/rfc822" }.freeze
|
|
23
|
+
private_constant :HEADERS
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Representation of a Recurrence object
|
|
5
|
+
# @see https://docs.nylas.com/reference#section-recurrence
|
|
6
|
+
class Recurrence
|
|
7
|
+
include Model::Attributable
|
|
8
|
+
has_n_of_attribute :rrule, :string
|
|
9
|
+
attribute :timezone, :string
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Used to create a hash-like structure which defaults to raising an exception in the event the key to
|
|
5
|
+
# retrieve does not exist.
|
|
6
|
+
class Registry
|
|
7
|
+
# Used to indicate an attempt to retrieve something not yet registered in a registry
|
|
8
|
+
# Includes the list of keys in the registry for debug purposes.
|
|
9
|
+
class MissingKeyError < Error
|
|
10
|
+
attr_accessor :key
|
|
11
|
+
|
|
12
|
+
def initialize(key, keys)
|
|
13
|
+
super("key #{key} not in #{keys}")
|
|
14
|
+
self.key = key
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
attr_accessor :registry_data
|
|
18
|
+
|
|
19
|
+
extend Forwardable
|
|
20
|
+
def_delegators :registry_data, :keys, :each, :reduce, :key?
|
|
21
|
+
|
|
22
|
+
def initialize(initial_data = {})
|
|
23
|
+
self.registry_data = initial_data.each.each_with_object({}) do |(key, value), registry|
|
|
24
|
+
registry[key] = value
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def [](key)
|
|
29
|
+
registry_data.fetch(key)
|
|
30
|
+
rescue KeyError
|
|
31
|
+
raise MissingKeyError.new(key, keys)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def []=(key, value)
|
|
35
|
+
registry_data[key] = value
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def to_h
|
|
39
|
+
registry_data
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
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
|
+
self.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
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Allows RSVPing to a particular event
|
|
5
|
+
# @see https://docs.nylas.com/reference#rsvping-to-invitations
|
|
6
|
+
class Rsvp
|
|
7
|
+
include Model
|
|
8
|
+
self.creatable = true
|
|
9
|
+
|
|
10
|
+
attribute :account_id, :string
|
|
11
|
+
attribute :event_id, :string
|
|
12
|
+
attribute :status, :string
|
|
13
|
+
attr_accessor :notify_participants
|
|
14
|
+
|
|
15
|
+
def save
|
|
16
|
+
api.execute(
|
|
17
|
+
method: :post,
|
|
18
|
+
path: "/send-rsvp",
|
|
19
|
+
payload: attributes.serialize_for_api,
|
|
20
|
+
query: { notify_participants: notify_participants }
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
4
|
+
# Ruby representation of a the Nylas Scheduler API
|
|
5
|
+
# @see https://developer.nylas.com/docs/api/scheduler/#overview
|
|
6
|
+
class Scheduler
|
|
7
|
+
include Model
|
|
8
|
+
self.resources_path = "/manage/pages"
|
|
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
|
+
|
|
16
|
+
attribute :id, :integer, read_only: true
|
|
17
|
+
attribute :app_client_id, :string
|
|
18
|
+
attribute :app_organization_id, :integer
|
|
19
|
+
attribute :config, :scheduler_config
|
|
20
|
+
attribute :edit_token, :string
|
|
21
|
+
attribute :name, :string
|
|
22
|
+
attribute :slug, :string
|
|
23
|
+
attribute :created_at, :date
|
|
24
|
+
attribute :modified_at, :date
|
|
25
|
+
|
|
26
|
+
has_n_of_attribute :access_tokens, :string
|
|
27
|
+
|
|
28
|
+
def get_available_calendars
|
|
29
|
+
raise ArgumentError, "Cannot get calendars for a page without an ID." if id.nil?
|
|
30
|
+
|
|
31
|
+
api.execute(
|
|
32
|
+
method: :get,
|
|
33
|
+
path: "/manage/pages/#{id}/calendars"
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def upload_image(content_type:, object_name:)
|
|
38
|
+
raise ArgumentError, "Cannot upload an image to a page without an ID." if id.nil?
|
|
39
|
+
|
|
40
|
+
payload = {
|
|
41
|
+
contentType: content_type,
|
|
42
|
+
objectName: object_name
|
|
43
|
+
}
|
|
44
|
+
api.execute(
|
|
45
|
+
method: :put,
|
|
46
|
+
path: "/manage/pages/#{id}/upload-image",
|
|
47
|
+
payload: JSON.dump(payload)
|
|
48
|
+
)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NylasV2
|
|
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 NylasV2
|
|
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
|