From 9e74efbdfbba04a7f26700b5691b8a841294ef95 Mon Sep 17 00:00:00 2001 From: kraju3 <35513942+kraju3@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:35:22 -0500 Subject: [PATCH] Adding support for query_params for messages endpoint (#480) Adding support for query_params to retrieve headers for messages along with field selection. select API parameter. --- lib/nylas/resources/messages.rb | 12 ++++++++---- spec/nylas/resources/messages_spec.rb | 11 +++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/nylas/resources/messages.rb b/lib/nylas/resources/messages.rb index 4465e70b..56e1e027 100644 --- a/lib/nylas/resources/messages.rb +++ b/lib/nylas/resources/messages.rb @@ -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 @@ -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 diff --git a/spec/nylas/resources/messages_spec.rb b/spec/nylas/resources/messages_spec.rb index b1dddf35..c1ec75b4 100644 --- a/spec/nylas/resources/messages_spec.rb +++ b/spec/nylas/resources/messages_spec.rb @@ -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 @@ -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