Class: Checkoff::Internal::SearchUrl::SimpleParamConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/checkoff/internal/search_url/simple_param_converter.rb

Overview

Convert simple parameters - ones where the param name itself doesn’t encode any parameters’

Instance Method Summary collapse

Constructor Details

#initialize(simple_url_params:) ⇒ SimpleParamConverter



224
225
226
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 224

def initialize(simple_url_params:)
  @simple_url_params = simple_url_params
end

Instance Method Details

#convertHash{String => String}



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 229

def convert
  # @type [Array<Array(String, String)>]
  arr_of_tuples = simple_url_params.to_a.flat_map do |key, values|
    # @type
    entry = convert_arg(key, values).each_slice(2).to_a
    entry
  end
  # @type [Hash{String => String}]
  out = T.cast(arr_of_tuples.to_h, T::Hash[String, String])
  unless out.include? 'sort_by'
    # keep results consistent between calls; API using default
    # sort_by does not seem to be.
    out['sort_by'] = 'created_at'
  end
  out
end