File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ module Typesense
4+ class SynonymSet
5+ def initialize ( synonym_set_name , api_call )
6+ @synonym_set_name = synonym_set_name
7+ @api_call = api_call
8+ end
9+
10+ def retrieve
11+ @api_call . get ( endpoint_path )
12+ end
13+
14+ def delete
15+ @api_call . delete ( endpoint_path )
16+ end
17+
18+ private
19+
20+ def endpoint_path
21+ "#{ SynonymSets ::RESOURCE_PATH } /#{ URI . encode_www_form_component ( @synonym_set_name ) } "
22+ end
23+ end
24+ end
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ module Typesense
4+ class SynonymSets
5+ RESOURCE_PATH = '/synonym_sets'
6+
7+ def initialize ( api_call )
8+ @api_call = api_call
9+ @synonym_sets = { }
10+ end
11+
12+ def upsert ( synonym_set_name , params )
13+ @api_call . put ( endpoint_path ( synonym_set_name ) , params )
14+ end
15+
16+ def retrieve
17+ @api_call . get ( endpoint_path )
18+ end
19+
20+ def []( synonym_set_name )
21+ @synonym_sets [ synonym_set_name ] ||= SynonymSet . new ( synonym_set_name , @api_call )
22+ end
23+
24+ private
25+
26+ def endpoint_path ( operation = nil )
27+ "#{ RESOURCE_PATH } #{ "/#{ URI . encode_www_form_component ( operation ) } " unless operation . nil? } "
28+ end
29+ end
30+ end
You can’t perform that action at this time.
0 commit comments