Class: Checkoff::Internal::SearchUrl::Parser

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

Overview

Parse Asana search URLs into parameters suitable to pass into the /workspaces/workspace_gid/tasks/search endpoint

Instance Method Summary collapse

Constructor Details

#initialize(_deps = {}) ⇒ Parser

Returns a new instance of Parser.

Parameters:

  • _deps (Hash) (defaults to: {})


20
21
22
# File 'lib/checkoff/internal/search_url/parser.rb', line 20

def initialize(_deps = {})
  # allow dependencies to be passed in by tests
end

Instance Method Details

#convert_params(url) ⇒ Array(Hash{String => String}, Array)

Parameters:

  • url (String)

Returns:

  • (Array(Hash{String => String}, Array))


26
27
28
29
30
31
32
33
34
35
# File 'lib/checkoff/internal/search_url/parser.rb', line 26

def convert_params(url)
  url_params = CGI.parse(URI.parse(url).query)
  custom_field_params, date_url_params, simple_url_params = partition_url_params(url_params)
  custom_field_args, custom_field_task_selector = convert_custom_field_params(custom_field_params)
  date_url_args, date_task_selector = convert_date_params(date_url_params)
  simple_url_args = convert_simple_params(simple_url_params)
  # raise 'merge these things'
  [ResultsMerger.merge_args(custom_field_args, date_url_args, simple_url_args),
   ResultsMerger.merge_task_selectors(date_task_selector, custom_field_task_selector)]
end