Skip to content

Releases: nylas/nylas-python

v5.14.0

04 Apr 19:26
Compare
Choose a tag to compare

This release of the Nylas Python SDK brings a couple of new features.

Release Notes

Added

  • Added support for verifying webhook signatures (#257)
  • Added optional parameter for token-info endpoint (#256)

Verifying webhook signatures

from flask import Flask, request, jsonify
from nylas import APIClient, Webhook
import os
import json

app = Flask(__name__)
port = 9000
NYLAS_CLIENT_SECRET = os.environ.get("NYLAS_CLIENT_SECRET")

@app.route("/", methods=["POST"])
def webhook_callback():
    signature = request.headers.get("X-Nylas-Signature")
    request_data = json.dumps(request.get_json())
    
    if not Webhook.verify_webhook_signature(signature, request_data, NYLAS_CLIENT_SECRET):
        return jsonify({"error": "Invalid signature"}), 403

    body = request.json
    print("Webhook event received: ", json.dumps(body))

    return jsonify({"success": True}), 200

if __name__ == "__main__":
    app.run(port=port)

v5.13.1

01 Feb 19:24
Compare
Choose a tag to compare

This release of the Nylas Python SDK brings a few fixes.

Release Notes

Changed

  • fix send_authorization not returning the correct dict (#254)
  • fix expanded threads not inflating the messages objects properly (#254)
  • fix class attributes with leading underscores not serializing as expected (#254)

v5.13.0

01 Feb 18:31
Compare
Choose a tag to compare

This release of the Nylas Python SDK includes a small change as well as the release of local webhook development support built directly into the SDK. When implementing this feature in your app, the SDK will create a tunnel connection to a websocket server and registers it as a webhook callback to your Nylas account. See below for a usage example.

Release Notes

Added

  • Add local webhook development support (#252)

Changed

  • Use PEP508 syntax for conditional dependencies (#250)

Usage

Webhook Tunnel

During the setup process you can pass in methods to override the websocket client's callback methods. The most important method is the on_message method which returns a parsed delta event from the webhook server.

from client.restful_models import Webhook
from nylas import APIClient

from services.tunnel import open_webhook_tunnel

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


def run_webhook():
    def on_message(delta):
        if delta["type"] == Webhook.Trigger.MESSAGE_UPDATED:
            print(delta)

    def on_open(ws):
        print("opened")

    def on_error(ws, err):
        print("Error found")
        print(err)

    open_webhook_tunnel(
        nylas, {"on_message": on_message, "on_open": on_open, "on_error": on_error}
    )


if __name__ == "__main__":
    run_webhook()

Contributors 🎸

v5.12.1

06 Jan 22:29
Compare
Choose a tag to compare

This release of the Nylas Python SDK brings a singular change.

Release Notes

Changed

  • Only install enum34 on python34 and below (#247)

New Contributors 🎉

v5.12.0

16 Dec 17:31
Compare
Choose a tag to compare

This release of the Nylas Python SDK brings a single addition.

Release Notes

Added

  • Add support for sending raw MIME messages (#243)

Usage

Sending raw MIME messages

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

raw_mime = """MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Subject: With Love, From Nylas
From: You <[email protected]>
To: My Nylas Friend <[email protected]>

This email was sent via raw MIME using the Nylas email API. Visit https://nylas.com for details.
"""

draft = nylas.drafts.create()

# Send the raw MIME
msg = draft.send_raw(raw_mime)

v5.11.0

18 Nov 23:15
Compare
Choose a tag to compare

This release of the Nylas Python SDK brings a few additions.

Release Notes

Added

  • Add support for calendar colors (for Microsoft calendars) (#238)
  • Add support for rate limit errors (#239)
  • Add support for visibility field in Event (#240)

v5.10.2

11 Oct 21:26
Compare
Choose a tag to compare

This release of the Nylas Python SDK brings a singular change.

Release Notes

Changed

  • Update package setup to be compatible with PEP 517 (#235)

New Contributors 🎉

v5.10.1

22 Sep 19:33
Compare
Choose a tag to compare

This release of the Nylas Python SDK brings a singular fix.

Release Notes

Fixed

  • Fix authentication for integrations (#233)

v5.10.0

29 Jul 20:48
Compare
Choose a tag to compare

This release of the Nylas Python SDK brings a few additions.

Release Notes

Added

  • Add metadata field to JobStatus (#227)
  • Add missing hosted authentication parameters (#229)
  • Add support for calendar field in free-busy, availability, and consecutive availability queries (#228)

Using New Features

New calendars field in free-busy/availability queries

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

# Free busy with calendars
start_time = datetime.now()
end_time = datetime.now() + timedelta(hours = 24)
calendars = [{
  "account_id": "test_account_id",
  "calendar_ids": ["example_calendar_a", "example_calendar_b"]
}]

free_busy = nylas.free_busy("[email protected]", start_time, end_time, calendars)

# Availability with calendars
emails = ["[email protected]", "[email protected]", "[email protected]"]
start_time = datetime.now()
end_time = datetime.now() + timedelta(hours = 24)
duration = timedelta(minutes=30)
interval = timedelta(hours=1, minutes=30)
calendars = [{
  "account_id": "test_account_id",
  "calendar_ids": ["example_calendar_a", "example_calendar_b"]
}]

api_client.availability(emails, duration, interval, start_at, end_at, calendars=calendars)

# Consecutive availability with calendars
emails = [["[email protected]"], ["[email protected]", "[email protected]"]]
start_time = datetime.now()
end_time = datetime.now() + timedelta(hours = 24)
duration = timedelta(minutes=30)
interval = timedelta(hours=1, minutes=30)
calendars = [{
  "account_id": "test_account_id",
  "calendar_ids": ["example_calendar_a", "example_calendar_b"]
}]

api_client.consecutive_availability(emails, duration, interval, start_at, end_at, calendars=calendars)

New Contributors

v5.9.2

30 Jun 19:45
Compare
Choose a tag to compare

This release of the Nylas Python SDK brings a small change.

Release Notes

Changed

  • Add enforce_read_only parameter to overriding as_json functions (#225)