nylas 5.17.0 → 6.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nylas/client.rb +62 -0
  3. data/lib/nylas/config.rb +19 -0
  4. data/lib/nylas/errors.rb +41 -89
  5. data/lib/nylas/handler/admin_api_operations.rb +95 -0
  6. data/lib/nylas/handler/api_operations.rb +138 -0
  7. data/lib/nylas/handler/grants_api_operations.rb +99 -0
  8. data/lib/nylas/handler/http_client.rb +179 -0
  9. data/lib/nylas/resources/applications.rb +27 -0
  10. data/lib/nylas/resources/auth.rb +197 -0
  11. data/lib/nylas/resources/calendars.rb +31 -0
  12. data/lib/nylas/resources/events.rb +20 -0
  13. data/lib/nylas/resources/grants.rb +20 -0
  14. data/lib/nylas/resources/redirect_uris.rb +20 -0
  15. data/lib/nylas/resources/resource.rb +18 -0
  16. data/lib/nylas/resources/webhooks.rb +37 -0
  17. data/lib/nylas/version.rb +1 -1
  18. data/lib/nylas.rb +20 -148
  19. metadata +70 -257
  20. data/lib/nylas/account.rb +0 -56
  21. data/lib/nylas/api.rb +0 -246
  22. data/lib/nylas/application_details.rb +0 -13
  23. data/lib/nylas/calendar.rb +0 -46
  24. data/lib/nylas/calendar_collection.rb +0 -144
  25. data/lib/nylas/categorize.rb +0 -14
  26. data/lib/nylas/collection.rb +0 -175
  27. data/lib/nylas/component.rb +0 -35
  28. data/lib/nylas/component_collection.rb +0 -10
  29. data/lib/nylas/constraints.rb +0 -56
  30. data/lib/nylas/contact.rb +0 -53
  31. data/lib/nylas/contact_group.rb +0 -23
  32. data/lib/nylas/current_account.rb +0 -23
  33. data/lib/nylas/delta.rb +0 -56
  34. data/lib/nylas/deltas.rb +0 -19
  35. data/lib/nylas/deltas_collection.rb +0 -40
  36. data/lib/nylas/draft.rb +0 -100
  37. data/lib/nylas/email_address.rb +0 -12
  38. data/lib/nylas/event.rb +0 -144
  39. data/lib/nylas/event_collection.rb +0 -15
  40. data/lib/nylas/event_conferencing.rb +0 -12
  41. data/lib/nylas/event_conferencing_autocreate.rb +0 -10
  42. data/lib/nylas/event_conferencing_details.rb +0 -14
  43. data/lib/nylas/event_notification.rb +0 -17
  44. data/lib/nylas/file.rb +0 -75
  45. data/lib/nylas/filter_attributes.rb +0 -25
  46. data/lib/nylas/folder.rb +0 -26
  47. data/lib/nylas/free_busy.rb +0 -13
  48. data/lib/nylas/free_busy_collection.rb +0 -48
  49. data/lib/nylas/http_client.rb +0 -279
  50. data/lib/nylas/im_address.rb +0 -11
  51. data/lib/nylas/job_status.rb +0 -27
  52. data/lib/nylas/job_status_collection.rb +0 -21
  53. data/lib/nylas/label.rb +0 -27
  54. data/lib/nylas/logging.rb +0 -41
  55. data/lib/nylas/message.rb +0 -98
  56. data/lib/nylas/message_headers.rb +0 -27
  57. data/lib/nylas/message_tracking.rb +0 -13
  58. data/lib/nylas/model/attributable.rb +0 -89
  59. data/lib/nylas/model/attribute_definition.rb +0 -24
  60. data/lib/nylas/model/attributes.rb +0 -97
  61. data/lib/nylas/model/list_attribute_definition.rb +0 -39
  62. data/lib/nylas/model/transferable.rb +0 -53
  63. data/lib/nylas/model.rb +0 -217
  64. data/lib/nylas/native_authentication.rb +0 -39
  65. data/lib/nylas/neural.rb +0 -87
  66. data/lib/nylas/neural_categorizer.rb +0 -29
  67. data/lib/nylas/neural_clean_conversation.rb +0 -33
  68. data/lib/nylas/neural_contact_link.rb +0 -11
  69. data/lib/nylas/neural_contact_name.rb +0 -11
  70. data/lib/nylas/neural_message_options.rb +0 -35
  71. data/lib/nylas/neural_ocr.rb +0 -16
  72. data/lib/nylas/neural_sentiment_analysis.rb +0 -17
  73. data/lib/nylas/neural_signature_contact.rb +0 -81
  74. data/lib/nylas/neural_signature_extraction.rb +0 -18
  75. data/lib/nylas/new_message.rb +0 -39
  76. data/lib/nylas/nylas_date.rb +0 -25
  77. data/lib/nylas/open_hours.rb +0 -15
  78. data/lib/nylas/outbox.rb +0 -116
  79. data/lib/nylas/outbox_job_status.rb +0 -19
  80. data/lib/nylas/outbox_message.rb +0 -17
  81. data/lib/nylas/participant.rb +0 -13
  82. data/lib/nylas/phone_number.rb +0 -11
  83. data/lib/nylas/physical_address.rb +0 -17
  84. data/lib/nylas/raw_message.rb +0 -25
  85. data/lib/nylas/recurrence.rb +0 -11
  86. data/lib/nylas/registry.rb +0 -42
  87. data/lib/nylas/room_resource.rb +0 -19
  88. data/lib/nylas/rsvp.rb +0 -24
  89. data/lib/nylas/scheduler.rb +0 -51
  90. data/lib/nylas/scheduler_booking_confirmation.rb +0 -24
  91. data/lib/nylas/scheduler_booking_request.rb +0 -17
  92. data/lib/nylas/scheduler_collection.rb +0 -104
  93. data/lib/nylas/scheduler_config.rb +0 -20
  94. data/lib/nylas/scheduler_time_slot.rb +0 -14
  95. data/lib/nylas/search_collection.rb +0 -10
  96. data/lib/nylas/send_grid_verified_status.rb +0 -12
  97. data/lib/nylas/services/tunnel.rb +0 -128
  98. data/lib/nylas/thread.rb +0 -66
  99. data/lib/nylas/time_slot.rb +0 -16
  100. data/lib/nylas/time_slot_capacity.rb +0 -13
  101. data/lib/nylas/timespan.rb +0 -20
  102. data/lib/nylas/token_info.rb +0 -20
  103. data/lib/nylas/types.rb +0 -168
  104. data/lib/nylas/web_page.rb +0 -11
  105. data/lib/nylas/webhook.rb +0 -111
  106. data/lib/nylas/when.rb +0 -75
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- # Structure to represent the Web Page Schema
5
- # @see https://docs.nylas.com/reference#contactsid
6
- class WebPage
7
- include Model::Attributable
8
- attribute :type, :string
9
- attribute :url, :string
10
- end
11
- end
data/lib/nylas/webhook.rb DELETED
@@ -1,111 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module WebhookState
4
- # Module representing the possible 'state' values in a Webhook
5
- # @see https://developer.nylas.com/docs/api#post/a/client_id/webhooks
6
-
7
- ACTIVE = "active"
8
- INACTIVE = "inactive"
9
- end
10
-
11
- module WebhookTrigger
12
- # Module representing the possible 'trigger' values in a Webhook
13
- # @see https://developer.nylas.com/docs/api#post/a/client_id/webhooks
14
-
15
- ACCOUNT_CONNECTED = "account.connected"
16
- ACCOUNT_RUNNING = "account.running"
17
- ACCOUNT_STOPPED = "account.stopped"
18
- ACCOUNT_INVALID = "account.invalid"
19
- ACCOUNT_SYNC_ERROR = "account.sync_error"
20
- MESSAGE_CREATED = "message.created"
21
- MESSAGE_OPENED = "message.opened"
22
- MESSAGE_LINK_CLICKED = "message.link_clicked"
23
- MESSAGE_UPDATED = "message.updated"
24
- MESSAGE_BOUNCED = "message.bounced"
25
- THREAD_REPLIED = "thread.replied"
26
- CONTACT_CREATED = "contact.created"
27
- CONTACT_UPDATED = "contact.updated"
28
- CONTACT_DELETED = "contact.deleted"
29
- CALENDAR_CREATED = "calendar.created"
30
- CALENDAR_UPDATED = "calendar.updated"
31
- CALENDAR_DELETED = "calendar.deleted"
32
- EVENT_CREATED = "event.created"
33
- EVENT_UPDATED = "event.updated"
34
- EVENT_DELETED = "event.deleted"
35
- JOB_SUCCESSFUL = "job.successful"
36
- JOB_FAILED = "job.failed"
37
- JOB_DELAYED = "job.delayed"
38
- JOB_CANCELLED = "job.cancelled"
39
- end
40
-
41
- module Nylas
42
- # Represents a webhook attached to your application.
43
- # @see https://docs.nylas.com/reference#webhooks
44
- class Webhook
45
- require "openssl"
46
- include Model
47
- self.creatable = true
48
- self.listable = true
49
- self.showable = true
50
- self.updatable = true
51
- self.destroyable = true
52
- self.auth_method = HttpClient::AuthMethod::BASIC
53
- attribute :id, :string, read_only: true
54
- attribute :application_id, :string, read_only: true
55
-
56
- attribute :callback_url, :string
57
- attribute :state, :string
58
- attribute :version, :string, read_only: true
59
- has_n_of_attribute :triggers, :string
60
-
61
- STATE = [:inactive].freeze
62
-
63
- def save
64
- result = if persisted?
65
- update_call(update_payload)
66
- else
67
- create
68
- end
69
-
70
- attributes.merge(result)
71
- end
72
-
73
- def save_all_attributes
74
- save
75
- end
76
-
77
- def update(**data)
78
- raise ArgumentError, "Only 'state' is allowed to be updated" if data.length > 1 || !data.key?(:state)
79
-
80
- attributes.merge(**data)
81
- payload = JSON.dump(data)
82
- update_call(payload)
83
-
84
- true
85
- end
86
-
87
- def update_all_attributes(**data)
88
- update(**data)
89
- end
90
-
91
- def self.resources_path(api:)
92
- "/a/#{api.app_id}/webhooks"
93
- end
94
-
95
- # Verify incoming webhook signature came from Nylas
96
- # @param nylas_signature [str] The signature to verify
97
- # @param raw_body [str] The raw body from the payload
98
- # @param client_secret [str] Client secret of the app receiving the webhook
99
- # @return [Boolean] True if the webhook signature was verified from Nylas
100
- def self.verify_webhook_signature(nylas_signature, raw_body, client_secret)
101
- digest = OpenSSL::HMAC.hexdigest("SHA256", client_secret, raw_body)
102
- digest == nylas_signature
103
- end
104
-
105
- private
106
-
107
- def update_payload
108
- JSON.dump({ state: state })
109
- end
110
- end
111
- end
data/lib/nylas/when.rb DELETED
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nylas
4
- require "tzinfo"
5
-
6
- # Structure to represent all the Nylas time types.
7
- # @see https://docs.nylas.com/reference#section-time
8
- class When
9
- extend Forwardable
10
-
11
- include Model::Attributable
12
-
13
- attribute :object, :string, read_only: true
14
-
15
- # when object == 'date'
16
- attribute :date, :date
17
-
18
- # when object == 'datespan'
19
- attribute :start_date, :date
20
- attribute :end_date, :date
21
-
22
- # when object == 'time'
23
- attribute :time, :unix_timestamp
24
- # Timezone must be set to a valid IANA database timezone name
25
- attribute :timezone, :string
26
-
27
- # when object == 'timespan'
28
- attribute :start_time, :unix_timestamp
29
- attribute :end_time, :unix_timestamp
30
- # Both timezone fields must be set to a valid IANA database timezone name
31
- attribute :start_timezone, :string
32
- attribute :end_timezone, :string
33
-
34
- def_delegators :range, :cover?
35
-
36
- def as_timespan
37
- return unless object == "timespan"
38
-
39
- Timespan.new(object: object, start_time: start_time, end_time: end_time)
40
- end
41
-
42
- def range
43
- case object
44
- when "timespan"
45
- Range.new(start_time, end_time)
46
- when "datespan"
47
- Range.new(start_date, end_date)
48
- when "date"
49
- Range.new(date, date)
50
- when "time"
51
- Range.new(time, time)
52
- end
53
- end
54
-
55
- # Validates the When object
56
- # @return [Boolean] True if the When is valid
57
- # @raise [ArgumentError] If any of the timezone fields are not valid IANA database names
58
- def valid?
59
- validate_timezone(timezone) if timezone
60
- validate_timezone(start_timezone) if start_timezone
61
- validate_timezone(end_timezone) if end_timezone
62
-
63
- true
64
- end
65
-
66
- private
67
-
68
- def validate_timezone(timezone_var)
69
- return if TZInfo::Timezone.all_identifiers.include?(timezone_var)
70
-
71
- raise ArgumentError,
72
- format("The timezone provided (%s) is not a valid IANA timezone database name", timezone_var)
73
- end
74
- end
75
- end