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

Adding support for query_params for messages endpoint #480

Merged
merged 3 commits into from
Jul 25, 2024
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
12 changes: 8 additions & 4 deletions lib/nylas/resources/messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ def list(identifier:, query_params: nil)
#
# @param identifier [String] Grant ID or email account to query.
# @param message_id [String] The id of the message to return.
# @param query_params [Hash, nil] Query params to pass to the request.
# @return [Array(Hash, String)] The message and API request ID.
def find(identifier:, message_id:)
def find(identifier:, message_id:, query_params: nil)
get(
path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}"
path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}",
query_params: query_params
)
end

Expand All @@ -50,11 +52,13 @@ def find(identifier:, message_id:)
# @param identifier [String] Grant ID or email account in which to update an object.
# @param message_id [String] The id of the message to update.
# @param request_body [Hash] The values to update the message with
# @param query_params [Hash, nil] Query params to pass to the request.
# @return [Array(Hash, String)] The updated message and API Request ID.
def update(identifier:, message_id:, request_body:)
def update(identifier:, message_id:, request_body:, query_params: nil)
put(
path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}",
request_body: request_body
request_body: request_body,
query_params: query_params
)
end

Expand Down
11 changes: 7 additions & 4 deletions spec/nylas/resources/messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@
it "calls the get method with the correct parameters" do
identifier = "abc-123-grant-id"
message_id = "5d3qmne77v32r8l4phyuksl2x"
query_params = { fields: "include_headers" }
path = "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}"
allow(messages).to receive(:get)
.with(path: path)
.with(path: path, query_params: query_params)
.and_return(response)

message_response = messages.find(identifier: identifier, message_id: message_id)
message_response = messages.find(identifier: identifier, message_id: message_id,
query_params: query_params)

expect(message_response).to eq(response)
end
Expand All @@ -87,13 +89,14 @@
folders: ["folder-123"],
metadata: { foo: "bar" }
}
query_params = { fields: "include_headers" }
path = "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}"
allow(messages).to receive(:put)
.with(path: path, request_body: request_body)
.with(path: path, request_body: request_body, query_params: query_params)
.and_return(response)

message_response = messages.update(identifier: identifier, message_id: message_id,
request_body: request_body)
request_body: request_body, query_params: query_params)

expect(message_response).to eq(response)
end
Expand Down
Loading