From d3ce3a3d4033c05224ae58311858ab60ed56d07a Mon Sep 17 00:00:00 2001 From: kraju3 Date: Tue, 23 Jul 2024 22:02:13 -0500 Subject: [PATCH 1/3] Adding support for query_params for messages endpoint --- lib/nylas/resources/messages.rb | 12 ++++++++---- spec/nylas/resources/messages_spec.rb | 10 ++++++---- 2 files changed, 14 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..7d731899 100644 --- a/spec/nylas/resources/messages_spec.rb +++ b/spec/nylas/resources/messages_spec.rb @@ -66,12 +66,13 @@ 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, message_id: message_id, 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 +88,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 From 23f416a125ac0ca4a58f06712a11cd9338ea0da9 Mon Sep 17 00:00:00 2001 From: kraju3 Date: Wed, 24 Jul 2024 08:12:19 -0500 Subject: [PATCH 2/3] Fix tests --- spec/nylas/resources/messages_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/nylas/resources/messages_spec.rb b/spec/nylas/resources/messages_spec.rb index 7d731899..ca8e4b5f 100644 --- a/spec/nylas/resources/messages_spec.rb +++ b/spec/nylas/resources/messages_spec.rb @@ -69,7 +69,7 @@ query_params = { fields: "include_headers" } path = "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}" allow(messages).to receive(:get) - .with(path: path, message_id: message_id, query_params: query_params) + .with(path: path, query_params: query_params) .and_return(response) message_response = messages.find(identifier: identifier, message_id: message_id, query_params: query_params) From 5a8edb65dedcdd5aeffbdb79d052e347b33544a0 Mon Sep 17 00:00:00 2001 From: kraju3 Date: Wed, 24 Jul 2024 08:30:53 -0500 Subject: [PATCH 3/3] Fixing tests --- spec/nylas/resources/messages_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/nylas/resources/messages_spec.rb b/spec/nylas/resources/messages_spec.rb index ca8e4b5f..c1ec75b4 100644 --- a/spec/nylas/resources/messages_spec.rb +++ b/spec/nylas/resources/messages_spec.rb @@ -72,7 +72,8 @@ .with(path: path, query_params: query_params) .and_return(response) - message_response = messages.find(identifier: identifier, message_id: message_id, query_params: query_params) + message_response = messages.find(identifier: identifier, message_id: message_id, + query_params: query_params) expect(message_response).to eq(response) end