Class: Insightly2::Utils::UrlHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/insightly2/utils/url_helper.rb

Class Method Summary collapse

Class Method Details

.build_url(path: nil, params: nil) ⇒ UrlHelper

Build a URL with a querystring containing optional params if supplied.

Parameters:

  • path (UrlHelper) (defaults to: nil)

    The name of the resource path as per the URL e.g. contacts.

  • params (Hash) (defaults to: nil)

    A hash of params we’re turning into a querystring.

Returns:

  • (UrlHelper)

    The URL of the resource with required params.



8
9
10
11
12
13
14
# File 'lib/insightly2/utils/url_helper.rb', line 8

def self.build_url(path: nil, params: nil)
  params.delete_if {|k,v| v.blank?}
  params = params.to_query
  query = path
  query << ("?" + params) unless params.blank?
  query
end