Skip to content

v5.5.0

Compare
Choose a tag to compare
@mrashed-dev mrashed-dev released this 28 Oct 18:55
· 97 commits to main since this release

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