Class: Checkoff::Internal::SearchUrl::CustomFieldParamConverter

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

Overview

Convert custom field parameters from an Asana search URL into API search arguments and Checkoff task selectors

Instance Method Summary collapse

Constructor Details

#initialize(custom_field_params:) ⇒ CustomFieldParamConverter

Returns a new instance of CustomFieldParamConverter.

Parameters:

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


13
14
15
# File 'lib/checkoff/internal/search_url/custom_field_param_converter.rb', line 13

def initialize(custom_field_params:)
  @custom_field_params = custom_field_params
end

Instance Method Details

#convertArray(Hash<String, String>, Array<[Symbol, Array]>)

Returns:

  • (Array(Hash<String, String>, Array<[Symbol, Array]>))


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/checkoff/internal/search_url/custom_field_param_converter.rb', line 18

def convert
  # @type args [Hash<String, String>]
  args = {}
  # @type task_selector [Array<[Symbol, Array]>]
  task_selector = []
  by_custom_field.each do |gid, single_custom_field_params|
    # @sg-ignore
    new_args, new_task_selector = convert_single_custom_field_params(gid,
                                                                     single_custom_field_params)

    args = ResultsMerger.merge_args(args, new_args)

    # @sg-ignore
    task_selector = ResultsMerger.merge_task_selectors(task_selector, new_task_selector)
  end
  [args, task_selector]
end