From 6e0061f1697f4077f10f4e81241fccd94a485e0a Mon Sep 17 00:00:00 2001 From: Andrew Dally Date: Tue, 28 May 2024 10:59:27 -0400 Subject: [PATCH 1/2] nylas -> nylas_v2 (actually) --- .rubocop.yml | 6 +- .rubocop_todo.yml | 34 ++-- .tool-versions | 1 + CHANGELOG.md | 33 ++-- Contributing.md | 10 +- Gemfile | 2 +- README.md | 14 +- bin/release | 2 +- examples/authentication/app.rb | 2 +- examples/listening-for-webhooks/demo-app.rb | 2 +- examples/plain-ruby/accounts.rb | 2 +- examples/plain-ruby/calendars.rb | 2 +- examples/plain-ruby/components.rb | 4 +- examples/plain-ruby/contacts.rb | 4 +- examples/plain-ruby/deltas.rb | 4 +- examples/plain-ruby/drafts.rb | 2 +- examples/plain-ruby/events.rb | 2 +- examples/plain-ruby/files.rb | 2 +- examples/plain-ruby/folders.rb | 2 +- examples/plain-ruby/job_status.rb | 4 +- examples/plain-ruby/labels.rb | 2 +- examples/plain-ruby/messages.rb | 7 +- examples/plain-ruby/neural.rb | 6 +- examples/plain-ruby/outbox.rb | 4 +- examples/plain-ruby/room_resource.rb | 2 +- examples/plain-ruby/scheduler.rb | 10 +- examples/plain-ruby/sending-messages.rb | 4 +- examples/plain-ruby/streaming.rb | 4 +- examples/plain-ruby/threads.rb | 7 +- examples/plain-ruby/webhooks.rb | 2 +- gem_config.rb | 14 +- lib/nylas-streaming.rb | 12 +- lib/{nylas.rb => nylas_v2.rb} | 168 +++++++++--------- lib/{nylas => nylas_v2}/account.rb | 2 +- lib/{nylas => nylas_v2}/api.rb | 4 +- .../application_details.rb | 2 +- lib/{nylas => nylas_v2}/calendar.rb | 2 +- .../calendar_collection.rb | 10 +- lib/{nylas => nylas_v2}/categorize.rb | 2 +- lib/{nylas => nylas_v2}/collection.rb | 2 +- lib/{nylas => nylas_v2}/component.rb | 2 +- .../component_collection.rb | 2 +- lib/{nylas => nylas_v2}/constraints.rb | 2 +- lib/{nylas => nylas_v2}/contact.rb | 2 +- lib/{nylas => nylas_v2}/contact_group.rb | 2 +- lib/{nylas => nylas_v2}/current_account.rb | 2 +- lib/{nylas => nylas_v2}/delta.rb | 2 +- lib/{nylas => nylas_v2}/deltas.rb | 2 +- lib/{nylas => nylas_v2}/deltas_collection.rb | 2 +- lib/{nylas => nylas_v2}/draft.rb | 2 +- lib/{nylas => nylas_v2}/email_address.rb | 2 +- lib/{nylas => nylas_v2}/errors.rb | 2 +- lib/{nylas => nylas_v2}/event.rb | 2 +- lib/{nylas => nylas_v2}/event_collection.rb | 2 +- lib/{nylas => nylas_v2}/event_conferencing.rb | 2 +- .../event_conferencing_autocreate.rb | 2 +- .../event_conferencing_details.rb | 2 +- lib/{nylas => nylas_v2}/event_notification.rb | 2 +- lib/{nylas => nylas_v2}/file.rb | 2 +- lib/{nylas => nylas_v2}/filter_attributes.rb | 2 +- lib/{nylas => nylas_v2}/folder.rb | 2 +- lib/{nylas => nylas_v2}/free_busy.rb | 2 +- .../free_busy_collection.rb | 2 +- lib/{nylas => nylas_v2}/http_client.rb | 12 +- lib/{nylas => nylas_v2}/im_address.rb | 2 +- lib/{nylas => nylas_v2}/job_status.rb | 2 +- .../job_status_collection.rb | 2 +- lib/{nylas => nylas_v2}/label.rb | 2 +- lib/{nylas => nylas_v2}/logging.rb | 2 +- lib/{nylas => nylas_v2}/message.rb | 2 +- lib/{nylas => nylas_v2}/message_headers.rb | 2 +- lib/{nylas => nylas_v2}/message_tracking.rb | 2 +- lib/{nylas => nylas_v2}/model.rb | 2 +- lib/{nylas => nylas_v2}/model/attributable.rb | 2 +- .../model/attribute_definition.rb | 2 +- lib/{nylas => nylas_v2}/model/attributes.rb | 4 +- .../model/list_attribute_definition.rb | 2 +- lib/{nylas => nylas_v2}/model/transferable.rb | 2 +- .../native_authentication.rb | 2 +- lib/{nylas => nylas_v2}/neural.rb | 2 +- lib/{nylas => nylas_v2}/neural_categorizer.rb | 2 +- .../neural_clean_conversation.rb | 2 +- .../neural_contact_link.rb | 2 +- .../neural_contact_name.rb | 2 +- .../neural_message_options.rb | 2 +- lib/{nylas => nylas_v2}/neural_ocr.rb | 2 +- .../neural_sentiment_analysis.rb | 2 +- .../neural_signature_contact.rb | 2 +- .../neural_signature_extraction.rb | 2 +- lib/{nylas => nylas_v2}/new_message.rb | 2 +- lib/{nylas => nylas_v2}/nylas_date.rb | 2 +- lib/{nylas => nylas_v2}/open_hours.rb | 2 +- lib/{nylas => nylas_v2}/outbox.rb | 2 +- lib/{nylas => nylas_v2}/outbox_job_status.rb | 2 +- lib/{nylas => nylas_v2}/outbox_message.rb | 2 +- lib/{nylas => nylas_v2}/participant.rb | 2 +- lib/{nylas => nylas_v2}/phone_number.rb | 2 +- lib/{nylas => nylas_v2}/physical_address.rb | 2 +- lib/{nylas => nylas_v2}/raw_message.rb | 2 +- lib/{nylas => nylas_v2}/recurrence.rb | 2 +- lib/{nylas => nylas_v2}/registry.rb | 2 +- lib/{nylas => nylas_v2}/room_resource.rb | 2 +- lib/{nylas => nylas_v2}/rsvp.rb | 2 +- lib/{nylas => nylas_v2}/scheduler.rb | 2 +- .../scheduler_booking_confirmation.rb | 2 +- .../scheduler_booking_request.rb | 2 +- .../scheduler_collection.rb | 2 +- lib/{nylas => nylas_v2}/scheduler_config.rb | 2 +- .../scheduler_time_slot.rb | 2 +- lib/{nylas => nylas_v2}/search_collection.rb | 2 +- .../send_grid_verified_status.rb | 2 +- lib/{nylas => nylas_v2}/thread.rb | 2 +- lib/{nylas => nylas_v2}/time_slot.rb | 2 +- lib/{nylas => nylas_v2}/time_slot_capacity.rb | 2 +- lib/{nylas => nylas_v2}/timespan.rb | 2 +- lib/{nylas => nylas_v2}/token_info.rb | 2 +- lib/{nylas => nylas_v2}/types.rb | 2 +- lib/{nylas => nylas_v2}/version.rb | 2 +- lib/{nylas => nylas_v2}/web_page.rb | 2 +- lib/{nylas => nylas_v2}/webhook.rb | 2 +- lib/{nylas => nylas_v2}/when.rb | 2 +- ...ming.gemspec => nylas-v2-streaming.gemspec | 4 +- nylas.gemspec => nylas-v2.gemspec | 2 +- spec/{nylas => nylas_v2}/account_spec.rb | 26 +-- spec/{nylas => nylas_v2}/api_spec.rb | 36 ++-- .../calendar_collection_spec.rb | 38 ++-- spec/{nylas => nylas_v2}/calendar_spec.rb | 22 +-- spec/{nylas => nylas_v2}/collection_spec.rb | 60 +++---- spec/{nylas => nylas_v2}/component_spec.rb | 18 +- .../{nylas => nylas_v2}/contact_group_spec.rb | 4 +- spec/{nylas => nylas_v2}/contact_spec.rb | 4 +- .../current_account_spec.rb | 2 +- spec/{nylas => nylas_v2}/delta_spec.rb | 4 +- .../deltas_collection_spec.rb | 14 +- spec/{nylas => nylas_v2}/deltas_spec.rb | 16 +- spec/{nylas => nylas_v2}/draft_spec.rb | 50 +++--- spec/{nylas => nylas_v2}/event_spec.rb | 90 +++++----- .../filter_attributes_spec.rb | 2 +- spec/{nylas => nylas_v2}/folder_spec.rb | 18 +- .../free_busy_collection_spec.rb | 4 +- spec/{nylas => nylas_v2}/free_busy_spec.rb | 2 +- spec/{nylas => nylas_v2}/http_client_spec.rb | 40 ++--- spec/{nylas => nylas_v2}/job_status_spec.rb | 2 +- spec/{nylas => nylas_v2}/label_spec.rb | 2 +- spec/{nylas => nylas_v2}/message_spec.rb | 30 ++-- .../model/attributes_spec.rb | 2 +- spec/{nylas => nylas_v2}/model_spec.rb | 24 +-- .../native_authentication_spec.rb | 18 +- spec/{nylas => nylas_v2}/neural_spec.rb | 30 ++-- spec/{nylas => nylas_v2}/new_message_spec.rb | 4 +- .../outbox_job_status_spec.rb | 2 +- .../outbox_message_spec.rb | 4 +- spec/{nylas => nylas_v2}/outbox_spec.rb | 6 +- spec/{nylas => nylas_v2}/raw_message_spec.rb | 2 +- .../{nylas => nylas_v2}/room_resource_spec.rb | 8 +- .../scheduler_collection_spec.rb | 34 ++-- spec/{nylas => nylas_v2}/scheduler_spec.rb | 40 ++--- .../send_grid_verified_status_spec.rb | 2 +- spec/{nylas => nylas_v2}/thread_spec.rb | 14 +- spec/{nylas => nylas_v2}/webhook_spec.rb | 26 +-- spec/{nylas => nylas_v2}/when_spec.rb | 2 +- spec/spec_helper.rb | 12 +- 162 files changed, 646 insertions(+), 648 deletions(-) create mode 100644 .tool-versions rename lib/{nylas.rb => nylas_v2.rb} (53%) rename lib/{nylas => nylas_v2}/account.rb (99%) rename lib/{nylas => nylas_v2}/api.rb (99%) rename lib/{nylas => nylas_v2}/application_details.rb (95%) rename lib/{nylas => nylas_v2}/calendar.rb (98%) rename lib/{nylas => nylas_v2}/calendar_collection.rb (92%) rename lib/{nylas => nylas_v2}/categorize.rb (96%) rename lib/{nylas => nylas_v2}/collection.rb (99%) rename lib/{nylas => nylas_v2}/component.rb (98%) rename lib/{nylas => nylas_v2}/component_collection.rb (93%) rename lib/{nylas => nylas_v2}/constraints.rb (99%) rename lib/{nylas => nylas_v2}/contact.rb (99%) rename lib/{nylas => nylas_v2}/contact_group.rb (97%) rename lib/{nylas => nylas_v2}/current_account.rb (97%) rename lib/{nylas => nylas_v2}/delta.rb (98%) rename lib/{nylas => nylas_v2}/deltas.rb (97%) rename lib/{nylas => nylas_v2}/deltas_collection.rb (98%) rename lib/{nylas => nylas_v2}/draft.rb (99%) rename lib/{nylas => nylas_v2}/email_address.rb (95%) rename lib/{nylas => nylas_v2}/errors.rb (99%) rename lib/{nylas => nylas_v2}/event.rb (99%) rename lib/{nylas => nylas_v2}/event_collection.rb (95%) rename lib/{nylas => nylas_v2}/event_conferencing.rb (96%) rename lib/{nylas => nylas_v2}/event_conferencing_autocreate.rb (95%) rename lib/{nylas => nylas_v2}/event_conferencing_details.rb (96%) rename lib/{nylas => nylas_v2}/event_notification.rb (96%) rename lib/{nylas => nylas_v2}/file.rb (99%) rename lib/{nylas => nylas_v2}/filter_attributes.rb (97%) rename lib/{nylas => nylas_v2}/folder.rb (97%) rename lib/{nylas => nylas_v2}/free_busy.rb (95%) rename lib/{nylas => nylas_v2}/free_busy_collection.rb (98%) rename lib/{nylas => nylas_v2}/http_client.rb (97%) rename lib/{nylas => nylas_v2}/im_address.rb (94%) rename lib/{nylas => nylas_v2}/job_status.rb (98%) rename lib/{nylas => nylas_v2}/job_status_collection.rb (97%) rename lib/{nylas => nylas_v2}/label.rb (97%) rename lib/{nylas => nylas_v2}/logging.rb (98%) rename lib/{nylas => nylas_v2}/message.rb (99%) rename lib/{nylas => nylas_v2}/message_headers.rb (98%) rename lib/{nylas => nylas_v2}/message_tracking.rb (95%) rename lib/{nylas => nylas_v2}/model.rb (99%) rename lib/{nylas => nylas_v2}/model/attributable.rb (99%) rename lib/{nylas => nylas_v2}/model/attribute_definition.rb (97%) rename lib/{nylas => nylas_v2}/model/attributes.rb (98%) rename lib/{nylas => nylas_v2}/model/list_attribute_definition.rb (98%) rename lib/{nylas => nylas_v2}/model/transferable.rb (98%) rename lib/{nylas => nylas_v2}/native_authentication.rb (99%) rename lib/{nylas => nylas_v2}/neural.rb (99%) rename lib/{nylas => nylas_v2}/neural_categorizer.rb (98%) rename lib/{nylas => nylas_v2}/neural_clean_conversation.rb (98%) rename lib/{nylas => nylas_v2}/neural_contact_link.rb (96%) rename lib/{nylas => nylas_v2}/neural_contact_name.rb (96%) rename lib/{nylas => nylas_v2}/neural_message_options.rb (98%) rename lib/{nylas => nylas_v2}/neural_ocr.rb (96%) rename lib/{nylas => nylas_v2}/neural_sentiment_analysis.rb (97%) rename lib/{nylas => nylas_v2}/neural_signature_contact.rb (99%) rename lib/{nylas => nylas_v2}/neural_signature_extraction.rb (97%) rename lib/{nylas => nylas_v2}/new_message.rb (98%) rename lib/{nylas => nylas_v2}/nylas_date.rb (97%) rename lib/{nylas => nylas_v2}/open_hours.rb (96%) rename lib/{nylas => nylas_v2}/outbox.rb (99%) rename lib/{nylas => nylas_v2}/outbox_job_status.rb (97%) rename lib/{nylas => nylas_v2}/outbox_message.rb (96%) rename lib/{nylas => nylas_v2}/participant.rb (95%) rename lib/{nylas => nylas_v2}/phone_number.rb (94%) rename lib/{nylas => nylas_v2}/physical_address.rb (96%) rename lib/{nylas => nylas_v2}/raw_message.rb (97%) rename lib/{nylas => nylas_v2}/recurrence.rb (94%) rename lib/{nylas => nylas_v2}/registry.rb (98%) rename lib/{nylas => nylas_v2}/room_resource.rb (97%) rename lib/{nylas => nylas_v2}/rsvp.rb (97%) rename lib/{nylas => nylas_v2}/scheduler.rb (98%) rename lib/{nylas => nylas_v2}/scheduler_booking_confirmation.rb (98%) rename lib/{nylas => nylas_v2}/scheduler_booking_request.rb (97%) rename lib/{nylas => nylas_v2}/scheduler_collection.rb (99%) rename lib/{nylas => nylas_v2}/scheduler_config.rb (97%) rename lib/{nylas => nylas_v2}/scheduler_time_slot.rb (96%) rename lib/{nylas => nylas_v2}/search_collection.rb (93%) rename lib/{nylas => nylas_v2}/send_grid_verified_status.rb (95%) rename lib/{nylas => nylas_v2}/thread.rb (99%) rename lib/{nylas => nylas_v2}/time_slot.rb (96%) rename lib/{nylas => nylas_v2}/time_slot_capacity.rb (95%) rename lib/{nylas => nylas_v2}/timespan.rb (96%) rename lib/{nylas => nylas_v2}/token_info.rb (97%) rename lib/{nylas => nylas_v2}/types.rb (99%) rename lib/{nylas => nylas_v2}/version.rb (78%) rename lib/{nylas => nylas_v2}/web_page.rb (94%) rename lib/{nylas => nylas_v2}/webhook.rb (99%) rename lib/{nylas => nylas_v2}/when.rb (99%) rename nylas-streaming.gemspec => nylas-v2-streaming.gemspec (79%) rename nylas.gemspec => nylas-v2.gemspec (90%) rename spec/{nylas => nylas_v2}/account_spec.rb (81%) rename spec/{nylas => nylas_v2}/api_spec.rb (89%) rename spec/{nylas => nylas_v2}/calendar_collection_spec.rb (84%) rename spec/{nylas => nylas_v2}/calendar_spec.rb (89%) rename spec/{nylas => nylas_v2}/collection_spec.rb (82%) rename spec/{nylas => nylas_v2}/component_spec.rb (90%) rename spec/{nylas => nylas_v2}/contact_group_spec.rb (94%) rename spec/{nylas => nylas_v2}/contact_spec.rb (97%) rename spec/{nylas => nylas_v2}/current_account_spec.rb (97%) rename spec/{nylas => nylas_v2}/delta_spec.rb (96%) rename spec/{nylas => nylas_v2}/deltas_collection_spec.rb (83%) rename spec/{nylas => nylas_v2}/deltas_spec.rb (93%) rename spec/{nylas => nylas_v2}/draft_spec.rb (87%) rename spec/{nylas => nylas_v2}/event_spec.rb (89%) rename spec/{nylas => nylas_v2}/filter_attributes_spec.rb (95%) rename spec/{nylas => nylas_v2}/folder_spec.rb (84%) rename spec/{nylas => nylas_v2}/free_busy_collection_spec.rb (96%) rename spec/{nylas => nylas_v2}/free_busy_spec.rb (97%) rename spec/{nylas => nylas_v2}/http_client_spec.rb (90%) rename spec/{nylas => nylas_v2}/job_status_spec.rb (98%) rename spec/{nylas => nylas_v2}/label_spec.rb (96%) rename spec/{nylas => nylas_v2}/message_spec.rb (92%) rename spec/{nylas => nylas_v2}/model/attributes_spec.rb (94%) rename spec/{nylas => nylas_v2}/model_spec.rb (92%) rename spec/{nylas => nylas_v2}/native_authentication_spec.rb (89%) rename spec/{nylas => nylas_v2}/neural_spec.rb (92%) rename spec/{nylas => nylas_v2}/new_message_spec.rb (91%) rename spec/{nylas => nylas_v2}/outbox_job_status_spec.rb (97%) rename spec/{nylas => nylas_v2}/outbox_message_spec.rb (98%) rename spec/{nylas => nylas_v2}/outbox_spec.rb (95%) rename spec/{nylas => nylas_v2}/raw_message_spec.rb (96%) rename spec/{nylas => nylas_v2}/room_resource_spec.rb (88%) rename spec/{nylas => nylas_v2}/scheduler_collection_spec.rb (87%) rename spec/{nylas => nylas_v2}/scheduler_spec.rb (86%) rename spec/{nylas => nylas_v2}/send_grid_verified_status_spec.rb (89%) rename spec/{nylas => nylas_v2}/thread_spec.rb (93%) rename spec/{nylas => nylas_v2}/webhook_spec.rb (84%) rename spec/{nylas => nylas_v2}/when_spec.rb (98%) diff --git a/.rubocop.yml b/.rubocop.yml index 38ae91e0..65b41978 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -24,15 +24,15 @@ Metrics/BlockLength: Metrics/ParameterLists: Max: 8 Exclude: - - "lib/nylas/calendar_collection.rb" + - "lib/nylas_v2/calendar_collection.rb" Metrics/MethodLength: Exclude: - - "lib/nylas/calendar_collection.rb" + - "lib/nylas_v2/calendar_collection.rb" Metrics/ModuleLength: Exclude: - - "lib/nylas/model.rb" + - "lib/nylas_v2/model.rb" Naming/FileName: Exclude: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 581841b8..02961513 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -19,13 +19,13 @@ Gemspec/RequiredRubyVersion: # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. Layout/EmptyLineBetweenDefs: Exclude: - - 'lib/nylas/errors.rb' + - 'lib/nylas_v2/errors.rb' # Offense count: 1 # Configuration parameters: AllowComments, AllowNil. Lint/SuppressedException: Exclude: - - 'lib/nylas/logging.rb' + - 'lib/nylas_v2/logging.rb' # Offense count: 1 # Configuration parameters: IgnoredMethods. @@ -42,19 +42,19 @@ Metrics/MethodLength: # Configuration parameters: AllowConsecutiveOneLiners. RSpec/EmptyLineAfterExample: Exclude: - - 'spec/nylas/message_spec.rb' + - 'spec/nylas_v2/message_spec.rb' # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: CustomTransform, IgnoredWords. RSpec/ExampleWording: Exclude: - - 'spec/nylas/http_client_spec.rb' + - 'spec/nylas_v2/http_client_spec.rb' # Offense count: 8 RSpec/StubbedMock: Exclude: - - 'spec/nylas/native_authentication_spec.rb' + - 'spec/nylas_v2/native_authentication_spec.rb' # Offense count: 6 # Cop supports --auto-correct. @@ -62,8 +62,8 @@ RSpec/StubbedMock: # SupportedStyles: separated, grouped Style/AccessorGrouping: Exclude: - - 'lib/nylas/errors.rb' - - 'lib/nylas/http_client.rb' + - 'lib/nylas_v2/errors.rb' + - 'lib/nylas_v2/http_client.rb' # Offense count: 1 # Configuration parameters: AllowedConstants. @@ -71,39 +71,39 @@ Style/Documentation: Exclude: - 'spec/**/*' - 'test/**/*' - - 'lib/nylas/http_client.rb' - - 'lib/nylas/when.rb' + - 'lib/nylas_v2/http_client.rb' + - 'lib/nylas_v2/when.rb' # Offense count: 1 # Cop supports --auto-correct. Style/ExplicitBlockArgument: Exclude: - - 'lib/nylas/collection.rb' + - 'lib/nylas_v2/collection.rb' # Offense count: 1 # Cop supports --auto-correct. Style/GlobalStdStream: Exclude: - - 'lib/nylas/logging.rb' + - 'lib/nylas_v2/logging.rb' # Offense count: 1 # Cop supports --auto-correct. Style/IfUnlessModifier: Exclude: - - 'lib/nylas/model/attributable.rb' + - 'lib/nylas_v2/model/attributable.rb' # Offense count: 2 # Cop supports --auto-correct. Style/KeywordParametersOrder: Exclude: - - 'lib/nylas/http_client.rb' - - 'lib/nylas/model.rb' + - 'lib/nylas_v2/http_client.rb' + - 'lib/nylas_v2/model.rb' # Offense count: 1 # Cop supports --auto-correct. Style/RedundantAssignment: Exclude: - - 'lib/nylas/model.rb' + - 'lib/nylas_v2/model.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -115,10 +115,10 @@ Style/RedundantBegin: # Cop supports --auto-correct. Style/RedundantSelf: Exclude: - - 'lib/nylas/message.rb' + - 'lib/nylas_v2/message.rb' # Offense count: 1 # Cop supports --auto-correct. Style/StringConcatenation: Exclude: - - 'spec/nylas/model_spec.rb' + - 'spec/nylas_v2/model_spec.rb' diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..d6608a7e --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 3.0.6 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bd77b8b..219f983e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,7 +82,7 @@ ### 5.3.0 / 2021-08-18 * Add support for Neural API * Fix issue where `Delta` did not have a header attribute for expanded headers -* Fix ArgumentError when calling `Nylas::API#send!` due to missing double splat (**) +* Fix ArgumentError when calling `NylasV2::API#send!` due to missing double splat (**) * Fix issue where server errors are not reported if HTML is returned * Fix issue where expanded `Thread` objects were not returning messages @@ -160,10 +160,10 @@ ### 4.6.0 / 2019-09-25 * Add support for `/contacts/groups` endpoint. -* Fix issue when calling `.save` on `message` (https://github.com/nylas/nylas-ruby/pull/233) +* Fix issue when calling `.save` on `message` (https://github.com/nylas_v2/nylas-ruby/pull/233) * Add support for Rails 6. -* Fix issue for updating `message` with sending `label_ids` (https://github.com/nylas/nylas-ruby/pull/231) -* Support for `when` in `Nylas::Event` for more attributes. +* Fix issue for updating `message` with sending `label_ids` (https://github.com/nylas_v2/nylas-ruby/pull/231) +* Support for `when` in `NylasV2::Event` for more attributes. * Add internal transfer api to support initialize related objects. * Fix encoding issues when downloading attachments. @@ -183,14 +183,14 @@ * Drop support for Ruby 2.2 and 2.3: they have reached end-of-life * Add support for Ruby 2.5 and 2.6 -* Add `scopes` argument to `Nylas::API#authenticate` for +* Add `scopes` argument to `NylasV2::API#authenticate` for [selective sync](https://docs.nylas.com/docs/how-to-use-selective-sync) * Add `Account#revoke_all` * Add X-Nylas-Client-Id header for HTTP requests ### 4.2.4 / 2018-08-07 * Enables silent addition of fields to API without impact to SDK -* Fixes api attribute breakage on enumeration (https://github.com/nylas/nylas-ruby/issues/188) +* Fixes api attribute breakage on enumeration (https://github.com/nylas_v2/nylas-ruby/issues/188) ### 4.0.0 / 2018-01-?? * Drop support for ruby 2.0 and below @@ -206,7 +206,7 @@ * Numerous other bug fixes ### 3.1.1 / 2017-06-23 -* Fix deleting event request (https://github.com/nylas/nylas-ruby/issues/101) +* Fix deleting event request (https://github.com/nylas_v2/nylas-ruby/issues/101) ### 3.1.0 / 2017-05-10 * Adds support for message tracking (https://github.com/cberkom) @@ -219,14 +219,14 @@ * Add webhooks example code * Removes experimental JRuby support -[full changelog](https://github.com/nylas/nylas-ruby/compare/v2.0.1...v3.0.0) +[full changelog](https://github.com/nylas_v2/nylas-ruby/compare/v2.0.1...v3.0.0) ### 2.0.1 / 2016-02-12 * Fix folders and labels updates for threads and messages * Revert pull request #71 -[full changelog](https://github.com/nylas/nylas-ruby/compare/v2.0.0...v2.0.1) +[full changelog](https://github.com/nylas_v2/nylas-ruby/compare/v2.0.0...v2.0.1) ### 2.0.0 / 2016-02-05 @@ -234,20 +234,20 @@ * Modify `delta_stream method` to remove built-in `EventMachine.run` block and allow for multiple streams. `delta_stream` must now be called from inside an `EventMachine.run` block * `url_for_authentication` now accepts a `:state` parameter (see https://nylas.com/docs#server_side_explicit_flow for more details) -[full changelog](https://github.com/nylas/nylas-ruby/compare/v1.3.0...v2.0.0) +[full changelog](https://github.com/nylas_v2/nylas-ruby/compare/v1.3.0...v2.0.0) ### 1.3.0 / 2015-12-07 * Deprecate the tags API * Remove the archive!/unarchive! methods -* Expose `starred`, `unread`, `has_attachments` in Nylas::Thread +* Expose `starred`, `unread`, `has_attachments` in NylasV2::Thread -[full changelog](https://github.com/nylas/nylas-ruby/compare/v1.2.1...v1.3.0) +[full changelog](https://github.com/nylas_v2/nylas-ruby/compare/v1.2.1...v1.3.0) ### 1.2.0 / 2015-11-19 -* Add `Messages#files?` [Issue #40](https://github.com/nylas/nylas-ruby/issues/40) -* Return an external Enumerator when no block given. [Issue #42](https://github.com/nylas/nylas-ruby/issues/42) ([Steven Harman](https://github.com/stevenharman)) +* Add `Messages#files?` [Issue #40](https://github.com/nylas_v2/nylas-ruby/issues/40) +* Return an external Enumerator when no block given. [Issue #42](https://github.com/nylas_v2/nylas-ruby/issues/42) ([Steven Harman](https://github.com/stevenharman)) * Expose `folders` in the Delta Stream API. * Add `Inbox::Error` base class for all errors. ([Steven Harman](https://github.com/stevenharman)) * Expose `sync_state` on the `/account` API. ([Steven Harman](https://github.com/stevenharman)) @@ -255,7 +255,7 @@ * Ruby < 1.9.3 no longer supported * Add travis support for Mac OS X -[full changelog](https://github.com/nylas/nylas-ruby/compare/v1.1.0...v1.2.0) +[full changelog](https://github.com/nylas_v2/nylas-ruby/compare/v1.1.0...v1.2.0) ### 1.1.0 / 2015-09-22 @@ -265,5 +265,4 @@ * minor bug fixes * various test cleanups ([Steven Harman](https://github.com/stevenharman)) -[full changelog](https://github.com/nylas/nylas-ruby/compare/v1.0.0...v1.1.0) - +[full changelog](https://github.com/nylas_v2/nylas-ruby/compare/v1.0.0...v1.1.0) diff --git a/Contributing.md b/Contributing.md index 019c09c3..13e49a01 100644 --- a/Contributing.md +++ b/Contributing.md @@ -5,18 +5,18 @@ The following is a set of guidelines for contributing to the Nylas Ruby SDK; the # How to Ask a Question -If you have a question about how to use the Ruby SDK, please [create an issue](https://github.com/nylas/nylas-ruby/issues) and label it as a question. If you have more general questions about the Nylas Communications Platform, or the Nylas Email, Calendar, and Contacts API, please reach out to support@nylas.com to get help. +If you have a question about how to use the Ruby SDK, please [create an issue](https://github.com/nylas_v2/nylas-ruby/issues) and label it as a question. If you have more general questions about the Nylas Communications Platform, or the Nylas Email, Calendar, and Contacts API, please reach out to support@nylas.com to get help. # How To Contribute ## Report a Bug or Request a Feature -If you encounter any bugs while using this software, or want to request a new feature or enhancement, please [create an issue to report it](https://github.com/nylas/nylas-ruby/issues), and make sure you add a label to indicate what type of issue it is. +If you encounter any bugs while using this software, or want to request a new feature or enhancement, please [create an issue to report it](https://github.com/nylas_v2/nylas-ruby/issues), and make sure you add a label to indicate what type of issue it is. ## Contribute Code -Pull requests are welcome for bug fixes. If you want to implement something new, [please request a feature first so we can discuss it](https://github.com/nylas/nylas-ruby/issues). +Pull requests are welcome for bug fixes. If you want to implement something new, [please request a feature first so we can discuss it](https://github.com/nylas_v2/nylas-ruby/issues). -While writing your code contribution, make sure you follow the testing conventions found in the [spec](https://github.com/nylas/nylas-ruby/tree/master/spec/nylas) [directory](https://github.com/nylas/nylas-ruby/tree/master/spec/nylas) for any components that you add. +While writing your code contribution, make sure you follow the testing conventions found in the [spec](https://github.com/nylas_v2/nylas-ruby/tree/master/spec/nylas) [directory](https://github.com/nylas_v2/nylas-ruby/tree/master/spec/nylas) for any components that you add. - Pull requests may be submitted before they are feature complete to get feedback and thoughts from the core team. - Pull requests should pass tests across the supported versions of Ruby, as defined in .travis.yml. To do so, run bin/test. @@ -26,4 +26,4 @@ While writing your code contribution, make sure you follow the testing conventio Before you submit any code, we need you to sign our [Contributor License Agreement](https://docs.google.com/forms/d/e/1FAIpQLSdCnXWsaTkw5jhJ8DMtMu5TUI9Q-El_rCuGzkdBvnNJr8oDWQ/viewform); this ensures we can continue to protect your contributions under an open source license well into the future. -Please follow [best practices](https://github.com/trein/dev-best-practices/wiki/Git-Commit-Best-Practices) for creating git commits. When your code is ready to be submitted, you can [submit a pull request](https://help.github.com/articles/creating-a-pull-request/) to begin the code review process. \ No newline at end of file +Please follow [best practices](https://github.com/trein/dev-best-practices/wiki/Git-Commit-Best-Practices) for creating git commits. When your code is ready to be submitted, you can [submit a pull request](https://help.github.com/articles/creating-a-pull-request/) to begin the code review process. diff --git a/Gemfile b/Gemfile index 1c1dd47e..07961907 100644 --- a/Gemfile +++ b/Gemfile @@ -2,4 +2,4 @@ source "https://rubygems.org" -gemspec name: "nylas" +gemspec name: "nylas-v2" diff --git a/README.md b/README.md index 60981ddb..48d880cd 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ # Nylas Ruby SDK -[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/nylas/nylas-ruby/CI)](https://github.com/nylas/nylas-ruby/actions/workflows/rspec.yml) -[![codecov](https://codecov.io/gh/nylas/nylas-ruby/branch/main/graph/badge.svg?token=IKH0YMH4KA)](https://codecov.io/gh/nylas/nylas-ruby) +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/nylas_v2/nylas-ruby/CI)](https://github.com/nylas_v2/nylas-ruby/actions/workflows/rspec.yml) +[![codecov](https://codecov.io/gh/nylas_v2/nylas-ruby/branch/main/graph/badge.svg?token=IKH0YMH4KA)](https://codecov.io/gh/nylas_v2/nylas-ruby) The Nylas Communications Platform allows developers to quickly build features that connect to every inbox, calendar, and contacts book in the world. Nylas makes it easy to build an integration that can be completed in days, and provides pre-built security and compliance features, and a 99.9% guaranteed uptime. Integrations with the Nylas Communications Platform are secure, reliable, and easy to use and maintain. @@ -27,7 +27,7 @@ If you have a question that needs an answer, please reach out to support@nylas.c - Ruby 2.3 or above. - Ruby Frameworks: `rest-client`, `json`, `yajl-ruby`. -We support Rails 4.2 and above. A more detailed compatibility list can be found in our [list of Gemfiles](https://github.com/nylas/nylas-ruby/tree/master/gemfiles). +We support Rails 4.2 and above. A more detailed compatibility list can be found in our [list of Gemfiles](https://github.com/nylas_v2/nylas-ruby/tree/master/gemfiles). ### Install @@ -52,7 +52,7 @@ gem install nylas To install the SDK from source, clone this repo and install with bundle. ```bash -git clone https://github.com/nylas/nylas-ruby.git && cd nylas-ruby +git clone https://github.com/nylas_v2/nylas-ruby.git && cd nylas-ruby bundle install ``` @@ -76,7 +76,7 @@ You can run tests locally using ```rspec```: ```shell rspec spec ``` - + ### MacOS 10.11 (El Capitan) Note Apple stopped bundling OpenSSL with MacOS 10.11. However, one of the dependencies of this gem (EventMachine) requires it. If you're on El Capitan and are unable to install the gem, try running the following commands in a terminal: @@ -99,7 +99,7 @@ All of the functionality of the Nylas Communications Platform is available throu ```ruby require 'nylas' -nylas = Nylas::API.new( +nylas = NylasV2::API.new( app_id: CLIENT_ID, app_secret: CLIENT_SECRET, access_token: ACCESS_TOKEN @@ -122,4 +122,4 @@ Please refer to [Contributing](Contributing.md) for information about how to mak ## 📝 License -This project is licensed under the terms of the MIT license. Please refer to [LICENSE](LICENSE.txt) for the full terms. +This project is licensed under the terms of the MIT license. Please refer to [LICENSE](LICENSE.txt) for the full terms. diff --git a/bin/release b/bin/release index 13c7366e..7c39db80 100755 --- a/bin/release +++ b/bin/release @@ -2,7 +2,7 @@ set -e bin/test -SDK_VERSION=`ruby -e "require './lib/nylas/version' ; puts Nylas::VERSION"` +SDK_VERSION=`ruby -e "require './lib/nylas_v2/version' ; puts NylasV2::VERSION"` echo "Going to release version $SDK_VERSION of the SDK!" gem build nylas.gemspec diff --git a/examples/authentication/app.rb b/examples/authentication/app.rb index abe2e128..1113ef8e 100644 --- a/examples/authentication/app.rb +++ b/examples/authentication/app.rb @@ -24,7 +24,7 @@ send(method, "/auth/:provider/callback") do auth_hash = env['omniauth.auth'] # => OmniAuth::AuthHash - api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET']) + api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET']) nylas_token = api.authenticate(name: auth_hash[:info][:name], email_address: auth_hash[:info][:email], provider: :gmail, settings: { google_client_id: ENV['GOOGLE_CLIENT_ID'], diff --git a/examples/listening-for-webhooks/demo-app.rb b/examples/listening-for-webhooks/demo-app.rb index 8c5b875a..ec719df2 100644 --- a/examples/listening-for-webhooks/demo-app.rb +++ b/examples/listening-for-webhooks/demo-app.rb @@ -10,7 +10,7 @@ json = request.body.read logger.info ["json", json] data = JSON.parse(json, symbolize_names: true) - deltas = Nylas::Deltas.new(**data) + deltas = NylasV2::Deltas.new(**data) deltas.map do |delta| logger.info ["delta", delta.to_h] logger.info ["instance", delta.instance.class, delta.instance.to_h] diff --git a/examples/plain-ruby/accounts.rb b/examples/plain-ruby/accounts.rb index 431f2a9b..90eb691b 100644 --- a/examples/plain-ruby/accounts.rb +++ b/examples/plain-ruby/accounts.rb @@ -2,7 +2,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the API. It # follows the rough structure of the [Nylas API Reference](https://docs.nylas.com/reference). -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) # Retrieving the account information for given access token diff --git a/examples/plain-ruby/calendars.rb b/examples/plain-ruby/calendars.rb index f9bd99af..635eae73 100644 --- a/examples/plain-ruby/calendars.rb +++ b/examples/plain-ruby/calendars.rb @@ -3,7 +3,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the Nylas # Calendar API. # See https://docs.nylas.com/reference#calendars -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) diff --git a/examples/plain-ruby/components.rb b/examples/plain-ruby/components.rb index f4c7b525..e54bb011 100644 --- a/examples/plain-ruby/components.rb +++ b/examples/plain-ruby/components.rb @@ -2,7 +2,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the API. It # follows the rough structure of the [Nylas API Reference](https://docs.nylas.com/reference). -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET']) +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET']) # Create a component # NOTE: you will need to set the account_id and the access_token @@ -23,4 +23,4 @@ demonstrate { example_component.name } # Delete a component -demonstrate { example_component.destroy } \ No newline at end of file +demonstrate { example_component.destroy } diff --git a/examples/plain-ruby/contacts.rb b/examples/plain-ruby/contacts.rb index 6da518fa..0b2a84dc 100644 --- a/examples/plain-ruby/contacts.rb +++ b/examples/plain-ruby/contacts.rb @@ -1,7 +1,7 @@ require_relative '../helpers' # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the API. It # follows the rough structure of the [Nylas API Reference](https://docs.nylas.com/reference). -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) # Retrieving a count of contacts demonstrate { api.contacts.count } @@ -66,7 +66,7 @@ demonstrate { contact_with_picture.picture_url } begin demonstrate { contact_with_picture.picture } -rescue Nylas::ResourceNotFound +rescue NylasV2::ResourceNotFound puts "That contacts picture didn't propagate yet :/" end diff --git a/examples/plain-ruby/deltas.rb b/examples/plain-ruby/deltas.rb index 5e8fa4cf..3fa55a28 100644 --- a/examples/plain-ruby/deltas.rb +++ b/examples/plain-ruby/deltas.rb @@ -3,7 +3,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the Nylas # # Deltas API. # See https://docs.nylas.com/reference#deltas -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) @@ -27,7 +27,7 @@ # 5 delta's demonstrate { deltas_from_cursor.take(5).map(&:to_h) } -# Models are cast to Nylas::Model objects +# Models are cast to NylasV2::Model objects demonstrate { deltas_from_cursor.first&.model&.class } # And can be viewed directly diff --git a/examples/plain-ruby/drafts.rb b/examples/plain-ruby/drafts.rb index b71f790f..f02e3177 100644 --- a/examples/plain-ruby/drafts.rb +++ b/examples/plain-ruby/drafts.rb @@ -2,7 +2,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the Nylas # Drafts API. See https://docs.nylas.com/reference#drafts for API documentation -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) # Creating a draft diff --git a/examples/plain-ruby/events.rb b/examples/plain-ruby/events.rb index 3aa1b95c..812e5e74 100644 --- a/examples/plain-ruby/events.rb +++ b/examples/plain-ruby/events.rb @@ -3,7 +3,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the Nylas # Events API. # See https://docs.nylas.com/reference#events -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) # Counting the events diff --git a/examples/plain-ruby/files.rb b/examples/plain-ruby/files.rb index c3c40a5b..7659647a 100644 --- a/examples/plain-ruby/files.rb +++ b/examples/plain-ruby/files.rb @@ -3,7 +3,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the Nylas Files # API. # See https://docs.nylas.com/reference#files -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) # Listing files diff --git a/examples/plain-ruby/folders.rb b/examples/plain-ruby/folders.rb index 2f005646..d8e50913 100644 --- a/examples/plain-ruby/folders.rb +++ b/examples/plain-ruby/folders.rb @@ -2,7 +2,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the API. It # follows the rough structure of the [Nylas API Reference](https://docs.nylas.com/reference). -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_FOLDER_USERS_ACCESS_TOKEN']) # Retrieving the count of folders diff --git a/examples/plain-ruby/job_status.rb b/examples/plain-ruby/job_status.rb index ad80b460..d12b044b 100644 --- a/examples/plain-ruby/job_status.rb +++ b/examples/plain-ruby/job_status.rb @@ -2,7 +2,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the Nylas # Drafts API. See https://docs.nylas.com/reference#drafts for API documentation -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) # Getting all job statuses @@ -15,4 +15,4 @@ end # Get a boolean value representing status -demonstrate { api.job_statuses.first.successful? } \ No newline at end of file +demonstrate { api.job_statuses.first.successful? } diff --git a/examples/plain-ruby/labels.rb b/examples/plain-ruby/labels.rb index 43621fe7..c64a47b4 100644 --- a/examples/plain-ruby/labels.rb +++ b/examples/plain-ruby/labels.rb @@ -2,7 +2,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the API. It # follows the rough structure of the [Nylas API Reference](https://docs.nylas.com/reference). -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) # Retrieving the count of labels diff --git a/examples/plain-ruby/messages.rb b/examples/plain-ruby/messages.rb index 30b6e52f..6b5740af 100644 --- a/examples/plain-ruby/messages.rb +++ b/examples/plain-ruby/messages.rb @@ -2,7 +2,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the Nylas # Messages API. See https://docs.nylas.com/reference#messages for API documentation -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) # Retrieving a count of messages @@ -27,7 +27,7 @@ demonstrate do begin api.messages.create - rescue Nylas::ModelNotCreatableError => e + rescue NylasV2::ModelNotCreatableError => e "#{e.class}: #{e.message}" end end @@ -37,7 +37,7 @@ demonstrate do begin message.destroy - rescue Nylas::ModelNotDestroyableError => e + rescue NylasV2::ModelNotDestroyableError => e "#{e.class}: #{e.message}" end end @@ -45,4 +45,3 @@ # Messages may be searched. # See https://docs.nylas.com/reference#messages-search and https://docs.nylas.com/reference#search demonstrate { api.messages.search("That really important email").map(&:to_h) } - diff --git a/examples/plain-ruby/neural.rb b/examples/plain-ruby/neural.rb index 6fd558da..6f0626cb 100644 --- a/examples/plain-ruby/neural.rb +++ b/examples/plain-ruby/neural.rb @@ -2,7 +2,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the API. It # follows the rough structure of the [Nylas API Reference](https://docs.nylas.com/reference). -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) message_id = api.messages.first.id @@ -33,7 +33,7 @@ # Also just pass in the file ID without a range to perform OCR on all pages ocr = api.neural.ocr_request(file_id, [1]) demonstrate { ocr.to_h } - rescue Nylas::Error => e + rescue NylasV2::Error => e puts "#{e.class}: #{e.message}" end end @@ -49,7 +49,7 @@ conversations = api.neural.clean_conversation([message_id]) demonstrate { conversations[0].to_h } # Provide some options to the endpoint -options = Nylas::NeuralMessageOptions.new(ignore_images: false) +options = NylasV2::NeuralMessageOptions.new(ignore_images: false) conversations = api.neural.clean_conversation([message_id], options) demonstrate { conversations[0].to_h } # Parse the images from the clean conversation diff --git a/examples/plain-ruby/outbox.rb b/examples/plain-ruby/outbox.rb index 4f2364bd..0a24b4b5 100644 --- a/examples/plain-ruby/outbox.rb +++ b/examples/plain-ruby/outbox.rb @@ -3,11 +3,11 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the API. It # follows the rough structure of the [Nylas API Reference](https://docs.nylas.com/reference). -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) # Prepare the draft and timestamps -draft = Nylas::Draft.new(to: [{ email: ENV.fetch('NYLAS_EXAMPLE_EMAIL', 'not-a-real-email@example.com'), name: "Me" }], +draft = NylasV2::Draft.new(to: [{ email: ENV.fetch('NYLAS_EXAMPLE_EMAIL', 'not-a-real-email@example.com'), name: "Me" }], subject: "A new draft!", metadata: {sdk: "Ruby SDK"}) tomorrow = Date.today + 1 diff --git a/examples/plain-ruby/room_resource.rb b/examples/plain-ruby/room_resource.rb index ebc33788..72df3f8b 100644 --- a/examples/plain-ruby/room_resource.rb +++ b/examples/plain-ruby/room_resource.rb @@ -2,7 +2,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the API. It # follows the rough structure of the [Nylas API Reference](https://docs.nylas.com/reference). -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) # Retrieving a list of room resources diff --git a/examples/plain-ruby/scheduler.rb b/examples/plain-ruby/scheduler.rb index d5d65692..fc391560 100644 --- a/examples/plain-ruby/scheduler.rb +++ b/examples/plain-ruby/scheduler.rb @@ -3,7 +3,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the Nylas # Scheduler API. # See https://developer.nylas.com/docs/api/scheduler/#overview -nylas = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +nylas = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) # Create a scheduler page @@ -32,14 +32,14 @@ # Get Google Availability begin demonstrate { nylas.scheduler.get_google_availability } -rescue Nylas::Error => e +rescue NylasV2::Error => e puts "#{e.class}: #{e.message}" end # Get Office 365 Availability begin demonstrate { nylas.scheduler.get_office_365_availability } -rescue Nylas::Error => e +rescue NylasV2::Error => e puts "#{e.class}: #{e.message}" end @@ -51,7 +51,7 @@ demonstrate { available_timeslots.inspect } # Book a timeslot -booking_request = Nylas::SchedulerBookingRequest.new( +booking_request = NylasV2::SchedulerBookingRequest.new( additional_values: { important: "true" }, @@ -70,7 +70,7 @@ # Confirm a booking (Expect an error because we already cancelled this meeting) begin demonstrate { nylas.scheduler.confirm_booking(example_scheduler.slug, booking_confirmation.edit_hash) } -rescue Nylas::Error => e +rescue NylasV2::Error => e puts "#{e.class}: #{e.message}" end diff --git a/examples/plain-ruby/sending-messages.rb b/examples/plain-ruby/sending-messages.rb index a12f2a9e..b7914058 100644 --- a/examples/plain-ruby/sending-messages.rb +++ b/examples/plain-ruby/sending-messages.rb @@ -2,7 +2,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to send messages via the API # See https://docs.nylas.com/reference#sending -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) # Sending a message as a hash @@ -15,7 +15,7 @@ # Sending a message by instantiating a message instance demonstrate do - message = Nylas::NewMessage.new(to: [{ email: ENV.fetch('NYLAS_EXAMPLE_EMAIL', 'not-a-real-email@example.com'), + message = NylasV2::NewMessage.new(to: [{ email: ENV.fetch('NYLAS_EXAMPLE_EMAIL', 'not-a-real-email@example.com'), name: "An example recipient" }], subject: "you've got another mail!", body: "It's a really good another mail!", api: api) diff --git a/examples/plain-ruby/streaming.rb b/examples/plain-ruby/streaming.rb index b15bddd5..3ead379a 100644 --- a/examples/plain-ruby/streaming.rb +++ b/examples/plain-ruby/streaming.rb @@ -16,9 +16,9 @@ def interactive_stream(include_types: [], exclude_types: []) end Signal.trap("TERM") { EventMachine.stop } - api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], + api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) - Nylas::Streaming.deltas(api: api, cursor: ENV['NYLAS_PREVIOUS_CURSOR'], + NylasV2::Streaming.deltas(api: api, cursor: ENV['NYLAS_PREVIOUS_CURSOR'], include_types: include_types, exclude_types: exclude_types) do |delta| puts "#{delta.event} of #{delta.object} #{delta.model.id} as a #{delta.class}" end diff --git a/examples/plain-ruby/threads.rb b/examples/plain-ruby/threads.rb index 7123075e..dc68f210 100644 --- a/examples/plain-ruby/threads.rb +++ b/examples/plain-ruby/threads.rb @@ -2,7 +2,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the API. It # follows the rough structure of the [Nylas API Reference](https://docs.nylas.com/reference). -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'], access_token: ENV['NYLAS_ACCESS_TOKEN']) @@ -25,7 +25,7 @@ demonstrate do begin api.threads.create - rescue Nylas::ModelNotCreatableError => e + rescue NylasV2::ModelNotCreatableError => e "#{e.class}: #{e.message}" end end @@ -36,7 +36,7 @@ demonstrate do begin thread.destroy - rescue Nylas::ModelNotDestroyableError => e + rescue NylasV2::ModelNotDestroyableError => e "#{e.class}: #{e.message}" end end @@ -45,4 +45,3 @@ # Threads may be searched. # See https://docs.nylas.com/reference#search-threads and https://docs.nylas.com/reference#search demonstrate { api.threads.search("That really important email").map(&:to_h) } - diff --git a/examples/plain-ruby/webhooks.rb b/examples/plain-ruby/webhooks.rb index 3ff11a0a..4b474b21 100644 --- a/examples/plain-ruby/webhooks.rb +++ b/examples/plain-ruby/webhooks.rb @@ -2,7 +2,7 @@ # An executable specification that demonstrates how to use the Nylas Ruby SDK to interact with the Nylas # Webhooks API. See https://docs.nylas.com/reference#webhooks for API documentation -api = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET']) +api = NylasV2::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET']) # Webhooks can be retrieved as a collection diff --git a/gem_config.rb b/gem_config.rb index 1b1f560d..3a91d8d2 100644 --- a/gem_config.rb +++ b/gem_config.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require "./lib/nylas/version" +require "./lib/nylas_v2/version" # Consistently apply nylas' standard gem data across gems module GemConfig def self.apply(gem, name) gem.name = name - gem.files = Dir.glob("lib/{#{name}.rb,#{name}/**/*.rb}") + gem.files = Dir.glob("lib/nylas_v2.rb,nylas_v2/**/*.rb}") gem.license = "MIT" - gem.version = Nylas::VERSION + gem.version = NylasV2::VERSION gem.platform = "ruby" gem.required_ruby_version = ">= 2.3" append_nylas_data(gem) @@ -25,12 +25,12 @@ def self.append_nylas_data(gem) def self.metadata { - "bug_tracker_uri" => "https://github.com/nylas/nylas-ruby/issues", - "changelog_uri" => "https://github.com/nylas/nylas-ruby/blob/master/CHANGELOG.md", + "bug_tracker_uri" => "https://github.com/nylas_v2/nylas-ruby/issues", + "changelog_uri" => "https://github.com/nylas_v2/nylas-ruby/blob/master/CHANGELOG.md", "documentation_uri" => "http://www.rubydoc.info/gems/nylas", "homepage_uri" => "https://www.nylas.com", - "source_code_uri" => "https://github.com/nylas/nylas-ruby", - "wiki_uri" => "https://github.com/nylas/nylas-ruby/wiki" + "source_code_uri" => "https://github.com/nylas_v2/nylas-ruby", + "wiki_uri" => "https://github.com/nylas_v2/nylas-ruby/wiki" } end diff --git a/lib/nylas-streaming.rb b/lib/nylas-streaming.rb index 867c991a..28aa3d02 100644 --- a/lib/nylas-streaming.rb +++ b/lib/nylas-streaming.rb @@ -4,11 +4,11 @@ require "em-http" require "nylas" -module Nylas +module NylasV2 # Provides methods to work with the Nylas Streaming Deltas API # @see https://docs.nylas.com/reference#streaming-delta-updates module Streaming - # @see Nylas::Streaming::DeltaStream#initialize + # @see NylasV2::Streaming::DeltaStream#initialize def self.deltas(**kwargs, &callback) DeltaStream.new(**kwargs).stream(&callback) end @@ -19,7 +19,7 @@ class DeltaStream :connect_timeout, :inactivity_timeout # @param cursor [String] Cursor to start listening for changes on - # @param api [Nylas::API] + # @param api [NylasV2::API] # @param expanded [Boolean] Expands threads and messages # @param exclude_types [Array] List of Object types *not* to include in the stream # @param include_types [Array] List of Object types to exclusively include in the stream @@ -40,8 +40,8 @@ def stream parser.on_parse_complete = lambda do |data| begin yield(Types.registry[:delta].cast(data.merge(api: api))) - rescue Nylas::Error => e - Nylas::Logging.logger.error(e) + rescue NylasV2::Error => e + NylasV2::Logging.logger.error(e) raise e end end @@ -67,7 +67,7 @@ def listener end def http_error_handler(client) - raise Nylas::Error, client.error + raise NylasV2::Error, client.error end def parser diff --git a/lib/nylas.rb b/lib/nylas_v2.rb similarity index 53% rename from lib/nylas.rb rename to lib/nylas_v2.rb index ca8587f7..bb5a0e7a 100644 --- a/lib/nylas.rb +++ b/lib/nylas_v2.rb @@ -21,104 +21,104 @@ require "ostruct" require "forwardable" -require_relative "nylas/version" -require_relative "nylas/errors" +require_relative "nylas_v2/version" +require_relative "nylas_v2/errors" -require_relative "nylas/logging" -require_relative "nylas/registry" -require_relative "nylas/types" -require_relative "nylas/constraints" +require_relative "nylas_v2/logging" +require_relative "nylas_v2/registry" +require_relative "nylas_v2/types" +require_relative "nylas_v2/constraints" -require_relative "nylas/http_client" -require_relative "nylas/api" -require_relative "nylas/collection" -require_relative "nylas/model" +require_relative "nylas_v2/http_client" +require_relative "nylas_v2/api" +require_relative "nylas_v2/collection" +require_relative "nylas_v2/model" # Attribute types supported by the API -require_relative "nylas/email_address" -require_relative "nylas/event" -require_relative "nylas/file" -require_relative "nylas/folder" -require_relative "nylas/im_address" -require_relative "nylas/label" -require_relative "nylas/message_headers" -require_relative "nylas/message_tracking" -require_relative "nylas/participant" -require_relative "nylas/physical_address" -require_relative "nylas/phone_number" -require_relative "nylas/recurrence" -require_relative "nylas/rsvp" -require_relative "nylas/timespan" -require_relative "nylas/web_page" -require_relative "nylas/nylas_date" -require_relative "nylas/when" -require_relative "nylas/free_busy" -require_relative "nylas/time_slot" -require_relative "nylas/time_slot_capacity" -require_relative "nylas/open_hours" -require_relative "nylas/event_conferencing" -require_relative "nylas/event_conferencing_details" -require_relative "nylas/event_conferencing_autocreate" -require_relative "nylas/event_notification" -require_relative "nylas/component" +require_relative "nylas_v2/email_address" +require_relative "nylas_v2/event" +require_relative "nylas_v2/file" +require_relative "nylas_v2/folder" +require_relative "nylas_v2/im_address" +require_relative "nylas_v2/label" +require_relative "nylas_v2/message_headers" +require_relative "nylas_v2/message_tracking" +require_relative "nylas_v2/participant" +require_relative "nylas_v2/physical_address" +require_relative "nylas_v2/phone_number" +require_relative "nylas_v2/recurrence" +require_relative "nylas_v2/rsvp" +require_relative "nylas_v2/timespan" +require_relative "nylas_v2/web_page" +require_relative "nylas_v2/nylas_date" +require_relative "nylas_v2/when" +require_relative "nylas_v2/free_busy" +require_relative "nylas_v2/time_slot" +require_relative "nylas_v2/time_slot_capacity" +require_relative "nylas_v2/open_hours" +require_relative "nylas_v2/event_conferencing" +require_relative "nylas_v2/event_conferencing_details" +require_relative "nylas_v2/event_conferencing_autocreate" +require_relative "nylas_v2/event_notification" +require_relative "nylas_v2/component" # Custom collection types -require_relative "nylas/event_collection" -require_relative "nylas/search_collection" -require_relative "nylas/deltas_collection" -require_relative "nylas/free_busy_collection" -require_relative "nylas/calendar_collection" -require_relative "nylas/component_collection" -require_relative "nylas/scheduler_collection" -require_relative "nylas/job_status_collection" -require_relative "nylas/outbox" +require_relative "nylas_v2/event_collection" +require_relative "nylas_v2/search_collection" +require_relative "nylas_v2/deltas_collection" +require_relative "nylas_v2/free_busy_collection" +require_relative "nylas_v2/calendar_collection" +require_relative "nylas_v2/component_collection" +require_relative "nylas_v2/scheduler_collection" +require_relative "nylas_v2/job_status_collection" +require_relative "nylas_v2/outbox" # Models supported by the API -require_relative "nylas/account" -require_relative "nylas/calendar" -require_relative "nylas/contact" -require_relative "nylas/contact_group" -require_relative "nylas/current_account" -require_relative "nylas/deltas" -require_relative "nylas/delta" -require_relative "nylas/draft" -require_relative "nylas/message" -require_relative "nylas/room_resource" -require_relative "nylas/new_message" -require_relative "nylas/raw_message" -require_relative "nylas/thread" -require_relative "nylas/webhook" -require_relative "nylas/scheduler" -require_relative "nylas/job_status" -require_relative "nylas/token_info" -require_relative "nylas/application_details" -require_relative "nylas/outbox_message" -require_relative "nylas/outbox_job_status" -require_relative "nylas/send_grid_verified_status" +require_relative "nylas_v2/account" +require_relative "nylas_v2/calendar" +require_relative "nylas_v2/contact" +require_relative "nylas_v2/contact_group" +require_relative "nylas_v2/current_account" +require_relative "nylas_v2/deltas" +require_relative "nylas_v2/delta" +require_relative "nylas_v2/draft" +require_relative "nylas_v2/message" +require_relative "nylas_v2/room_resource" +require_relative "nylas_v2/new_message" +require_relative "nylas_v2/raw_message" +require_relative "nylas_v2/thread" +require_relative "nylas_v2/webhook" +require_relative "nylas_v2/scheduler" +require_relative "nylas_v2/job_status" +require_relative "nylas_v2/token_info" +require_relative "nylas_v2/application_details" +require_relative "nylas_v2/outbox_message" +require_relative "nylas_v2/outbox_job_status" +require_relative "nylas_v2/send_grid_verified_status" # Neural specific types -require_relative "nylas/neural" -require_relative "nylas/neural_sentiment_analysis" -require_relative "nylas/neural_ocr" -require_relative "nylas/neural_categorizer" -require_relative "nylas/neural_clean_conversation" -require_relative "nylas/neural_contact_link" -require_relative "nylas/neural_contact_name" -require_relative "nylas/neural_signature_contact" -require_relative "nylas/neural_signature_extraction" -require_relative "nylas/neural_message_options" -require_relative "nylas/categorize" -require_relative "nylas/scheduler_config" -require_relative "nylas/scheduler_time_slot" -require_relative "nylas/scheduler_booking_request" -require_relative "nylas/scheduler_booking_confirmation" +require_relative "nylas_v2/neural" +require_relative "nylas_v2/neural_sentiment_analysis" +require_relative "nylas_v2/neural_ocr" +require_relative "nylas_v2/neural_categorizer" +require_relative "nylas_v2/neural_clean_conversation" +require_relative "nylas_v2/neural_contact_link" +require_relative "nylas_v2/neural_contact_name" +require_relative "nylas_v2/neural_signature_contact" +require_relative "nylas_v2/neural_signature_extraction" +require_relative "nylas_v2/neural_message_options" +require_relative "nylas_v2/categorize" +require_relative "nylas_v2/scheduler_config" +require_relative "nylas_v2/scheduler_time_slot" +require_relative "nylas_v2/scheduler_booking_request" +require_relative "nylas_v2/scheduler_booking_confirmation" -require_relative "nylas/native_authentication" +require_relative "nylas_v2/native_authentication" -require_relative "nylas/filter_attributes" +require_relative "nylas_v2/filter_attributes" # an SDK for interacting with the Nylas API # @see https://docs.nylas.com/reference -module Nylas +module NylasV2 Types.registry[:account] = Types::ModelType.new(model: Account) Types.registry[:calendar] = Types::ModelType.new(model: Calendar) Types.registry[:contact] = Types::ModelType.new(model: Contact) diff --git a/lib/nylas/account.rb b/lib/nylas_v2/account.rb similarity index 99% rename from lib/nylas/account.rb rename to lib/nylas_v2/account.rb index cec19799..02cb85de 100644 --- a/lib/nylas/account.rb +++ b/lib/nylas_v2/account.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Representation of the accounts for Account management purposes. # @see https://docs.nylas.com/reference#account-management class Account diff --git a/lib/nylas/api.rb b/lib/nylas_v2/api.rb similarity index 99% rename from lib/nylas/api.rb rename to lib/nylas_v2/api.rb index be2d4bcc..87780b04 100644 --- a/lib/nylas/api.rb +++ b/lib/nylas_v2/api.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Methods to retrieve data from the Nylas API as Ruby objects class API attr_accessor :client @@ -16,7 +16,7 @@ class API # @param access_token [String] (Optional) Your users access token. # @param api_server [String] (Optional) Which Nylas API Server to connect to. Only change this if # you're using a self-hosted Nylas instance. - # @return [Nylas::API] + # @return [NylasV2::API] def initialize(client: nil, app_id: nil, app_secret: nil, access_token: nil, api_server: "https://api.nylas.com") self.client = client || HttpClient.new(app_id: app_id, app_secret: app_secret, diff --git a/lib/nylas/application_details.rb b/lib/nylas_v2/application_details.rb similarity index 95% rename from lib/nylas/application_details.rb rename to lib/nylas_v2/application_details.rb index ca43e087..85de657e 100644 --- a/lib/nylas/application_details.rb +++ b/lib/nylas_v2/application_details.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent a Nylas Application Detail object. # @see https://developer.nylas.com/docs/api/#get/a/client_id class ApplicationDetail diff --git a/lib/nylas/calendar.rb b/lib/nylas_v2/calendar.rb similarity index 98% rename from lib/nylas/calendar.rb rename to lib/nylas_v2/calendar.rb index 9cb6c46e..a42dfc5f 100644 --- a/lib/nylas/calendar.rb +++ b/lib/nylas_v2/calendar.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby bindings for the Nylas Calendar API # @see https://docs.nylas.com/reference#calendars class Calendar diff --git a/lib/nylas/calendar_collection.rb b/lib/nylas_v2/calendar_collection.rb similarity index 92% rename from lib/nylas/calendar_collection.rb rename to lib/nylas_v2/calendar_collection.rb index 9ff78830..602937f2 100644 --- a/lib/nylas/calendar_collection.rb +++ b/lib/nylas_v2/calendar_collection.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Additional methods for some of Calendar's other functionality # @see https://developer.nylas.com/docs/connectivity/calendar class CalendarCollection < Collection @@ -13,8 +13,8 @@ class CalendarCollection < Collection # @param buffer [Integer] The amount of buffer time in minutes that you want around existing meetings # @param round_robin [String] Finds available meeting times in a round-robin style # @param event_collection_id [String] Unique identifier for a collection of events that are created - # @param free_busy [Array] A list of free-busy data for users not in your organization - # @param open_hours [Array] Additional times email accounts are available + # @param free_busy [Array] A list of free-busy data for users not in your organization + # @param open_hours [Array] Additional times email accounts are available # @param calendars [Array] Check account and calendar IDs for free/busy status # @return [Hash] The availability information; a list of time slots where all participants are available def availability(duration_minutes:, @@ -55,8 +55,8 @@ def availability(duration_minutes:, # @param end_time [Integer] The timestamp for the end of the event # @param emails [Array>] Emails on the same domain to check # @param buffer [Integer] The amount of buffer time in minutes that you want around existing meetings - # @param free_busy [Array] A list of free-busy data for users not in your organization - # @param open_hours [Array] Additional times email accounts are available + # @param free_busy [Array] A list of free-busy data for users not in your organization + # @param open_hours [Array] Additional times email accounts are available # @param calendars [Array] Check account and calendar IDs for free/busy status # @return [Hash] The availability information; a list of all possible groupings that share time slots def consecutive_availability(duration_minutes:, diff --git a/lib/nylas/categorize.rb b/lib/nylas_v2/categorize.rb similarity index 96% rename from lib/nylas/categorize.rb rename to lib/nylas_v2/categorize.rb index 0c6a1922..8600e96a 100644 --- a/lib/nylas/categorize.rb +++ b/lib/nylas_v2/categorize.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the Neural Categorize object. # @see https://developer.nylas.com/docs/intelligence/categorizer/#categorize-message-response class Categorize diff --git a/lib/nylas/collection.rb b/lib/nylas_v2/collection.rb similarity index 99% rename from lib/nylas/collection.rb rename to lib/nylas_v2/collection.rb index a8e3594e..652bc538 100644 --- a/lib/nylas/collection.rb +++ b/lib/nylas_v2/collection.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # An enumerable for working with index and search endpoints class Collection attr_accessor :model, :api, :constraints diff --git a/lib/nylas/component.rb b/lib/nylas_v2/component.rb similarity index 98% rename from lib/nylas/component.rb rename to lib/nylas_v2/component.rb index a114118f..2e5246ca 100644 --- a/lib/nylas/component.rb +++ b/lib/nylas_v2/component.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent a the Component Schema. class Component include Model diff --git a/lib/nylas/component_collection.rb b/lib/nylas_v2/component_collection.rb similarity index 93% rename from lib/nylas/component_collection.rb rename to lib/nylas_v2/component_collection.rb index 0476cf59..692c7c0c 100644 --- a/lib/nylas/component_collection.rb +++ b/lib/nylas_v2/component_collection.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Additional configuration for the Component CRUD API class ComponentCollection < Collection def resources_path diff --git a/lib/nylas/constraints.rb b/lib/nylas_v2/constraints.rb similarity index 99% rename from lib/nylas/constraints.rb rename to lib/nylas_v2/constraints.rb index 11913c25..cbda2997 100644 --- a/lib/nylas/constraints.rb +++ b/lib/nylas_v2/constraints.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # The constraints a particular GET request will include in their query params class Constraints attr_accessor :where, :limit, :offset, :view, :per_page, :accept diff --git a/lib/nylas/contact.rb b/lib/nylas_v2/contact.rb similarity index 99% rename from lib/nylas/contact.rb rename to lib/nylas_v2/contact.rb index f827f397..ac84d7dd 100644 --- a/lib/nylas/contact.rb +++ b/lib/nylas_v2/contact.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # ActiveModel compliant interface for interacting with the Contacts API # @see https://docs.nylas.com/reference#contacts class Contact diff --git a/lib/nylas/contact_group.rb b/lib/nylas_v2/contact_group.rb similarity index 97% rename from lib/nylas/contact_group.rb rename to lib/nylas_v2/contact_group.rb index 5249c3c3..a0a19b6b 100644 --- a/lib/nylas/contact_group.rb +++ b/lib/nylas_v2/contact_group.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the Contact Group schema # @see https://docs.nylas.com/reference#contactsid class ContactGroup diff --git a/lib/nylas/current_account.rb b/lib/nylas_v2/current_account.rb similarity index 97% rename from lib/nylas/current_account.rb rename to lib/nylas_v2/current_account.rb index cf7a7ee5..626b6585 100644 --- a/lib/nylas/current_account.rb +++ b/lib/nylas_v2/current_account.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby representation of the Nylas /account API # @see https://docs.nylas.com/reference#account class CurrentAccount diff --git a/lib/nylas/delta.rb b/lib/nylas_v2/delta.rb similarity index 98% rename from lib/nylas/delta.rb rename to lib/nylas_v2/delta.rb index 362cde3e..c005039d 100644 --- a/lib/nylas/delta.rb +++ b/lib/nylas_v2/delta.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby object to represent a single change. Used both when receiving a webhook, as well as the deltas API. # @see https://docs.nylas.com/reference#receiving-notifications # @see https://docs.nylas.com/reference#deltas diff --git a/lib/nylas/deltas.rb b/lib/nylas_v2/deltas.rb similarity index 97% rename from lib/nylas/deltas.rb rename to lib/nylas_v2/deltas.rb index 9a217eca..c16fdf36 100644 --- a/lib/nylas/deltas.rb +++ b/lib/nylas_v2/deltas.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby object to represent a collection of changes. Used both when receiving a webhook, as well as the # deltas API. # @see https://docs.nylas.com/reference#receiving-notifications diff --git a/lib/nylas/deltas_collection.rb b/lib/nylas_v2/deltas_collection.rb similarity index 98% rename from lib/nylas/deltas_collection.rb rename to lib/nylas_v2/deltas_collection.rb index a8d8a096..a3c9874d 100644 --- a/lib/nylas/deltas_collection.rb +++ b/lib/nylas_v2/deltas_collection.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Special collection for delta objects class DeltasCollection < Collection attr_accessor :deltas diff --git a/lib/nylas/draft.rb b/lib/nylas_v2/draft.rb similarity index 99% rename from lib/nylas/draft.rb rename to lib/nylas_v2/draft.rb index d1d9729c..44d4cc21 100644 --- a/lib/nylas/draft.rb +++ b/lib/nylas_v2/draft.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby representatin of a Nylas Draft object # @see https://docs.nylas.com/reference#drafts class Draft diff --git a/lib/nylas/email_address.rb b/lib/nylas_v2/email_address.rb similarity index 95% rename from lib/nylas/email_address.rb rename to lib/nylas_v2/email_address.rb index 8caf6f17..e05f7fbd 100644 --- a/lib/nylas/email_address.rb +++ b/lib/nylas_v2/email_address.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the Email Address Schema # @see https://docs.nylas.com/reference#contactsid class EmailAddress diff --git a/lib/nylas/errors.rb b/lib/nylas_v2/errors.rb similarity index 99% rename from lib/nylas/errors.rb rename to lib/nylas_v2/errors.rb index 620c9cd2..1432011c 100644 --- a/lib/nylas/errors.rb +++ b/lib/nylas_v2/errors.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 Error = Class.new(::StandardError) class ModelActionError < Error; end diff --git a/lib/nylas/event.rb b/lib/nylas_v2/event.rb similarity index 99% rename from lib/nylas/event.rb rename to lib/nylas_v2/event.rb index 20750a10..72c55da7 100644 --- a/lib/nylas/event.rb +++ b/lib/nylas_v2/event.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent a the Event Schema. # @see https://docs.nylas.com/reference#events class Event diff --git a/lib/nylas/event_collection.rb b/lib/nylas_v2/event_collection.rb similarity index 95% rename from lib/nylas/event_collection.rb rename to lib/nylas_v2/event_collection.rb index 451ecbe6..fbec0641 100644 --- a/lib/nylas/event_collection.rb +++ b/lib/nylas_v2/event_collection.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Syntactical sugar methods for some of the Event's filters # @see https://docs.nylas.com/reference#get-events class EventCollection < Collection diff --git a/lib/nylas/event_conferencing.rb b/lib/nylas_v2/event_conferencing.rb similarity index 96% rename from lib/nylas/event_conferencing.rb rename to lib/nylas_v2/event_conferencing.rb index 5d26f748..797fd956 100644 --- a/lib/nylas/event_conferencing.rb +++ b/lib/nylas_v2/event_conferencing.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the Event Conferencing object # @see https://developer.nylas.com/docs/connectivity/calendar/conference-sync-beta class EventConferencing diff --git a/lib/nylas/event_conferencing_autocreate.rb b/lib/nylas_v2/event_conferencing_autocreate.rb similarity index 95% rename from lib/nylas/event_conferencing_autocreate.rb rename to lib/nylas_v2/event_conferencing_autocreate.rb index ef206b7b..296b862b 100644 --- a/lib/nylas/event_conferencing_autocreate.rb +++ b/lib/nylas_v2/event_conferencing_autocreate.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the autocreate object within the Event Conferencing object # @see https://developer.nylas.com/docs/connectivity/calendar/conference-sync-beta class EventConferencingAutocreate diff --git a/lib/nylas/event_conferencing_details.rb b/lib/nylas_v2/event_conferencing_details.rb similarity index 96% rename from lib/nylas/event_conferencing_details.rb rename to lib/nylas_v2/event_conferencing_details.rb index bfd4601a..d5489995 100644 --- a/lib/nylas/event_conferencing_details.rb +++ b/lib/nylas_v2/event_conferencing_details.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the details object within the Event Conferencing object # @see https://developer.nylas.com/docs/connectivity/calendar/conference-sync-beta class EventConferencingDetails diff --git a/lib/nylas/event_notification.rb b/lib/nylas_v2/event_notification.rb similarity index 96% rename from lib/nylas/event_notification.rb rename to lib/nylas_v2/event_notification.rb index a7c0a691..b022458e 100644 --- a/lib/nylas/event_notification.rb +++ b/lib/nylas_v2/event_notification.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the Event Notification object # @see https://developer.nylas.com/docs/connectivity/calendar/event-notifications class EventNotification diff --git a/lib/nylas/file.rb b/lib/nylas_v2/file.rb similarity index 99% rename from lib/nylas/file.rb rename to lib/nylas_v2/file.rb index fb7b33c8..d4251ed4 100644 --- a/lib/nylas/file.rb +++ b/lib/nylas_v2/file.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent a the File Schema. # @see https://docs.nylas.com/reference#events class File diff --git a/lib/nylas/filter_attributes.rb b/lib/nylas_v2/filter_attributes.rb similarity index 97% rename from lib/nylas/filter_attributes.rb rename to lib/nylas_v2/filter_attributes.rb index 9daf06d8..0813ffa9 100644 --- a/lib/nylas/filter_attributes.rb +++ b/lib/nylas_v2/filter_attributes.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Methods to check and raise error if extra attributes are present class FilterAttributes def initialize(attributes:, allowed_attributes:) diff --git a/lib/nylas/folder.rb b/lib/nylas_v2/folder.rb similarity index 97% rename from lib/nylas/folder.rb rename to lib/nylas_v2/folder.rb index 5721297e..c5f5e44d 100644 --- a/lib/nylas/folder.rb +++ b/lib/nylas_v2/folder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the Folder Schema # @see https://docs.nylas.com/reference#folders class Folder diff --git a/lib/nylas/free_busy.rb b/lib/nylas_v2/free_busy.rb similarity index 95% rename from lib/nylas/free_busy.rb rename to lib/nylas_v2/free_busy.rb index 92c4ec39..52c604f9 100644 --- a/lib/nylas/free_busy.rb +++ b/lib/nylas_v2/free_busy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Query free/busy information for a calendar during a certain time period # @see https://docs.nylas.com/reference#calendars-free-busy class FreeBusy diff --git a/lib/nylas/free_busy_collection.rb b/lib/nylas_v2/free_busy_collection.rb similarity index 98% rename from lib/nylas/free_busy_collection.rb rename to lib/nylas_v2/free_busy_collection.rb index 320e129e..c100f865 100644 --- a/lib/nylas/free_busy_collection.rb +++ b/lib/nylas_v2/free_busy_collection.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Helper to get and build `FreeBusy` objects class FreeBusyCollection extend Forwardable diff --git a/lib/nylas/http_client.rb b/lib/nylas_v2/http_client.rb similarity index 97% rename from lib/nylas/http_client.rb rename to lib/nylas_v2/http_client.rb index 5f691195..1479338c 100644 --- a/lib/nylas/http_client.rb +++ b/lib/nylas_v2/http_client.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 require "yajl" require "base64" @@ -54,7 +54,7 @@ module AuthMethod # @param access_token [String] (Optional) Your users access token. # @param api_server [String] (Optional) Which Nylas API Server to connect to. Only change this if # you're using a self-hosted Nylas instance. - # @return [Nylas::HttpClient] + # @return [NylasV2::HttpClient] def initialize(app_id:, app_secret:, access_token: nil, api_server: "https://api.nylas.com") unless api_server.include?("://") raise "When overriding the Nylas API server address, you must include https://" @@ -66,7 +66,7 @@ def initialize(app_id:, app_secret:, access_token: nil, api_server: "https://api @app_id = app_id end - # @return [Nylas::HttpClient[] + # @return [NylasV2::HttpClient[] def as(access_token) HttpClient.new(app_id: app_id, access_token: access_token, app_secret: app_secret, api_server: api_server) @@ -103,7 +103,7 @@ def execute(method:, path: nil, headers: {}, query: {}, payload: nil, auth_metho begin response = parse_response(response) if content_type == "application/json" - rescue Nylas::JsonParseError + rescue NylasV2::JsonParseError handle_failed_response(result: result, response: response) raise end @@ -181,7 +181,7 @@ def default_headers "X-Nylas-API-Wrapper" => "ruby", "X-Nylas-Client-Id" => @app_id, "Nylas-API-Version" => SUPPORTED_API_VERSION, - "User-Agent" => "Nylas Ruby SDK #{Nylas::VERSION} - #{RUBY_VERSION}", + "User-Agent" => "Nylas Ruby SDK #{NylasV2::VERSION} - #{RUBY_VERSION}", "Content-type" => "application/json" } end @@ -191,7 +191,7 @@ def parse_response(response) Yajl::Parser.new(symbolize_names: true).parse(response) rescue Yajl::ParseError - raise Nylas::JsonParseError + raise NylasV2::JsonParseError end inform_on :parse_response, level: :debug, also_log: { result: true } diff --git a/lib/nylas/im_address.rb b/lib/nylas_v2/im_address.rb similarity index 94% rename from lib/nylas/im_address.rb rename to lib/nylas_v2/im_address.rb index 9d55936f..cee5a0a7 100644 --- a/lib/nylas/im_address.rb +++ b/lib/nylas_v2/im_address.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the IM Address Schema # @see https://docs.nylas.com/reference#contactsid class IMAddress diff --git a/lib/nylas/job_status.rb b/lib/nylas_v2/job_status.rb similarity index 98% rename from lib/nylas/job_status.rb rename to lib/nylas_v2/job_status.rb index eb192569..fef216d8 100644 --- a/lib/nylas/job_status.rb +++ b/lib/nylas_v2/job_status.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby representation of a Nylas Job Status object # @see https://developer.nylas.com/docs/api/#tag--Job-Status class JobStatus diff --git a/lib/nylas/job_status_collection.rb b/lib/nylas_v2/job_status_collection.rb similarity index 97% rename from lib/nylas/job_status_collection.rb rename to lib/nylas_v2/job_status_collection.rb index f0eb0162..6dbe2edc 100644 --- a/lib/nylas/job_status_collection.rb +++ b/lib/nylas_v2/job_status_collection.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Additional methods for some of Calendar's other functionality # @see https://developer.nylas.com/docs/connectivity/calendar class JobStatusCollection < Collection diff --git a/lib/nylas/label.rb b/lib/nylas_v2/label.rb similarity index 97% rename from lib/nylas/label.rb rename to lib/nylas_v2/label.rb index 25be9e84..be170745 100644 --- a/lib/nylas/label.rb +++ b/lib/nylas_v2/label.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the Label Schema # @see https://docs.nylas.com/reference#labels class Label diff --git a/lib/nylas/logging.rb b/lib/nylas_v2/logging.rb similarity index 98% rename from lib/nylas/logging.rb rename to lib/nylas_v2/logging.rb index b115fca5..4f94a1e8 100644 --- a/lib/nylas/logging.rb +++ b/lib/nylas_v2/logging.rb @@ -5,7 +5,7 @@ rescue LoadError end -module Nylas +module NylasV2 # Exposes a shared logger for debugging purposes module Logging def self.included(object) diff --git a/lib/nylas/message.rb b/lib/nylas_v2/message.rb similarity index 99% rename from lib/nylas/message.rb rename to lib/nylas_v2/message.rb index eb424ee8..08106571 100644 --- a/lib/nylas/message.rb +++ b/lib/nylas_v2/message.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby representatin of a Nylas Message object # @see https://docs.nylas.com/reference#messages class Message diff --git a/lib/nylas/message_headers.rb b/lib/nylas_v2/message_headers.rb similarity index 98% rename from lib/nylas/message_headers.rb rename to lib/nylas_v2/message_headers.rb index 28bf844c..33ff7fc6 100644 --- a/lib/nylas/message_headers.rb +++ b/lib/nylas_v2/message_headers.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Translates message headers into a Ruby object # @see https://docs.nylas.com/reference#section-message-views class MessageHeaders diff --git a/lib/nylas/message_tracking.rb b/lib/nylas_v2/message_tracking.rb similarity index 95% rename from lib/nylas/message_tracking.rb rename to lib/nylas_v2/message_tracking.rb index c1c0a130..74f3949d 100644 --- a/lib/nylas/message_tracking.rb +++ b/lib/nylas_v2/message_tracking.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Message tracking features # @see https://docs.nylas.com/reference#message-tracking-overview class MessageTracking diff --git a/lib/nylas/model.rb b/lib/nylas_v2/model.rb similarity index 99% rename from lib/nylas/model.rb rename to lib/nylas_v2/model.rb index 109d7ead..684cdf89 100644 --- a/lib/nylas/model.rb +++ b/lib/nylas_v2/model.rb @@ -5,7 +5,7 @@ require_relative "model/attributable" require_relative "model/attributes" require_relative "model/transferable" -module Nylas +module NylasV2 # Include this to define a class to represent an object returned from the API module Model attr_accessor :api diff --git a/lib/nylas/model/attributable.rb b/lib/nylas_v2/model/attributable.rb similarity index 99% rename from lib/nylas/model/attributable.rb rename to lib/nylas_v2/model/attributable.rb index 9c6d2df9..0a06166f 100644 --- a/lib/nylas/model/attributable.rb +++ b/lib/nylas_v2/model/attributable.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 module Model # Allows defining of typecastable attributes on a model module Attributable diff --git a/lib/nylas/model/attribute_definition.rb b/lib/nylas_v2/model/attribute_definition.rb similarity index 97% rename from lib/nylas/model/attribute_definition.rb rename to lib/nylas_v2/model/attribute_definition.rb index 773070f9..9d36b5ce 100644 --- a/lib/nylas/model/attribute_definition.rb +++ b/lib/nylas_v2/model/attribute_definition.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 module Model # Define a particular attribute for a given model class AttributeDefinition diff --git a/lib/nylas/model/attributes.rb b/lib/nylas_v2/model/attributes.rb similarity index 98% rename from lib/nylas/model/attributes.rb rename to lib/nylas_v2/model/attributes.rb index 9de96014..4bbb1590 100644 --- a/lib/nylas/model/attributes.rb +++ b/lib/nylas_v2/model/attributes.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 module Model # Stores the actual model data to allow for type casting and clean/dirty checking class Attributes @@ -17,7 +17,7 @@ def [](key) def []=(key, value) data[key] = cast(key, value) - rescue Nylas::Registry::MissingKeyError + rescue NylasV2::Registry::MissingKeyError # Don't crash when a new attribute is added end diff --git a/lib/nylas/model/list_attribute_definition.rb b/lib/nylas_v2/model/list_attribute_definition.rb similarity index 98% rename from lib/nylas/model/list_attribute_definition.rb rename to lib/nylas_v2/model/list_attribute_definition.rb index 221b5194..a605d7c8 100644 --- a/lib/nylas/model/list_attribute_definition.rb +++ b/lib/nylas_v2/model/list_attribute_definition.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 module Model # Allows models to have an attribute which is a lists of another type of thing class ListAttributeDefinition diff --git a/lib/nylas/model/transferable.rb b/lib/nylas_v2/model/transferable.rb similarity index 98% rename from lib/nylas/model/transferable.rb rename to lib/nylas_v2/model/transferable.rb index acb5d37e..ff994bb5 100644 --- a/lib/nylas/model/transferable.rb +++ b/lib/nylas_v2/model/transferable.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 module Model # Allows definition of attributes, which should transfer to other dependent attributes module Transferable diff --git a/lib/nylas/native_authentication.rb b/lib/nylas_v2/native_authentication.rb similarity index 99% rename from lib/nylas/native_authentication.rb rename to lib/nylas_v2/native_authentication.rb index e4eabf2d..e38d1578 100644 --- a/lib/nylas/native_authentication.rb +++ b/lib/nylas_v2/native_authentication.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Authenticate your application using the native interface # @see https://docs.nylas.com/reference#native-authentication-1 class NativeAuthentication diff --git a/lib/nylas/neural.rb b/lib/nylas_v2/neural.rb similarity index 99% rename from lib/nylas/neural.rb rename to lib/nylas_v2/neural.rb index e6d46a8a..e4e1a218 100644 --- a/lib/nylas/neural.rb +++ b/lib/nylas_v2/neural.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Class containing methods for accessing Neural API features. # @see https://developer.nylas.com/docs/intelligence/ class Neural diff --git a/lib/nylas/neural_categorizer.rb b/lib/nylas_v2/neural_categorizer.rb similarity index 98% rename from lib/nylas/neural_categorizer.rb rename to lib/nylas_v2/neural_categorizer.rb index 875b0986..ea4186cd 100644 --- a/lib/nylas/neural_categorizer.rb +++ b/lib/nylas_v2/neural_categorizer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent a the Neural Categorizer object. # @see https://developer.nylas.com/docs/intelligence/categorizer/#categorize-message-response class NeuralCategorizer < Message diff --git a/lib/nylas/neural_clean_conversation.rb b/lib/nylas_v2/neural_clean_conversation.rb similarity index 98% rename from lib/nylas/neural_clean_conversation.rb rename to lib/nylas_v2/neural_clean_conversation.rb index b71fe929..5e51297c 100644 --- a/lib/nylas/neural_clean_conversation.rb +++ b/lib/nylas_v2/neural_clean_conversation.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent a the Neural Clean Conversations object. # @see https://developer.nylas.com/docs/intelligence/clean-conversations/#clean-conversation-response class NeuralCleanConversation < Message diff --git a/lib/nylas/neural_contact_link.rb b/lib/nylas_v2/neural_contact_link.rb similarity index 96% rename from lib/nylas/neural_contact_link.rb rename to lib/nylas_v2/neural_contact_link.rb index ab2edd54..66f37451 100644 --- a/lib/nylas/neural_contact_link.rb +++ b/lib/nylas_v2/neural_contact_link.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the "Link" object in the Neural API's Signature Extraction Contact object # @see https://developer.nylas.com/docs/intelligence/signature-extraction/#parse-signature-response class NeuralContactLink diff --git a/lib/nylas/neural_contact_name.rb b/lib/nylas_v2/neural_contact_name.rb similarity index 96% rename from lib/nylas/neural_contact_name.rb rename to lib/nylas_v2/neural_contact_name.rb index dffb98a1..821d3923 100644 --- a/lib/nylas/neural_contact_name.rb +++ b/lib/nylas_v2/neural_contact_name.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the "Name" object in the Neural API's Signature Extraction Contact object # @see https://developer.nylas.com/docs/intelligence/signature-extraction/#parse-signature-response class NeuralContactName diff --git a/lib/nylas/neural_message_options.rb b/lib/nylas_v2/neural_message_options.rb similarity index 98% rename from lib/nylas/neural_message_options.rb rename to lib/nylas_v2/neural_message_options.rb index 4bc87a2c..e13fae3f 100644 --- a/lib/nylas/neural_message_options.rb +++ b/lib/nylas_v2/neural_message_options.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent a the Neural Optical Character Recognition object. # @see https://developer.nylas.com/docs/intelligence/optical-charecter-recognition/#ocr-response class NeuralMessageOptions diff --git a/lib/nylas/neural_ocr.rb b/lib/nylas_v2/neural_ocr.rb similarity index 96% rename from lib/nylas/neural_ocr.rb rename to lib/nylas_v2/neural_ocr.rb index c285d1ad..0cb8f35a 100644 --- a/lib/nylas/neural_ocr.rb +++ b/lib/nylas_v2/neural_ocr.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent a the Neural Optical Character Recognition object. # @see https://developer.nylas.com/docs/intelligence/optical-charecter-recognition/#ocr-response class NeuralOcr < File diff --git a/lib/nylas/neural_sentiment_analysis.rb b/lib/nylas_v2/neural_sentiment_analysis.rb similarity index 97% rename from lib/nylas/neural_sentiment_analysis.rb rename to lib/nylas_v2/neural_sentiment_analysis.rb index aadbcac8..5ab51b17 100644 --- a/lib/nylas/neural_sentiment_analysis.rb +++ b/lib/nylas_v2/neural_sentiment_analysis.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent a the Neural Sentiment Analysis object. # @see https://developer.nylas.com/docs/intelligence/sentiment-analysis/#sentiment-analysis-response-message class NeuralSentimentAnalysis diff --git a/lib/nylas/neural_signature_contact.rb b/lib/nylas_v2/neural_signature_contact.rb similarity index 99% rename from lib/nylas/neural_signature_contact.rb rename to lib/nylas_v2/neural_signature_contact.rb index 9998377a..29564a1e 100644 --- a/lib/nylas/neural_signature_contact.rb +++ b/lib/nylas_v2/neural_signature_contact.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the Neural API's Signature Extraction Contact object # @see https://developer.nylas.com/docs/intelligence/signature-extraction/#parse-signature-response class NeuralSignatureContact diff --git a/lib/nylas/neural_signature_extraction.rb b/lib/nylas_v2/neural_signature_extraction.rb similarity index 97% rename from lib/nylas/neural_signature_extraction.rb rename to lib/nylas_v2/neural_signature_extraction.rb index 5f419319..3c8b98d7 100644 --- a/lib/nylas/neural_signature_extraction.rb +++ b/lib/nylas_v2/neural_signature_extraction.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent a the Signature Extraction Schema. # @see https://developer.nylas.com/docs/intelligence/signature-extraction/#signature-feedback-response class NeuralSignatureExtraction < Message diff --git a/lib/nylas/new_message.rb b/lib/nylas_v2/new_message.rb similarity index 98% rename from lib/nylas/new_message.rb rename to lib/nylas_v2/new_message.rb index 7338f9a9..761269ec 100644 --- a/lib/nylas/new_message.rb +++ b/lib/nylas_v2/new_message.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Data structure for sending a message via the Nylas API class NewMessage include Model diff --git a/lib/nylas/nylas_date.rb b/lib/nylas_v2/nylas_date.rb similarity index 97% rename from lib/nylas/nylas_date.rb rename to lib/nylas_v2/nylas_date.rb index 977bdc54..ca985797 100644 --- a/lib/nylas/nylas_date.rb +++ b/lib/nylas_v2/nylas_date.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent Nylas's more complex Date Schema # @see https://docs.nylas.com/reference#contactsid class NylasDate diff --git a/lib/nylas/open_hours.rb b/lib/nylas_v2/open_hours.rb similarity index 96% rename from lib/nylas/open_hours.rb rename to lib/nylas_v2/open_hours.rb index 95eb81d5..5872a58e 100644 --- a/lib/nylas/open_hours.rb +++ b/lib/nylas_v2/open_hours.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Additional times email accounts are available # @see https://developer.nylas.com/docs/api/#post/calendars/availability class OpenHours diff --git a/lib/nylas/outbox.rb b/lib/nylas_v2/outbox.rb similarity index 99% rename from lib/nylas/outbox.rb rename to lib/nylas_v2/outbox.rb index 5c421258..b9aad02b 100644 --- a/lib/nylas/outbox.rb +++ b/lib/nylas_v2/outbox.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Methods for Outbox functionality # @see https://developer.nylas.com/docs/api/#tag--Outbox class Outbox diff --git a/lib/nylas/outbox_job_status.rb b/lib/nylas_v2/outbox_job_status.rb similarity index 97% rename from lib/nylas/outbox_job_status.rb rename to lib/nylas_v2/outbox_job_status.rb index 1eb35724..7523d609 100644 --- a/lib/nylas/outbox_job_status.rb +++ b/lib/nylas_v2/outbox_job_status.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby representation of a Nylas Outbox Job Status object # @see https://developer.nylas.com/docs/api/#post/v2/outbox class OutboxJobStatus < JobStatus diff --git a/lib/nylas/outbox_message.rb b/lib/nylas_v2/outbox_message.rb similarity index 96% rename from lib/nylas/outbox_message.rb rename to lib/nylas_v2/outbox_message.rb index a6e2f457..306e0fe4 100644 --- a/lib/nylas/outbox_message.rb +++ b/lib/nylas_v2/outbox_message.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby representation of a Nylas Outbox Message object # @see https://developer.nylas.com/docs/api/#post/v2/outbox class OutboxMessage < Draft diff --git a/lib/nylas/participant.rb b/lib/nylas_v2/participant.rb similarity index 95% rename from lib/nylas/participant.rb rename to lib/nylas_v2/participant.rb index 7ec8c95b..a0284542 100644 --- a/lib/nylas/participant.rb +++ b/lib/nylas_v2/participant.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the Participant class Participant include Model::Attributable diff --git a/lib/nylas/phone_number.rb b/lib/nylas_v2/phone_number.rb similarity index 94% rename from lib/nylas/phone_number.rb rename to lib/nylas_v2/phone_number.rb index 8b8a0e40..d8e247f7 100644 --- a/lib/nylas/phone_number.rb +++ b/lib/nylas_v2/phone_number.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the Phone Number Schema # @see https://docs.nylas.com/reference#contactsid class PhoneNumber diff --git a/lib/nylas/physical_address.rb b/lib/nylas_v2/physical_address.rb similarity index 96% rename from lib/nylas/physical_address.rb rename to lib/nylas_v2/physical_address.rb index cb07ca07..4d796ed6 100644 --- a/lib/nylas/physical_address.rb +++ b/lib/nylas_v2/physical_address.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the Physical Address schema # @see https://docs.nylas.com/reference#contactsid class PhysicalAddress diff --git a/lib/nylas/raw_message.rb b/lib/nylas_v2/raw_message.rb similarity index 97% rename from lib/nylas/raw_message.rb rename to lib/nylas_v2/raw_message.rb index beebc51f..f259f6c6 100644 --- a/lib/nylas/raw_message.rb +++ b/lib/nylas_v2/raw_message.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Allows sending of email with nylas from an rfc822 compatible string class RawMessage attr_accessor :api, :mime_compatible_string diff --git a/lib/nylas/recurrence.rb b/lib/nylas_v2/recurrence.rb similarity index 94% rename from lib/nylas/recurrence.rb rename to lib/nylas_v2/recurrence.rb index 5b10d999..8a119b70 100644 --- a/lib/nylas/recurrence.rb +++ b/lib/nylas_v2/recurrence.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Representation of a Recurrence object # @see https://docs.nylas.com/reference#section-recurrence class Recurrence diff --git a/lib/nylas/registry.rb b/lib/nylas_v2/registry.rb similarity index 98% rename from lib/nylas/registry.rb rename to lib/nylas_v2/registry.rb index 0971d1ea..5cb3bc4f 100644 --- a/lib/nylas/registry.rb +++ b/lib/nylas_v2/registry.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Used to create a hash-like structure which defaults to raising an exception in the event the key to # retrieve does not exist. class Registry diff --git a/lib/nylas/room_resource.rb b/lib/nylas_v2/room_resource.rb similarity index 97% rename from lib/nylas/room_resource.rb rename to lib/nylas_v2/room_resource.rb index 7a7f498d..1a23b8a8 100644 --- a/lib/nylas/room_resource.rb +++ b/lib/nylas_v2/room_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby representation of a Nylas Room Resource object # @see https://developer.nylas.com/docs/api/#tag--Room-Resources class RoomResource diff --git a/lib/nylas/rsvp.rb b/lib/nylas_v2/rsvp.rb similarity index 97% rename from lib/nylas/rsvp.rb rename to lib/nylas_v2/rsvp.rb index 6907f58e..6f21f5a6 100644 --- a/lib/nylas/rsvp.rb +++ b/lib/nylas_v2/rsvp.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Allows RSVPing to a particular event # @see https://docs.nylas.com/reference#rsvping-to-invitations class Rsvp diff --git a/lib/nylas/scheduler.rb b/lib/nylas_v2/scheduler.rb similarity index 98% rename from lib/nylas/scheduler.rb rename to lib/nylas_v2/scheduler.rb index 9e5cdb9d..8946b6f5 100644 --- a/lib/nylas/scheduler.rb +++ b/lib/nylas_v2/scheduler.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby representation of a the Nylas Scheduler API # @see https://developer.nylas.com/docs/api/scheduler/#overview class Scheduler diff --git a/lib/nylas/scheduler_booking_confirmation.rb b/lib/nylas_v2/scheduler_booking_confirmation.rb similarity index 98% rename from lib/nylas/scheduler_booking_confirmation.rb rename to lib/nylas_v2/scheduler_booking_confirmation.rb index d08904d8..9ed8b386 100644 --- a/lib/nylas/scheduler_booking_confirmation.rb +++ b/lib/nylas_v2/scheduler_booking_confirmation.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the booking response returned from the Scheduler API class SchedulerBookingConfirmation include Model::Attributable diff --git a/lib/nylas/scheduler_booking_request.rb b/lib/nylas_v2/scheduler_booking_request.rb similarity index 97% rename from lib/nylas/scheduler_booking_request.rb rename to lib/nylas_v2/scheduler_booking_request.rb index b05a63b1..990014d1 100644 --- a/lib/nylas/scheduler_booking_request.rb +++ b/lib/nylas_v2/scheduler_booking_request.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the booking request used for the Scheduler API class SchedulerBookingRequest include Model::Attributable diff --git a/lib/nylas/scheduler_collection.rb b/lib/nylas_v2/scheduler_collection.rb similarity index 99% rename from lib/nylas/scheduler_collection.rb rename to lib/nylas_v2/scheduler_collection.rb index 62da6595..8c3e3c73 100644 --- a/lib/nylas/scheduler_collection.rb +++ b/lib/nylas_v2/scheduler_collection.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Additional methods for some of Scheduler's other functionality # @see https://developer.nylas.com/docs/api/scheduler#overview class SchedulerCollection < Collection diff --git a/lib/nylas/scheduler_config.rb b/lib/nylas_v2/scheduler_config.rb similarity index 97% rename from lib/nylas/scheduler_config.rb rename to lib/nylas_v2/scheduler_config.rb index 04f1f014..c91fe763 100644 --- a/lib/nylas/scheduler_config.rb +++ b/lib/nylas_v2/scheduler_config.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Configuration settings for a Scheduler page # @see https://developer.nylas.com/docs/api/scheduler class SchedulerConfig diff --git a/lib/nylas/scheduler_time_slot.rb b/lib/nylas_v2/scheduler_time_slot.rb similarity index 96% rename from lib/nylas/scheduler_time_slot.rb rename to lib/nylas_v2/scheduler_time_slot.rb index 6b21c004..4b0f456a 100644 --- a/lib/nylas/scheduler_time_slot.rb +++ b/lib/nylas_v2/scheduler_time_slot.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the time slot object from the Scheduler API class SchedulerTimeSlot include Model::Attributable diff --git a/lib/nylas/search_collection.rb b/lib/nylas_v2/search_collection.rb similarity index 93% rename from lib/nylas/search_collection.rb rename to lib/nylas_v2/search_collection.rb index fe651a22..04f55aee 100644 --- a/lib/nylas/search_collection.rb +++ b/lib/nylas_v2/search_collection.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ensures our search requests hit the right path class SearchCollection < Collection def resources_path diff --git a/lib/nylas/send_grid_verified_status.rb b/lib/nylas_v2/send_grid_verified_status.rb similarity index 95% rename from lib/nylas/send_grid_verified_status.rb rename to lib/nylas_v2/send_grid_verified_status.rb index 885a6836..ef31c1d9 100644 --- a/lib/nylas/send_grid_verified_status.rb +++ b/lib/nylas_v2/send_grid_verified_status.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby representation of a Nylas Send Grid verified status object # @see https://docs.nylas.com/reference#drafts class SendGridVerifiedStatus diff --git a/lib/nylas/thread.rb b/lib/nylas_v2/thread.rb similarity index 99% rename from lib/nylas/thread.rb rename to lib/nylas_v2/thread.rb index 4ade9aaf..d35e19a0 100644 --- a/lib/nylas/thread.rb +++ b/lib/nylas_v2/thread.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Ruby representation of the Nylas /threads API # @see https://docs.nylas.com/reference#threads class Thread diff --git a/lib/nylas/time_slot.rb b/lib/nylas_v2/time_slot.rb similarity index 96% rename from lib/nylas/time_slot.rb rename to lib/nylas_v2/time_slot.rb index 610617e5..1612e954 100644 --- a/lib/nylas/time_slot.rb +++ b/lib/nylas_v2/time_slot.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Query free/busy information for a calendar during a certain time period # @see https://docs.nylas.com/reference#calendars-free-busy class TimeSlot diff --git a/lib/nylas/time_slot_capacity.rb b/lib/nylas_v2/time_slot_capacity.rb similarity index 95% rename from lib/nylas/time_slot_capacity.rb rename to lib/nylas_v2/time_slot_capacity.rb index 9a6a7600..87869e96 100644 --- a/lib/nylas/time_slot_capacity.rb +++ b/lib/nylas_v2/time_slot_capacity.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Capacity values for a timeslot # @see https://docs.nylas.com/reference#calendars-free-busy class TimeSlotCapacity diff --git a/lib/nylas/timespan.rb b/lib/nylas_v2/timespan.rb similarity index 96% rename from lib/nylas/timespan.rb rename to lib/nylas_v2/timespan.rb index c85f3dcf..26428c57 100644 --- a/lib/nylas/timespan.rb +++ b/lib/nylas_v2/timespan.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent a Nylas Timespan. # @see https://docs.nylas.com/reference#section-timespan class Timespan diff --git a/lib/nylas/token_info.rb b/lib/nylas_v2/token_info.rb similarity index 97% rename from lib/nylas/token_info.rb rename to lib/nylas_v2/token_info.rb index 64590fbb..db412b0a 100644 --- a/lib/nylas/token_info.rb +++ b/lib/nylas_v2/token_info.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent information about a Nylas access token. # @see https://developer.nylas.com/docs/api/#post/a/client_id/accounts/id/token-info class TokenInfo diff --git a/lib/nylas/types.rb b/lib/nylas_v2/types.rb similarity index 99% rename from lib/nylas/types.rb rename to lib/nylas_v2/types.rb index df8b6c41..45a8c59b 100644 --- a/lib/nylas/types.rb +++ b/lib/nylas_v2/types.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Collection of attribute types module Types def self.registry diff --git a/lib/nylas/version.rb b/lib/nylas_v2/version.rb similarity index 78% rename from lib/nylas/version.rb rename to lib/nylas_v2/version.rb index e052f255..8945ca8e 100644 --- a/lib/nylas/version.rb +++ b/lib/nylas_v2/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -module Nylas +module NylasV2 VERSION = "5.14.0" end diff --git a/lib/nylas/web_page.rb b/lib/nylas_v2/web_page.rb similarity index 94% rename from lib/nylas/web_page.rb rename to lib/nylas_v2/web_page.rb index a002cf93..694d9b48 100644 --- a/lib/nylas/web_page.rb +++ b/lib/nylas_v2/web_page.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 # Structure to represent the Web Page Schema # @see https://docs.nylas.com/reference#contactsid class WebPage diff --git a/lib/nylas/webhook.rb b/lib/nylas_v2/webhook.rb similarity index 99% rename from lib/nylas/webhook.rb rename to lib/nylas_v2/webhook.rb index 8d2f4c60..b15cd387 100644 --- a/lib/nylas/webhook.rb +++ b/lib/nylas_v2/webhook.rb @@ -36,7 +36,7 @@ module WebhookTrigger JOB_FAILED = "job.failed" end -module Nylas +module NylasV2 # Represents a webhook attached to your application. # @see https://docs.nylas.com/reference#webhooks class Webhook diff --git a/lib/nylas/when.rb b/lib/nylas_v2/when.rb similarity index 99% rename from lib/nylas/when.rb rename to lib/nylas_v2/when.rb index 1268d60b..7ced11f4 100644 --- a/lib/nylas/when.rb +++ b/lib/nylas_v2/when.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Nylas +module NylasV2 require "tzinfo" # Structure to represent all the Nylas time types. diff --git a/nylas-streaming.gemspec b/nylas-v2-streaming.gemspec similarity index 79% rename from nylas-streaming.gemspec rename to nylas-v2-streaming.gemspec index b46db7b3..f1c5d7aa 100644 --- a/nylas-streaming.gemspec +++ b/nylas-v2-streaming.gemspec @@ -3,11 +3,11 @@ require "./gem_config" Gem::Specification.new do |gem| - GemConfig.apply(gem, "nylas-streaming") + GemConfig.apply(gem, "nylas-v2-streaming") gem.summary = %(Gem for interacting with the Nylas Deltas Streaming API) gem.description = %(Gem for interacting with the Nylas Deltas Streaming API.) gem.add_runtime_dependency "em-http-request", "~> 1.1", ">= 1.1.3" - gem.add_runtime_dependency "nylas", "~> 4.0" + gem.add_runtime_dependency "nylas-v2", "~> 4.0" gem.add_runtime_dependency "yajl-ruby", "~> 1.2", ">= 1.2.1" end diff --git a/nylas.gemspec b/nylas-v2.gemspec similarity index 90% rename from nylas.gemspec rename to nylas-v2.gemspec index 903b7e54..0b45eef2 100644 --- a/nylas.gemspec +++ b/nylas-v2.gemspec @@ -3,7 +3,7 @@ require "./gem_config" Gem::Specification.new do |gem| - GemConfig.apply(gem, "nylas") + GemConfig.apply(gem, "nylas-v2") gem.summary = %(Gem for interacting with the Nylas API) gem.description = %(Gem for interacting with the Nylas API.) gem.add_runtime_dependency "rest-client", ">= 2.0", "< 3.0" diff --git a/spec/nylas/account_spec.rb b/spec/nylas_v2/account_spec.rb similarity index 81% rename from spec/nylas/account_spec.rb rename to spec/nylas_v2/account_spec.rb index e3871a02..d82d3625 100644 --- a/spec/nylas/account_spec.rb +++ b/spec/nylas_v2/account_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe Nylas::Account do +describe NylasV2::Account do it "is filterable" do expect(described_class).to be_filterable end @@ -40,7 +40,7 @@ end it "can update metadata" do - api = instance_double("Nylas::API", execute: { success: true }, app_id: "app-987") + api = instance_double("NylasV2::API", execute: { success: true }, app_id: "app-987") account = described_class.from_json('{ "id": "acc-1234" }', api: api) account.metadata = { @@ -49,7 +49,7 @@ account.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :put, path: "/a/app-987/accounts/acc-1234", payload: JSON.dump( @@ -62,13 +62,13 @@ end it "can be downgraded" do - api = instance_double("Nylas::API", execute: { success: true }, app_id: "app-987") + api = instance_double("NylasV2::API", execute: { success: true }, app_id: "app-987") account = described_class.from_json('{ "id": "acc-1234" }', api: api) expect(account.downgrade).to be_truthy expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :post, path: "/a/app-987/accounts/acc-1234/downgrade", payload: nil, @@ -77,13 +77,13 @@ end it "can be upgraded" do - api = instance_double("Nylas::API", execute: { success: true }, app_id: "app-987") + api = instance_double("NylasV2::API", execute: { success: true }, app_id: "app-987") account = described_class.from_json('{ "id": "acc-1234" }', api: api) expect(account.upgrade).to be_truthy expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :post, path: "/a/app-987/accounts/acc-1234/upgrade", payload: nil, @@ -92,14 +92,14 @@ end it "can revoke all tokens" do - api = instance_double("Nylas::API", execute: { success: true }, app_id: "app-987") + api = instance_double("NylasV2::API", execute: { success: true }, app_id: "app-987") account = described_class.from_json('{ "id": "acc-1234" }', api: api) access_token = "some_access_token" expect(account.revoke_all(keep_access_token: access_token)).to be_truthy expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :post, path: "/a/app-987/accounts/acc-1234/revoke-all", payload: be_json("keep_access_token" => access_token), @@ -108,13 +108,13 @@ end it "can be destroyed" do - api = instance_double("Nylas::API", execute: { success: true }, app_id: "app-987") + api = instance_double("NylasV2::API", execute: { success: true }, app_id: "app-987") account = described_class.from_json('{ "id": "acc-1234" }', api: api) expect(account.destroy).to be_truthy expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :delete, path: "/a/app-987/accounts/acc-1234", payload: nil, @@ -123,7 +123,7 @@ end it "can return token information" do - api = instance_double("Nylas::API", app_id: "app-987") + api = instance_double("NylasV2::API", app_id: "app-987") account = described_class.from_json('{ "id": "acc-1234" }', api: api) token_info_response = { scopes: "email.send,email.modify,calendar", @@ -136,7 +136,7 @@ token_info = account.token_info("test-token") expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :post, path: "/a/app-987/accounts/acc-1234/token-info", payload: be_json("access_token" => "test-token"), diff --git a/spec/nylas/api_spec.rb b/spec/nylas_v2/api_spec.rb similarity index 89% rename from spec/nylas/api_spec.rb rename to spec/nylas_v2/api_spec.rb index ee96885f..a6f4c122 100644 --- a/spec/nylas/api_spec.rb +++ b/spec/nylas_v2/api_spec.rb @@ -4,10 +4,10 @@ # This spec is the only one that should have any webmock stuff going on, everything else should use the # FakeAPI to see what requests were made and what they included. -describe Nylas::API do +describe NylasV2::API do describe "#exchange_code_for_token" do it "retrieves oauth token with code" do - client = Nylas::HttpClient.new(app_id: "fake-app", app_secret: "fake-secret") + client = NylasV2::HttpClient.new(app_id: "fake-app", app_secret: "fake-secret") data = { "client_id" => "fake-app", "client_secret" => "fake-secret", @@ -28,7 +28,7 @@ end it "retrieves full response from the server" do - client = Nylas::HttpClient.new(app_id: "fake-app", app_secret: "fake-secret") + client = NylasV2::HttpClient.new(app_id: "fake-app", app_secret: "fake-secret") data = { "client_id" => "fake-app", "client_secret" => "fake-secret", @@ -136,19 +136,19 @@ end describe "#contact_groups" do - it "returns Nylas::Collection for contact groups" do - client = instance_double("Nylas::HttpClient") + it "returns NylasV2::Collection for contact groups" do + client = instance_double("NylasV2::HttpClient") api = described_class.new(client: client) result = api.contact_groups - expect(result).to be_a(Nylas::Collection) + expect(result).to be_a(NylasV2::Collection) end end describe "#current_account" do it "retrieves the account for the current OAuth Access Token" do - client = Nylas::HttpClient.new(app_id: "not-real", app_secret: "also-not-real", + client = NylasV2::HttpClient.new(app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal") allow(client).to receive(:execute).with(method: :get, path: "/account").and_return(id: 1234) api = described_class.new(client: client) @@ -156,26 +156,26 @@ end it "raises an exception if there is not an access token set" do - client = Nylas::HttpClient.new(app_id: "not-real", app_secret: "also-not-real") + client = NylasV2::HttpClient.new(app_id: "not-real", app_secret: "also-not-real") allow(client).to receive(:execute).with(method: :get, path: "/account").and_return(id: 1234) api = described_class.new(client: client) - expect { api.current_account.id }.to raise_error Nylas::NoAuthToken, + expect { api.current_account.id }.to raise_error NylasV2::NoAuthToken, "No access token was provided and the " \ "current_account method requires one" end it "sets X-Nylas-Client-Id header" do - client = Nylas::HttpClient.new(app_id: "not-real", app_secret: "also-not-real") + client = NylasV2::HttpClient.new(app_id: "not-real", app_secret: "also-not-real") expect(client.default_headers).to include("X-Nylas-Client-Id" => "not-real") end end describe "#free_busy" do - it "returns `Nylas::FreeBusyCollection` for free busy details" do + it "returns `NylasV2::FreeBusyCollection` for free busy details" do emails = ["test@example.com", "anothertest@example.com"] start_time = 1_609_439_400 end_time = 1_640_975_400 - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" @@ -211,7 +211,7 @@ end_time: Time.at(end_time) ) - expect(result).to be_a(Nylas::FreeBusyCollection) + expect(result).to be_a(NylasV2::FreeBusyCollection) free_busy = result.last expect(free_busy.object).to eq("free_busy") expect(free_busy.email).to eq("test@example.com") @@ -225,7 +225,7 @@ describe "application details" do it "gets the application details" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real" ) @@ -244,7 +244,7 @@ app_details = api.application_details - expect(app_details).to be_a(Nylas::ApplicationDetail) + expect(app_details).to be_a(NylasV2::ApplicationDetail) expect(app_details.application_name).to eq("My New App Name") expect(app_details.icon_url).to eq("http://localhost/icon.png") expect(app_details.redirect_uris).to eq(%w[http://localhost/callback]) @@ -256,11 +256,11 @@ icon_url: "http://localhost/updated_icon.png", redirect_uris: %w[http://localhost/callback http://localhost/updated] } - app_details = Nylas::ApplicationDetail.new + app_details = NylasV2::ApplicationDetail.new app_details.application_name = "Updated App Name" app_details.icon_url = "http://localhost/updated_icon.png" app_details.redirect_uris = %w[http://localhost/callback http://localhost/updated] - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real" ) @@ -274,7 +274,7 @@ updated_app_details = api.update_application_details(app_details) - expect(updated_app_details).to be_a(Nylas::ApplicationDetail) + expect(updated_app_details).to be_a(NylasV2::ApplicationDetail) end end diff --git a/spec/nylas/calendar_collection_spec.rb b/spec/nylas_v2/calendar_collection_spec.rb similarity index 84% rename from spec/nylas/calendar_collection_spec.rb rename to spec/nylas_v2/calendar_collection_spec.rb index 9fd2b233..bcaa0467 100644 --- a/spec/nylas/calendar_collection_spec.rb +++ b/spec/nylas_v2/calendar_collection_spec.rb @@ -2,13 +2,13 @@ require "spec_helper" -describe Nylas::CalendarCollection do +describe NylasV2::CalendarCollection do describe "availability" do it "makes a request to get single availability" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) - calendar_collection = described_class.new(model: Nylas::Calendar, api: api) - free_busy = Nylas::FreeBusy.new( + calendar_collection = described_class.new(model: NylasV2::Calendar, api: api) + free_busy = NylasV2::FreeBusy.new( email: "swag@nylas.com", time_slots: [ { @@ -19,7 +19,7 @@ } ] ) - open_hours = Nylas::OpenHours.new( + open_hours = NylasV2::OpenHours.new( emails: ["swag@nylas.com"], days: [0], timezone: "America/Chicago", @@ -80,8 +80,8 @@ end it "optional params are omitted when getting single availability" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) - calendar_collection = described_class.new(model: Nylas::Calendar, api: api) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) + calendar_collection = described_class.new(model: NylasV2::Calendar, api: api) calendar_collection.availability( duration_minutes: 30, @@ -108,10 +108,10 @@ end it "makes a request to get multiple availability" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) - calendar_collection = described_class.new(model: Nylas::Calendar, api: api) - free_busy = Nylas::FreeBusy.new( + calendar_collection = described_class.new(model: NylasV2::Calendar, api: api) + free_busy = NylasV2::FreeBusy.new( email: "swag@nylas.com", time_slots: [ { @@ -122,7 +122,7 @@ } ] ) - open_hours = Nylas::OpenHours.new( + open_hours = NylasV2::OpenHours.new( emails: %w[one@example.com two@example.com three@example.com swag@nylas.com], days: [0], timezone: "America/Chicago", @@ -179,8 +179,8 @@ end it "optional params are omitted when getting multiple availability" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) - calendar_collection = described_class.new(model: Nylas::Calendar, api: api) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) + calendar_collection = described_class.new(model: NylasV2::Calendar, api: api) calendar_collection.consecutive_availability( duration_minutes: 30, @@ -209,10 +209,10 @@ describe "verification" do it "throws an error if an email does not exist in open hours" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) - calendar_collection = described_class.new(model: Nylas::Calendar, api: api) - free_busy = Nylas::FreeBusy.new( + calendar_collection = described_class.new(model: NylasV2::Calendar, api: api) + free_busy = NylasV2::FreeBusy.new( email: "one@example.com", time_slots: [ { @@ -223,7 +223,7 @@ } ] ) - open_hours = Nylas::OpenHours.new( + open_hours = NylasV2::OpenHours.new( emails: %w[one@example.com two@example.com three@example.com swag@nylas.com], days: [0], timezone: "America/Chicago", @@ -248,8 +248,8 @@ end it "throws an error if at least one of 'emails' or 'calendars' is not provided" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) - calendar_collection = described_class.new(model: Nylas::Calendar, api: api) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) + calendar_collection = described_class.new(model: NylasV2::Calendar, api: api) expect do calendar_collection.consecutive_availability( diff --git a/spec/nylas/calendar_spec.rb b/spec/nylas_v2/calendar_spec.rb similarity index 89% rename from spec/nylas/calendar_spec.rb rename to spec/nylas_v2/calendar_spec.rb index 11c7754d..fdaebafe 100644 --- a/spec/nylas/calendar_spec.rb +++ b/spec/nylas_v2/calendar_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -describe Nylas::Calendar do +describe NylasV2::Calendar do describe "JSONs" do let(:calendar) do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { id: "cal-8766", object: "calendar", @@ -63,7 +63,7 @@ describe "read on" do it "Serializes all the attributes into Ruby objects" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { id: "cal-8766", object: "calendar", @@ -100,7 +100,7 @@ describe "#read_only?" do it "returns true when read_only attribute from API return true" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { read_only: true } @@ -111,7 +111,7 @@ end it "returns false when read_only attribute from API return false" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { read_only: false } @@ -124,7 +124,7 @@ describe "#primary?" do it "returns true when is_primary attribute from API return true" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { is_primary: true } @@ -135,7 +135,7 @@ end it "returns false when is_primary attribute from API return false" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { is_primary: false } @@ -148,8 +148,8 @@ describe "#events" do it "sets the constraints properly for getting child events" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) - events = Nylas::EventCollection.new(model: Nylas::Event, api: api) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) + events = NylasV2::EventCollection.new(model: NylasV2::Event, api: api) allow(api).to receive(:events).and_return(events) data = { id: "cal-123" @@ -158,12 +158,12 @@ event_collection = calendar.events - expect(event_collection).to be_a Nylas::EventCollection + expect(event_collection).to be_a NylasV2::EventCollection event_collection.execute expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, headers: {}, method: :get, path: "/events", diff --git a/spec/nylas/collection_spec.rb b/spec/nylas_v2/collection_spec.rb similarity index 82% rename from spec/nylas/collection_spec.rb rename to spec/nylas_v2/collection_spec.rb index 66afa356..ceb01b76 100644 --- a/spec/nylas/collection_spec.rb +++ b/spec/nylas_v2/collection_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe Nylas::Collection do +describe NylasV2::Collection do def example_instance_json '{ "id": "1234" }' end @@ -17,7 +17,7 @@ def example_instance_hash it "Returns an enumerable for a single page of results, filtered by `offset` and `limit` and `where`" do allow(api).to receive(:execute) .with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :get, path: "/collection", query: { limit: 100, offset: 0 }, @@ -34,7 +34,7 @@ def example_instance_hash it "allows you to use a block directly" do allow(api).to receive(:execute) .with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :get, path: "/collection", query: { limit: 100, offset: 0 }, @@ -58,7 +58,7 @@ def example_instance_hash collection = described_class.new(model: FullModel, api: api) allow(api).to receive(:execute) .with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :get, path: "/collection", query: { limit: 100, offset: 0 }, @@ -67,7 +67,7 @@ def example_instance_hash allow(api).to receive(:execute) .with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :get, path: "/collection", query: { limit: 100, offset: 100 }, @@ -82,7 +82,7 @@ def example_instance_hash it "retrieves a single object, without filtering based upon `where` clauses earlier in the chain" do collection = described_class.new(model: FullModel, api: api) allow(api).to receive(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :get, path: "/collection/1234", query: {}, @@ -104,7 +104,7 @@ def example_instance_hash expect(instance.id).to eql "1234" expect(instance.api).to eq(api) expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :get, path: "/collection/1234", query: { view: "expanded" }, @@ -121,7 +121,7 @@ def example_instance_hash expect(instance.id).to eql "1234" expect(instance.api).to eq(api) expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :get, path: "/collection/1234", query: {}, @@ -139,7 +139,7 @@ def example_instance_hash ] ) allow(api).to receive(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :get, path: "/collection/1234", query: {}, @@ -155,7 +155,7 @@ def example_instance_hash describe "#where" do it "raises a NotImplementedError stating the model is not searchable when the model is not searchable" do collection = described_class.new(model: NonFilterableModel, api: api) - expect { collection.where(id: "1234") }.to raise_error(Nylas::ModelNotFilterableError) + expect { collection.where(id: "1234") }.to raise_error(NylasV2::ModelNotFilterableError) end end @@ -163,7 +163,7 @@ def example_instance_hash it "sends the data to the appropriate endpoint using a post" it "Raises a not implemented error if the model is not creatable" do collection = described_class.new(model: NotCreatableModel, api: api) - expect { collection.create(string: "1234") }.to raise_error(Nylas::ModelNotCreatableError) + expect { collection.create(string: "1234") }.to raise_error(NylasV2::ModelNotCreatableError) end end @@ -173,7 +173,7 @@ def example_instance_hash collection = described_class.new(model: FullModel, api: api) allow(api).to receive(:execute) .with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :get, path: "/collection", query: { limit: 100, offset: 0, view: "count" }, @@ -187,7 +187,7 @@ def example_instance_hash collection = described_class.new(model: FullModel, api: api) allow(api).to receive(:execute) .with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :get, path: "/collection", query: { id: "1234", limit: 100, offset: 0, view: "count" }, @@ -203,7 +203,7 @@ def example_instance_hash collection = described_class.new(model: FullModel, api: api) allow(api).to receive(:execute) .with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :get, path: "/collection", query: { limit: 100, offset: 0 }, @@ -217,26 +217,26 @@ def example_instance_hash describe "HTTP errors" do http_codes_errors = { - 400 => Nylas::InvalidRequest, - 401 => Nylas::UnauthorizedRequest, - 402 => Nylas::MessageRejected, - 403 => Nylas::AccessDenied, - 404 => Nylas::ResourceNotFound, - 405 => Nylas::MethodNotAllowed, - 410 => Nylas::ResourceRemoved, - 418 => Nylas::TeapotError, - 422 => Nylas::MailProviderError, - 429 => Nylas::SendingQuotaExceeded, - 500 => Nylas::InternalError, - 501 => Nylas::EndpointNotYetImplemented, - 502 => Nylas::BadGateway, - 503 => Nylas::ServiceUnavailable, - 504 => Nylas::RequestTimedOut + 400 => NylasV2::InvalidRequest, + 401 => NylasV2::UnauthorizedRequest, + 402 => NylasV2::MessageRejected, + 403 => NylasV2::AccessDenied, + 404 => NylasV2::ResourceNotFound, + 405 => NylasV2::MethodNotAllowed, + 410 => NylasV2::ResourceRemoved, + 418 => NylasV2::TeapotError, + 422 => NylasV2::MailProviderError, + 429 => NylasV2::SendingQuotaExceeded, + 500 => NylasV2::InternalError, + 501 => NylasV2::EndpointNotYetImplemented, + 502 => NylasV2::BadGateway, + 503 => NylasV2::ServiceUnavailable, + 504 => NylasV2::RequestTimedOut } http_codes_errors.each do |code, error| it "raises error if API returns #{error} with #{code}" do - api = Nylas::API.new + api = NylasV2::API.new model = instance_double("Model") allow(model).to receive(:searchable?).and_return(true) allow(model).to receive(:resources_path) diff --git a/spec/nylas/component_spec.rb b/spec/nylas_v2/component_spec.rb similarity index 90% rename from spec/nylas/component_spec.rb rename to spec/nylas_v2/component_spec.rb index 46d8afa0..6fd8307e 100644 --- a/spec/nylas/component_spec.rb +++ b/spec/nylas_v2/component_spec.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -describe Nylas::Component do +describe NylasV2::Component do describe ".from_json" do it "Deserializes all the attributes into Ruby objects" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" ) - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) data = { id: "abc-123", account_id: "account-123", @@ -45,12 +45,12 @@ describe "saving" do it "POST with no ID set" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" ) - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) data = { account_id: "account-123", name: "test-component", @@ -71,7 +71,7 @@ component.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :post, path: "/component/not-real", payload: JSON.dump( @@ -90,12 +90,12 @@ end it "PUT with ID set" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" ) - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) data = { id: "abc-123", account_id: "account-123", @@ -117,7 +117,7 @@ scheduler.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :put, path: "/component/not-real/abc-123", payload: JSON.dump( diff --git a/spec/nylas/contact_group_spec.rb b/spec/nylas_v2/contact_group_spec.rb similarity index 94% rename from spec/nylas/contact_group_spec.rb rename to spec/nylas_v2/contact_group_spec.rb index 9551bf8e..f2d9b226 100644 --- a/spec/nylas/contact_group_spec.rb +++ b/spec/nylas_v2/contact_group_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe Nylas::ContactGroup do +describe NylasV2::ContactGroup do it "is not filterable" do expect(described_class).not_to be_filterable end @@ -31,7 +31,7 @@ describe ".from_json" do it "Deserializes all the attributes into Ruby objects" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { id: "group-id", account_id: "account-id", diff --git a/spec/nylas/contact_spec.rb b/spec/nylas_v2/contact_spec.rb similarity index 97% rename from spec/nylas/contact_spec.rb rename to spec/nylas_v2/contact_spec.rb index d9a42278..f07ffbca 100644 --- a/spec/nylas/contact_spec.rb +++ b/spec/nylas_v2/contact_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe Nylas::Contact do +describe NylasV2::Contact do let(:full_json) do '{ "id": "1234", "object": "contact", "account_id": "12345", ' \ '"given_name":"given", "middle_name": "middle", "surname": "surname", ' \ @@ -32,7 +32,7 @@ contact.update(given_name: "Given", birthday: "2017-01-01", emails: [ { type: "work", email: "given@other-job.example.com" }, - Nylas::EmailAddress.new(type: "home", email: "given@other-home.example.com") + NylasV2::EmailAddress.new(type: "home", email: "given@other-home.example.com") ]) expect(contact.given_name).to eql "Given" diff --git a/spec/nylas/current_account_spec.rb b/spec/nylas_v2/current_account_spec.rb similarity index 97% rename from spec/nylas/current_account_spec.rb rename to spec/nylas_v2/current_account_spec.rb index 2a1a9e36..b9c4eb41 100644 --- a/spec/nylas/current_account_spec.rb +++ b/spec/nylas_v2/current_account_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe Nylas::CurrentAccount do +describe NylasV2::CurrentAccount do it "is not filterable" do expect(described_class).not_to be_filterable end diff --git a/spec/nylas/delta_spec.rb b/spec/nylas_v2/delta_spec.rb similarity index 96% rename from spec/nylas/delta_spec.rb rename to spec/nylas_v2/delta_spec.rb index 6a44f944..d5786067 100644 --- a/spec/nylas/delta_spec.rb +++ b/spec/nylas_v2/delta_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe Nylas::Delta do +describe NylasV2::Delta do it "initialize data" do data = { object: "message", @@ -62,7 +62,7 @@ delta = described_class.new(**data) - expect(delta.model).to be_a(Nylas::Message) + expect(delta.model).to be_a(NylasV2::Message) end it "returns `nil` if `object` is nil" do diff --git a/spec/nylas/deltas_collection_spec.rb b/spec/nylas_v2/deltas_collection_spec.rb similarity index 83% rename from spec/nylas/deltas_collection_spec.rb rename to spec/nylas_v2/deltas_collection_spec.rb index 41c23a77..21f78021 100644 --- a/spec/nylas/deltas_collection_spec.rb +++ b/spec/nylas_v2/deltas_collection_spec.rb @@ -2,13 +2,13 @@ require "spec_helper" -describe Nylas::DeltasCollection do +describe NylasV2::DeltasCollection do describe "#find_each" do it "supports iterating until the responses are empty" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute) .with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, path: "/delta", method: :get, query: { cursor: "1", limit: 100, offset: 0 }, @@ -16,7 +16,7 @@ ).and_return(deltas: [{ object: "draft" }], cursor_start: "1", cursor_end: "2") allow(api).to receive(:execute) .with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, path: "/delta", method: :get, query: { cursor: "2", limit: 100, offset: 0 }, @@ -24,7 +24,7 @@ ).and_return(deltas: [{ object: "message" }], cursor_start: "2", cursor_end: "3") allow(api).to receive(:execute) .with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, path: "/delta", method: :get, query: { cursor: "3", limit: 100, offset: 0 }, @@ -42,14 +42,14 @@ describe "#latest" do it "retrieves the results for the cursor that comes from the latest_cursor end point" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute) .with(path: "/delta/latest_cursor", method: :post) .and_return(cursor: "4") allow(api).to receive(:execute) .with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, path: "/delta", method: :get, query: { cursor: "4", limit: 100, offset: 0 }, diff --git a/spec/nylas/deltas_spec.rb b/spec/nylas_v2/deltas_spec.rb similarity index 93% rename from spec/nylas/deltas_spec.rb rename to spec/nylas_v2/deltas_spec.rb index 0e7caafc..c0804096 100644 --- a/spec/nylas/deltas_spec.rb +++ b/spec/nylas_v2/deltas_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe Nylas::Deltas do +describe NylasV2::Deltas do it "safely inflates an account.running event" do data = { "deltas": [ @@ -27,7 +27,7 @@ expect(delta.date).to eql(Time.at(1_514_335_663)) expect(delta.type).to eql "account.running" expect(delta.object).to eql "account" - expect(delta.model).to be_a Nylas::Account + expect(delta.model).to be_a NylasV2::Account expect(delta.id).to eql "dlt-09876" expect(delta.namespace_id).to eql "acc-2345" expect(delta.account_id).to eql "acc-2345" @@ -77,7 +77,7 @@ delta = deltas.first expect(delta.date).to eql(Time.at(1_514_339_684)) expect(delta.object).to eql("message") - expect(delta.model).to be_a Nylas::Message + expect(delta.model).to be_a NylasV2::Message expect(delta.model.id).to eql "msg-1234" expect(delta.model.thread_id).to eql "thread-098" expect(delta.model.received_date).to eql Time.at(1_514_339_665) @@ -134,7 +134,7 @@ references: [""] } ) - expect(message_delta.model).to be_a(Nylas::Message) + expect(message_delta.model).to be_a(NylasV2::Message) expect(message_delta.id).to eq("message-id") expect(message_delta.account_id).to eq("acc-id") expect(message_delta.headers.in_reply_to).to eq("") @@ -148,7 +148,7 @@ object: "event", id: "event-id" ) - expect(event_delta.model).to be_a(Nylas::Event) + expect(event_delta.model).to be_a(NylasV2::Event) expect(event_delta.model.attributes.to_h).to include( account_id: "acc-id", object: "event", @@ -172,7 +172,7 @@ expect(deltas.count).to eq(1) delta = deltas.last - expect(delta.model).to be_a(Nylas::Message) + expect(delta.model).to be_a(NylasV2::Message) expect(delta.attributes.to_h).to eq( object: "message" ) @@ -193,7 +193,7 @@ expect(deltas.count).to eq(1) delta = deltas.last expect(delta.id).to eq("some-id") - expect(delta.model).to be_a(Nylas::Event) + expect(delta.model).to be_a(NylasV2::Event) expect(delta.attributes.to_h).to eq( id: "some-id", object: "event" @@ -216,7 +216,7 @@ expect(deltas.count).to eq(1) delta = deltas.last expect(delta.id).to eq("some-id") - expect(delta.model).to be_a(Nylas::Message) + expect(delta.model).to be_a(NylasV2::Message) expect(delta.attributes.to_h).to eq( id: "some-id", object: "message" diff --git a/spec/nylas/draft_spec.rb b/spec/nylas_v2/draft_spec.rb similarity index 87% rename from spec/nylas/draft_spec.rb rename to spec/nylas_v2/draft_spec.rb index a8fca625..76894489 100644 --- a/spec/nylas/draft_spec.rb +++ b/spec/nylas_v2/draft_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe Nylas::Draft do +describe NylasV2::Draft do it "is not filterable" do expect(described_class).not_to be_filterable end @@ -30,8 +30,8 @@ describe "update" do context "with `files` key" do it "if `files` present, remove from the payload and sets the proper file_ids key" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) - file = Nylas::File.new(id: "abc-123") + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) + file = NylasV2::File.new(id: "abc-123") data = { id: "draft-1234" } @@ -43,7 +43,7 @@ draft.update(subject: "Updated subject", files: [file]) expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/drafts/draft-1234", payload: JSON.dump( @@ -57,7 +57,7 @@ context "when `files` key does not exists" do it "does not set the file_ids key or make any further changes to the payload" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) data = { id: "draft-1234" } @@ -69,7 +69,7 @@ draft.update(subject: "Updated subject") expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/drafts/draft-1234", payload: JSON.dump( @@ -85,7 +85,7 @@ id: "draft-1234", version: 1 } - api = instance_double(Nylas::API, execute: expected_response) + api = instance_double(NylasV2::API, execute: expected_response) data = { id: "draft-1234", version: 0 @@ -101,7 +101,7 @@ end it "sends the version number if the user does not manually add it" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) data = { id: "draft-1234", subject: "This is a draft", @@ -118,7 +118,7 @@ draft.update(**updated) expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/drafts/draft-1234", payload: JSON.dump( @@ -133,8 +133,8 @@ describe "#create" do context "when `files` key exists" do it "removes `files` from the payload and sets the proper file_ids key" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) - file = Nylas::File.new(id: "abc-123") + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) + file = NylasV2::File.new(id: "abc-123") data = { id: "draft-1234", files: [file] @@ -147,7 +147,7 @@ draft.create expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :post, path: "/drafts", payload: JSON.dump( @@ -161,7 +161,7 @@ context "when `files` key does not exists" do it "does nothing" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) data = { id: "draft-1234" } @@ -173,7 +173,7 @@ draft.create expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :post, path: "/drafts", payload: JSON.dump( @@ -188,8 +188,8 @@ describe "save" do context "when `files` key exists" do it "removes `files` from the payload and sets the proper file_ids key" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) - file = Nylas::File.new(id: "abc-123") + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) + file = NylasV2::File.new(id: "abc-123") data = { id: "draft-1234", files: [file] @@ -202,7 +202,7 @@ draft.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/drafts/draft-1234", payload: JSON.dump( @@ -216,7 +216,7 @@ context "when `files` key does not exists" do it "does nothing" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) data = { id: "draft-1234" } @@ -228,7 +228,7 @@ draft.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/drafts/draft-1234", payload: JSON.dump( @@ -244,7 +244,7 @@ id: "draft-1234", version: 1 } - api = instance_double(Nylas::API, execute: expected_response) + api = instance_double(NylasV2::API, execute: expected_response) data = { id: "draft-1234" } @@ -261,7 +261,7 @@ describe "#send!" do it "sends the payload if the draft was not created on the server" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) draft = described_class.from_hash({ reply_to_message_id: "mess-1234", to: [{ email: "to@example.com", name: "To Example" }], from: [{ email: "from@example.com", name: "From Example" }], @@ -273,7 +273,7 @@ draft.send! expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :post, path: "/send", payload: update_json, @@ -282,7 +282,7 @@ end it "includes tracking when sending the draft" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) draft = described_class.from_hash({ id: "draft-1234", "version": 5 }, api: api) draft.tracking = { opens: true, links: true, thread_replies: true, payload: "this is a payload" } allow(api).to receive(:execute) @@ -290,7 +290,7 @@ draft.send! expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :post, path: "/send", payload: JSON.dump( @@ -305,7 +305,7 @@ describe ".from_json" do it "Deserializes all the attributes into Ruby objects" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { id: "drft-592", version: 0, object: "draft", account_id: "acc-9987", thread_id: "thread-1234", reply_to_message_id: "mess-1234", date: 1_513_276_982, to: [{ email: "to@example.com", name: "To Example" }], diff --git a/spec/nylas/event_spec.rb b/spec/nylas_v2/event_spec.rb similarity index 89% rename from spec/nylas/event_spec.rb rename to spec/nylas_v2/event_spec.rb index e8d6a110..c8ea75fe 100644 --- a/spec/nylas/event_spec.rb +++ b/spec/nylas_v2/event_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -describe Nylas::Event do +describe NylasV2::Event do describe ".from_json" do it "Deserializes all the attributes into Ruby objects" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { id: "event-8766", object: "event", @@ -104,7 +104,7 @@ describe "busy?" do it "returns true when busy attribute from API return true" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { account_id: "acc-1234", busy: true, @@ -117,7 +117,7 @@ end it "returns false when busy attribute from API return false" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { account_id: "acc-1234", busy: false, @@ -132,7 +132,7 @@ describe "#read_only?" do it "returns true when read_only attribute from API return true" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { account_id: "acc-1234", read_only: true, @@ -145,7 +145,7 @@ end it "returns false when read_only attribute from API return false" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { account_id: "acc-1234", read_only: false, @@ -160,7 +160,7 @@ describe "#rsvp" do it "calls `Rsvp` with the given status and flag to notify_participants" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { id: "event-123", account_id: "acc-1234", @@ -168,12 +168,12 @@ calendar_id: "cal-0987" } rsvp = instance_double("Rsvp", save: nil) - allow(Nylas::Rsvp).to receive(:new).and_return(rsvp) + allow(NylasV2::Rsvp).to receive(:new).and_return(rsvp) event = described_class.from_json(JSON.dump(data), api: api) event.rsvp(:yes, notify_participants: true) - expect(Nylas::Rsvp).to have_received(:new).with( + expect(NylasV2::Rsvp).to have_received(:new).with( api: api, status: :yes, event_id: "event-123", @@ -187,7 +187,7 @@ describe "account_id" do context "when saving" do it "is excluded from payload" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { id: "event-id", @@ -200,7 +200,7 @@ event.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/events/event-id", payload: { @@ -216,7 +216,7 @@ describe "object" do context "when saving" do it "is excluded from payload" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { id: "event-id", @@ -228,7 +228,7 @@ event.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/events/event-id", payload: { @@ -243,7 +243,7 @@ describe "id" do context "when saving" do it "is excluded from payload" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { id: "event-id", @@ -254,7 +254,7 @@ event.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/events/event-id", payload: { @@ -265,7 +265,7 @@ end it "sends the conferencing autocreate object even if settings is empty" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { id: "event-id", @@ -282,7 +282,7 @@ event.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/events/event-id", payload: { @@ -299,7 +299,7 @@ end it "sends the conferencing object if details alone is set" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { id: "event-id", @@ -321,7 +321,7 @@ event.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/events/event-id", payload: { @@ -343,7 +343,7 @@ end it "throws an error if both conferencing details and autocreate are set" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { id: "event-id", @@ -370,7 +370,7 @@ end it "throws an error if capacity is less than the amount of participants" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { id: "event-id", @@ -385,7 +385,7 @@ end it "does not throw an error if capacity is -1" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { id: "event-id", @@ -399,7 +399,7 @@ end it "does not throw an error if participants less than or equal to capacity" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { id: "event-id", @@ -420,7 +420,7 @@ describe "reminder_minutes" do context "when saving" do it "is formatted properly if set to a numeric value" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { reminder_minutes: "20" @@ -430,7 +430,7 @@ event.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :post, path: "/events", payload: { @@ -441,7 +441,7 @@ end it "is left as-is if user already formatted properly" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { reminder_minutes: "[20]" @@ -451,7 +451,7 @@ event.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :post, path: "/events", payload: { @@ -462,7 +462,7 @@ end it "does not send reminder_minutes if unset" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { reminder_minutes: "" @@ -472,7 +472,7 @@ event.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :post, path: "/events", payload: {}.to_json, @@ -485,7 +485,7 @@ describe "notify_participants" do context "when creating" do it "sends notify_participants in query params" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { account_id: "acc-1234", @@ -498,7 +498,7 @@ event.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :post, path: "/events", payload: { @@ -512,7 +512,7 @@ end it "sends nothing when `notify_participants` is not set" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { account_id: "acc-1234", @@ -524,7 +524,7 @@ event.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :post, path: "/events", payload: { @@ -538,7 +538,7 @@ context "when updating" do it "sends notify_participants in query params" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute) data = { id: "event-8766", @@ -552,7 +552,7 @@ event.update(location: "Somewhere else!") expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/events/event-8766", payload: { @@ -565,7 +565,7 @@ end it "sends nothing when `notify_participants` is not set" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute) data = { id: "event-8766", @@ -578,7 +578,7 @@ event.update(location: "Somewhere else!") expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/events/event-8766", payload: { @@ -591,7 +591,7 @@ context "when deleting" do it "sends notify_participants in query params" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute) data = { id: "event-8766", @@ -605,7 +605,7 @@ event.destroy expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :delete, path: "/events/event-8766", payload: nil, @@ -616,7 +616,7 @@ end it "sends nothing when `notify_participants` is not set" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute) data = { id: "event-8766", @@ -629,7 +629,7 @@ event.destroy expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :delete, path: "/events/event-8766", payload: nil, @@ -641,7 +641,7 @@ describe "generating an ICS" do it "sends the event ID if set" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { id: "event-id", @@ -666,7 +666,7 @@ end it "sends the event object if event id is not set" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { calendar_id: "cal-0987", @@ -695,7 +695,7 @@ end it "throws an error if event has no calendar ID set" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { title: "An Event", @@ -711,7 +711,7 @@ end it "throws an error if event has no when object set" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:execute).and_return({}) data = { calendar_id: "cal-0987", diff --git a/spec/nylas/filter_attributes_spec.rb b/spec/nylas_v2/filter_attributes_spec.rb similarity index 95% rename from spec/nylas/filter_attributes_spec.rb rename to spec/nylas_v2/filter_attributes_spec.rb index 50644caa..90ff91ea 100644 --- a/spec/nylas/filter_attributes_spec.rb +++ b/spec/nylas_v2/filter_attributes_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe Nylas::FilterAttributes do +describe NylasV2::FilterAttributes do describe "#check" do context "when `attributes` and `allowed_attributes` are similar" do it "does not raise any error" do diff --git a/spec/nylas/folder_spec.rb b/spec/nylas_v2/folder_spec.rb similarity index 84% rename from spec/nylas/folder_spec.rb rename to spec/nylas_v2/folder_spec.rb index ba9d3e5b..11f97a15 100644 --- a/spec/nylas/folder_spec.rb +++ b/spec/nylas_v2/folder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe Nylas::Folder do +describe NylasV2::Folder do it "is not filterable" do expect(described_class).not_to be_filterable end @@ -23,7 +23,7 @@ describe "API operations" do it "sends a POST when saving a new folder" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) json = JSON.dump(display_name: "All Mail", name: "all") folder = described_class.from_json(json, api: api) allow(api).to receive(:execute).and_return({}) @@ -31,7 +31,7 @@ folder.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :post, path: "/folders", payload: { @@ -43,7 +43,7 @@ end it "sends a PUT when updating an existing folder" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) json = JSON.dump(id: "folder_id", display_name: "All Mail", name: "all", account_id: "acc-234", object: "folder") folder = described_class.from_json(json, api: api) @@ -54,7 +54,7 @@ ) expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/folders/folder_id", payload: { @@ -65,7 +65,7 @@ end it "sends a PUT when saving an existing folder" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) json = JSON.dump(id: "folder_id", display_name: "All Mail", name: "all", account_id: "acc-234", object: "folder") folder = described_class.from_json(json, api: api) @@ -74,7 +74,7 @@ folder.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/folders/folder_id", payload: { @@ -86,7 +86,7 @@ end it "sends a DELETE when deleting an existing folder" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) json = JSON.dump(id: "folder_id", display_name: "All Mail", name: "all", account_id: "acc-234", object: "folder") folder = described_class.from_json(json, api: api) @@ -95,7 +95,7 @@ folder.destroy expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :delete, path: "/folders/folder_id", payload: nil, diff --git a/spec/nylas/free_busy_collection_spec.rb b/spec/nylas_v2/free_busy_collection_spec.rb similarity index 96% rename from spec/nylas/free_busy_collection_spec.rb rename to spec/nylas_v2/free_busy_collection_spec.rb index 28aa922f..8ecbcd49 100644 --- a/spec/nylas/free_busy_collection_spec.rb +++ b/spec/nylas_v2/free_busy_collection_spec.rb @@ -2,13 +2,13 @@ require "spec_helper" -describe Nylas::FreeBusyCollection do +describe NylasV2::FreeBusyCollection do describe "#each" do it "returns collection of `FreeBusy` objects" do start_time = 1_609_439_400 end_time = 1_640_975_400 emails = ["test@example.com", "anothertest@example.com"] - api = instance_double("Nylas::API") + api = instance_double("NylasV2::API") free_busy_response = [ { object: "free_busy", diff --git a/spec/nylas/free_busy_spec.rb b/spec/nylas_v2/free_busy_spec.rb similarity index 97% rename from spec/nylas/free_busy_spec.rb rename to spec/nylas_v2/free_busy_spec.rb index 63c0a82d..b2eaa4bb 100644 --- a/spec/nylas/free_busy_spec.rb +++ b/spec/nylas_v2/free_busy_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe Nylas::FreeBusy do +describe NylasV2::FreeBusy do describe "#email" do it "reads and write value for email" do email = "test@example.com" diff --git a/spec/nylas/http_client_spec.rb b/spec/nylas_v2/http_client_spec.rb similarity index 90% rename from spec/nylas/http_client_spec.rb rename to spec/nylas_v2/http_client_spec.rb index 5ad75ee8..6d0a65d3 100644 --- a/spec/nylas/http_client_spec.rb +++ b/spec/nylas_v2/http_client_spec.rb @@ -3,7 +3,7 @@ require "spec_helper" require "webmock/rspec" -describe Nylas::HttpClient do +describe NylasV2::HttpClient do let(:full_json) do '{"snippet":"\u26a1\ufe0f Some text \ud83d","starred":false,"subject":"Updates"}' end @@ -17,7 +17,7 @@ it "raises if the JSON is unable to be deserialized" do nylas = described_class.new(app_id: "id", app_secret: "secret", access_token: "token") - expect { nylas.parse_response("{{") }.to raise_error(Nylas::JsonParseError) + expect { nylas.parse_response("{{") }.to raise_error(NylasV2::JsonParseError) end end @@ -38,7 +38,7 @@ stub_request(:get, "https://api.nylas.com/contacts/1234") .to_return(status: 200, body: "abc", headers: { "Content-Type" => "Application/Json" }) - expect { nylas.execute(method: :get, path: "/contacts/1234") }.to raise_error(Nylas::JsonParseError) + expect { nylas.execute(method: :get, path: "/contacts/1234") }.to raise_error(NylasV2::JsonParseError) end it "still throws an API error if content-type == application/json but response is not a json" do @@ -47,7 +47,7 @@ stub_request(:get, "https://api.nylas.com/contacts/1234") .to_return(status: 400, body: "abc", headers: { "Content-Type" => "Application/Json" }) - expect { nylas.execute(method: :get, path: "/contacts/1234") }.to raise_error(Nylas::InvalidRequest) + expect { nylas.execute(method: :get, path: "/contacts/1234") }.to raise_error(NylasV2::InvalidRequest) end it "skips parsing when content-type is not JSON" do @@ -91,21 +91,21 @@ describe "HTTP errors" do http_codes_errors = { - 400 => Nylas::InvalidRequest, - 401 => Nylas::UnauthorizedRequest, - 402 => Nylas::MessageRejected, - 403 => Nylas::AccessDenied, - 404 => Nylas::ResourceNotFound, - 405 => Nylas::MethodNotAllowed, - 410 => Nylas::ResourceRemoved, - 418 => Nylas::TeapotError, - 422 => Nylas::MailProviderError, - 429 => Nylas::SendingQuotaExceeded, - 500 => Nylas::InternalError, - 501 => Nylas::EndpointNotYetImplemented, - 502 => Nylas::BadGateway, - 503 => Nylas::ServiceUnavailable, - 504 => Nylas::RequestTimedOut + 400 => NylasV2::InvalidRequest, + 401 => NylasV2::UnauthorizedRequest, + 402 => NylasV2::MessageRejected, + 403 => NylasV2::AccessDenied, + 404 => NylasV2::ResourceNotFound, + 405 => NylasV2::MethodNotAllowed, + 410 => NylasV2::ResourceRemoved, + 418 => NylasV2::TeapotError, + 422 => NylasV2::MailProviderError, + 429 => NylasV2::SendingQuotaExceeded, + 500 => NylasV2::InternalError, + 501 => NylasV2::EndpointNotYetImplemented, + 502 => NylasV2::BadGateway, + 503 => NylasV2::ServiceUnavailable, + 504 => NylasV2::RequestTimedOut } http_codes_errors.each do |code, error| @@ -151,7 +151,7 @@ .to_return(status: 429, body: error_json, headers: error_headers) expect { nylas.execute(method: :get, path: "/contacts") } - .to raise_error(an_instance_of(Nylas::SendingQuotaExceeded) + .to raise_error(an_instance_of(NylasV2::SendingQuotaExceeded) .and(having_attributes( rate_limit: 500, rate_limit_reset: 10 diff --git a/spec/nylas/job_status_spec.rb b/spec/nylas_v2/job_status_spec.rb similarity index 98% rename from spec/nylas/job_status_spec.rb rename to spec/nylas_v2/job_status_spec.rb index 546aaf89..ed497ffe 100644 --- a/spec/nylas/job_status_spec.rb +++ b/spec/nylas_v2/job_status_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe Nylas::JobStatus do +describe NylasV2::JobStatus do it "is not creatable" do expect(described_class).not_to be_creatable end diff --git a/spec/nylas/label_spec.rb b/spec/nylas_v2/label_spec.rb similarity index 96% rename from spec/nylas/label_spec.rb rename to spec/nylas_v2/label_spec.rb index f8ededa6..58444f3a 100644 --- a/spec/nylas/label_spec.rb +++ b/spec/nylas_v2/label_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe Nylas::Label do +describe NylasV2::Label do it "is not filterable" do expect(described_class).not_to be_filterable end diff --git a/spec/nylas/message_spec.rb b/spec/nylas_v2/message_spec.rb similarity index 92% rename from spec/nylas/message_spec.rb rename to spec/nylas_v2/message_spec.rb index 7809e252..1cb5818d 100644 --- a/spec/nylas/message_spec.rb +++ b/spec/nylas_v2/message_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -describe Nylas::Message do +describe NylasV2::Message do describe ".from_json" do it "Deserializes all the attributes into Ruby objects" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { id: "mess-8766", object: "message", account_id: "acc-1234", thread_id: "thread-1234", date: 1_511_302_748, to: [{ email: "to@example.com", name: "To Example" }], @@ -131,7 +131,7 @@ describe "#save" do context "when `labels` key exists" do it "removes `labels` from the payload" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) data = { id: "message-1234", labels: [ @@ -147,7 +147,7 @@ message.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/messages/message-1234", payload: JSON.dump( @@ -159,7 +159,7 @@ end it "removes the folder node and replaces with folder_id" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) data = { id: "message-1234", folder: { display_name: "Inbox", id: "folder-inbox", name: "inbox" }, @@ -174,7 +174,7 @@ message.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/messages/message-1234", payload: JSON.dump( @@ -186,7 +186,7 @@ ) end it "does not overwrite folder_id if set" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) data = { id: "message-1234", folder: { display_name: "Inbox", id: "folder-inbox", name: "inbox" }, @@ -202,7 +202,7 @@ message.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/messages/message-1234", payload: JSON.dump( @@ -217,7 +217,7 @@ describe "#update" do it "let's you set the starred, unread, folder, and label ids" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) message = described_class.from_json('{ "id": "message-1234" }', api: api) message.update( @@ -228,7 +228,7 @@ ) expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/messages/message-1234", payload: JSON.dump( @@ -243,7 +243,7 @@ ) end it "raises an argument error if the data has any keys that aren't allowed to be updated" do - api = instance_double(Nylas::API, execute: "{}") + api = instance_double(NylasV2::API, execute: "{}") message = described_class.from_json('{ "id": "message-1234" }', api: api) expect do message.update(subject: "A new subject!") @@ -254,14 +254,14 @@ describe "update_folder" do it "moves message to new `folder`" do folder_id = "9999" - api = instance_double(Nylas::API, execute: "{}") + api = instance_double(NylasV2::API, execute: "{}") message = described_class.from_json('{ "id": "message-1234" }', api: api) allow(api).to receive(:execute) message.update_folder(folder_id) expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/messages/message-1234", payload: { folder_id: folder_id }.to_json, @@ -272,7 +272,7 @@ describe "#expanded" do it "fetch or return expanded version of message" do - api = instance_double(Nylas::API, execute: "{}") + api = instance_double(NylasV2::API, execute: "{}") message = described_class.from_json('{ "id": "message-1234" }', api: api) data = { id: "draft-1234", headers: { "In-Reply-To": "", @@ -290,7 +290,7 @@ expect(message.expanded.headers.references[0]).to eql "" end it "transfers api to attributes that need it" do - api = instance_double(Nylas::API, execute: "{}") + api = instance_double(NylasV2::API, execute: "{}") message = described_class.from_json('{ "id": "message-1234" }', api: api) data = { id: "draft-1234", headers: { "In-Reply-To": "", diff --git a/spec/nylas/model/attributes_spec.rb b/spec/nylas_v2/model/attributes_spec.rb similarity index 94% rename from spec/nylas/model/attributes_spec.rb rename to spec/nylas_v2/model/attributes_spec.rb index 97c1b15c..47c83042 100644 --- a/spec/nylas/model/attributes_spec.rb +++ b/spec/nylas_v2/model/attributes_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe Nylas::Model::Attributes do +describe NylasV2::Model::Attributes do describe "#serialize_for_api" do it "rejects keys which are read_only" do test_json = { diff --git a/spec/nylas/model_spec.rb b/spec/nylas_v2/model_spec.rb similarity index 92% rename from spec/nylas/model_spec.rb rename to spec/nylas_v2/model_spec.rb index fe81886a..3112626c 100644 --- a/spec/nylas/model_spec.rb +++ b/spec/nylas_v2/model_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe Nylas::Model do +describe NylasV2::Model do def example_instance_json "{ }" end @@ -20,19 +20,19 @@ def example_instance_hash describe "#save" do it "raises a NotImplementedError exception if the model is flagged as not updatable" do instance = NotUpdatableModel.from_hash({ id: "model-1234" }, api: api) - expect { instance.save }.to raise_error(Nylas::ModelNotUpdatableError) + expect { instance.save }.to raise_error(NylasV2::ModelNotUpdatableError) end it "raises a ModelNotCreatable exception if the model is new and is flagged as not creatable" do instance = NotCreatableModel.from_hash({}, api: api) - expect { instance.save }.to raise_error(Nylas::ModelNotCreatableError) + expect { instance.save }.to raise_error(NylasV2::ModelNotCreatableError) end end describe "#update" do it "raises a NotImplementedError exception if the model is flagged as read only" do instance = NotUpdatableModel.from_json(example_instance_json, api: api) - expect { instance.update(name: "other") }.to raise_error(Nylas::ModelNotUpdatableError) + expect { instance.update(name: "other") }.to raise_error(NylasV2::ModelNotUpdatableError) end it "raises a MissingFieldError if attempting to set a field that does not exist" do @@ -40,7 +40,7 @@ def example_instance_hash instance = FullModel.new expect do instance.update(fake_attribute: "not real") - end.to raise_error(Nylas::ModelMissingFieldError, expected_message) + end.to raise_error(NylasV2::ModelMissingFieldError, expected_message) end end @@ -57,7 +57,7 @@ def example_instance_hash instance.save_all_attributes expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, payload: { id: "1234", @@ -83,13 +83,13 @@ def example_instance_hash it "raises a NotImplementedError exception if the model is flagged as not updatable" do instance = NotUpdatableModel.from_hash({ id: "model-1234" }, api: api) - expect { instance.save_all_attributes }.to raise_error(Nylas::ModelNotUpdatableError) + expect { instance.save_all_attributes }.to raise_error(NylasV2::ModelNotUpdatableError) end it "raises a ModelNotCreatable exception if the model is new and is flagged as not creatable" do instance = NotCreatableModel.from_hash({}, api: api) - expect { instance.save_all_attributes }.to raise_error(Nylas::ModelNotCreatableError) + expect { instance.save_all_attributes }.to raise_error(NylasV2::ModelNotCreatableError) end end @@ -111,7 +111,7 @@ def example_instance_hash instance.update_all_attributes(**update_params) expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, payload: update_params.to_json, path: "/collection/1234", @@ -124,7 +124,7 @@ def example_instance_hash it "raises a NotImplementedError exception if the model is flagged as read only" do instance = NotUpdatableModel.from_json(example_instance_json, api: api) - expect { instance.update_all_attributes(name: "other") }.to raise_error(Nylas::ModelNotUpdatableError) + expect { instance.update_all_attributes(name: "other") }.to raise_error(NylasV2::ModelNotUpdatableError) end it "raises a MissingFieldError if attempting to set a field that does not exist" do @@ -133,7 +133,7 @@ def example_instance_hash expect do instance.update_all_attributes(fake_attribute: "not real") - end.to raise_error(Nylas::ModelMissingFieldError, expected_message) + end.to raise_error(NylasV2::ModelMissingFieldError, expected_message) end end @@ -150,7 +150,7 @@ def example_instance_hash instance.reload expect(instance.id).to eql "1234" expect(instance.string).to eql "I am real" - expect { instance.attributes[:fake_attribute] }.to raise_error Nylas::Registry::MissingKeyError + expect { instance.attributes[:fake_attribute] }.to raise_error NylasV2::Registry::MissingKeyError end end diff --git a/spec/nylas/native_authentication_spec.rb b/spec/nylas_v2/native_authentication_spec.rb similarity index 89% rename from spec/nylas/native_authentication_spec.rb rename to spec/nylas_v2/native_authentication_spec.rb index 64f6fd4e..40d786e7 100644 --- a/spec/nylas/native_authentication_spec.rb +++ b/spec/nylas_v2/native_authentication_spec.rb @@ -4,10 +4,10 @@ # rubocop:disable RSpec/MessageSpies -describe Nylas::NativeAuthentication do +describe NylasV2::NativeAuthentication do describe "#authenticate" do it "sets all scopes by default" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" @@ -20,7 +20,7 @@ method: :post, path: "/connect/token", payload: be_json_including("code" => 1234) ).and_return(access_token: "fake-token") - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) expect( api.authenticate( @@ -33,7 +33,7 @@ end it "allows arrays of one scope" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" @@ -46,7 +46,7 @@ method: :post, path: "/connect/token", payload: be_json_including("code" => 1234) ).and_return(access_token: "fake-token") - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) expect( api.authenticate( @@ -60,7 +60,7 @@ end it "allows arrays of two scopes" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" @@ -73,7 +73,7 @@ method: :post, path: "/connect/token", payload: be_json_including("code" => 1234) ).and_return(access_token: "fake-token") - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) expect( api.authenticate( @@ -87,7 +87,7 @@ end it "allows string scopes" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" @@ -100,7 +100,7 @@ method: :post, path: "/connect/token", payload: be_json_including("code" => 1234) ).and_return(access_token: "fake-token") - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) expect( api.authenticate( diff --git a/spec/nylas/neural_spec.rb b/spec/nylas_v2/neural_spec.rb similarity index 92% rename from spec/nylas/neural_spec.rb rename to spec/nylas_v2/neural_spec.rb index 404e1904..41447425 100644 --- a/spec/nylas/neural_spec.rb +++ b/spec/nylas_v2/neural_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe Nylas::Neural do +describe NylasV2::Neural do describe "Clean Conversation" do let(:data) do [ @@ -32,7 +32,7 @@ end it "Deserializes all the attributes into Ruby objects" do - api = instance_double(Nylas::API, execute: data) + api = instance_double(NylasV2::API, execute: data) neural = described_class.new(api: api) clean_conversation = neural.clean_conversation(["abc123"]) @@ -52,9 +52,9 @@ end it "Sends the options in the body" do - api = instance_double(Nylas::API, execute: data) + api = instance_double(NylasV2::API, execute: data) neural = described_class.new(api: api) - options = Nylas::NeuralMessageOptions.new( + options = NylasV2::NeuralMessageOptions.new( ignore_links: false, ignore_images: false, ignore_tables: false, @@ -79,8 +79,8 @@ end it "Parses the image correctly" do - api = instance_double(Nylas::API, execute: data) - files = instance_double(Nylas::Collection, find: Nylas::File.new(id: "file123")) + api = instance_double(NylasV2::API, execute: data) + files = instance_double(NylasV2::Collection, find: NylasV2::File.new(id: "file123")) allow(api).to receive(:files).and_return(files) neural = described_class.new(api: api) clean_conversation = neural.clean_conversation(["abc123"]) @@ -104,7 +104,7 @@ end it "Deserializes the message request into Ruby objects" do - api = instance_double(Nylas::API, execute: [data]) + api = instance_double(NylasV2::API, execute: [data]) neural = described_class.new(api: api) sentiment = neural.sentiment_analysis_message(["abc123"]) @@ -125,7 +125,7 @@ end it "Deserializes the text request into Ruby objects" do - api = instance_double(Nylas::API, execute: data) + api = instance_double(NylasV2::API, execute: data) neural = described_class.new(api: api) sentiment = neural.sentiment_analysis_text("This is some text") @@ -196,7 +196,7 @@ end it "Deserializes all the attributes into Ruby objects" do - api = instance_double(Nylas::API, execute: data) + api = instance_double(NylasV2::API, execute: data) neural = described_class.new(api: api) signature = neural.extract_signature(["abc123"]) @@ -223,9 +223,9 @@ end it "Sends the options in the body" do - api = instance_double(Nylas::API, execute: data) + api = instance_double(NylasV2::API, execute: data) neural = described_class.new(api: api) - options = Nylas::NeuralMessageOptions.new( + options = NylasV2::NeuralMessageOptions.new( ignore_links: false, ignore_images: false, ignore_tables: false, @@ -251,7 +251,7 @@ end it "Converts signature contact object to a Nylas contact object" do - api = instance_double(Nylas::API, execute: data) + api = instance_double(NylasV2::API, execute: data) neural = described_class.new(api: api) signature = neural.extract_signature(["abc123"]) contact = signature[0].contacts.to_contact_object @@ -300,7 +300,7 @@ end it "Deserializes all the attributes into Ruby objects" do - api = instance_double(Nylas::API, execute: [data]) + api = instance_double(NylasV2::API, execute: [data]) neural = described_class.new(api: api) categorize = neural.categorize(["abc123"]) @@ -321,7 +321,7 @@ end it "Re-categorizes the message" do - api = instance_double(Nylas::API, execute: [data]) + api = instance_double(NylasV2::API, execute: [data]) neural = described_class.new(api: api) allow(api).to receive(:neural).and_return(neural) categorize = neural.categorize(["abc123"]) @@ -350,7 +350,7 @@ end it "Deserializes all the attributes into Ruby objects" do - api = instance_double(Nylas::API, execute: data) + api = instance_double(NylasV2::API, execute: data) neural = described_class.new(api: api) ocr = neural.ocr_request("abc123") diff --git a/spec/nylas/new_message_spec.rb b/spec/nylas_v2/new_message_spec.rb similarity index 91% rename from spec/nylas/new_message_spec.rb rename to spec/nylas_v2/new_message_spec.rb index 65ec04bc..5818b36a 100644 --- a/spec/nylas/new_message_spec.rb +++ b/spec/nylas_v2/new_message_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe Nylas::NewMessage do +describe NylasV2::NewMessage do describe "#send!" do data = { reply_to_message_id: "mess-1234", @@ -18,7 +18,7 @@ } it "sends the message directly" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) allow(api).to receive(:send!) diff --git a/spec/nylas/outbox_job_status_spec.rb b/spec/nylas_v2/outbox_job_status_spec.rb similarity index 97% rename from spec/nylas/outbox_job_status_spec.rb rename to spec/nylas_v2/outbox_job_status_spec.rb index ca0ed559..e8a47c41 100644 --- a/spec/nylas/outbox_job_status_spec.rb +++ b/spec/nylas_v2/outbox_job_status_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe Nylas::OutboxJobStatus do +describe NylasV2::OutboxJobStatus do it "Deserializes all the attributes into Ruby objects" do data = { job_status_id: "job-status-123", status: "pending", original_data: { send_at: 1649179701, retry_limit_datetime: 1649266101, diff --git a/spec/nylas/outbox_message_spec.rb b/spec/nylas_v2/outbox_message_spec.rb similarity index 98% rename from spec/nylas/outbox_message_spec.rb rename to spec/nylas_v2/outbox_message_spec.rb index a19d1ae4..cf7bb0df 100644 --- a/spec/nylas/outbox_message_spec.rb +++ b/spec/nylas_v2/outbox_message_spec.rb @@ -2,9 +2,9 @@ require "spec_helper" -describe Nylas::OutboxMessage do +describe NylasV2::OutboxMessage do it "Deserializes all the attributes into Ruby objects" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { send_at: 1649179701, retry_limit_datetime: 1649266101, original_send_at: 1649179701, account_id: "acc-9987", thread_id: "thread-1234", reply_to_message_id: "mess-1234", date: 1_513_276_982, to: [{ email: "to@example.com", name: "To Example" }], diff --git a/spec/nylas/outbox_spec.rb b/spec/nylas_v2/outbox_spec.rb similarity index 95% rename from spec/nylas/outbox_spec.rb rename to spec/nylas_v2/outbox_spec.rb index cd90bb27..8518cc46 100644 --- a/spec/nylas/outbox_spec.rb +++ b/spec/nylas_v2/outbox_spec.rb @@ -3,8 +3,8 @@ require "spec_helper" require "date" -describe Nylas::Outbox do - let(:api) { instance_double(Nylas::API) } +describe NylasV2::Outbox do + let(:api) { instance_double(NylasV2::API) } let(:outbox) { described_class.new(api: api) } let(:tomorrow) { Date.today + 1 } let(:day_after) { Date.today + 2 } @@ -15,7 +15,7 @@ describe "standard operations" do let(:draft) do - Nylas::Draft.new(to: [{ email: "not-a-real-email@example.com", name: "Example" }], + NylasV2::Draft.new(to: [{ email: "not-a-real-email@example.com", name: "Example" }], subject: "A new draft!", metadata: { sdk: "Ruby SDK" }) end diff --git a/spec/nylas/raw_message_spec.rb b/spec/nylas_v2/raw_message_spec.rb similarity index 96% rename from spec/nylas/raw_message_spec.rb rename to spec/nylas_v2/raw_message_spec.rb index 356bfd10..55c0f496 100644 --- a/spec/nylas/raw_message_spec.rb +++ b/spec/nylas_v2/raw_message_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe Nylas::RawMessage do +describe NylasV2::RawMessage do describe ".#send!" do it "calls execute on api with params" do message_string = "MIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\n" \ diff --git a/spec/nylas/room_resource_spec.rb b/spec/nylas_v2/room_resource_spec.rb similarity index 88% rename from spec/nylas/room_resource_spec.rb rename to spec/nylas_v2/room_resource_spec.rb index 17734a40..c9b0bfdc 100644 --- a/spec/nylas/room_resource_spec.rb +++ b/spec/nylas_v2/room_resource_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe Nylas::RoomResource do +describe NylasV2::RoomResource do it "is not creatable" do expect(described_class).not_to be_creatable end @@ -49,13 +49,13 @@ context "when getting" do it "makes a call to the /resources endpoint" do - api = instance_double(Nylas::API, execute: "{}") - resource = Nylas::Collection.new(model: described_class, api: api) + api = instance_double(NylasV2::API, execute: "{}") + resource = NylasV2::Collection.new(model: described_class, api: api) api.execute(resource.to_be_executed) expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :get, path: "/resources", headers: {}, diff --git a/spec/nylas/scheduler_collection_spec.rb b/spec/nylas_v2/scheduler_collection_spec.rb similarity index 87% rename from spec/nylas/scheduler_collection_spec.rb rename to spec/nylas_v2/scheduler_collection_spec.rb index b9919575..e105564b 100644 --- a/spec/nylas/scheduler_collection_spec.rb +++ b/spec/nylas_v2/scheduler_collection_spec.rb @@ -2,11 +2,11 @@ require "spec_helper" -describe Nylas::SchedulerCollection do +describe NylasV2::SchedulerCollection do describe "ProviderAvailability" do it "(getGoogleAvailability) should call the correct endpoint" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) - scheduler_collection = described_class.new(model: Nylas::Scheduler, api: api) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) + scheduler_collection = described_class.new(model: NylasV2::Scheduler, api: api) scheduler_collection.get_google_availability @@ -17,8 +17,8 @@ end it "(getOffice365Availability) should call the correct endpoint" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) - scheduler_collection = described_class.new(model: Nylas::Scheduler, api: api) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) + scheduler_collection = described_class.new(model: NylasV2::Scheduler, api: api) scheduler_collection.get_office_365_availability @@ -43,8 +43,8 @@ created_at: "2021-06-24", modified_at: "2021-06-24" } - api = instance_double(Nylas::API, execute: scheduler_json) - scheduler_collection = described_class.new(model: Nylas::Scheduler, api: api) + api = instance_double(NylasV2::API, execute: scheduler_json) + scheduler_collection = described_class.new(model: NylasV2::Scheduler, api: api) scheduler = scheduler_collection.get_page_slug("test-slug") @@ -73,8 +73,8 @@ start: 1636728347 } ] - api = instance_double(Nylas::API, execute: scheduler_time_slots) - scheduler_collection = described_class.new(model: Nylas::Scheduler, api: api) + api = instance_double(NylasV2::API, execute: scheduler_time_slots) + scheduler_collection = described_class.new(model: NylasV2::Scheduler, api: api) timeslots = scheduler_collection.get_available_time_slots("test-slug") @@ -92,8 +92,8 @@ end it "cancel booking" do - api = instance_double(Nylas::API, execute: JSON.parse("{}")) - scheduler_collection = described_class.new(model: Nylas::Scheduler, api: api) + api = instance_double(NylasV2::API, execute: JSON.parse("{}")) + scheduler_collection = described_class.new(model: NylasV2::Scheduler, api: api) scheduler_collection.cancel_booking("test-slug", "test-edit-hash", "test") @@ -125,17 +125,17 @@ start_time: 1636728347, title: "Test Booking" } - api = instance_double(Nylas::API, execute: booking_confirmation) - scheduler_collection = described_class.new(model: Nylas::Scheduler, api: api) + api = instance_double(NylasV2::API, execute: booking_confirmation) + scheduler_collection = described_class.new(model: NylasV2::Scheduler, api: api) - slot = Nylas::SchedulerTimeSlot.new( + slot = NylasV2::SchedulerTimeSlot.new( account_id: "test-account-id", calendar_id: "test-calendar-id", emails: ["recipient@example.com"], start: Time.at(1636728347), end: Time.at(1636731958) ) - timeslot_to_book = Nylas::SchedulerBookingRequest.new( + timeslot_to_book = NylasV2::SchedulerBookingRequest.new( additional_values: { test: "yes" }, @@ -207,8 +207,8 @@ start_time: 1636728347, title: "Test Booking" } - api = instance_double(Nylas::API, execute: booking_confirmation) - scheduler_collection = described_class.new(model: Nylas::Scheduler, api: api) + api = instance_double(NylasV2::API, execute: booking_confirmation) + scheduler_collection = described_class.new(model: NylasV2::Scheduler, api: api) booking_confirmation = scheduler_collection.confirm_booking("test-slug", "test-edit-hash") diff --git a/spec/nylas/scheduler_spec.rb b/spec/nylas_v2/scheduler_spec.rb similarity index 86% rename from spec/nylas/scheduler_spec.rb rename to spec/nylas_v2/scheduler_spec.rb index 08541ec9..35426b03 100644 --- a/spec/nylas/scheduler_spec.rb +++ b/spec/nylas_v2/scheduler_spec.rb @@ -2,15 +2,15 @@ require "spec_helper" -describe Nylas::Scheduler do +describe NylasV2::Scheduler do describe ".from_json" do it "Deserializes all the attributes into Ruby objects" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" ) - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) data = { id: 123, app_client_id: "test-client-id", @@ -30,7 +30,7 @@ expect(scheduler.id).to be 123 expect(scheduler.app_client_id).to eql "test-client-id" expect(scheduler.app_organization_id).to be 0 - expect(scheduler.config).to be_a(Nylas::SchedulerConfig) + expect(scheduler.config).to be_a(NylasV2::SchedulerConfig) expect(scheduler.config.timezone).to eql "America/Los_Angeles" expect(scheduler.edit_token).to eql "token" expect(scheduler.name).to eql "Test" @@ -40,12 +40,12 @@ end it "uses 'api.schedule.nylas.com' endpoint" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" ) - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) scheduler = api.scheduler @@ -55,12 +55,12 @@ describe "saving" do it "POST with no ID set" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" ) - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) data = { app_client_id: "test-client-id", app_organization_id: 0, @@ -79,7 +79,7 @@ scheduler.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :post, path: "/manage/pages", payload: JSON.dump( @@ -99,12 +99,12 @@ end it "PUT with ID set" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" ) - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) data = { id: 123, app_client_id: "test-client-id", @@ -124,7 +124,7 @@ scheduler.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/manage/pages/123", payload: JSON.dump( @@ -146,12 +146,12 @@ describe "get available calendars" do it "makes a request with an ID present" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" ) - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) data = { id: 123 } @@ -167,12 +167,12 @@ end it "throws an error if no ID present" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" ) - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) scheduler = described_class.from_json(JSON.dump({}), api: api) allow(api).to receive(:execute).and_return({}) @@ -184,12 +184,12 @@ describe "upload image" do it "makes a request with an ID present" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" ) - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) data = { id: 123 } @@ -209,12 +209,12 @@ end it "throws an error if no ID present" do - client = Nylas::HttpClient.new( + client = NylasV2::HttpClient.new( app_id: "not-real", app_secret: "also-not-real", access_token: "seriously-unreal" ) - api = Nylas::API.new(client: client) + api = NylasV2::API.new(client: client) scheduler = described_class.from_json(JSON.dump({}), api: api) allow(api).to receive(:execute).and_return({}) diff --git a/spec/nylas/send_grid_verified_status_spec.rb b/spec/nylas_v2/send_grid_verified_status_spec.rb similarity index 89% rename from spec/nylas/send_grid_verified_status_spec.rb rename to spec/nylas_v2/send_grid_verified_status_spec.rb index 91168ec9..ecba7ff9 100644 --- a/spec/nylas/send_grid_verified_status_spec.rb +++ b/spec/nylas_v2/send_grid_verified_status_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe Nylas::SendGridVerifiedStatus do +describe NylasV2::SendGridVerifiedStatus do it "Deserializes all the attributes into Ruby objects" do data = { domain_verified: true, sender_verified: true } diff --git a/spec/nylas/thread_spec.rb b/spec/nylas_v2/thread_spec.rb similarity index 93% rename from spec/nylas/thread_spec.rb rename to spec/nylas_v2/thread_spec.rb index 693e98fc..a66a3a4d 100644 --- a/spec/nylas/thread_spec.rb +++ b/spec/nylas_v2/thread_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe Nylas::Thread do +describe NylasV2::Thread do it "is filterable" do expect(described_class).to be_filterable end @@ -16,7 +16,7 @@ end it "can be deserialized from JSON" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) json = JSON.dump(id: "thread-2345", account_id: "acc-1234", draft_ids: ["dra-987"], first_message_timestamp: 1_510_080_143, has_attachments: false, labels: [{ display_name: "All Mail", id: "label-all-mail", name: "all" }, @@ -79,14 +79,14 @@ describe "update_folder" do it "moves thread to new `folder`" do folder_id = "9999" - api = instance_double(Nylas::API, execute: "{}") + api = instance_double(NylasV2::API, execute: "{}") thread = described_class.from_json('{ "id": "thread-1234" }', api: api) allow(api).to receive(:execute) thread.update_folder(folder_id) expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/threads/thread-1234", payload: { folder_id: folder_id }.to_json, @@ -97,7 +97,7 @@ describe "#update" do it "let's you set the starred, unread, folder, and label ids" do - api = instance_double(Nylas::API, execute: {}) + api = instance_double(NylasV2::API, execute: {}) thread = described_class.from_json('{ "id": "thread-1234" }', api: api) thread.update( @@ -108,7 +108,7 @@ ) expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BEARER, + auth_method: NylasV2::HttpClient::AuthMethod::BEARER, method: :put, path: "/threads/thread-1234", payload: JSON.dump( @@ -122,7 +122,7 @@ end it "raises an argument error if the data has any keys that aren't allowed to be updated" do - api = instance_double(Nylas::API, execute: "{}") + api = instance_double(NylasV2::API, execute: "{}") thread = described_class.from_json('{ "id": "thread-1234" }', api: api) expect do thread.update(subject: "A new subject!") diff --git a/spec/nylas/webhook_spec.rb b/spec/nylas_v2/webhook_spec.rb similarity index 84% rename from spec/nylas/webhook_spec.rb rename to spec/nylas_v2/webhook_spec.rb index e02643a6..00148ef9 100644 --- a/spec/nylas/webhook_spec.rb +++ b/spec/nylas_v2/webhook_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe Nylas::Webhook do +describe NylasV2::Webhook do it "is creatable" do expect(described_class).to be_creatable end @@ -25,7 +25,7 @@ describe ".from_json" do it "Deserializes all the attributes into Ruby objects" do - api = instance_double(Nylas::API) + api = instance_double(NylasV2::API) data = { id: "webhook-123", application_id: "app-123", @@ -48,7 +48,7 @@ describe "#create" do it "Serializes all non-read-only attributes" do - api = instance_double(Nylas::API, execute: JSON.parse("{}"), app_id: "app-987") + api = instance_double(NylasV2::API, execute: JSON.parse("{}"), app_id: "app-987") data = { application_id: "app-123", callback_url: "https://url.com/callback", @@ -62,7 +62,7 @@ webhook.create expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :post, path: "/a/app-987/webhooks", payload: JSON.dump( @@ -77,7 +77,7 @@ describe "update" do it "Serializes only state" do - api = instance_double(Nylas::API, execute: JSON.parse("{}"), app_id: "app-987") + api = instance_double(NylasV2::API, execute: JSON.parse("{}"), app_id: "app-987") data = { id: "webhook-123", application_id: "app-123", @@ -92,7 +92,7 @@ webhook.update(state: WebhookState::INACTIVE) expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :put, path: "/a/app-987/webhooks/webhook-123", payload: JSON.dump( @@ -103,7 +103,7 @@ end it "Throws an error if update was called with something other than just state" do - api = instance_double(Nylas::API, execute: JSON.parse("{}"), app_id: "app-987") + api = instance_double(NylasV2::API, execute: JSON.parse("{}"), app_id: "app-987") data = { id: "webhook-123", application_id: "app-123", @@ -123,7 +123,7 @@ describe "save" do it "Creates if no id exists" do - api = instance_double(Nylas::API, execute: JSON.parse("{}"), app_id: "app-987") + api = instance_double(NylasV2::API, execute: JSON.parse("{}"), app_id: "app-987") data = { application_id: "app-123", callback_url: "https://url.com/callback", @@ -137,7 +137,7 @@ webhook.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :post, path: "/a/app-987/webhooks", payload: JSON.dump( @@ -150,7 +150,7 @@ end it "Updates if id exists" do - api = instance_double(Nylas::API, execute: JSON.parse("{}"), app_id: "app-987") + api = instance_double(NylasV2::API, execute: JSON.parse("{}"), app_id: "app-987") data = { id: "webhook-123", application_id: "app-123", @@ -165,7 +165,7 @@ webhook.save expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :put, path: "/a/app-987/webhooks/webhook-123", payload: JSON.dump( @@ -178,7 +178,7 @@ describe "#destroy" do it "Deletes the webhook on the API" do - api = instance_double(Nylas::API, execute: JSON.parse("{}"), app_id: "app-987") + api = instance_double(NylasV2::API, execute: JSON.parse("{}"), app_id: "app-987") data = { id: "webhook-123", application_id: "app-123", @@ -193,7 +193,7 @@ webhook.destroy expect(api).to have_received(:execute).with( - auth_method: Nylas::HttpClient::AuthMethod::BASIC, + auth_method: NylasV2::HttpClient::AuthMethod::BASIC, method: :delete, path: "/a/app-987/webhooks/webhook-123", payload: nil, diff --git a/spec/nylas/when_spec.rb b/spec/nylas_v2/when_spec.rb similarity index 98% rename from spec/nylas/when_spec.rb rename to spec/nylas_v2/when_spec.rb index a1476746..27ad1446 100644 --- a/spec/nylas/when_spec.rb +++ b/spec/nylas_v2/when_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe Nylas::When do +describe NylasV2::When do describe "valid" do it "throws if a timezone is set to a non-IANA string" do when_obj = described_class.new(timezone: "Non IANA") diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0f6bd4a5..622aae28 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,7 +6,7 @@ require "simplecov-cobertura" SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter -require "nylas" +require "nylas_v2" require "pry" require "webmock/rspec" require "rspec-json_matcher" @@ -14,7 +14,7 @@ RSpec.configuration.include RSpec::JsonMatcher class FakeAPI - def execute(method:, path:, payload: nil, query: {}, auth_method: Nylas::HttpClient::AuthMethod::BEARER) + def execute(method:, path:, payload: nil, query: {}, auth_method: NylasV2::HttpClient::AuthMethod::BEARER) requests.push(method: method, path: path, payload: payload, query: query, auth_method: auth_method) end @@ -26,7 +26,7 @@ def requests # Illustrates all the types and such a model can be built out of. Used for testing the generic Model # functionality without conflating it with actual Models class FullModel - include Nylas::Model + include NylasV2::Model self.creatable = true self.showable = true self.listable = true @@ -60,7 +60,7 @@ class FullModel end class NotCreatableModel - include Nylas::Model + include NylasV2::Model self.resources_path = "/not_creatable_collection" attribute :id, :string @@ -78,7 +78,7 @@ class NotCreatableModel end class NotUpdatableModel - include Nylas::Model + include NylasV2::Model self.resources_path = "/not_updatable_collection" attribute :id, :string @@ -96,7 +96,7 @@ class NotUpdatableModel end class NonFilterableModel < FullModel - include Nylas::Model + include NylasV2::Model self.resources_path = "/non_filterable_collection" attribute :id, :string From 1d9359c667a8aa9fc7e11adfec3298eb4b99e6ec Mon Sep 17 00:00:00 2001 From: Andrew Dally Date: Tue, 28 May 2024 11:49:56 -0400 Subject: [PATCH 2/2] use underscore for gem name --- Gemfile | 2 +- nylas-v2-streaming.gemspec => nylas_v2-streaming.gemspec | 4 ++-- nylas-v2.gemspec => nylas_v2.gemspec | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename nylas-v2-streaming.gemspec => nylas_v2-streaming.gemspec (79%) rename nylas-v2.gemspec => nylas_v2.gemspec (90%) diff --git a/Gemfile b/Gemfile index 07961907..9ffb8cf4 100644 --- a/Gemfile +++ b/Gemfile @@ -2,4 +2,4 @@ source "https://rubygems.org" -gemspec name: "nylas-v2" +gemspec name: "nylas_v2" diff --git a/nylas-v2-streaming.gemspec b/nylas_v2-streaming.gemspec similarity index 79% rename from nylas-v2-streaming.gemspec rename to nylas_v2-streaming.gemspec index f1c5d7aa..192262c0 100644 --- a/nylas-v2-streaming.gemspec +++ b/nylas_v2-streaming.gemspec @@ -3,11 +3,11 @@ require "./gem_config" Gem::Specification.new do |gem| - GemConfig.apply(gem, "nylas-v2-streaming") + GemConfig.apply(gem, "nylas_v2-streaming") gem.summary = %(Gem for interacting with the Nylas Deltas Streaming API) gem.description = %(Gem for interacting with the Nylas Deltas Streaming API.) gem.add_runtime_dependency "em-http-request", "~> 1.1", ">= 1.1.3" - gem.add_runtime_dependency "nylas-v2", "~> 4.0" + gem.add_runtime_dependency "nylas_v2", "~> 4.0" gem.add_runtime_dependency "yajl-ruby", "~> 1.2", ">= 1.2.1" end diff --git a/nylas-v2.gemspec b/nylas_v2.gemspec similarity index 90% rename from nylas-v2.gemspec rename to nylas_v2.gemspec index 0b45eef2..4f33a932 100644 --- a/nylas-v2.gemspec +++ b/nylas_v2.gemspec @@ -3,7 +3,7 @@ require "./gem_config" Gem::Specification.new do |gem| - GemConfig.apply(gem, "nylas-v2") + GemConfig.apply(gem, "nylas_v2") gem.summary = %(Gem for interacting with the Nylas API) gem.description = %(Gem for interacting with the Nylas API.) gem.add_runtime_dependency "rest-client", ">= 2.0", "< 3.0"