-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into attach_file_custom_filename
- Loading branch information
Showing
16 changed files
with
756 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "resource" | ||
require_relative "../handler/api_operations" | ||
|
||
module Nylas | ||
# Nylas Messages API | ||
class Availability < Resource | ||
include ApiOperations::Get | ||
|
||
# Return availabilities for a configuration. | ||
# @param query_params [Hash, nil] Query params to pass to the request. | ||
# @return [Array(Array(Hash), String, String)] The list of configurations, API Request ID, | ||
# and next cursor. | ||
def list(query_params: nil) | ||
get_list( | ||
path: "#{api_uri}/v3/scheduling/availability", | ||
query_params: query_params | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "resource" | ||
require_relative "../handler/api_operations" | ||
|
||
module Nylas | ||
# Nylas Messages API | ||
class Bookings < Resource | ||
include ApiOperations::Get | ||
include ApiOperations::Post | ||
include ApiOperations::Put | ||
include ApiOperations::Delete | ||
include ApiOperations::Patch | ||
|
||
# Return a booking. | ||
# @param booking_id [String] The id of the booking to return. | ||
# @param query_params [Hash, nil] Query params to pass to the request. | ||
# @return [Array(Hash, String)] The booking and API request ID. | ||
def find(booking_id:, query_params:) | ||
get( | ||
path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}", | ||
query_params: query_params | ||
) | ||
end | ||
|
||
# Create a booking. | ||
# @param request_body [Hash] The values to create the booking with. | ||
# @param query_params [Hash, nil] Query params to pass to the request. | ||
# @return [Array(Hash, String)] The created booking and API Request ID. | ||
def create(request_body:, query_params:) | ||
post( | ||
path: "#{api_uri}/v3/scheduling/bookings", | ||
request_body: request_body, | ||
query_params: query_params | ||
) | ||
end | ||
|
||
# Create a booking. | ||
# @param request_body [Hash] The values to update the booking with. | ||
# @param booking_id [String] The id of the booking to update. | ||
# @param query_params [Hash, nil] Query params to pass to the request. | ||
# @return [Array(Hash, String)] The created booking and API Request ID. | ||
def update(request_body:, booking_id:, query_params:) | ||
patch( | ||
path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}", | ||
request_body: request_body, | ||
query_params: query_params | ||
) | ||
end | ||
|
||
# Confirm a booking. | ||
# @param booking_id [String] The id of the booking to confirm. | ||
# @param request_body [Hash] The values to update the booking with | ||
# @param query_params [Hash, nil] Query params to pass to the request. | ||
# @return [Array(Hash, String)] The updated booking and API Request ID. | ||
def confirm_booking(booking_id:, request_body:, query_params:) | ||
put( | ||
path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}", | ||
request_body: request_body, | ||
query_params: query_params | ||
) | ||
end | ||
|
||
# Delete a booking. | ||
# @param booking_id [String] The id of the booking to delete. | ||
# @param query_params [Hash, nil] Query params to pass to the request. | ||
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation. | ||
def destroy(booking_id:, query_params:) | ||
_, request_id = delete( | ||
path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}", | ||
query_params: query_params | ||
) | ||
|
||
[true, request_id] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "resource" | ||
require_relative "../handler/api_operations" | ||
|
||
module Nylas | ||
# Nylas Scheduler Configurations API | ||
class Configurations < Resource | ||
include ApiOperations::Get | ||
include ApiOperations::Post | ||
include ApiOperations::Put | ||
include ApiOperations::Delete | ||
|
||
# Return all Scheduler Configurations. | ||
# | ||
# @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, String)] The list of configurations, API Request ID, | ||
# and next cursor. | ||
def list(identifier:, query_params: nil) | ||
get_list( | ||
path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations", | ||
query_params: query_params | ||
) | ||
end | ||
|
||
# Return a Configuration. | ||
# | ||
# @param identifier [String] Grant ID or email account to query. | ||
# @param configuration_id [String] The id of the configuration to return. | ||
# @return [Array(Hash, String)] The configuration and API request ID. | ||
def find(identifier:, configuration_id:) | ||
get( | ||
path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations/#{configuration_id}" | ||
) | ||
end | ||
|
||
# Create a configuration. | ||
# | ||
# @param identifier [String] Grant ID or email account in which to create the object. | ||
# @param request_body [Hash] The values to create the configuration with. | ||
# @return [Array(Hash, String)] The created configuration and API Request ID. | ||
def create(identifier:, request_body:) | ||
post( | ||
path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations", | ||
request_body: request_body | ||
) | ||
end | ||
|
||
# Update a configuration. | ||
# | ||
# @param identifier [String] Grant ID or email account in which to update an object. | ||
# @param configuration_id [String] The id of the configuration to update. | ||
# @param request_body [Hash] The values to update the configuration with | ||
# @return [Array(Hash, String)] The updated configuration and API Request ID. | ||
def update(identifier:, configuration_id:, request_body:) | ||
put( | ||
path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations/#{configuration_id}", | ||
request_body: request_body | ||
) | ||
end | ||
|
||
# Delete a configuration. | ||
# | ||
# @param identifier [String] Grant ID or email account from which to delete an object. | ||
# @param configuration_id [String] The id of the configuration to delete. | ||
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation. | ||
def destroy(identifier:, configuration_id:) | ||
_, request_id = delete( | ||
path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations/#{configuration_id}" | ||
) | ||
|
||
[true, request_id] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "./configurations" | ||
require_relative "./sessions" | ||
require_relative "./bookings" | ||
require_relative "./availability" | ||
|
||
module Nylas | ||
# Nylas Scheduler API | ||
# This class provides access to the Scheduler resources, including | ||
# configurations, bookings, sessions, and availability. | ||
# | ||
# @attr_reader [Nylas::Configurations] configurations The Scheduler configurations resource for your | ||
# Nylas application. | ||
# @attr_reader [Nylas::Bookings] bookings The Scheduler bookings resource for your | ||
# Nylas application. | ||
# @attr_reader [Nylas::Sessions] sessions The Scheduler sessions resource for your | ||
# Nylas application. | ||
# @attr_reader [Nylas::Availability] availability The Scheduler availability resource for your | ||
# Nylas application. | ||
class Scheduler | ||
attr_reader :configurations, :sessions, :bookings, :availability | ||
|
||
# Initializes the Scheduler class. | ||
# | ||
# @param api_client [APIClient] The Nylas API client instance for making requests. | ||
def initialize(api_client) | ||
@api_client = api_client | ||
@configurations = Configurations.new(@api_client) | ||
@bookings = Bookings.new(@api_client) | ||
@sessions = Sessions.new(@api_client) | ||
@availability = Availability.new(@api_client) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "resource" | ||
require_relative "../handler/api_operations" | ||
|
||
module Nylas | ||
# Nylas Messages API | ||
class Sessions < Resource | ||
include ApiOperations::Post | ||
include ApiOperations::Delete | ||
|
||
# Create a session for a configuration. | ||
# @param request_body [Hash] The values to create a configuration sessions. | ||
# @return [Array(Hash, String)] The created configuration and API Request ID. | ||
def create(request_body:) | ||
post( | ||
path: "#{api_uri}/v3/scheduling/sessions", | ||
request_body: request_body | ||
) | ||
end | ||
|
||
# Delete a session for a configuration. | ||
# @param session_id [String] The id of the session to delete. | ||
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation. | ||
def destroy(session_id:) | ||
_, request_id = delete( | ||
path: "#{api_uri}/v3/scheduling/sessions/#{session_id}" | ||
) | ||
|
||
[true, request_id] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
describe Nylas::Availability do | ||
let(:availability) { described_class.new(client) } | ||
let(:response) do | ||
[{ | ||
"emails": ["[email protected]"], | ||
"start_time": 1659367800, | ||
"end_time": 1659369600 | ||
}, | ||
{ | ||
"emails": ["[email protected]"], | ||
"start_time": 1659376800, | ||
"end_time": 1659378600 | ||
}] | ||
end | ||
|
||
describe "#list" do | ||
let(:list_response) do | ||
response | ||
end | ||
|
||
it "calls the get method with the correct parameters" do | ||
query_params = { "start_time": 1659376800, "end_time": 1659369600, | ||
configuration_id: "confifiguration-123" } | ||
path = "#{api_uri}/v3/scheduling/availability" | ||
allow(availability).to receive(:get_list) | ||
.with(path: path, query_params: query_params) | ||
.and_return(list_response) | ||
|
||
availability_response = availability.list(query_params: query_params) | ||
expect(availability_response).to eq(list_response) | ||
end | ||
end | ||
end |
Oops, something went wrong.