Module: Booru::Request

Included in:
Client
Defined in:
lib/booru/request.rb

Constant Summary collapse

HEADERS =
{
  'User-Agent' => 'Mozilla/5.0',
}

Instance Method Summary collapse

Instance Method Details

#get(path, options = {}) ⇒ Object



9
10
11
# File 'lib/booru/request.rb', line 9

def get(path, options={})
  request(:get, path, HEADERS.merge(options))
end

#post(path, options = {}) ⇒ Object



13
14
15
# File 'lib/booru/request.rb', line 13

def post(path, options = {})
  request(:post, path, HEADERS.merge(options))
end

#request(method, path, options) ⇒ Object

Perform an HTTP request



18
19
20
21
22
23
24
25
26
27
# File 'lib/booru/request.rb', line 18

def request(method, path, options)
  case method
  when :get
    response = RestClient.get("#{@host}#{path}", options)
  when :post
    response = RestClient.post("#{@host}#{path}", options)
  end
  raise_errors(response)
  response
end