Method: Coyodlee::UriBuilder#build

Defined in:
lib/coyodlee/uri_builder.rb

#build(resource_path, query: nil, use_ssl: true) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/coyodlee/uri_builder.rb', line 12

def build(resource_path, query: nil, use_ssl: true)
  uri_builder = use_ssl ? URI::HTTPS : URI::HTTP
  revised_resource_path = if resource_path.start_with?('/')
                            resource_path.slice(1..-1)
                          else
                            resource_path
                          end
  path = [@path_prefix, @cobrand, @version, revised_resource_path]
           .compact
           .join('/')
           .prepend('/')
  uri_builder.build(host: @host, path: path, query: query)
end