Sha256: bd3f8bbe936d031656c5027c45da0bf9602acf6a7fab877571c5ba819cdc4cd1

Contents?: true

Size: 618 Bytes

Versions: 4

Compression:

Stored size: 618 Bytes

Contents

# frozen_string_literal: true

module Typesense
  class Presets
    RESOURCE_PATH = '/presets'

    def initialize(api_call)
      @api_call = api_call
      @presets = {}
    end

    def upsert(preset_name, params)
      @api_call.put(endpoint_path(preset_name), params)
    end

    def retrieve
      @api_call.get(endpoint_path)
    end

    def [](preset_name)
      @presets[preset_name] ||= Preset.new(preset_name, @api_call)
    end

    private

    def endpoint_path(operation = nil)
      "#{Presets::RESOURCE_PATH}#{operation.nil? ? '' : "/#{URI.encode_www_form_component(operation)}"}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
typesense-3.0.0.rc1 lib/typesense/presets.rb
typesense-2.1.0 lib/typesense/presets.rb
typesense-2.1.0.rc2 lib/typesense/presets.rb
typesense-2.1.0.rc1 lib/typesense/presets.rb