From 2a8163b16517a81f10acb69fd31925687700c196 Mon Sep 17 00:00:00 2001 From: Dan Wentworth Date: Thu, 15 Dec 2022 16:19:09 +0000 Subject: [PATCH] Adds a conversations/search endpoint --- README.md | 5 ++++- lib/frontapp/client/conversations.rb | 5 +++++ spec/conversations_spec.rb | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 871a494..cf9b341 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,9 @@ note = client.add_contact_note!("ctc_55c8c149", { # Get all conversations conversations = client.conversations +# Search conversations +conversations = client.search_conversations("is:assigned before:1649974320") + # Get a specific conversation converstation = client.get_conversation("cnv_55c8c149") @@ -434,4 +437,4 @@ Special thanks to: - [langsharpe](https://github.com/langsharpe) - [thechrisoshow](https://github.com/thechrisoshow) - [feolea](https://github.com/feolea) -- [jefferal1995](https://github.com/jefferal1995) \ No newline at end of file +- [jefferal1995](https://github.com/jefferal1995) diff --git a/lib/frontapp/client/conversations.rb b/lib/frontapp/client/conversations.rb index 1e76c23..3d34c14 100644 --- a/lib/frontapp/client/conversations.rb +++ b/lib/frontapp/client/conversations.rb @@ -6,6 +6,11 @@ def conversations(params = {}) list("conversations", params) end + def search_conversations(query, params = {}) + encoded_query = URI.encode(query) + list("conversations/search/#{encoded_query}", params) + end + # Parameters # Name Type Description # ------------------------------------ diff --git a/spec/conversations_spec.rb b/spec/conversations_spec.rb index aca7c15..408280a 100644 --- a/spec/conversations_spec.rb +++ b/spec/conversations_spec.rb @@ -540,6 +540,14 @@ frontapp.conversations end + it "can search conversations" do + query = "is:assigned before:1649974320" + stub_request(:get, "#{base_url}/conversations/search/#{URI.encode(query)}"). + with( headers: headers). + to_return(status: 200, body: all_conversations_response) + frontapp.search_conversations(query) + end + it "can get a specific conversation" do stub_request(:get, "#{base_url}/conversations/#{conversation_id}"). with( headers: headers).