-
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.
This PR address the issue where, if round_robin is left as nil, it always yields an error. This is because the Nylas Docs were out of date for the availability endpoint. round_robin is optional, and when omitted, returns collective availability. However, sending null is not valid despite what it says in the documentation. Now, we omit the value from the json payload if the value is nil.
- Loading branch information
1 parent
03356df
commit ce61604
Showing
3 changed files
with
92 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,9 +49,6 @@ | |
start_time: 1590454800, | ||
end_time: 1590780800, | ||
emails: ["[email protected]"], | ||
buffer: 5, | ||
round_robin: "max-fairness", | ||
event_collection_id: "abc-123", | ||
free_busy: [ | ||
{ | ||
email: "[email protected]", | ||
|
@@ -74,6 +71,37 @@ | |
days: [0] | ||
} | ||
], | ||
calendars: [], | ||
buffer: 5, | ||
round_robin: "max-fairness", | ||
event_collection_id: "abc-123" | ||
) | ||
) | ||
end | ||
|
||
it "optional params are omitted when getting single availability" do | ||
api = instance_double(Nylas::API, execute: JSON.parse("{}")) | ||
calendar_collection = described_class.new(model: Nylas::Calendar, api: api) | ||
|
||
calendar_collection.availability( | ||
duration_minutes: 30, | ||
interval_minutes: 5, | ||
start_time: 1590454800, | ||
end_time: 1590780800, | ||
emails: ["[email protected]"] | ||
) | ||
|
||
expect(api).to have_received(:execute).with( | ||
method: :post, | ||
path: "/calendars/availability", | ||
payload: JSON.dump( | ||
duration_minutes: 30, | ||
interval_minutes: 5, | ||
start_time: 1590454800, | ||
end_time: 1590780800, | ||
emails: ["[email protected]"], | ||
free_busy: [], | ||
open_hours: [], | ||
calendars: [] | ||
) | ||
) | ||
|
@@ -122,7 +150,6 @@ | |
start_time: 1590454800, | ||
end_time: 1590780800, | ||
emails: [["[email protected]"], %w[[email protected] [email protected]]], | ||
buffer: 5, | ||
free_busy: [ | ||
{ | ||
email: "[email protected]", | ||
|
@@ -145,6 +172,35 @@ | |
days: [0] | ||
} | ||
], | ||
calendars: [], | ||
buffer: 5 | ||
) | ||
) | ||
end | ||
|
||
it "optional params are omitted when getting multiple availability" do | ||
api = instance_double(Nylas::API, execute: JSON.parse("{}")) | ||
calendar_collection = described_class.new(model: Nylas::Calendar, api: api) | ||
|
||
calendar_collection.consecutive_availability( | ||
duration_minutes: 30, | ||
interval_minutes: 5, | ||
start_time: 1590454800, | ||
end_time: 1590780800, | ||
emails: [["[email protected]"]] | ||
) | ||
|
||
expect(api).to have_received(:execute).with( | ||
method: :post, | ||
path: "/calendars/availability/consecutive", | ||
payload: JSON.dump( | ||
duration_minutes: 30, | ||
interval_minutes: 5, | ||
start_time: 1590454800, | ||
end_time: 1590780800, | ||
emails: [["[email protected]"]], | ||
free_busy: [], | ||
open_hours: [], | ||
calendars: [] | ||
) | ||
) | ||
|