Module: DaisybillApi::Data::Url

Defined in:
lib/daisybill_api/data/url.rb

Constant Summary collapse

DEFAULT_PATH =
"/api/v1"

Class Method Summary collapse

Class Method Details

.build(path, params = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/daisybill_api/data/url.rb', line 9

def build(path, params = {})
  port = DaisybillApi.configuration.port
  builder = port == 443 ? URI::HTTPS : URI::HTTP
  builder.build({
      host: DaisybillApi.configuration.host,
      port: port,
      path: "#{DEFAULT_PATH}#{path}",
      query: to_query(params)
    })
end

.to_query(hash) ⇒ Object



20
21
22
# File 'lib/daisybill_api/data/url.rb', line 20

def to_query(hash)
  URI.encode_www_form hash
end