Releases: nylas/nylas-ruby
v5.12.0
v5.11.0
This new release of the Nylas Ruby SDK brings support for new fields in Event and Job Status.
Release Notes
Added
Usage
Event Reminders
example_calendar = api.calendars.last
api.events.create(
title: "A fun event!",
location: "The Party Zone",
calendar_id: example_calendar.id,
when: { start_time: Time.now + 60, end_time: Time.now + 120 },
reminder_minutes: 20,
reminder_method: "email"
)
v5.10.0
This new release of the Nylas Ruby SDK brings support for collective and group events, as well as a fix.
Release Notes
Added
- Support collective and group events
Fixed
- Fix
ModelNotFilterableError
when querying for accounts with metadata
v5.9.2
v5.9.1
v5.9.0
This release of the Nylas Ruby SDK comes with a few new features and changes!
Release Notes
Added
- Add Outbox support
- Add new
authentication_type
field in Account - Add support for basic authentication
Changed
- Enable Nylas API v2.5 support
Using New Features
Outbox
To send a new message to the outbox:
nylas = Nylas::API.new(
app_id: APP_ID,
app_secret: APP_SECRET,
access_token: ACCESS_TOKEN
)
# Create a new draft
draft = Nylas::Draft.new(to: [{ email: "[email protected]", name: "Me" }],
subject: "A new draft!",
metadata: {sdk: "Ruby SDK"})
# Set additional optional parameters
tomorrow = (Date.today + 1).to_time.to_i
day_after = (Date.today + 2).to_time.to_i
# Send the outbox message
outbox_job_status = nylas.outbox.send(draft, send_at: tomorrow, retry_limit_datetime: day_after)
To update an outbox message after sending it
nylas = Nylas::API.new(
app_id: APP_ID,
app_secret: APP_SECRET,
access_token: ACCESS_TOKEN
)
# Fetch the job status
outbox_job_status = nylas.job_statuses.find("JOB_STATUS_ID")
outbox_message = outbox_job_status.original_data
# Make changes
outbox_message.subject = "Updated subject"
tomorrow = (Date.today + 1).to_time.to_i
day_after = (Date.today + 2).to_time.to_i
# Update the outbox job
updated_job_status = nylas.outbox.send('JOB_STATUS_ID', message: outbox_message, send_at: tomorrow, retry_limit_datetime: day_after);
To delete an outbox job
nylas = Nylas::API.new(
app_id: APP_ID,
app_secret: APP_SECRET,
access_token: ACCESS_TOKEN
)
nylas.outbox.delete("JOB_STATUS_ID")
We also support SendGrid operations. To get the authentication and verification status
nylas = Nylas::API.new(
app_id: APP_ID,
app_secret: APP_SECRET,
access_token: ACCESS_TOKEN
)
send_grid_verification = nylas.outbox.send_grid_verification_status
verification.domain_verified
verification.sender_verified
To delete a SendGrid user:
nylas = Nylas::API.new(
app_id: APP_ID,
app_secret: APP_SECRET,
access_token: ACCESS_TOKEN
)
nylas.outbox.delete_send_grid_sub_user("[email protected]");
v5.8.0
This release of the Nylas Ruby SDK comes with a few new features and fixes!
Release Notes
Added
- Improved support for
Webhook
objects - Support
calendars
for availability methods (#350)
Fixed
- Fix
interval_minutes
keyword for availability methods (#351)
Using New Features
Webhooks
We have provided some modules that can help with setting the correct values for webhooks:
# For state,
WebhookState::ACTIVE # = "active"
WebhookState::INACTIVE # = "inactive"
# For triggers
WebhookTrigger::ACCOUNT_CONNECTED # = "account.connected"
WebhookTrigger::MESSAGE_CREATED # = "message.created"
WebhookTrigger::THREAD_REPLIED # = "thread.replied"
WebhookTrigger::CALENDAR_UPDATED # = "calendar.updated"
# ... and many, many more!
To create a webhook:
nylas = Nylas::API.new(
app_id: APP_ID,
app_secret: APP_SECRET,
access_token: ACCESS_TOKEN
)
webhook = nylas.webhooks.create(
callback_url: "WEBHOOK_URL",
state: WebhookState::ACTIVE,
triggers: [WebhookTrigger::EVENT_CREATED],
)
To update a webhook:
nylas = Nylas::API.new(
app_id: APP_ID,
app_secret: APP_SECRET,
access_token: ACCESS_TOKEN
)
webhook = api.webhooks.first
webhook.update(state: WebhookState::INACTIVE)
To delete a webhook:
nylas = Nylas::API.new(
app_id: APP_ID,
app_secret: APP_SECRET,
access_token: ACCESS_TOKEN
)
webhook = api.webhooks.first
webhook.destroy
New Contributors
- @thestrabusiness made their first contributions with
Support calendars keyword for availability requests
(#350) andUpdate interval keyword arg for calendar availability methods
(#351)
v5.7.0
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
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
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
andAccount
(#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)