Class: DNSimpler::HTTP

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/dnsimpler/http.rb

Class Method Summary collapse

Class Method Details

.base_optionsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dnsimpler/http.rb', line 7

def self.base_options
  opts = {
    base_uri: DNSimpler.base_uri,
    format: :json,
    headers: {
      'Accept' => 'application/json',
      'User-Agent' => "dnsimpler/#{DNSimpler::VERSION}",
      'X-DNSimple-Token' => "#{DNSimpler.username}:#{DNSimpler.token}"
    }
  }

  unless DNSimpler.http_proxy.nil?
    proxy = DNSimpler.http_proxy
    opts[:http_proxy_addr] = proxy[:addr]
    opts[:http_proxy_port] = proxy[:port]
    opts[:http_proxy_user] = proxy[:user]
    opts[:http_proxy_pass] = proxy[:pass]
  end

  puts "Base Options: #{opts}" if DNSimpler.debug

  return opts
end