Module: NationBuilder::Utils::UrlBuilder
- Defined in:
- lib/nationbuilder/utils.rb
Class Method Summary collapse
Class Method Details
.call(nation, path) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/nationbuilder/utils.rb', line 5 def call(nation, path) url_string = path.include?("http") ? path : "https://#{nation[:slug]}.nationbuilder.com" + path uri = URI.parse(url_string) existing_query = URI.decode_www_form(String(uri.query)).to_h new_query_ar = existing_query.merge("token" => nation[:token]).to_a uri.query = URI.encode_www_form(new_query_ar) uri.to_s end |