Module: Waqi::Resource::HttpRequest

Included in:
Client
Defined in:
lib/waqi/resources/http_request.rb

Instance Method Summary collapse

Instance Method Details

#default_url(url) ⇒ Object



15
16
17
# File 'lib/waqi/resources/http_request.rb', line 15

def default_url(url)
    url+"?token=#{@api_key}"
end

#get(url, params: {}, headers: {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/waqi/resources/http_request.rb', line 4

def get(url, params: {}, headers: {})
    begin
        response = @connection.get(default_url(url), params, headers)
    rescue Faraday::Error => e
        e.response[:status]
        e.response[:body]
    end

    response.body
end