Skip to content

Releases: nylas/nylas-ruby

v5.7.0

21 Jan 16:25
Compare
Choose a tag to compare

This new release of the Nylas Ruby SDK introduces some new features as well as enhancements.

New Features

  • Add job status support
  • Add Event to ICS support
  • Add support for getting access token information

Enhancements

  • Improved support for Application Details
  • Enable ability to delete Account objects
  • Fix saving and deleting Folder objects

Using New Features

Job Status

To view all Job statuses

nylas.job_statuses

To view a specific Job status

nylas.job_statuses.find("JOB_STATUS_ID")

To get a boolean value representing Job status success/failure

job_status = nylas.job_statuses.find("JOB_STATUS_ID")
job_status.successful?

Generating an ICS from an Event

nylas = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'],
                     access_token: ENV['NYLAS_ACCESS_TOKEN'])
example_event = api.events.last

# Generate an ICS from an event
ics = example_event.generate_ics

# You can also pass ICS Options for more configuration
ics = example_event.generate_ics(
  ical_uid: "test_uuid",
  method: "add",
  prodid: "test_prodid"
)

Getting information about an access token

nylas = Nylas::API.new(
    app_id: APP_ID,
    app_secret: APP_SECRET,
    access_token: ACCESS_TOKEN
)

account = nylas.accounts.first
token_info = account.token_info("ACCESS_TOKEN")

Improved Application Detail support

To get application details:

nylas = Nylas::API.new(
    app_id: APP_ID,
    app_secret: APP_SECRET
)

app_data = nylas.application_details

To update application details:

nylas = Nylas::API.new(
    app_id: APP_ID,
    app_secret: APP_SECRET
)

app_data = nylas.application_details
app_data.application_name = "New Name"

updated_app_data = nylas.updated_application_details(app_data)

Deleting an account

nylas = Nylas::API.new(
    app_id: APP_ID,
    app_secret: APP_SECRET,
    access_token: ACCESS_TOKEN
)

account = nylas.accounts.find('{id}')

# Delete the account
account.destroy

v5.6.1

13 Dec 22:56
Compare
Choose a tag to compare

This new release of the Nylas Ruby SDK introduces a couple of enhancements.

Enhancements

  • Enabled support for adding metadata to a NewMessage/Draft
  • Fix bug where updating an Event results in an API error

Using Newly Enabled Metadata Support

Metadata can now be added to a Draft:

draft = api.drafts.create(to: [{ email: "[email protected]"}],
                          subject: "A new draft!",
                          metadata: {test: "yes"})
draft.send!

Metadata can also be directly added to a NewMessage and sent:

message = api.send!(to: [{ email: "[email protected]"}],
                          subject: "A new message!",
                          metadata: {test: "yes"})

v5.6.0

22 Nov 21:32
Compare
Choose a tag to compare

This new release of the Nylas Ruby SDK introduces some new features as well as enhancements.

