Class: RestClient
- Inherits:
-
Object
- Object
- RestClient
- Includes:
- Singleton
- Defined in:
- lib/nesstar-api/rest-client.rb
Defined Under Namespace
Classes: ServerError
Instance Method Summary collapse
Instance Method Details
#get_binary(path) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nesstar-api/rest-client.rb', line 27 def get_binary(path) uri = get_uri(path) Net::HTTP.start(uri.host, uri.port) do | http | response = http.get(uri.request_uri) if response.is_a? Net::HTTPServerError raise ServerError, parse_server_error(response.body) end yield(response.body) end end |
#get_values(path) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nesstar-api/rest-client.rb', line 16 def get_values(path) uri = get_uri(path) response = Net::HTTP.get_response uri if response.is_a? Net::HTTPServerError raise ServerError, parse_server_error(response.body) end json = JSON.parse response.body json['payload'] end |
#init(url) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/nesstar-api/rest-client.rb', line 9 def init(url) unless url =~ /\// url = url + '/' end @@url = url end |