From 0a641ae149ffbbf889ebb5d8e2f84238c960aa5e Mon Sep 17 00:00:00 2001 From: Tinco Andringa Date: Thu, 7 Nov 2024 12:13:03 +0100 Subject: [PATCH] To support Ruby 3.2+, stop using the deprecated URI.encode --- lib/frontapp/client.rb | 8 ++++---- spec/client_spec.rb | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/frontapp/client.rb b/lib/frontapp/client.rb index 1c1c7ea..bd2b0fa 100644 --- a/lib/frontapp/client.rb +++ b/lib/frontapp/client.rb @@ -142,15 +142,15 @@ def format_query(params) res << q.map do |k, v| case v when Symbol, String - "q[#{k}]=#{URI.encode(v)}" + "q[#{k}]=#{URI.encode_uri_component(v)}" when Array then - v.map { |c| "q[#{k}][]=#{URI.encode(c.to_s)}" }.join("&") + v.map { |c| "q[#{k}][]=#{URI.encode_uri_component(c.to_s)}" }.join("&") else - "q[#{k}]=#{URI.encode(v.to_s)}" + "q[#{k}]=#{URI.encode_uri_component(v.to_s)}" end end end - res << params.map {|k,v| "#{k}=#{URI.encode(v.to_s)}"} + res << params.map {|k,v| "#{k}=#{URI.encode_uri_component(v.to_s)}"} res.join("&") end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index d448dca..c4e60b3 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -41,4 +41,11 @@ expect(results).to eq([result_1, result_2]) end + it "can list with params" do + stub_request(:get, "#{base_url}/conversations?page=2"). + with(headers: headers). + to_return(status: 200, body: JSON.generate(response_2)) + results = frontapp.conversations(page: 2) + expect(results).to eq([result_2]) + end end