Skip to content

Commit

Permalink
v6.0.0 (#460)
Browse files Browse the repository at this point in the history
# Description
This PR is a culmination of all the PRs that contained v6-related development, with formal support for the Nylas API v3. This release is essentially the same as the v6.0.0.beta.4 release found on rubygems. Please refer to the readme for a quick start guide on using the new SDK, as well as links to the upgrade doc as well as the SDK reference docs.

# Changelog
* **BREAKING CHANGE**: Ruby SDK v6 supports the Nylas API v3 exclusively, dropping support for any endpoints that are not available in v3.
* **BREAKING CHANGE**: Officially support minimum Ruby v3
* **BREAKING CHANGE**: Removed all models and typing from the SDK
* **REMOVED**: Local Webhook development support is removed due to incompatibility
* Rewrote the majority of SDK to be more modular and efficient
* Created error classes for the different API errors as well as SDK-specific errors
* Added a configurable timeout for outgoing calls to the API

========================================================================================

* Major Refactor and API v3 base implementation (#418)

* AV-1468 Purge collections and models

* new design

* FIRST WORKING API CALL!!!

* update

* quik cfix

* testing file

* refactor http handling for resources

* node sdk parity

* refactor

* refactor

* application + redirect_uris

* scopes

* fix

* more fix

* fixes

* more fix

---------

Co-authored-by: Mostafa Rashed <[email protected]>

* Generate SDK references github action (#423)

* v3 Polish: Cleanup & documentation (#420)

This PR:

* adds Yard documentation
* cleans up typos and just code tidy
* Update dependencies and gemspec
* Update readme
* Repo cleanup
* Bug fixes

* v6.0.0.beta.1 Release (#425)

This PR is for releasing the first beta of v6 on RubyGems.

* Add better documentation, more errors, default timeout (#426)

This PR adds an upgrade doc, updates the readme, adds more error classes and a default timeout.

Co-authored-by: Lrubin <[email protected]>

* Add support for free-busy endpoint (#428)

* Add support for read, update, and delete for messages (#429)

* Update README for Hacktoberfest (#427)

add blurb on hacktoberfest guidelines

* Fix Rubocop complains

None of them related to my code, but everything is fixed and tested

* Remove hackathon blurb

---------

Co-authored-by: Mostafa Rashed <[email protected]>

* Add support for custom authentication, connectors, and credentials APIs (#431)

Adds support for custom authentication, the connectors API and the credentials API.

* Add Folders API support (#433)

This PR adds support for the Folders API

* Ruby SDK Messages, Threads, Drafts, and Send support (#432)

This PR adds support to messages, threads, drafts, and send.

* Ruby Attachments API support (#434)

This PR adds support for the Attachments API

* v6.0.0 beta 2 release (#436)

* Added additional error classes (#426)
* Added support for free/busy endpoint (#428)
* Added support for Messages, Drafts, and Smart Compose APIs (#432)
* Added support for custom authentication, connectors, and credentials APIs (#431)
* Added support for folders API (#433)
* Added support for attachments API (#434)
* Set default timeout to 30 seconds (#426)

* Fixed issue when sending message without attachments (#437)

This PR fixes a bug that arises when sending messages and creating or modifying drafts without any attachments present.

* Fix free-busy endpoint (#440)

The endpoint for free-busy was "availability" when it should be "free-busy"

* Add support for contacts API (#438)

This PR adds support for the contacts API.

* Update drafts.rb to include send

Adding "send" to the drafts endpoint

* Add missing webhooks (#445)

Added webhook triggers for:

* Message Opened
* Message Link Clicked
* Thread Replied

* Fix doc lines

* Added send-rsvp support for events api (#444)

Added send-rsvp support for events api

* Move `Grants` to `NylasClient` and custom authentication to `Auth` (#447)

* Move grants out of auth

* move grant create to custom auth

* Update CHANGELOG.md

* Fix OAuth URL building throwing an error (#449)

There is a syntax error when calling build_query.

* v6.0.0 beta 3 Release (#450)

* Update CHANGELOG.md

* linting

* bump ver

* Update CHANGELOG.md

* Fix List and Find Scheduled Messages (#451)

List and Find Scheduled messages are mixed up

* Fix incorrect PKCE code challenge generation (#452)

This PR fixes the PKCE code challenge generation; the correct method the API wants is for us to base64 encode the hex string as opposed to base64 encoding resulting hashed bytearray directly.

* Fixed incompatible types when building OAuth2 URL (#453)

We were encoding our URL prematurely, causing an error to be thrown when setting additional parameters (PKCE, etc.)

* Update contact_groups to list_groups (#455)

* Update connectors.rb (#454)

* Added v6 beta tests and fixes (#458)

Increase code coverage to ~100%. Fixes were also completed:
* **BREAKING CHANGE**: Renamed `Applications.info()` to `Applications.get_details()` for consistency
* **BREAKING CHANGE**: Changed return type of `Auth.url_for_oauth2_pkce()` from `OpenStruct` to a hash for consistency
* Added support for detecting providers
* Added enhanced support for the `Webhooks` API
* Default `client_secret` to the configured `api_key` for token exchange methods if not provided
* Fixed construction of query parameters
* Fixed construction of OAuth2 URL
* Fixed typo in paths for `Grants` class

* v6.0.0 beta 4 release (#459)

# Changelog
* **BREAKING CHANGE**: Renamed `Applications.info()` to `Applications.get_details()` for consistency
* **BREAKING CHANGE**: Changed return type of `Auth.url_for_oauth2_pkce()` from `OpenStruct` to a hash for consistency
* Added support for detecting providers
* Added enhanced support for the `Webhooks` API
* Default `client_secret` to the configured `api_key` for token exchange methods if not provided
* Fixed list and find scheduled messages
* Fixed incorrect PKCE code challenge generation
* Fixed incompatible types when building OAuth2 URL
* Fixed construction of query parameters
* Fixed construction of OAuth2 URL
* Fixed typo in paths for `Grants` class

* Update CHANGELOG.md

* remove unneded changes from v5

* cleanup references to beta

* add xml for simplecov for codecov support

---------

Co-authored-by: Albert T <[email protected]>
Co-authored-by: Aaron de Mello <[email protected]>
Co-authored-by: Lrubin <[email protected]>
Co-authored-by: Blag <[email protected]>
Co-authored-by: YIFAN WU <[email protected]>
  • Loading branch information
6 people authored Feb 5, 2024
1 parent 5561ab7 commit dc9e9ff
Show file tree
Hide file tree
Showing 225 changed files with 5,440 additions and 12,103 deletions.
3 changes: 0 additions & 3 deletions .arcconfig

This file was deleted.

4 changes: 0 additions & 4 deletions .codeclimate.yml

This file was deleted.

20 changes: 7 additions & 13 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,11 @@ jobs:
fail-fast: false
matrix:
include:
- gemfile: rails5
ruby: 2.5
- gemfile: rails6
ruby: 2.5
- gemfile: rails5
ruby: 2.6
- gemfile: rails6
ruby: 2.6
- gemfile: rails6
ruby: 3.0
name: Ruby ${{ matrix.ruby }}, Gemfile ${{ matrix.gemfile }}
- ruby: 3.0
- ruby: 3.1
- ruby: 3.2

name: Ruby ${{ matrix.ruby }}
steps:
- uses: actions/checkout@v2

Expand All @@ -42,8 +36,8 @@ jobs:

- name: Bundle install
run: |
bundle config set gemfile "${GITHUB_WORKSPACE}/gemfiles/Gemfile.${{ matrix.gemfile }}"
bundle install --jobs 4 --retry 3
bundle config set gemfile "${GITHUB_WORKSPACE}/Gemfile"
bundle install
- name: Run tests
run: bundle exec rspec spec
Expand Down
32 changes: 13 additions & 19 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,22 @@ name: Rubocop

on:
push:
branches: [main]
branches: [ main ]
pull_request:
branches: [main]
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
gemfile: [rubocop]
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: gemfiles/Gemfile.${{ matrix.gemfile }}

steps:
- uses: actions/checkout@v2
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
with:
ruby-version: 3.0
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run rubocop
run: bundle exec rubocop --config .rubocop.yml
- uses: actions/checkout@v2
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
with:
ruby-version: 3.0
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Generate docs
run: bundle exec rubocop --config .rubocop.yml
45 changes: 45 additions & 0 deletions .github/workflows/sdk-reference.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: sdk-reference

on:
push:
branches:
- main
pull_request:

jobs:
docs:
runs-on: ubuntu-latest
environment:
name: sdk-reference
url: ${{ steps.deploy.outputs.url }}
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
with:
ruby-version: 3.0
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run rubocop
run: bundle exec yard
- name: Set env BRANCH
run: echo "BRANCH=$(echo $GITHUB_REF | cut -d'/' -f 3)" >> $GITHUB_ENV
- name: Set env CLOUDFLARE_BRANCH
run: |
if [[ $BRANCH == 'main' && $GITHUB_EVENT_NAME == 'push' ]]; then
echo "CLOUDFLARE_BRANCH=main" >> "$GITHUB_ENV"
else
echo "CLOUDFLARE_BRANCH=$BRANCH" >> "$GITHUB_ENV"
fi
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
id: deploy
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: nylas-ruby-sdk-reference
directory: doc
wranglerVersion: "3"
branch: ${{ env.CLOUDFLARE_BRANCH }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ TAGS
*.swp
vendor/
out
test.rb
21 changes: 0 additions & 21 deletions .overcommit.yml

This file was deleted.

33 changes: 16 additions & 17 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ inherit_from: .rubocop_todo.yml

require: rubocop-rspec
AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 3.0
DisplayCopNames: true
DisplayStyleGuide: true
Exclude:
Expand All @@ -21,27 +21,23 @@ Metrics/BlockLength:
- "*.gemspec"
- "spec/**/*_spec.rb"

Metrics/ParameterLists:
Max: 8
Exclude:
- "lib/nylas/calendar_collection.rb"
Metrics/AbcSize:
Enabled: false

Metrics/MethodLength:
Exclude:
- "lib/nylas/calendar_collection.rb"
- "lib/nylas/services/tunnel.rb"

Metrics/AbcSize:
Exclude:
- "lib/nylas/services/tunnel.rb"
Enabled: false

Metrics/ModuleLength:
Exclude:
- "lib/nylas/model.rb"
Enabled: false

Naming/FileName:
Exclude:
- "lib/nylas-streaming.rb"
Metrics/ParameterLists:
Enabled: false

Metrics/PerceivedComplexity:
Enabled: false

Metrics/CyclomaticComplexity:
Enabled: false

Metrics/ClassLength:
Enabled: false
Expand All @@ -57,3 +53,6 @@ RSpec/MultipleExpectations:

RSpec/ExampleLength:
Enabled: false

RSpec/FilePath:
Enabled: false
6 changes: 6 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--no-private
--protected
--exclude lib/nylas/handler/api_operations.rb
--exclude lib/nylas/handler/http_client.rb
--exclude lib/nylas/resources/base_resource.rb
lib/**/*.rb
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Changelog

### Unreleased
* Add support for count on message/thread search
* Add support for detect provider endpoint
* Add accept header by default
* Fix contact picture encoding error
### 6.0.0 / 2024-02-05
* **BREAKING CHANGE**: Ruby SDK v6 supports the Nylas API v3 exclusively, dropping support for any endpoints that are not available in v3.
* **BREAKING CHANGE**: Officially support minimum Ruby v3
* **BREAKING CHANGE**: Removed all models and typing from the SDK
* **REMOVED**: Local Webhook development support is removed due to incompatibility
* Rewrote the majority of SDK to be more modular and efficient
* Created error classes for the different API errors as well as SDK-specific errors
* Added a configurable timeout for outgoing calls to the API

### 5.17.0 / 2022-04-04
* Add support for verifying webhook signatures
Expand Down
76 changes: 35 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,29 @@

# 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)
[![Gem (including prereleases)](https://img.shields.io/gem/v/nylas?include_prereleases)](https://rubygems.org/gems/nylas)
[![codecov](https://codecov.io/gh/nylas/nylas-ruby/branch/main/graph/badge.svg?token=IKH0YMH4KA)](https://codecov.io/gh/nylas/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.
This is the GitHub repository for the Nylas Ruby SDK. This repo is primarily for anyone who wants to make contributions to the SDK or install it from source. For documentation on how to use this SDK to access the Nylas Email, Calendar, or Contacts APIs, see the official [Ruby SDK Quickstart Guide](https://developer.nylas.com/docs/sdks/ruby/).

Nylas provides REST APIs for [Email](https://docs.nylas.com/docs/quickstart-email), [Calendar](https://docs.nylas.com/docs/quickstart-calendar), and [Contacts](https://docs.nylas.com/docs/quickstart-contacts), and the Ruby SDK is the quickest way to build your first integration using Ruby.
The Nylas Communications Platform provides REST APIs for [Email](https://developer.nylas.com/docs/email/), [Calendar](https://developer.nylas.com/docs/calendar/), and [Contacts](https://developer.nylas.com/docs/contacts/), and the Nylas SDK is the quickest way to build your integration using Ruby.

This is the GitHub repository for the Nylas Ruby SDK and is primarily for anyone who wants to make contributions to the SDK or install it from source. If you are looking to use Ruby to access the Nylas Email, Calendar, or Contacts API you should refer to our official [Ruby](https://docs.nylas.com/docs/quickstart-ruby) [SDK Quickstart Guide](https://docs.nylas.com/docs/quickstart-ruby).
Here are some resources to help you get started:

Here are some additional resources to help you get started:
- [Sign up for the Nylas v3 Beta program to access the v3 Dashboard](https://info.nylas.com/apiv3betasignup.html?utm_source=github&utm_medium=devrel-surfaces&utm_campaign=&utm_content=ruby-sdk-upgrade)
- [Nylas API v3 Quickstart Guide](https://developer.nylas.com/docs/v3-beta/v3-quickstart/)
- [Nylas SDK Reference](https://nylas-ruby-sdk-reference.pages.dev/)
- [Nylas API Reference](https://developer.nylas.com/docs/api/v3-beta/)
- [Nylas Samples repo for code samples and example applications](https://github.com/orgs/nylas-samples/repositories?q=&type=all&language=ruby)

- [Nylas SDK Tutorials](https://docs.nylas.com/docs/tutorials)
- [Get Started with the Nylas Communications Platform](https://docs.nylas.com/docs/getting-started)
- [Sign up for your Nylas developer account.](https://nylas.com/register)
- [Nylas API Reference](https://docs.nylas.com/reference)

If you have a question that needs an answer, please reach out to [email protected] to get help.
If you have a question about the Nylas Communications Platform, [contact Nylas Support](https://support.nylas.com/) for help.

## ⚙️ Install

### Prerequisites
- 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).
- Ruby 3.0 or above.
- Ruby Frameworks: `rest-client` and `yajl-ruby`.

### Install

Expand All @@ -43,7 +42,7 @@ And then execute:
bundle
```

To run scripts that use the Nylas Ruby SDK, install the nylas gem.
To run scripts that use the Nylas Ruby SDK, install the `nylas` gem.

```bash
gem install nylas
Expand All @@ -56,7 +55,7 @@ git clone https://github.com/nylas/nylas-ruby.git && cd nylas-ruby
bundle install
```

### Setup Ruby SDK for Development
### Set up Ruby SDK for Development

Install [RubyGems](https://rubygems.org/pages/download) if you don't already have it:

Expand All @@ -76,52 +75,47 @@ 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:

```bash
sudo brew install openssl
sudo brew link openssl --force
gem install nylas
```

## ⚡️ Usage

To use this SDK, you first need to [sign up for a free Nylas developer account](https://nylas.com/register).
To use this SDK, you must first [sign up for the v3 Beta and get a free Nylas account](https://info.nylas.com/apiv3betasignup.html?utm_source=github&utm_medium=devrel-surfaces&utm_campaign=&utm_content=ruby-sdk-upgrade).

Then, follow our guide to [setup your first app and get your API access keys](https://docs.nylas.com/docs/get-your-developer-api-keys).
Then, follow the Quickstart guide to [set up your first app and get your API keys](https://developer.nylas.com/docs/v3-beta/v3-quickstart/).

All of the functionality of the Nylas Communications Platform is available through the `API` object. To access data for an account that’s connected to Nylas, create a new API client object and pass the variables you gathered when you got your developer API keys. In the following example, replace `CLIENT_ID`, `CLIENT_SECRET`, and `ACCESS_TOKEN` with your values.
For code examples that demonstrate how to use this SDK, take a look at our [Ruby repos in the Nylas Samples collection](https://github.com/orgs/nylas-samples/repositories?q=&type=all&language=ruby).

### 🚀 Making Your First Request

All of the functionality of the Nylas Communications Platform is available through the `Client` object. To access data for an account that’s connected to Nylas, create a new API client object and pass in your Nylas API key. In the following example, replace `NYLAS_API_KEY` with your Nylas API Key, and you can provide other additional configurations such as the Nylas API url and the timeout.

```ruby
require 'nylas'

nylas = Nylas::API.new(
app_id: CLIENT_ID,
app_secret: CLIENT_SECRET,
access_token: ACCESS_TOKEN
nylas = Nylas::Client.new(
api_key: "NYLAS_API_KEY",
)
```

Now, you can use `nylas` to access full email, calendar, and contacts functionality. For example, here is how you would print the subject line for the most recent email message to the console.

Now, you can use `nylas` to access full email, calendar, and contacts functionality, for example to list all the calendars for a given account:

```ruby
message = nylas.messages.first
puts(message.subject)
calendars, _request_ids = nylas.calendars.list(identifier: "GRANT_ID")
```

To learn more about how to use the Nylas Ruby SDK, please refer to our [Ruby](https://docs.nylas.com/docs/quickstart-ruby) [SDK QuickStart Guide](https://docs.nylas.com/docs/quickstart-ruby).
## 📚 Documentation

Nylas maintains a [reference guide for the Ruby SDK](https://nylas-ruby-sdk-reference.pages.dev/) to help you get familiar with the available methods and classes.

## ✨ Upgrading from 5.x

See [UPGRADE.md](UPGRADE.md) for instructions on upgrading from 5.x to 6.x.

**Note**: The Ruby SDK v6.x is not compatible with the Nylas API earlier than v3-beta. If you are using Nylas v2.7 or earlier, continue using the v5.x Nylas Ruby SDK.

## 💙 Contributing

Please refer to [Contributing](Contributing.md) for information about how to make contributions to this project. We welcome questions, bug reports, and pull requests.

Taking part in Hacktoberfest 2023 (i.e. issue is tagged with `hacktoberfest`)? Read our [Nylas Hacktoberfest 2023 contribution guidelines](https://github.com/nylas-samples/nylas-hacktoberfest-2023/blob/main/readme.md).

## 📝 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.
Loading

0 comments on commit dc9e9ff

Please sign in to comment.