nylas 5.17.0 → 6.0.3

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.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nylas/client.rb +121 -0
  3. data/lib/nylas/config.rb +19 -0
  4. data/lib/nylas/errors.rb +63 -89
  5. data/lib/nylas/handler/api_operations.rb +162 -0
  6. data/lib/nylas/handler/http_client.rb +252 -0
  7. data/lib/nylas/resources/applications.rb +27 -0
  8. data/lib/nylas/resources/attachments.rb +65 -0
  9. data/lib/nylas/resources/auth.rb +209 -0
  10. data/lib/nylas/resources/calendars.rb +101 -0
  11. data/lib/nylas/resources/connectors.rb +80 -0
  12. data/lib/nylas/resources/contacts.rb +89 -0
  13. data/lib/nylas/resources/credentials.rb +75 -0
  14. data/lib/nylas/resources/drafts.rb +121 -0
  15. data/lib/nylas/resources/events.rb +98 -0
  16. data/lib/nylas/resources/folders.rb +73 -0
  17. data/lib/nylas/resources/grants.rb +59 -0
  18. data/lib/nylas/resources/messages.rb +135 -0
  19. data/lib/nylas/resources/redirect_uris.rb +68 -0
  20. data/lib/nylas/resources/resource.rb +18 -0
  21. data/lib/nylas/resources/smart_compose.rb +36 -0
  22. data/lib/nylas/resources/threads.rb +62 -0
  23. data/lib/nylas/resources/webhooks.rb +121 -0
  24. data/lib/nylas/utils/file_utils.rb +61 -0
  25. data/lib/nylas/version.rb +1 -1
  26. data/lib/nylas.rb +31 -148
  27. metadata +88 -247
  28. data/lib/nylas/account.rb +0 -56
  29. data/lib/nylas/api.rb +0 -246
  30. data/lib/nylas/application_details.rb +0 -13
  31. data/lib/nylas/calendar.rb +0 -46
  32. data/lib/nylas/calendar_collection.rb +0 -144
  33. data/lib/nylas/categorize.rb +0 -14
  34. data/lib/nylas/collection.rb +0 -175
  35. data/lib/nylas/component.rb +0 -35
  36. data/lib/nylas/component_collection.rb +0 -10
  37. data/lib/nylas/constraints.rb +0 -56
  38. data/lib/nylas/contact.rb +0 -53
  39. data/lib/nylas/contact_group.rb +0 -23
  40. data/lib/nylas/current_account.rb +0 -23
  41. data/lib/nylas/delta.rb +0 -56
  42. data/lib/nylas/deltas.rb +0 -19
  43. data/lib/nylas/deltas_collection.rb +0 -40
  44. data/lib/nylas/draft.rb +0 -100
  45. data/lib/nylas/email_address.rb +0 -12
  46. data/lib/nylas/event.rb +0 -144
  47. data/lib/nylas/event_collection.rb +0 -15
  48. data/lib/nylas/event_conferencing.rb +0 -12
  49. data/lib/nylas/event_conferencing_autocreate.rb +0 -10
  50. data/lib/nylas/event_conferencing_details.rb +0 -14
  51. data/lib/nylas/event_notification.rb +0 -17
  52. data/lib/nylas/file.rb +0 -75
  53. data/lib/nylas/filter_attributes.rb +0 -25
  54. data/lib/nylas/folder.rb +0 -26
  55. data/lib/nylas/free_busy.rb +0 -13
  56. data/lib/nylas/free_busy_collection.rb +0 -48
  57. data/lib/nylas/http_client.rb +0 -279
  58. data/lib/nylas/im_address.rb +0 -11
  59. data/lib/nylas/job_status.rb +0 -27
  60. data/lib/nylas/job_status_collection.rb +0 -21
  61. data/lib/nylas/label.rb +0 -27
  62. data/lib/nylas/logging.rb +0 -41
  63. data/lib/nylas/message.rb +0 -98
  64. data/lib/nylas/message_headers.rb +0 -27
  65. data/lib/nylas/message_tracking.rb +0 -13
  66. data/lib/nylas/model/attributable.rb +0 -89
  67. data/lib/nylas/model/attribute_definition.rb +0 -24
  68. data/lib/nylas/model/attributes.rb +0 -97
  69. data/lib/nylas/model/list_attribute_definition.rb +0 -39
  70. data/lib/nylas/model/transferable.rb +0 -53
  71. data/lib/nylas/model.rb +0 -217
  72. data/lib/nylas/native_authentication.rb +0 -39
  73. data/lib/nylas/neural.rb +0 -87
  74. data/lib/nylas/neural_categorizer.rb +0 -29
  75. data/lib/nylas/neural_clean_conversation.rb +0 -33
  76. data/lib/nylas/neural_contact_link.rb +0 -11
  77. data/lib/nylas/neural_contact_name.rb +0 -11
  78. data/lib/nylas/neural_message_options.rb +0 -35
  79. data/lib/nylas/neural_ocr.rb +0 -16
  80. data/lib/nylas/neural_sentiment_analysis.rb +0 -17
  81. data/lib/nylas/neural_signature_contact.rb +0 -81
  82. data/lib/nylas/neural_signature_extraction.rb +0 -18
  83. data/lib/nylas/new_message.rb +0 -39
  84. data/lib/nylas/nylas_date.rb +0 -25
  85. data/lib/nylas/open_hours.rb +0 -15
  86. data/lib/nylas/outbox.rb +0 -116
  87. data/lib/nylas/outbox_job_status.rb +0 -19
  88. data/lib/nylas/outbox_message.rb +0 -17
  89. data/lib/nylas/participant.rb +0 -13
  90. data/lib/nylas/phone_number.rb +0 -11
  91. data/lib/nylas/physical_address.rb +0 -17
  92. data/lib/nylas/raw_message.rb +0 -25
  93. data/lib/nylas/recurrence.rb +0 -11
  94. data/lib/nylas/registry.rb +0 -42
  95. data/lib/nylas/room_resource.rb +0 -19
  96. data/lib/nylas/rsvp.rb +0 -24
  97. data/lib/nylas/scheduler.rb +0 -51
  98. data/lib/nylas/scheduler_booking_confirmation.rb +0 -24
  99. data/lib/nylas/scheduler_booking_request.rb +0 -17
  100. data/lib/nylas/scheduler_collection.rb +0 -104
  101. data/lib/nylas/scheduler_config.rb +0 -20
  102. data/lib/nylas/scheduler_time_slot.rb +0 -14
  103. data/lib/nylas/search_collection.rb +0 -10
  104. data/lib/nylas/send_grid_verified_status.rb +0 -12
  105. data/lib/nylas/services/tunnel.rb +0 -128
  106. data/lib/nylas/thread.rb +0 -66
  107. data/lib/nylas/time_slot.rb +0 -16
  108. data/lib/nylas/time_slot_capacity.rb +0 -13
  109. data/lib/nylas/timespan.rb +0 -20
  110. data/lib/nylas/token_info.rb +0 -20
  111. data/lib/nylas/types.rb +0 -168
  112. data/lib/nylas/web_page.rb +0 -11
  113. data/lib/nylas/webhook.rb +0 -111
  114. data/lib/nylas/when.rb +0 -75
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # The constraints a particular GET request will include in their query params
5
- class Constraints
6
- attr_accessor :where, :limit, :offset, :view, :per_page, :accept
7
-
8
- def initialize(where: {}, limit: nil, offset: 0, view: nil, per_page: 100, accept: "application/json")
9
- self.where = where
10
- self.limit = limit
11
- self.offset = offset
12
- self.view = view
13
- self.per_page = per_page
14
- self.accept = accept
15
- end
16
-
17
- def merge(where: {}, limit: nil, offset: nil, view: nil, per_page: nil, accept: nil)
18
- Constraints.new(where: self.where.merge(where),
19
- limit: limit || self.limit,
20
- per_page: per_page || self.per_page,
21
- offset: offset || self.offset,
22
- view: view || self.view,
23
- accept: accept || self.accept)
24
- end
25
-
26
- def next_page
27
- merge(offset: offset + per_page)
28
- end
29
-
30
- def to_query
31
- query = where.each_with_object({}) do |(name, value), result|
32
- result[name] = value
33
- end
34
- query[:limit] = limit_for_query
35
- query[:offset] = offset unless offset.nil?
36
- query[:view] = view unless view.nil?
37
- query
38
- end
39
-
40
- def to_headers
41
- accept == "application/json" ? {} : { "Accept" => accept, "Content-types" => accept }
42
- end
43
-
44
- def limit_for_query
45
- !limit.nil? && limit < per_page ? limit : per_page
46
- end
47
-
48
- def self.from_constraints(constraints = Constraints.new)
49
- return constraints if constraints.is_a?(Constraints)
50
- return new(**constraints) if constraints.respond_to?(:key?)
51
- return new if constraints.nil?
52
-
53
- raise TypeError, "passed in constraints #{constraints} cannot be cast to a set of constraints"
54
- end
55
- end
56
- end
data/lib/nylas/contact.rb DELETED
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # ActiveModel compliant interface for interacting with the Contacts API
5
- # @see https://docs.nylas.com/reference#contacts
6
- class Contact
7
- include Model
8
- self.resources_path = "/contacts"
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, :string, read_only: true
17
- attribute :object, :string, default: "contact"
18
- attribute :account_id, :string, read_only: true
19
-
20
- attribute :given_name, :string
21
- attribute :middle_name, :string
22
- attribute :picture_url, :string
23
- attribute :surname, :string
24
- attribute :birthday, :string
25
- attribute :suffix, :string
26
- attribute :nickname, :string
27
- attribute :company_name, :string
28
- attribute :job_title, :string
29
- attribute :manager_name, :string
30
- attribute :office_location, :string
31
- attribute :notes, :string
32
- attribute :source, :string
33
- attribute :job_status_id, :string, read_only: true
34
-
35
- has_n_of_attribute :groups, :contact_group
36
- has_n_of_attribute :emails, :email_address
37
- has_n_of_attribute :im_addresses, :im_address
38
- has_n_of_attribute :physical_addresses, :physical_address
39
- has_n_of_attribute :phone_numbers, :phone_number
40
- has_n_of_attribute :web_pages, :web_page
41
-
42
- # @returns [Tempfile] path to the retrieved picture. It is preferrable to cache this in your system than
43
- # to retrieve it from nylas every time.
44
- def picture
45
- return @picture_tempfile if @picture_tempfile
46
-
47
- @picture_tempfile = Tempfile.new
48
- @picture_tempfile.write(api.get(path: "#{resource_path}/picture"))
49
- @picture_tempfile.close
50
- @picture_tempfile
51
- end
52
- end
53
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Structure to represent the Contact Group schema
5
- # @see https://docs.nylas.com/reference#contactsid
6
- class ContactGroup
7
- include Model
8
- self.resources_path = "/contacts/groups"
9
-
10
- self.creatable = false
11
- self.destroyable = false
12
- self.filterable = false
13
- self.listable = true
14
- self.showable = false
15
- self.updatable = false
16
-
17
- attribute :id, :string
18
- attribute :object, :string
19
- attribute :account_id, :string
20
- attribute :name, :string
21
- attribute :path, :string
22
- end
23
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Ruby representation of the Nylas /account API
5
- # @see https://docs.nylas.com/reference#account
6
- class CurrentAccount
7
- include Model
8
- self.showable = true
9
-
10
- self.resources_path = "/account"
11
-
12
- attribute :id, :string
13
- attribute :object, :string, default: "account"
14
-
15
- attribute :account_id, :string
16
- attribute :email_address, :string
17
- attribute :name, :string
18
- attribute :organization_unit, :string
19
- attribute :provider, :string
20
- attribute :sync_state, :string
21
- attribute :linked_at, :unix_timestamp
22
- end
23
- end
data/lib/nylas/delta.rb DELETED
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Ruby object to represent a single change. Used both when receiving a webhook, as well as the deltas API.
5
- # @see https://docs.nylas.com/reference#receiving-notifications
6
- # @see https://docs.nylas.com/reference#deltas
7
- class Delta
8
- include Model::Attributable
9
-
10
- attribute :id, :string
11
- attribute :type, :string
12
- attribute :object, :string
13
- attribute :event, :string
14
- attribute :cursor, :string
15
- attribute :namespace_id, :string
16
- attribute :account_id, :string
17
-
18
- attribute :headers, :message_headers
19
-
20
- attribute :date, :unix_timestamp
21
- attribute :metadata, :hash
22
- attribute :object_attributes, :hash
23
-
24
- def model
25
- return nil if object.nil?
26
-
27
- @model ||= Types.registry[object.to_sym].cast(object_attributes_with_ids)
28
- end
29
-
30
- private
31
-
32
- def object_attributes_with_ids
33
- (object_attributes || {}).merge(id: id, account_id: account_id)
34
- end
35
- end
36
-
37
- # Casts Delta data from either a webhook or a delta stream to a Delta
38
- class DeltaType < Types::ModelType
39
- def initialize
40
- super(model: Delta)
41
- end
42
-
43
- def cast(data)
44
- data = if data.key?(:object_data)
45
- object_data = data.delete(:object_data)
46
- data.merge(object_data)
47
- else
48
- data
49
- end
50
-
51
- data = data.merge(data[:attributes]) if data[:attributes]
52
- data[:object_attributes] = data.delete(:attributes)
53
- super(**data)
54
- end
55
- end
56
- end
data/lib/nylas/deltas.rb DELETED
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Ruby object to represent a collection of changes. Used both when receiving a webhook, as well as the
5
- # deltas API.
6
- # @see https://docs.nylas.com/reference#receiving-notifications
7
- # @see https://docs.nylas.com/reference#deltas
8
- class Deltas
9
- include Model
10
- self.resources_path = "/delta"
11
- self.filterable = true
12
- has_n_of_attribute :deltas, :delta
13
- attribute :cursor_start, :string
14
- attribute :cursor_end, :string
15
-
16
- extend Forwardable
17
- def_delegators :deltas, :count, :length, :each, :map, :first, :last, :to_a, :empty?
18
- end
19
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Special collection for delta objects
5
- class DeltasCollection < Collection
6
- attr_accessor :deltas
7
-
8
- extend Forwardable
9
- def_delegators :execute, :cursor_start, :cursor_end,
10
- :count, :each, :to_h, :to_a, :empty?
11
-
12
- def initialize(api:, constraints: nil, model: Deltas)
13
- super(api: api, model: model, constraints: constraints)
14
- end
15
-
16
- def latest_cursor
17
- api.execute(method: :post, path: "#{resources_path}/latest_cursor")[:cursor]
18
- end
19
-
20
- def latest
21
- since(latest_cursor)
22
- end
23
-
24
- def since(cursor)
25
- where(cursor: cursor)
26
- end
27
-
28
- def next_page(*)
29
- return nil if empty?
30
-
31
- where(cursor: cursor_end)
32
- end
33
-
34
- # Retrieves the data from the API for the particular constraints
35
- # @return [Detlas]
36
- def execute
37
- self.deltas ||= Deltas.new(**api.execute(**to_be_executed))
38
- end
39
- end
40
- end
data/lib/nylas/draft.rb DELETED
@@ -1,100 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Ruby representatin of a Nylas Draft object
5
- # @see https://docs.nylas.com/reference#drafts
6
- class Draft
7
- include Model
8
- self.resources_path = "/drafts"
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
16
-
17
- attribute :id, :string
18
- attribute :object, :string
19
- attribute :version, :integer
20
- attribute :account_id, :string
21
- attribute :thread_id, :string
22
- attribute :reply_to_message_id, :string
23
-
24
- has_n_of_attribute :to, :email_address
25
- has_n_of_attribute :from, :email_address
26
- has_n_of_attribute :cc, :email_address
27
- has_n_of_attribute :bcc, :email_address
28
- has_n_of_attribute :reply_to, :email_address
29
-
30
- attribute :date, :unix_timestamp
31
- attribute :subject, :string
32
- attribute :snippet, :string
33
- attribute :body, :string
34
- attribute :starred, :boolean
35
- attribute :unread, :boolean
36
- attribute :metadata, :hash
37
-
38
- has_n_of_attribute :events, :event
39
- has_n_of_attribute :files, :file, read_only: true
40
- has_n_of_attribute :file_ids, :string
41
- attribute :folder, :folder
42
- has_n_of_attribute :labels, :label
43
-
44
- attribute :tracking, :message_tracking
45
- attribute :job_status_id, :string, read_only: true
46
-
47
- transfer :api, to: %i[events files folder labels]
48
-
49
- def update(**data)
50
- # If files are provided, replace files with file IDs
51
- self.files = data[:files] if data[:files]
52
- extract_file_ids!
53
- data[:file_ids] = file_ids
54
- # If version is not provided, add version or request will fail
55
- data[:version] = version unless data[:version]
56
-
57
- super
58
- end
59
-
60
- def create
61
- extract_file_ids!
62
-
63
- super
64
- end
65
-
66
- def send!
67
- return execute(method: :post, path: "/send", payload: to_json) unless id
68
-
69
- data = { draft_id: id, version: version }
70
- data[:tracking] = tracking.to_h if tracking
71
- execute(method: :post, path: "/send", payload: JSON.dump(data))
72
- end
73
-
74
- def starred?
75
- starred
76
- end
77
-
78
- def unread?
79
- unread
80
- end
81
-
82
- def destroy
83
- execute(method: :delete, path: resource_path, payload: attributes.serialize_for_api(keys: [:version]))
84
- end
85
-
86
- def save
87
- extract_file_ids!
88
-
89
- super
90
- end
91
-
92
- private
93
-
94
- def extract_file_ids!
95
- files = self.files || []
96
-
97
- self.file_ids ||= files.map(&:id)
98
- end
99
- end
100
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Structure to represent the Email Address Schema
5
- # @see https://docs.nylas.com/reference#contactsid
6
- class EmailAddress
7
- include Model::Attributable
8
- attribute :type, :string
9
- attribute :email, :string
10
- attribute :name, :string
11
- end
12
- end
data/lib/nylas/event.rb DELETED
@@ -1,144 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Structure to represent a the Event Schema.
5
- # @see https://docs.nylas.com/reference#events
6
- class Event
7
- include Model
8
- self.resources_path = "/events"
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
17
-
18
- attribute :id, :string, read_only: true
19
- attribute :object, :string, read_only: true
20
- attribute :account_id, :string, read_only: true
21
- attribute :calendar_id, :string
22
- attribute :master_event_id, :string
23
- attribute :message_id, :string
24
- attribute :ical_uid, :string
25
- attribute :event_collection_id, :string
26
-
27
- attribute :capacity, :integer
28
- attribute :busy, :boolean
29
- attribute :description, :string
30
- attribute :location, :string
31
- attribute :owner, :string
32
- attribute :recurrence, :recurrence
33
- has_n_of_attribute :participants, :participant
34
- attribute :read_only, :boolean
35
- attribute :status, :string
36
- attribute :title, :string
37
- attribute :when, :when
38
- attribute :metadata, :hash
39
- attribute :conferencing, :event_conferencing
40
- has_n_of_attribute :notifications, :event_notification
41
- has_n_of_attribute :round_robin_order, :string
42
- attribute :original_start_time, :unix_timestamp
43
- attribute :organizer_email, :string
44
- attribute :organizer_name, :string
45
- attribute :reminder_minutes, :string
46
- attribute :reminder_method, :string
47
- attribute :job_status_id, :string, read_only: true
48
- attribute :visibility, :string
49
- attribute :updated_at, :unix_timestamp, read_only: true
50
-
51
- attr_accessor :notify_participants
52
-
53
- def busy?
54
- busy
55
- end
56
-
57
- def read_only?
58
- read_only
59
- end
60
-
61
- def save
62
- validate
63
- format_reminder_minutes
64
-
65
- super
66
- end
67
-
68
- def rsvp(status, notify_participants:)
69
- rsvp = Rsvp.new(api: api, status: status, notify_participants: notify_participants,
70
- event_id: id, account_id: account_id)
71
- rsvp.save
72
- end
73
-
74
- # Generate an ICS file server-side, from an Event
75
- # @param ical_uid [String] Unique identifier used events across calendaring systems
76
- # @param method [String] Description of invitation and response methods for attendees
77
- # @param prodid [String] Company-specific unique product identifier
78
- # @return [String] String for writing directly into an ICS file
79
- def generate_ics(ical_uid: nil, method: nil, prodid: nil)
80
- raise ArgumentError, "Cannot generate an ICS file for an event without a Calendar ID or when set" unless
81
- calendar_id && self.when
82
-
83
- payload = build_ics_event_payload(ical_uid, method, prodid)
84
- response = api.execute(
85
- method: :post,
86
- path: "#{resources_path}/to-ics",
87
- payload: JSON.dump(payload)
88
- )
89
-
90
- response[:ics]
91
- end
92
-
93
- private
94
-
95
- def validate
96
- if conferencing
97
- body = to_h
98
- if body.dig(:conferencing, :details) && body.dig(:conferencing, :autocreate)
99
- raise ArgumentError, "Cannot set both 'details' and 'autocreate' in conferencing object."
100
- end
101
- end
102
- return unless capacity && capacity != -1 && participants && participants.length > capacity
103
-
104
- raise ArgumentError, "The number of participants in the event exceeds the set capacity."
105
- end
106
-
107
- def build_ics_event_payload(ical_uid, method, prodid)
108
- payload = {}
109
- if id
110
- payload[:event_id] = id
111
- else
112
- payload = to_h(enforce_read_only: true)
113
- end
114
- ics_options = build_ics_options_payload(ical_uid, method, prodid)
115
- payload["ics_options"] = ics_options unless ics_options.empty?
116
- payload
117
- end
118
-
119
- def build_ics_options_payload(ical_uid, method, prodid)
120
- payload = {}
121
- payload["ical_uid"] = ical_uid if ical_uid
122
- payload["method"] = method if method
123
- payload["prodid"] = prodid if prodid
124
- payload
125
- end
126
-
127
- # Formats the reminder minute field to match the API format: "[%d]"
128
- def format_reminder_minutes
129
- return if reminder_minutes.nil? || reminder_minutes.empty? || reminder_minutes.match(/\[\d+\]/)
130
-
131
- self.reminder_minutes = "[#{reminder_minutes}]"
132
- end
133
-
134
- def query_params
135
- if notify_participants.nil?
136
- {}
137
- else
138
- {
139
- notify_participants: notify_participants
140
- }
141
- end
142
- end
143
- end
144
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Syntactical sugar methods for some of the Event's filters
5
- # @see https://docs.nylas.com/reference#get-events
6
- class EventCollection < Collection
7
- def expand_recurring
8
- where(expand_recurring: true)
9
- end
10
-
11
- def show_cancelled
12
- where(show_cancelled: true)
13
- end
14
- end
15
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Structure to represent the Event Conferencing object
5
- # @see https://developer.nylas.com/docs/connectivity/calendar/conference-sync-beta
6
- class EventConferencing
7
- include Model::Attributable
8
- attribute :provider, :string
9
- attribute :details, :event_conferencing_details
10
- attribute :autocreate, :event_conferencing_autocreate
11
- end
12
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Structure to represent the autocreate object within the Event Conferencing object
5
- # @see https://developer.nylas.com/docs/connectivity/calendar/conference-sync-beta
6
- class EventConferencingAutocreate
7
- include Model::Attributable
8
- attribute :settings, :hash, default: {}
9
- end
10
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Structure to represent the details object within the Event Conferencing object
5
- # @see https://developer.nylas.com/docs/connectivity/calendar/conference-sync-beta
6
- class EventConferencingDetails
7
- include Model::Attributable
8
- attribute :meeting_code, :string
9
- attribute :password, :string
10
- attribute :pin, :string
11
- attribute :url, :string
12
- has_n_of_attribute :phone, :string
13
- end
14
- end
@@ -1,17 +0,0 @@
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/file.rb DELETED
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Structure to represent a the File Schema.
5
- # @see https://docs.nylas.com/reference#events
6
- class File
7
- include Model
8
- self.resources_path = "/files"
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
16
-
17
- attribute :id, :string
18
- attribute :account_id, :string
19
- attribute :content_id, :string
20
- has_n_of_attribute :message_ids, :string
21
-
22
- attribute :object, :string
23
-
24
- attribute :content_type, :string
25
- attribute :filename, :string
26
- attribute :size, :integer
27
- attribute :content_disposition, :string
28
-
29
- attr_accessor :file
30
-
31
- # Downloads and caches a local copy of the file.
32
- # @return [Tempfile] - Local copy of the file
33
- def download
34
- return file if file
35
-
36
- self.file = retrieve_file
37
- end
38
-
39
- # Redownloads a file even if it's been cached. Closes and unlinks the tempfile to help memory usage.
40
- def download!
41
- return download if file.nil?
42
-
43
- file.close
44
- file.unlink
45
- self.file = nil
46
- download
47
- end
48
-
49
- def create
50
- save
51
- end
52
-
53
- def save
54
- raise ModelNotUpdatableError if persisted?
55
-
56
- response = api.execute(path: "/files", method: :post, headers: { multipart: true },
57
- payload: { file: file })
58
- attributes.merge(response.first)
59
- true
60
- end
61
-
62
- private
63
-
64
- def retrieve_file
65
- response = api.get(path: "#{resource_path}/download")
66
- filename = response.headers.fetch(:content_disposition, "").gsub("attachment; filename=", "")
67
- # The returned filename can be longer than 256 chars which isn't supported by rb_sysopen.
68
- # 128 chars here is more than enough given that TempFile ensure the filename will be unique.
69
- temp_file = Tempfile.new(filename[0..127], encoding: "ascii-8bit")
70
- temp_file.write(response.body)
71
- temp_file.seek(0)
72
- temp_file
73
- end
74
- end
75
- end