Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

### Unreleased
* Treat 207 Multi-Status responses as successful, so a response that carries partial results is returned instead of raising an error
* Documented `tracking_options.domain_name` hash support for custom link and open tracking hostnames. See the [message tracking documentation](https://developer.nylas.com/docs/v3/email/message-tracking/)
* Documented Contact `metadata` and `metadata_pair` hashes, and added `contact.updated` and `contact.deleted` webhook trigger constants

Expand Down
2 changes: 1 addition & 1 deletion lib/nylas/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ def initialize(url, timeout)
end
end

HTTP_SUCCESS_CODES = [200, 201, 202, 302].freeze
HTTP_SUCCESS_CODES = [200, 201, 202, 207, 302].freeze
end
28 changes: 28 additions & 0 deletions spec/nylas/handler/http_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,21 @@ class TestHttpClient
"https://test.api.nylas.com/foo")
end.not_to raise_error
end

it "does not raise an error for a 207 Multi-Status response" do
response = {
request_id: "request-id",
data: {
recording: { url: "https://test.storage/recording.mp4" },
errors: [{ artifact: "summary", code: "generation_failed" }]
}
}

expect do
http_client.send(:handle_failed_response, 207, response,
"https://test.api.nylas.com/foo")
end.not_to raise_error
end
end

describe "#parse_json_evaluate_error" do
Expand All @@ -719,6 +734,19 @@ class TestHttpClient
"https://test.api.nylas.com/foo", "application/json")).to eq(response)
end

it "returns the parsed response for a 207 Multi-Status response" do
response = {
request_id: "request-id",
data: {
recording: { url: "https://test.storage/recording.mp4" },
errors: [{ artifact: "summary", code: "generation_failed" }]
}
}

expect(http_client.send(:parse_json_evaluate_error, 207, response.to_json,
"https://test.api.nylas.com/foo", "application/json")).to eq(response)
end

it "raises a Nylas::JsonParseError if the response is not valid JSON" do
response = "foo"

Expand Down
Loading