diff --git a/CHANGELOG.md b/CHANGELOG.md index 82ef0f21..89f80172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### Unreleased +* Documented `tentative_as_busy` support in the `Calendars#get_free_busy` request body, consistent with other Nylas SDKs + ### [6.8.0] * Added Policies resource for managing application policies * Added Rules resource for managing inbox rules and listing rule evaluations diff --git a/lib/nylas/resources/calendars.rb b/lib/nylas/resources/calendars.rb index d06b945d..297e8ca2 100644 --- a/lib/nylas/resources/calendars.rb +++ b/lib/nylas/resources/calendars.rb @@ -90,8 +90,13 @@ def get_availability(request_body:) # Get the free/busy schedule for a list of email addresses. # - # @param identifier [str] The identifier of the grant to act upon. - # @param request_body [Hash] Request body to pass to the request. + # @param identifier [String] The identifier of the grant to act upon. + # @param request_body [Hash] Request body to pass to the request. Supported keys: + # - `:start_time` [Integer] Unix timestamp for the start time to check free/busy for. + # - `:end_time` [Integer] Unix timestamp for the end time to check free/busy for. + # - `:emails` [Array] List of email addresses to check free/busy for. + # - `:tentative_as_busy` [Boolean, nil] When set to `false`, treats tentative calendar events as + # `busy: false`. Only applicable for Microsoft and EWS calendar providers. Defaults to `true`. # @return [Array(Array(Hash), String)] The free/busy response. def get_free_busy(identifier:, request_body:) post( diff --git a/spec/nylas/resources/calendars_spec.rb b/spec/nylas/resources/calendars_spec.rb index 31bd0075..c6b207a0 100644 --- a/spec/nylas/resources/calendars_spec.rb +++ b/spec/nylas/resources/calendars_spec.rb @@ -251,5 +251,23 @@ calendars.get_free_busy(identifier: identifier, request_body: request_body) end + + it "forwards the tentative_as_busy field in the request body" do + identifier = "abc-123-grant-id" + request_body = { + start_time: 1614556800, + end_time: 1614643200, + emails: ["test@gmail.com"], + tentative_as_busy: false + } + + allow(calendars).to receive(:post) + .with(path: "#{api_uri}/v3/grants/#{identifier}/calendars/free-busy", request_body: request_body) + + calendars.get_free_busy(identifier: identifier, request_body: request_body) + + expect(calendars).to have_received(:post) + .with(path: "#{api_uri}/v3/grants/#{identifier}/calendars/free-busy", request_body: request_body) + end end end