Class: Checkoff::Internal::SearchUrl::SimpleParamConverter
- Inherits:
-
Object
- Object
- Checkoff::Internal::SearchUrl::SimpleParamConverter
- Defined in:
- lib/checkoff/internal/search_url/simple_param_converter.rb,
sig/checkoff.rbs
Overview
Convert simple parameters - ones where the param name itself doesn't encode any parameters'
Constant Summary collapse
- ARGS =
{ 'portfolios.ids' => SimpleParam::PortfoliosIds, 'any_projects.ids' => SimpleParam::AnyProjectsIds, 'not_projects.ids' => SimpleParam::NotProjectsIds, 'completion' => SimpleParam::Completion, 'not_tags.ids' => SimpleParam::NotTagsIds, 'any_tags.ids' => SimpleParam::AnyTagsIds, 'all_tags.ids' => SimpleParam::AllTagsIds, 'subtask' => SimpleParam::Subtask, 'sort' => SimpleParam::Sort, 'milestone' => SimpleParam::Milestone, 'approval' => SimpleParam::Approval, 'searched_type' => SimpleParam::SearchedType, 'locatedIn' => SimpleParam::LocatedIn, }.freeze
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#convert ⇒ ::Hash[String, String]
@return — the converted params.
- #convert_arg(key, values) ⇒ ::Array[String]
-
#initialize(simple_url_params:) ⇒ SimpleParamConverter
constructor
@param
simple_url_params— the simple params.
Constructor Details
#initialize(simple_url_params:) ⇒ SimpleParamConverter
@param simple_url_params — the simple params
232 233 234 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 232 def initialize(simple_url_params:) @simple_url_params = simple_url_params end |
Instance Attribute Details
#simple_url_params ⇒ Hash{String => Array<String>} (readonly)
289 290 291 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 289 def simple_url_params @simple_url_params end |
Instance Method Details
#convert ⇒ ::Hash[String, String]
@return — the converted params
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 237 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 |
#convert_arg(key, values) ⇒ ::Array[String]
https://developers.asana.com/docs/search-tasks-in-a-workspace
@param key — the name of the search url param
@param values — the values of the search url param
@return — the converted params, as an alternating key/value flat array
278 279 280 281 282 283 284 285 286 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 278 def convert_arg(key, values) # @type [Class<SimpleParam::SimpleParam>] # @sg-ignore Hash#fetch generic<X> leak on rbs >= 4.1.0, fix in progress upstream # https://github.com/castwide/solargraph/pull/1228 clazz = ARGS.fetch(key) # @type [SimpleParam::SimpleParam] obj = clazz.new(key:, values:) obj.convert end |