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) ⇒ ::Hash[String, 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
222 223 224 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 222 def initialize(simple_url_params:) @simple_url_params = simple_url_params end |
Instance Attribute Details
#simple_url_params ⇒ Hash{String => Array<String>} (readonly)
280 281 282 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 280 def simple_url_params @simple_url_params end |
Instance Method Details
#convert ⇒ ::Hash[String, String]
@return — the converted params
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 227 def convert # @type [Array<Array(String, String)>] # @sg-ignore 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) ⇒ ::Hash[String, String]
https://developers.asana.com/docs/search-tasks-in-a-workspace @sg-ignore
@param key — the name of the search url param
@param values — the values of the search url param
@return — the converted params
270 271 272 273 274 275 276 277 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 270 def convert_arg(key, values) # @type [Class<SimpleParam::SimpleParam>] clazz = ARGS.fetch(key) # @type [SimpleParam::SimpleParam] obj = clazz.new(key:, values:) # @sg-ignore obj.convert end |