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

Returns a new instance of SimpleParamConverter.

Parameters:

  • simple_url_params (Hash<String, Array<String>>)

    the simple params



178
179
180
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 178

def initialize(simple_url_params:)
  @simple_url_params = simple_url_params
end

Instance Method Details

#convertHash<String, String>

Returns the converted params.

Returns:

  • (Hash<String, String>)

    the converted params



183
184
185
186
187
188
189
190
191
192
193
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 183

def convert
  out = simple_url_params.to_a.flat_map do |key, values|
    convert_arg(key, values).each_slice(2).to_a
  end.to_h
  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