Class: Checkoff::Internal::SearchUrl::Parser
- Inherits:
-
Object
- Object
- Checkoff::Internal::SearchUrl::Parser
- 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
- #convert_params(url) ⇒ Array(Hash<String, String>, Hash<String, String>)
-
#initialize(_deps = {}) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(_deps = {}) ⇒ Parser
Returns a new instance of Parser.
19 20 21 |
# File 'lib/checkoff/internal/search_url/parser.rb', line 19 def initialize(_deps = {}) # allow dependencies to be passed in by tests end |
Instance Method Details
#convert_params(url) ⇒ Array(Hash<String, String>, Hash<String, String>)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/checkoff/internal/search_url/parser.rb', line 25 def convert_params(url) url_params = CGI.parse(URI.parse(url).query) # @type custom_field_params [Hash<String, Array<String>>] # @type date_url_params [Hash<String, Array<String>>] # @type simple_url_params [Hash<String, Array<String>>] # @sg-ignore custom_field_params, date_url_params, simple_url_params = partition_url_params(url_params) # @type custom_field_args [Hash<String, String>] # @type custom_field_task_selector [Hash<String, String>] # @sg-ignore custom_field_args, custom_field_task_selector = convert_custom_field_params(custom_field_params) # @type date_args [Hash<String, String>] # @type date_task_selector [Hash<String, String>] # @sg-ignore 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 |