Skip to content

Releases: nylas/nylas-python

v5.5.0

01 Feb 18:51
Compare
Choose a tag to compare

This new release of the Nylas Python SDK a new feature as well as an enhancement.

New Features

  • Add support for Event to ICS

Enhancements

  • Enable full payload response for exchanging the token for code

Usage

Generate ICS from Event

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)
example_event = nylas.events.get('{id}')

# 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"
)

Exchange Token for Code (full payload)

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

ACCESS_TOKEN = nylas.send_authorization('{code_from_nylas}')

v5.4.2

13 Jan 22:23
Compare
Choose a tag to compare

This patch release of the Nylas Python SDK contains a single minor enhancement.

Enhancements

  • Add missing source field in Contact class

v5.4.1

23 Dec 18:48
Compare
Choose a tag to compare

This patch release of the Nylas Python SDK comtains as a couple of enhancements.

Enhancements

  • Improved support for Application Details
  • Fix issue where keyword arguments calling _update_resource were not correctly resolving to URL params

Usage

To get application details:

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET
)

app_data = nylas.application_details()

To update application details:

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET
)

updated_app_data = nylas.update_application_details(
    application_name="New Name",
    icon_url="https://myurl.com/icon.png",
    redirect_uris=["https://redirect.com"],
)

To delete an account:

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET
)

nylas.accounts.delete("{account_id}")

v5.4.0

16 Dec 19:05
Compare
Choose a tag to compare

This new release of the Nylas Python SDK a new feature as well as a couple of enhancements.

New Features

  • Add job status support

Enhancements

  • Add is_primary field to Calendar
  • Fix bug where updating an Event results in an API error

Usage

Job Status

To view all Job statuses

job_statuses = nylas.job_statuses.all()

To view a specific Job status

job_status = nylas.job_statuses.get("JOB_STATUS_ID")

To get a boolean value representing Job status success/failure

job_status = nylas.job_statuses.get("JOB_STATUS_ID")
job_status.is_successful()

v5.3.0

26 Nov 18:47
Compare
Choose a tag to compare

This new release of the Nylas Python SDK brings a slew of new features with support to many new Nylas APIs as well as new features to enhance existing models.

New Features

  • Add support for Scheduler API
  • Add support for Event notifications
  • Add support for Component CRUD
  • Add metadata support for Calendar, Message and Account

Enhancements

  • Improve error details returned from the API

Usage

Scheduler API

To create a new Scheduler page:

scheduler = nylas.scheduler.create()
scheduler.access_tokens = ["ACCESS_TOKEN"]
scheduler.name = "Python SDK Example"
scheduler.slug = "py_example_1"
scheduler.save()

To return all Scheduler pages:

scheduler_list = nylas.scheduler.all()

To return a single Scheduler page:

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

To update a Scheduler page:

scheduler = nylas.scheduler.get('SCHEDULER_ID')
scheduler.name = "Updated page name"
scheduler.save()

To delete a Scheduler page:

nylas.scheduler.delete('SCHEDULER_ID')

To get available calendars for a Scheduler page:

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

To upload an image:

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

Checking Provider Availability

# Google Availability
google_availability = nylas.scheduler.get_google_availability()

# Office 365 Availability
o365_availability = nylas.scheduler.get_office_365_availability()

Get page information/configuration

page_config = nylas.scheduler.get_page_slug('slug')

Retrieve available time slots

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

Book a time slot

slot = SchedulerTimeSlot.create(nylas)
slot.account_id = "test-account-id"
slot.calendar_id = "test-calendar-id"
slot.emails = ["recipient@example.com"]
slot.host_name = "Host"
slot.start = datetime.utcfromtimestamp(1636728347)
slot.end = datetime.utcfromtimestamp(1636731958)

timeslot_to_book = SchedulerBookingRequest.create(nylas)
timeslot_to_book.additional_values = {
    "test": "yes",
}
timeslot_to_book.email = "recipient@example.com"
timeslot_to_book.locale = "en_US"
timeslot_to_book.name = "Recipient Doe"
timeslot_to_book.timezone = "America/New_York"
timeslot_to_book.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');

Event Notifications

To create a notification for an event:

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

# Create a new event
event = nylas.events.create()

# Add notification details to the event
event.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: json.dumps({
      text: "Your reminder goes here!"
    })
  },
  {
    type: "sms",
    minutes_before_event: 60,
    message: "Test Event Notfication"
  }
]

To retrieve event notification details of an event:

# Get an event
event = nylas.events.get("EVENT_ID")

# Add notification details to the event
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:

# Get an event
event = nylas.events.get("EVENT_ID")

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

To delete a notification from an event:

# Get an event
event = nylas.events.get("EVENT_ID")

event.notifications = []
event.save()

Component CRUD

To create a new component:

component = nylas.components.create()
component.name = "Python Component"
component.type = "agenda"
component.public_account_id = "ACCOUNT_PUBLIC_ID"
component.access_token = "ACCOUNT_ACCESS_TOKEN"
component.save()

To get all components:

components = nylas.components.all()

To get a specific component:

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

To update a component:

component = nylas.components.get("{COMPONENT_ID}")
component.name = "Updated"
component.save()

To delete a component:

nylas.components.delete("{COMPONENT_ID}")

