Sha256: 94b31a6edbbc600c1830894bf6f634ee1f481608f3a266813473f564b7dc7b74
Contents?: true
Size: 579 Bytes
Versions: 1
Compression:
Stored size: 579 Bytes
Contents
module BlogApi class Request class RequestError < StandardError; end require 'httparty' require 'json' BASE_URL = 'https://k-blog0130.herokuapp.com/api/v2/'.freeze class << self def get(path, options: { format: :plain }) url = "#{BASE_URL}/#{path}" result = HTTParty.get(url, options) raise RequestError unless result.response.code == '200' json_parse(result) end private def json_parse(result, options: { symbolize_names: true }) JSON.parse(result, options) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
blog_api-1.0.0 | lib/blog_api/request.rb |