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