diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bbad76f..a5a47300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +### Unreleased +* Added support for scheduler APIs +* Added `query_params` field to `Folders` & `Threads` find + + ### 6.2.0 / 2024-09-24 * Added query support for folders * Added dependency on `ostruct` gem diff --git a/lib/nylas.rb b/lib/nylas.rb index b0375607..93a609d3 100644 --- a/lib/nylas.rb +++ b/lib/nylas.rb @@ -43,5 +43,6 @@ require_relative "nylas/resources/threads" require_relative "nylas/resources/redirect_uris" require_relative "nylas/resources/webhooks" +require_relative "nylas/resources/scheduler" require_relative "nylas/utils/file_utils" diff --git a/lib/nylas/client.rb b/lib/nylas/client.rb index 700d626c..d92ddc70 100644 --- a/lib/nylas/client.rb +++ b/lib/nylas/client.rb @@ -8,6 +8,7 @@ require_relative "resources/webhooks" require_relative "resources/applications" require_relative "resources/folders" +require_relative "resources/scheduler" module Nylas # Methods to retrieve data from the Nylas API as Ruby objects. @@ -117,5 +118,11 @@ def threads def webhooks Webhooks.new(self) end + + # The Scheduler resources for your Nylas application. + # @return [Nylas::Scheduler] Scheduler resources for your Nylas application. + def scheduler + Scheduler.new(self) + end end end diff --git a/lib/nylas/resources/availability.rb b/lib/nylas/resources/availability.rb new file mode 100644 index 00000000..8af639b2 --- /dev/null +++ b/lib/nylas/resources/availability.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require_relative "resource" +require_relative "../handler/api_operations" + +module Nylas + # Nylas Messages API + class Availability < Resource + include ApiOperations::Get + + # Return availabilities for a configuration. + # @param query_params [Hash, nil] Query params to pass to the request. + # @return [Array(Array(Hash), String, String)] The list of configurations, API Request ID, + # and next cursor. + def list(query_params: nil) + get_list( + path: "#{api_uri}/v3/scheduling/availability", + query_params: query_params + ) + end + end +end diff --git a/lib/nylas/resources/bookings.rb b/lib/nylas/resources/bookings.rb new file mode 100644 index 00000000..bb3f6d02 --- /dev/null +++ b/lib/nylas/resources/bookings.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +require_relative "resource" +require_relative "../handler/api_operations" + +module Nylas + # Nylas Messages API + class Bookings < Resource + include ApiOperations::Get + include ApiOperations::Post + include ApiOperations::Put + include ApiOperations::Delete + include ApiOperations::Patch + + # Return a booking. + # @param booking_id [String] The id of the booking to return. + # @param query_params [Hash, nil] Query params to pass to the request. + # @return [Array(Hash, String)] The booking and API request ID. + def find(booking_id:, query_params:) + get( + path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}", + query_params: query_params + ) + end + + # Create a booking. + # @param request_body [Hash] The values to create the booking with. + # @param query_params [Hash, nil] Query params to pass to the request. + # @return [Array(Hash, String)] The created booking and API Request ID. + def create(request_body:, query_params:) + post( + path: "#{api_uri}/v3/scheduling/bookings", + request_body: request_body, + query_params: query_params + ) + end + + # Create a booking. + # @param request_body [Hash] The values to update the booking with. + # @param booking_id [String] The id of the booking to update. + # @param query_params [Hash, nil] Query params to pass to the request. + # @return [Array(Hash, String)] The created booking and API Request ID. + def update(request_body:, booking_id:, query_params:) + patch( + path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}", + request_body: request_body, + query_params: query_params + ) + end + + # Confirm a booking. + # @param booking_id [String] The id of the booking to confirm. + # @param request_body [Hash] The values to update the booking with + # @param query_params [Hash, nil] Query params to pass to the request. + # @return [Array(Hash, String)] The updated booking and API Request ID. + def confirm_booking(booking_id:, request_body:, query_params:) + put( + path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}", + request_body: request_body, + query_params: query_params + ) + end + + # Delete a booking. + # @param booking_id [String] The id of the booking to delete. + # @param query_params [Hash, nil] Query params to pass to the request. + # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation. + def destroy(booking_id:, query_params:) + _, request_id = delete( + path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}", + query_params: query_params + ) + + [true, request_id] + end + end +end diff --git a/lib/nylas/resources/configurations.rb b/lib/nylas/resources/configurations.rb new file mode 100644 index 00000000..0d3cf6b0 --- /dev/null +++ b/lib/nylas/resources/configurations.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true + +require_relative "resource" +require_relative "../handler/api_operations" + +module Nylas + # Nylas Scheduler Configurations API + class Configurations < Resource + include ApiOperations::Get + include ApiOperations::Post + include ApiOperations::Put + include ApiOperations::Delete + + # Return all Scheduler Configurations. + # + # @param identifier [String] Grant ID or email account to query. + # @param query_params [Hash, nil] Query params to pass to the request. + # @return [Array(Array(Hash), String, String)] The list of configurations, API Request ID, + # and next cursor. + def list(identifier:, query_params: nil) + get_list( + path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations", + query_params: query_params + ) + end + + # Return a Configuration. + # + # @param identifier [String] Grant ID or email account to query. + # @param configuration_id [String] The id of the configuration to return. + # @return [Array(Hash, String)] The configuration and API request ID. + def find(identifier:, configuration_id:) + get( + path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations/#{configuration_id}" + ) + end + + # Create a configuration. + # + # @param identifier [String] Grant ID or email account in which to create the object. + # @param request_body [Hash] The values to create the configuration with. + # @return [Array(Hash, String)] The created configuration and API Request ID. + def create(identifier:, request_body:) + post( + path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations", + request_body: request_body + ) + end + + # Update a configuration. + # + # @param identifier [String] Grant ID or email account in which to update an object. + # @param configuration_id [String] The id of the configuration to update. + # @param request_body [Hash] The values to update the configuration with + # @return [Array(Hash, String)] The updated configuration and API Request ID. + def update(identifier:, configuration_id:, request_body:) + put( + path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations/#{configuration_id}", + request_body: request_body + ) + end + + # Delete a configuration. + # + # @param identifier [String] Grant ID or email account from which to delete an object. + # @param configuration_id [String] The id of the configuration to delete. + # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation. + def destroy(identifier:, configuration_id:) + _, request_id = delete( + path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations/#{configuration_id}" + ) + + [true, request_id] + end + end +end diff --git a/lib/nylas/resources/folders.rb b/lib/nylas/resources/folders.rb index 886f9469..1d021b6e 100644 --- a/lib/nylas/resources/folders.rb +++ b/lib/nylas/resources/folders.rb @@ -27,10 +27,12 @@ def list(identifier:, query_params: nil) # # @param identifier [String] Grant ID or email account to query. # @param folder_id [String] The id of the folder to return. + # @param query_params [Hash, nil] Query params to pass to the request. # @return [Array(Hash, String)] The folder and API request ID. - def find(identifier:, folder_id:) + def find(identifier:, folder_id:, query_params: nil) get( - path: "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}" + path: "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}", + query_params: query_params ) end diff --git a/lib/nylas/resources/scheduler.rb b/lib/nylas/resources/scheduler.rb new file mode 100644 index 00000000..50af898a --- /dev/null +++ b/lib/nylas/resources/scheduler.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require_relative "./configurations" +require_relative "./sessions" +require_relative "./bookings" +require_relative "./availability" + +module Nylas + # Nylas Scheduler API + # This class provides access to the Scheduler resources, including + # configurations, bookings, sessions, and availability. + # + # @attr_reader [Nylas::Configurations] configurations The Scheduler configurations resource for your + # Nylas application. + # @attr_reader [Nylas::Bookings] bookings The Scheduler bookings resource for your + # Nylas application. + # @attr_reader [Nylas::Sessions] sessions The Scheduler sessions resource for your + # Nylas application. + # @attr_reader [Nylas::Availability] availability The Scheduler availability resource for your + # Nylas application. + class Scheduler + attr_reader :configurations, :sessions, :bookings, :availability + + # Initializes the Scheduler class. + # + # @param api_client [APIClient] The Nylas API client instance for making requests. + def initialize(api_client) + @api_client = api_client + @configurations = Configurations.new(@api_client) + @bookings = Bookings.new(@api_client) + @sessions = Sessions.new(@api_client) + @availability = Availability.new(@api_client) + end + end +end diff --git a/lib/nylas/resources/sessions.rb b/lib/nylas/resources/sessions.rb new file mode 100644 index 00000000..7c392643 --- /dev/null +++ b/lib/nylas/resources/sessions.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require_relative "resource" +require_relative "../handler/api_operations" + +module Nylas + # Nylas Messages API + class Sessions < Resource + include ApiOperations::Post + include ApiOperations::Delete + + # Create a session for a configuration. + # @param request_body [Hash] The values to create a configuration sessions. + # @return [Array(Hash, String)] The created configuration and API Request ID. + def create(request_body:) + post( + path: "#{api_uri}/v3/scheduling/sessions", + request_body: request_body + ) + end + + # Delete a session for a configuration. + # @param session_id [String] The id of the session to delete. + # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation. + def destroy(session_id:) + _, request_id = delete( + path: "#{api_uri}/v3/scheduling/sessions/#{session_id}" + ) + + [true, request_id] + end + end +end diff --git a/lib/nylas/resources/threads.rb b/lib/nylas/resources/threads.rb index 7172f9ae..f251251d 100644 --- a/lib/nylas/resources/threads.rb +++ b/lib/nylas/resources/threads.rb @@ -26,10 +26,12 @@ def list(identifier:, query_params: nil) # # @param identifier [String] Grant ID or email account to query. # @param thread_id [String] The id of the thread to return. + # @param query_params [Hash, nil] Query params to pass to the request. # @return [Array(Hash, String)] The thread and API request ID. - def find(identifier:, thread_id:) + def find(identifier:, thread_id:, query_params: nil) get( - path: "#{api_uri}/v3/grants/#{identifier}/threads/#{thread_id}" + path: "#{api_uri}/v3/grants/#{identifier}/threads/#{thread_id}", + query_params: query_params ) end diff --git a/spec/nylas/resources/availability_spec.rb b/spec/nylas/resources/availability_spec.rb new file mode 100644 index 00000000..05994463 --- /dev/null +++ b/spec/nylas/resources/availability_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +describe Nylas::Availability do + let(:availability) { described_class.new(client) } + let(:response) do + [{ + "emails": ["user1@example.com"], + "start_time": 1659367800, + "end_time": 1659369600 + }, + { + "emails": ["user1@example.com"], + "start_time": 1659376800, + "end_time": 1659378600 + }] + end + + describe "#list" do + let(:list_response) do + response + end + + it "calls the get method with the correct parameters" do + query_params = { "start_time": 1659376800, "end_time": 1659369600, + configuration_id: "confifiguration-123" } + path = "#{api_uri}/v3/scheduling/availability" + allow(availability).to receive(:get_list) + .with(path: path, query_params: query_params) + .and_return(list_response) + + availability_response = availability.list(query_params: query_params) + expect(availability_response).to eq(list_response) + end + end +end diff --git a/spec/nylas/resources/bookings_spec.rb b/spec/nylas/resources/bookings_spec.rb new file mode 100644 index 00000000..6fcf3498 --- /dev/null +++ b/spec/nylas/resources/bookings_spec.rb @@ -0,0 +1,117 @@ +# frozen_string_literal: true + +describe Nylas::Bookings do + let(:bookings) { described_class.new(client) } + let(:response) do + [{ + "event_id": "eventid123", + "booking_id": "booking-123", + "title": "My test event", + "description": "test", + "organizer": { + "email": "scheduler-booking@nylas.com", + "name": "Test" + }, + "status": "booked" + }, "mock_request_id"] + end + + describe "#find" do + it "calls the get method with the correct parameters" do + booking_id = "booking-123" + path = "#{api_uri}/v3/scheduling/bookings/#{booking_id}" + allow(bookings).to receive(:get) + .with(path: path, query_params: nil) + .and_return(response) + + bookings_response = bookings.find(booking_id: booking_id, query_params: nil) + + expect(bookings_response).to eq(response) + end + end + + describe "#create" do + it "calls the post method with the correct parameters" do + request_body = { + start_time: 1730194200, + end_time: 1730196000, + participants: [ + { + email: "scheduler-booking@nylas.com" + } + ], + guest: { + name: "TEST", + email: "test@nylas.com" + } + } + path = "#{api_uri}/v3/scheduling/bookings" + allow(bookings).to receive(:post) + .with(path: path, request_body: request_body, query_params: nil) + .and_return(response) + + bookings_response = bookings.create(request_body: request_body, query_params: nil) + + expect(bookings_response).to eq(response) + end + end + + describe "#update" do + it "calls the patch method with the correct parameters" do + booking_id = "booking-123" + request_body = { + start_time: 1730194200, + end_time: 1730196000 + } + path = "#{api_uri}/v3/scheduling/bookings/#{booking_id}" + allow(bookings).to receive(:patch) + .with(path: path, request_body: request_body, query_params: nil) + .and_return(response) + + bookings_response = bookings.update( + request_body: request_body, + booking_id: booking_id, + query_params: nil + ) + + expect(bookings_response).to eq(response) + end + end + + describe "#confirm_booking" do + it "calls the put method with the correct parameters" do + booking_id = "booking-123" + request_body = { + salt: "_salt", + status: "cancelled" + } + path = "#{api_uri}/v3/scheduling/bookings/#{booking_id}" + allow(bookings).to receive(:put) + .with(path: path, request_body: request_body, query_params: nil) + .and_return(response) + + bookings_response = bookings.confirm_booking( + booking_id: booking_id, + request_body: request_body, + query_params: nil + ) + + expect(bookings_response).to eq(response) + end + end + + describe "#destroy" do + let(:delete_response) { [true, "mock_request_id"] } + + it "calls the delete method with the correct parameters" do + booking_id = "booking-123" + path = "#{api_uri}/v3/scheduling/bookings/#{booking_id}" + allow(bookings).to receive(:delete) + .with(path: path, query_params: nil) + .and_return(delete_response) + + bookings_response = bookings.destroy(booking_id: booking_id, query_params: nil) + expect(bookings_response).to eq(delete_response) + end + end +end diff --git a/spec/nylas/resources/configurations_spec.rb b/spec/nylas/resources/configurations_spec.rb new file mode 100644 index 00000000..d02bd436 --- /dev/null +++ b/spec/nylas/resources/configurations_spec.rb @@ -0,0 +1,265 @@ +# frozen_string_literal: true + +describe Nylas::Configurations do + let(:configurations) { described_class.new(client) } + let(:response) do + [{ + "id": "configuration-123", + "slug": nil, + "participants": [ + { + "email": "nylas-scheduler-1@gmail.com", + "is_organizer": true, + "name": "Nylas Scheduler", + "availability": { + "calendar_ids": [ + "primary" + ] + }, + "booking": { + "calendar_id": "nylas-scheduler-1@gmail.com" + }, + "timezone": "Europe/Amsterdam" + } + ], + "requires_session_auth": false, + "availability": { + "duration_minutes": 30, + "interval_minutes": 30, + "availability_rules": { + "availability_method": "collective", + "buffer": { + "before": 0, + "after": 0 + }, + "default_open_hours": [ + { + "days": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "exdates": nil, + "timezone": "Europe/Amsterdam", + "start": "00:15", + "end": "23:45" + } + ], + "round_robin_group_id": "" + } + }, + "event_booking": { + "title": "SDK - test", + "timezone": "Europe/Amsterdam", + "description": "", + "location": "", + "booking_type": "booking", + "conferencing": {}, + "hide_participants": nil, + "disable_emails": nil + }, + "scheduler": { + "available_days_in_future": 30, + "min_cancellation_notice": 0, + "min_booking_notice": 60, + "confirmation_redirect_url": "", + "hide_rescheduling_options": false, + "hide_cancellation_options": false, + "hide_additional_guests": false, + "cancellation_policy": "", + "email_template": { + "booking_confirmed": {} + } + }, + "appearance": nil + }, + { + "id": "configuration-456", + "slug": nil, + "participants": [ + { + "email": "nylas-scheduler-1@gmail.com", + "is_organizer": true, + "name": "Nylas Scheduler", + "availability": { + "calendar_ids": [ + "primary" + ] + }, + "booking": { + "calendar_id": "nylas-scheduler-1@gmail.com" + }, + "timezone": "Europe/Amsterdam" + } + ], + "requires_session_auth": false, + "availability": { + "duration_minutes": 30, + "availability_rules": { + "availability_method": "collective", + "buffer": { + "before": 0, + "after": 0 + }, + "default_open_hours": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5 + ], + "exdates": nil, + "timezone": "Europe/Amsterdam", + "start": "06:00", + "end": "23:00" + } + ], + "round_robin_group_id": "" + } + }, + "event_booking": { + "title": "test - 2", + "timezone": "Europe/Amsterdam", + "description": "", + "location": "", + "booking_type": "booking", + "conferencing": {}, + "hide_participants": nil, + "disable_emails": nil + }, + "scheduler": { + "available_days_in_future": 30, + "min_cancellation_notice": 0, + "min_booking_notice": 60, + "hide_rescheduling_options": false, + "hide_cancellation_options": false, + "hide_additional_guests": false, + "cancellation_policy": "", + "email_template": { + "booking_confirmed": {} + } + }, + "appearance": nil + }] + end + + describe "#list" do + let(:list_response) do + response + end + + it "calls the get method with the correct parameters" do + identifier = "grant-123" + path = "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations" + allow(configurations).to receive(:get_list) + .with(path: path, query_params: nil) + .and_return(list_response) + + configurations_response = configurations.list(identifier: identifier, query_params: nil) + expect(configurations_response).to eq(list_response) + end + end + + describe "#find" do + it "calls the get method with the correct parameters" do + identifier = "grant-123" + configuration_id = "configuration-123" + path = "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations/#{configuration_id}" + allow(configurations).to receive(:get) + .with(path: path) + .and_return(response[0]) + + configuration_response = configurations.find(identifier: identifier, configuration_id: configuration_id) + expect(configuration_response).to eq(response[0]) + end + end + + describe "#create" do + it "calls the post method with the correct parameters" do + identifier = "grant-123" + request_body = { + "requires_session_auth": false, + "participants": [ + { + name: "Test", + email: "nylas-scheduler-1@gmail.com", + is_organizer: true, + availability: { + calendar_ids: [ + "primary" + ] + }, + booking: { + calendar_id: "primary" + } + } + ], + availability: { + duration_minutes: 30 + }, + event_booking: { + title: "My test event" + } + } + path = "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations" + allow(configurations).to receive(:post) + .with(path: path, request_body: request_body) + .and_return(response[0]) + + configuration_response = configurations.create(identifier: identifier, request_body: request_body) + + expect(configuration_response).to eq(response[0]) + end + end + + describe "#update" do + let(:update_response) do + updated_data = response[0].dup + updated_data[:event_booking][:title] = "Updated Title" + updated_data + end + + it "calls the put method with the correct parameters" do + identifier = "grant-123" + configuration_id = "configuration-123" + request_body = { + event_booking: { + title: "Updated Title" + } + } + path = "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations/#{configuration_id}" + allow(configurations).to receive(:put) + .with(path: path, request_body: request_body) + .and_return(update_response) + + configuration_response = configurations.update( + identifier: identifier, + configuration_id: configuration_id, request_body: request_body + ) + + expect(configuration_response).to eq(update_response) + end + end + + describe "#destroy" do + it "calls the delete method with the correct parameters" do + identifier = "grant-123" + configuration_id = "configuration-123" + path = "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations/#{configuration_id}" + allow(configurations).to receive(:delete) + .with(path: path) + .and_return([true, "request-id-123"]) + + configuration_response = configurations.destroy(identifier: identifier, + configuration_id: configuration_id) + + expect(configuration_response).to eq([true, "request-id-123"]) + end + end +end diff --git a/spec/nylas/resources/folders_spec.rb b/spec/nylas/resources/folders_spec.rb index daa8c20a..63551aae 100644 --- a/spec/nylas/resources/folders_spec.rb +++ b/spec/nylas/resources/folders_spec.rb @@ -37,18 +37,39 @@ end describe "#find" do + let(:select_response) do + [{ + id: "5d3qmne77v32r8l4phyuksl2x", + grant_id: "abc-123-grant-id" + }, "mock_request_id"] + end + it "calls the get method with the correct parameters" do identifier = "abc-123-grant-id" folder_id = "5d3qmne77v32r8l4phyuksl2x" path = "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}" allow(folders).to receive(:get) - .with(path: path) + .with(path: path, query_params: nil) .and_return(response) folder_response = folders.find(identifier: identifier, folder_id: folder_id) expect(folder_response).to eq(response) end + + it "calls the get method with the correct query parameters" do + identifier = "abc-123-grant-id" + folder_id = "5d3qmne77v32r8l4phyuksl2x" + query_params = { select: "id,grant_id" } + path = "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}" + allow(folders).to receive(:get) + .with(path: path, query_params: query_params) + .and_return(select_response) + + folder_response = folders.find(identifier: identifier, folder_id: folder_id, query_params: query_params) + + expect(folder_response).to eq(select_response) + end end describe "#create" do diff --git a/spec/nylas/resources/sessions_spec.rb b/spec/nylas/resources/sessions_spec.rb new file mode 100644 index 00000000..0a885064 --- /dev/null +++ b/spec/nylas/resources/sessions_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +describe Nylas::Sessions do + let(:sessions) { described_class.new(client) } + let(:response) do + [{ + "session_id": "session-id-123" + }, "mock_request_id"] + end + + describe "#create" do + it "calls the post method with the correct parameters" do + request_body = { + configuration_id: "configuration-123", + time_to_live: 30 + } + path = "#{api_uri}/v3/scheduling/sessions" + allow(sessions).to receive(:post) + .with(path: path, request_body: request_body) + .and_return(response) + + sessions_response = sessions.create(request_body: request_body) + expect(sessions_response).to eq(response) + end + end + + describe "#destroy" do + it "calls the delete method with the correct parameters" do + session_id = "session-123" + path = "#{api_uri}/v3/scheduling/sessions/#{session_id}" + allow(sessions).to receive(:delete) + .with(path: path) + .and_return([true, "mock_request_id"]) + + sessions_response = sessions.destroy(session_id: session_id) + expect(sessions_response).to eq([true, "mock_request_id"]) + end + end +end diff --git a/spec/nylas/resources/threads_spec.rb b/spec/nylas/resources/threads_spec.rb index e95960d3..a03700dc 100644 --- a/spec/nylas/resources/threads_spec.rb +++ b/spec/nylas/resources/threads_spec.rb @@ -90,13 +90,26 @@ thread_id = "5d3qmne77v32r8l4phyuksl2x" path = "#{api_uri}/v3/grants/#{identifier}/threads/#{thread_id}" allow(threads).to receive(:get) - .with(path: path) + .with(path: path, query_params: nil) .and_return(response) thread_response = threads.find(identifier: identifier, thread_id: thread_id) expect(thread_response).to eq(response) end + + it "calls the get method with the correct query parameters" do + identifier = "abc-123-grant-id" + thread_id = "5d3qmne77v32r8l4phyuksl2x" + query_params = { foo: "bar" } + path = "#{api_uri}/v3/grants/#{identifier}/threads/#{thread_id}" + allow(threads).to receive(:get) + .with(path: path, query_params: query_params) + .and_return(response) + + thread_response = threads.find(identifier: identifier, thread_id: thread_id, query_params: query_params) + expect(thread_response).to eq(response) + end end describe "#update" do