Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom authentication, connectors, and credentials APIs #431

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/nylas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
require_relative "nylas/resources/applications"
require_relative "nylas/resources/auth"
require_relative "nylas/resources/calendars"
require_relative "nylas/resources/connectors"
require_relative "nylas/resources/credentials"
require_relative "nylas/resources/events"
require_relative "nylas/resources/grants"
require_relative "nylas/resources/messages"
require_relative "nylas/resources/redirect_uris"
require_relative "nylas/resources/webhooks"
8 changes: 8 additions & 0 deletions lib/nylas/client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require_relative "resources/calendars"
require_relative "resources/connectors"
require_relative "resources/messages"
require_relative "resources/events"
require_relative "resources/auth"
Expand Down Expand Up @@ -39,6 +40,13 @@ def calendars
Calendars.new(self)
end

# The connector resources for your Nylas application.
#
# @return [Nylas::Connectors] Connector resources for your Nylas application.
def connectors
Connectors.new(self)
end

# The event resources for your Nylas application.
#
# @return [Nylas::Events] Event resources for your Nylas application
Expand Down
95 changes: 0 additions & 95 deletions lib/nylas/handler/admin_api_operations.rb

This file was deleted.

10 changes: 5 additions & 5 deletions lib/nylas/handler/api_operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Get
#
# @param path [String] Destination path for the call.
# @param query_params [Hash, {}] Query params to pass to the call.
# @return [Array(Hash, String)] List of Nylas objects and API Request ID.
# @return Nylas data object and API Request ID.
def get(path:, query_params: {})
response = execute(
method: :get,
Expand All @@ -39,7 +39,7 @@ module Post
# @param query_params [Hash, {}] Query params to pass to the call.
# @param request_body [String, Hash, nil] Request body to pass to the call.
# @param headers [Hash, {}] Additional HTTP headers to include in the payload.
# @return [Array(Hash, String)] List of Nylas objects and API Request ID.
# @return Nylas data object and API Request ID.
def post(path:, query_params: {}, request_body: nil, headers: {})
response = execute(
method: :post,
Expand All @@ -66,7 +66,7 @@ module Put
# @param query_params [Hash, {}] Query params to pass to the call.
# @param request_body [String, Hash, nil] Request body to pass to the call.
# @param headers [Hash, {}] Additional HTTP headers to include in the payload.
# @return [Array(Hash, String)] List of Nylas objects and API Request ID.
# @return Nylas data object and API Request ID.
def put(path:, query_params: {}, request_body: nil, headers: {})
response = execute(
method: :put,
Expand All @@ -93,7 +93,7 @@ module Patch
# @param query_params [Hash, {}] Query params to pass to the call.
# @param request_body [String, Hash, nil] Request body to pass to the call.
# @param headers [Hash, {}] Additional HTTP headers to include in the payload.
# @return [Array(Hash, String)] List of Nylas objects and API Request ID.
# @return Nylas data object and API Request ID.
def patch(path:, query_params: {}, request_body: nil, headers: {})
response = execute(
method: :patch,
Expand All @@ -119,7 +119,7 @@ module Delete
# @param path [String] Destination path for the call.
# @param query_params [Hash, {}] Query params to pass to the call.
# @param headers [Hash, {}] Additional HTTP headers to include in the payload.
# @return [Array(Hash, String)] List of Nylas objects and API Request ID.
# @return Nylas data object and API Request ID.
def delete(path:, query_params: {}, headers: {})
response = execute(
method: :delete,
Expand Down
99 changes: 0 additions & 99 deletions lib/nylas/handler/grants_api_operations.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/nylas/resources/applications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Applications < Resource

# Initializes the application.
def initialize(sdk_instance)
super("applications", sdk_instance)
super(sdk_instance)
@redirect_uris = RedirectUris.new(sdk_instance)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nylas/resources/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Auth < Resource

# Initializes Auth.
def initialize(sdk_instance)
super("auth", sdk_instance)
super(sdk_instance)

@grants = Grants.new(sdk_instance)
end
Expand Down
82 changes: 70 additions & 12 deletions lib/nylas/resources/calendars.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,83 @@
# frozen_string_literal: true

require_relative "resource"
require_relative "../handler/grants_api_operations"
require_relative "../handler/api_operations"

module Nylas
# Calendars
# Nylas Calendar API
class Calendars < Resource
include GrantsApiOperations::Create
include GrantsApiOperations::Update
include GrantsApiOperations::List
include GrantsApiOperations::Destroy
include GrantsApiOperations::Find

# Initializes Calendars.
def initialize(sdk_instance)
super("calendars", sdk_instance)
include ApiOperations::Get
include ApiOperations::Post
include ApiOperations::Put
include ApiOperations::Delete

# Return all calendars.
#
# @param identifier [String] Grant ID or email account to query.
# @param query_params [Hash, nil] Query params to pass to the request.
# @return [Array(Array(Hash), String)] The list of calendars and API Request ID.
def list(identifier:, query_params: nil)
get(
path: "#{api_uri}/v3/grants/#{identifier}/calendars",
query_params: query_params
)
end

# Return a calendar.
#
# @param identifier [String] Grant ID or email account to query.
# @param calendar_id [String] The id of the calendar to return.
# Use "primary" to refer to the primary calendar associated with grant.
# @return [Array(Hash, String)] The calendar and API request ID.
def find(identifier:, calendar_id:)
get(
path: "#{api_uri}/v3/grants/#{identifier}/calendars/#{calendar_id}"
)
end

# Create a calendar.
#
# @param identifier [String] Grant ID or email account in which to create the object.
# @param request_body [Hash] The values to create the calendar with.
# @return [Array(Hash, String)] The created calendar and API Request ID.
def create(identifier:, request_body:)
post(
path: "#{api_uri}/v3/grants/#{identifier}/calendars",
request_body: request_body
)
end

# Update a calendar.
#
# @param identifier [String] Grant ID or email account in which to update an object.
# @param calendar_id [String] The id of the calendar to update.
# Use "primary" to refer to the primary calendar associated with grant.
# @param request_body [Hash] The values to update the calendar with
# @return [Array(Hash, String)] The updated calendar and API Request ID.
def update(identifier:, calendar_id:, request_body:)
put(
path: "#{api_uri}/v3/grants/#{identifier}/calendars/#{calendar_id}",
request_body: request_body
)
end

# Delete a calendar.
#
# @param identifier [String] Grant ID or email account from which to delete an object.
# @param calendar_id [String] The id of the calendar to delete.
# Use "primary" to refer to the primary calendar associated with grant.
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
def destroy(identifier:, calendar_id:)
_, request_id = delete(
path: "#{api_uri}/v3/grants/#{identifier}/calendars/#{calendar_id}"
)

[true, request_id]
end

# Checks multiple calendars to find available time slots for a single meeting.
#
# @param request_body Hash Request body to pass to the request.
# @param request_body [Hash] Request body to pass to the request.
# @return [Array(Hash, String)] Availability object and API request ID.
def get_availability(request_body:)
post(
Expand Down
Loading
Loading