Skip to content

Commit 6ab5bd1

Browse files
committed
New endpoints: spellcheck, trending_searches, and related_searches.
1 parent 2c68759 commit 6ab5bd1

6 files changed

Lines changed: 2741 additions & 2430 deletions

File tree

README.md

Lines changed: 2689 additions & 2426 deletions
Large diffs are not rendered by default.

examples/Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
PATH
22
remote: ..
33
specs:
4-
podcast_api (1.0.1)
4+
podcast_api (1.1.0)
55
httparty
66

77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
httparty (0.18.1)
10+
httparty (0.20.0)
1111
mime-types (~> 3.0)
1212
multi_xml (>= 0.5.2)
1313
mime-types (3.3.1)
1414
mime-types-data (~> 3.2015)
15-
mime-types-data (3.2021.0225)
15+
mime-types-data (3.2021.0901)
1616
multi_xml (0.6.0)
1717

1818
PLATFORMS

examples/sample.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
puts "Next billing date: #{response.headers['X-Listenapi-NextBillingDate']}"
2525
end
2626

27+
# response = client.spellcheck(q: 'evergrand stok')
28+
# puts JSON.parse(response.body)
29+
30+
# response = client.fetch_related_searches(q: 'evergrande')
31+
# puts JSON.parse(response.body)
32+
33+
# response = client.fetch_trending_searches()
34+
# puts JSON.parse(response.body)
2735

2836
# response = client.typeahead(q: 'startup', show_podcasts: 1)
2937
# puts JSON.parse(response.body)

lib/podcast_api.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ def typeahead(**kwargs)
6161
return send_http_request('get', "#{@base_url}/typeahead", {query: kwargs, headers: @headers})
6262
end
6363

64+
def spellcheck(**kwargs)
65+
return send_http_request('get', "#{@base_url}/spellcheck", {query: kwargs, headers: @headers})
66+
end
67+
68+
def fetch_related_searches(**kwargs)
69+
return send_http_request('get', "#{@base_url}/related_searches", {query: kwargs, headers: @headers})
70+
end
71+
72+
def fetch_trending_searches(**kwargs)
73+
return send_http_request('get', "#{@base_url}/trending_searches", {query: kwargs, headers: @headers})
74+
end
75+
6476
def fetch_best_podcasts(**kwargs)
6577
return send_http_request('get', "#{@base_url}/best_podcasts", {query: kwargs, headers: @headers})
6678
end

lib/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module PodcastApi
4-
VERSION = "1.0.4"
4+
VERSION = "1.1.0"
55
end

tests/podcast_api_test.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,34 @@ def test_typeahead_with_mock
3333
assert response['terms'].length > 0
3434
end
3535

36+
def test_spellcheck_with_mock
37+
term = 'test123'
38+
client = PodcastApi::Client.new
39+
response = client.spellcheck(q: term)
40+
assert_equal response.request.options[:query][:q], term
41+
assert_equal response.request.http_method, Net::HTTP::Get
42+
assert_equal response.request.path.path, '/api/v2/spellcheck'
43+
assert response['tokens'].length > 0
44+
end
45+
46+
def test_related_searches_with_mock
47+
term = 'test123'
48+
client = PodcastApi::Client.new
49+
response = client.fetch_related_searches(q: term)
50+
assert_equal response.request.options[:query][:q], term
51+
assert_equal response.request.http_method, Net::HTTP::Get
52+
assert_equal response.request.path.path, '/api/v2/related_searches'
53+
assert response['terms'].length > 0
54+
end
55+
56+
def test_trending_searches_with_mock
57+
client = PodcastApi::Client.new
58+
response = client.fetch_trending_searches()
59+
assert_equal response.request.http_method, Net::HTTP::Get
60+
assert_equal response.request.path.path, '/api/v2/trending_searches'
61+
assert response['terms'].length > 0
62+
end
63+
3664
def test_fetch_best_podcasts_with_mock
3765
genre_id = 123
3866
client = PodcastApi::Client.new

0 commit comments

Comments
 (0)