Expanded Metadata support

Adding Metadata to Calendar

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

# Or you can update a calendar with metadata

calendar = nylas.calendars.first()

calendar.metadata = {
  "event_type": "gathering"
}
calendar.save()

Query Calendars by Metadata

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

Adding Metadata to Message

message = nylas.messages.first()

message.metadata = {
  "test": "true"
}
message.save()

Adding Metadata to Account

account = api.accounts[0]

account.metadata = {
  "test": "true"
}
account.save()

Query Account by Metadata

accounts = api.accounts.where(metadata_key="test");

v5.2.0

24 Sep 20:50
Compare
Choose a tag to compare

This new release of the Nylas Python SDK brings a couple of critical fixes as well as enhancing support for Event Conference Sync with Auto Create Meetings (Private Beta) support as well as improving calendar availability support.

New Features

  • Add support for calendar consecutive availability
  • Add dynamic conferencing link creation support

Usage

Consecutive Availability

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

emails = [["one@example.com"], ["two@example.com", "three@example.com"]]
duration = 30
interval = 60
start_at = 1632236400
end_at = 1632240000
open_hours = api_client.open_hours(
    [
        "one@example.com",
        "two@example.com",
        "three@example.com",
        "visitor@external.net",
    ],
    [0],
    "America/Chicago",
    "10:00",
    "14:00",
)
free_busy = [
    {
        "email": "visitor@external.net",
        "time_slots": [
            {
                "object": "time_slot",
                "status": "busy",
                "start_time": 1632236400,
                "end_time": 1632240000,
            }
        ],
    }
]
api_client.consecutive_availability(
    emails,
    duration,
    interval,
    start_at,
    end_at,
    free_busy=free_busy,
    open_hours=open_hours,
)

Auto Create Meetings

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

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

#Create a new event
event = nylas.events.create()

# add conferencing details
event.conferencing = {
    "provider": "Zoom Meeting",
    "conferencing": {
        "autocreate": {
            "settings": {
                "password": "1234",
            },
        },
    },
}

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.1.0

31 Aug 17:54
Compare
Choose a tag to compare

This new release of the Nylas Python SDK brings a couple of critical fixes as well as adding support for Event Conference Sync (Beta).

New Features

  • Add Event conferencing support

Enhancements

  • Fix categorized_at type to be epoch in NeuralCategorizer
  • Fix error when creating events by filtering of "None" value attributes before making requests

v5.0.0

21 Jul 21:07
Compare
Choose a tag to compare

👋 Hey there! It's been a while but we have a new action-packed release for the Python SDK! This new release addresses a lot of issues and bugs. Furthermore we have some new exciting features such as support for the new Nylas Neural API, Event Metadata, and support for new Room Resources fields! Please note that with this release you may need to update your configuration as we have changed the names of the API configuration variables. More information can be found below under "Breaking Changes".

New Features

  • Add support for the Nylas Neural API (#163)
  • Add metadata support (#152)
  • Add new Room Resource fields (#156)
  • Add Nylas-API-Version header support (#157)

Enhancements

  • Transitioned from app_id and app_secret naming to client_id and client_secret (#159)
  • Fix adding a tracking object to an existing draft (#153)
  • Fix issue when converting offset-aware datetime objects to timestamp (#154)
  • Fix limit value in filter not being used when making .all() call (#155)
  • Fix from_ field set by attribute on draft ignored (#162)
  • Remove bumpversion from a required dependency to an extra dependency (#158)

Breaking Changes

API Configuration

The Python SDK previously used the variable names app_id and app_secret for the API configuration. They have now changed to client_id and client_secret. In the other Nylas components like the API and other SDKs the values are referred to as the Client ID and the Client Secret so this change was made for consistency and to reduce confusion.

If you were previously initializing APIClient by passing in the credentials as a variable assignment, you are required to update your code to reflect the new credential variable names:

client = APIClient(
        client_id="CLIENT_ID",
        client_secret="CLIENT_SECRET",
    )

If you were initializing it by just passing in the values in order like so:

client = APIClient(
        "CLIENT_ID",
        "CLIENT_SECRET",
    )

then no change is required on your part.

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 two optional parameters
# parseContact, a boolean for whether Nylas should parse the contact from the signature (API defaults to true)
# options, an object of options that can be enabled for the Neural endpoint, of type NeuralMessageOptions:
options = NeuralMessageOptions(
    ignore_links=False,
    ignore_images=False,
    ignore_tables=False,
    remove_conclusion_phrases=False,
    images_as_markdowns=False
)

signature = nylas.neural.extract_signature([MESSAGE_ID], true, 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")

Event Metadata

# To filter using either metadata_key or metadata_value you can pass in a string:
events = nylas.events.where(metadata_key='hello').all()

# or, you can pass in multiple strings as an array:
events = nylas.events.where(metadata_value=['value1', 'value2']).all()

# To filter on `metadata_pair` you can pass in a `dict` of key-value pairs to use in the query:
events = nylas.events.where(metadata_pair={'hello': 'world'}).all()

v4.12.1

17 Jul 12:04
Compare
Choose a tag to compare
Bump version: 4.12.0 → 4.12.1

v4.12.0

30 Jun 20:57
Compare
Choose a tag to compare
Bump version: 4.11.0 → 4.12.0