Method: Toolshed::Client.base_options

Defined in:
lib/toolshed/client.rb

.base_optionsObject



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/toolshed/client.rb', line 176

def self.base_options
  options = {
    :format => :json,
    :headers => { 'Accept' => 'application/json', 'User-Agent' => "toolshed-ruby/#{Toolshed::VERSION}" },
  }

  if http_proxy
    options.merge!(
      :http_proxyaddr => self.http_proxy[:addr],
      :http_proxyport => self.http_proxy[:port]
    )
  end

  if password
    options[:basic_auth] = { :username => username, :password => password }
  else
    raise Error, 'A password is required for all API requests.'
  end

  options
end