New Features

  • Add support for event notifications (#335)
  • Add metadata support for Calendar, Message and Account (#337)

Enhancements

  • Add more Scheduler support (#338)
  • Modify exchange_code_for_token to allow returning a full body (#336)

Using New Features

Event Notifications

api.events.create(
  title: "A fun event!",
  location: "The Party Zone",
  calendar_id: {CALENDAR_ID},
  conferencing: {
    provider: "Zoom Meeting",
    details: {
      url: "https://us02web.zoom.us/j/****************",
      meeting_code: "213",
      password: "xyz",
      phone: ["+11234567890"]
   },
  notifications: [
    {
      body: "Reminding you about our meeting.",
      minutes_before_event: 600,
      subject: "Test Event Notification",
      type: "email"
    },
    {
      type: "webhook",
      minutes_before_event: 600,
      url: "https://hooks.service.com/services/T01A03EEXDE/B01TBNH532R/HubIZu1zog4oYdFqQ8VUcuiW",
      payload: {
        text: "Your reminder goes here!"
      }.to_json
    },
    {
      type: "sms",
      minutes_before_event: "60",
      message: "Test Event Notfication"
    }
  ]
}

To retrieve event notification details of an event:

event = api.events.find("{EVENT_ID}")

minutes_before_event = event.notifications[0].minutes_before_event
type = event.notifications[0].type
body = event.notifications[0].body
url = event.notifications[0].url
subject = event.notifications[0].subject
payload = event.notifications[0].payload
message = event.notifications[0].message

To update an event with a notification:

event = api.events.find("{EVENT_ID}")

event.update(
  notifications: [{
      body: "Reminding you about our meeting.",
      minutes_before_event: 600,
      subject: "Test Event Notification",
      type: "email"
  }]
)

To delete a notification from an event:

event = api.events.find("{EVENT_ID}")

event.update(
  notifications: []
)

Expanded Metadata Support

Adding Metadata to Calendar

api.calendars.create(
  name: "My New Calendar",
  description: "Description of my new calendar",
  location: "Location description",
  timezone: "America/Los_Angeles",
  metadata: {
    event_type: "gathering"
  }
)

# Or you can update a calendar with metadata

calendar = api.calendars.last

calendar.update(metadata: {
  test: "true",
}};

Query Calendars by Metadata

calendars = api.calendars.where(metadata_pair: {event_type: "gathering"})

Adding Metadata to Message

message = api.messages.last

message.update(metadata: {
  test: "true",
}};

Query Messages by Metadata

messages = api.messages.where({metadata_key: "test"});

Adding Metadata to Account

account = api.current_account

account.update(metadata: {
  test: "true",
}};

Query Account by Metadata

accounts = api.accounts.where({metadata_key: "test"});

More Scheduler functionality

Checking Provider Availability

# Google Availability
google_availability = nylas.scheduler.get_google_availability

# Office 365 Availability
o365_availability = nylas.scheduler.get_office_365_availability

Retrieve available time slots

availabile_timeslots = nylas.scheduler.get_available_time_slots('slug')

Book a time slot

slot = Nylas::SchedulerTimeSlot.new(
  account_id: "test-account-id",
  calendar_id: "test-calendar-id",
  emails: ["[email protected]"],
  start: Time.at(1636728347),
  end: Time.at(1636731958)
)
timeslot_to_book = Nylas::SchedulerBookingRequest.new(
  additional_values: {
    test: "yes"
  },
  email: "[email protected]",
  locale: "en_US",
  name: "Recipient Doe",
  timezone: "America/New_York",
  slot: slot
)
booking_confirmation = nylas.scheduler.book_time_slot("slug", timeslot_to_book)

Confirm a booking

booking_confirmation = nylas.scheduler.confirm_booking('slug', 'edit-hash');

Cancel a booking

nylas.scheduler.cancel_booking('slug', 'edit-hash', 'reason');

Return full body for exchange_code_for_token

To return the entire full response body, pass in return_full_response: true with the code:

response_body = api.exchange_code_for_token("code", return_full_response: true)

v5.5.0

28 Oct 18:55
Compare
Choose a tag to compare

This new release of the Nylas Ruby SDK brings a few new features as well as a bugfix.

New Features

  • Add Component CRUD Support
  • Add Scheduler API support
  • Add support for calendar availability
  • Add support for File delete operation

Enhancements

  • Fix issue where file_ids get reset to empty

Using New Features

Component CRUD

To create a new component:

component = nylas.components.create(name: "New Component", type: "agenda", public_account_id: "ACCOUNT_PUBLIC_ID", access_token: "ACCOUNT_ACCESS_TOKEN")

To get all components:

components = nylas.components
components.each{ |component|
  puts(
    "Name: #{component.name} | "\
        "Type: #{component.type} | "\
        "Active: #{component.active} | "\
        "ID: #{component.id}"
    )
}

To get a specific component:

component = nylas.components.find("{COMPONENT_ID}")

To update a component:

component = nylas.components.find("{COMPONENT_ID}")
example_component.update(
  name: "Updated Name"
)

To delete a component:

component = nylas.components.find("{COMPONENT_ID}")
component.destroy

Scheduler API

To create a new Scheduler page:

nylas.scheduler.create(
  access_tokens: ["ACCESS_TOKEN"],
  name: "Ruby SDK Example",
  slug: "ruby_example")

To return all Scheduler pages:

scheduler_list = nylas.scheduler

To return a single Scheduler page:

scheduler = nylas.scheduler.find('SCHEDULER_ID')

To update a Scheduler page:

scheduler = nylas.scheduler.find('SCHEDULER_ID')
scheduler.update(
  name: "Updated page name"
)

To delete a Scheduler page:

scheduler = nylas.scheduler.find('SCHEDULER_ID')
scheduler.destroy

To get available calendars for a Scheduler page:

scheduler = nylas.scheduler.find('SCHEDULER_ID')
calendars = scheduler.get_available_calendars

To upload an image:

scheduler = nylas.scheduler.find('SCHEDULER_ID')
scheduler.upload_image(content_type: "image/png", object_name: "test.png")

Availability

nylas = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'],
                     access_token: ENV['NYLAS_ACCESS_TOKEN'])

free_busy = Nylas::FreeBusy.new(
  email: "[email protected]",
  time_slots: [
    {
      object: "time_slot",
      status: "busy",
      start_time: 1_609_439_400,
      end_time: 1_640_975_400
    }
  ]
)
open_hours = Nylas::OpenHours.new(
  emails: ["[email protected]"],
  days: [0],
  timezone: "America/Chicago",
  start: "10:00",
  end:  "14:00"
)

nylas.calendars.availability(
  duration_minutes: 30,
  interval: 5,
  start_time: 1590454800,
  end_time: 1590780800,
  emails: ["[email protected]"],
  buffer: 5,
  round_robin: "max-fairness",
  free_busy: [free_busy],
  open_hours: [open_hours]
)

Consecutive Availability

nylas = Nylas::API.new(app_id: ENV['NYLAS_APP_ID'], app_secret: ENV['NYLAS_APP_SECRET'],
                     access_token: ENV['NYLAS_ACCESS_TOKEN'])

free_busy = Nylas::FreeBusy.new(
  email: "[email protected]",
  time_slots: [
    {
      object: "time_slot",
      status: "busy",
      start_time: 1_609_439_400,
      end_time: 1_640_975_400
    }
  ]
)
open_hours = Nylas::OpenHours.new(
  emails: %w[[email protected] [email protected] [email protected] [email protected]],
  days: [0],
  timezone: "America/Chicago",
  start: "10:00",
  end:  "14:00"
)

nylas.calendars.consecutive_availability(
  duration_minutes: 30,
  interval: 5,
  start_time: 1590454800,
  end_time: 1590780800,
  emails: [["[email protected]"], %w[[email protected] [email protected]]],
  buffer: 5,
  free_busy: [free_busy],
  open_hours: [open_hours]
)

Deleting a file

file = nylas.files.find('FILE_ID')
file.destroy

v5.4.1

27 Sep 16:14
eec9201
Compare
Choose a tag to compare

This new release of the Nylas Ruby SDK brings a new fix

  • Fix draft send method to send existing draft when tracking is enabled (#327)

v5.4.0

23 Sep 21:30
Compare
Choose a tag to compare

This new release of the Nylas Ruby SDK brings a couple of fixes as well as adding support for event conferencing details and automatic meeting creation (beta).

New Features

  • Add support for Event Conferencing

Enhancements

  • Fix update draft failing if version is not explicitly set
  • Fix draft .send logic

Using New Features

Event Conferencing

Nylas::Event.conferencing is now a field that will contain conference details for Events that contain them, and it can be populated when new events through the SDK.

You can read the values like so:

event = api.events.find("{EVENT_ID}")
conferencing_provider = event.conferencing.provider
conferencing_url = event.conferencing.details.url
conferencing_meeting_code = event.conferencing.details.meeting_code
conferencing_password = event.conferencing.details.password
conferencing_pin = event.conferencing.details.pin
conferencing_phone = event.conferencing.details.phone

You can also build a new event that includes conferencing details with the SDK:

api.events.create(
  title: "A fun event!",
  location: "The Party Zone",
  calendar_id: {CALENDAR_ID},
  conferencing: {
    provider: "Zoom Meeting",
    details: {
      url: "https://us02web.zoom.us/j/****************",
      meeting_code: "213",
      password: "xyz",
      phone: ["+11234567890"]
   }
}

To have Nylas autocreate the conference field for you, pass the autocreate object to the new event:

api.events.create(
  title: "A fun event!",
  location: "The Party Zone",
  calendar_id: {CALENDAR_ID},
  conferencing: {
    provider: "Zoom Meeting",
    autocreate: {
      settings: {}
   }
}

A few notes and things to keep in mind:

  • Only one of details or autocreate can be present, and we have implemented client-side checking to enforce this rule
  • Autocreating conferencing data is an asynchronous operation on the server-side. The Event object returned will not have a conferencing field, but it should be available in a future get call once the conference is created on the backend. The initial Event object returned will have a jobStatusId value which can be used to check on the status of conference creation.
  • The settings object within the autocreate object maps to the settings the Nylas API will send to the conference provider for the conference creation. For example with Zoom the settings object maps to Zoom's Create a Meeting object.

v5.3.0

18 Aug 15:26
Compare
Choose a tag to compare

This new release of the Nylas Node SDK brings a couple of fixes as well as adding a few features. Most notably, this release brings forward support for the Nylas Neural API! More information below on how to use each part of the Neural API through our Node SDK.

New Features

  • Add support for the Neural API (#318)

Enhancements

  • Fix issue where Delta did not have a header attribute for expanded headers (#315, #314)
  • Fix ArgumentError when calling Nylas::API#send! due to missing double splat (**) (#317, #310)
  • Fix issue where server errors are not reported if HTML is returned (#316, #313)
  • Fix issue where expanded Thread objects were not returning messages (#319, #321)

Using New Features

Neural API

To use Sentiment Analysis:

# To perform sentiment analysis on a message, pass in the list of message ID:
message_analysis = nylas.neural.sentiment_analysis_message([MESSAGE_ID])

# To perform sentiment analysis on just text, pass in a string:
text_analysis = nylas.neural.sentiment_analysis_text("Hi, thank you so much for reaching out! We can catch up tomorrow.")

To use Signature Extraction:

const signature = nylas.neural.extract_signature([MESSAGE_ID])

# The method also accepts an optional parameter options, an object of options
# that can be enabled for the Neural endpoint, of type NeuralMessageOptions:
options = Nylas::NeuralMessageOptions.new(
    ignore_links: false,
    ignore_images: false,
    ignore_tables: false,
    remove_conclusion_phrases: false,
    images_as_markdown: false,
    parse_contact: false
)

signature = nylas.neural.extract_signature([MESSAGE_ID], options)

and to parse the contact and convert it to the standard Nylas contact object:

contact = signature[0].contacts.to_contact_object

To use Clean Conversations:

convo = nylas.neural.clean_conversation([MESSAGE_ID])

# You can also pass in an object of options that can be enabled for the Neural endpoint, of type NeuralMessageOptions
convo = nylas.neural.clean_conversation([MESSAGE_ID], options);

and to extract images from the result:

convo[0].extract_images

To use Optical Character Recognition:

ocr = nylas.neural.ocr_request(FILE_ID)

# This endpoint also supports a second, optional parameter for an array specifying the pages that the user wants analyzed:
ocr = nylas.neural.ocr_request(FILE_ID, [2, 3])

To use Categorizer

cat = nylas.neural.categorize([MESSAGE_ID])

# You can also send a request to recategorize the message:
cat = cat[0].recategorize("conversation")

v5.2.0

15 Jul 14:45
7bd1d24
Compare
Choose a tag to compare

New Features

  • Add support for Room Resource (#307)

Enhancements and Fixes

  • Fix issue where "302 Redirect" response codes were treated as errors (#306)
  • Fix issue where api value was overridden when calling message.expanded (#311)

Using New Features

Room Resource

Currently, the /resource endpoint only supports the GET operation without any extra functionality like filtering. To get a list of all room resource objects attached to your account, you can do the following:

#!/usr/bin/env ruby
require 'nylas'

# Initialize and connect to the Nylas client
nylas = Nylas::API.new(
  app_id: CLIENT_ID,
  app_secret: CLIENT_SECRET,
  access_token: ACCESS_TOKEN
)

resources = nylas.room_resources

v5.1.0

07 Jun 22:00
3deeaf3
Compare
Choose a tag to compare

New Features

  • Add support for read only attributes (#298)
  • Add save_all_attributes and update_all_attributes methods to support nullifying attributes. (#299)
  • Add support new Event metadata feature (#300)

Enhancements and Fixes

  • Fix attributes assignment for Delta (#297)
  • Fix issue where files couldn't be attached to drafts (#302)
  • Fix exception raise when content-type is not JSON (#303)
  • Fix issue where draft version wouldn't update after update or save (#304)

5.0.0

07 May 20:28
d4f7633
Compare
Choose a tag to compare

5.0.0 / 2021-05-07

  • Send Nylas-API-Version header to API with latest supported version. #296
  • Fix issue sending message using raw mime type. #294
  • Support for messages.expanded.find(id) to return expanded message. #293
  • Add support for hosted authentication #292
  • Fix bug to not send id, object and account_id on events update call #291