class RenderAPI::Endpoint
Constants
- HOST
- VERSION
Attributes
api_key[R]
Public Class Methods
new(api_key)
click to toggle source
# File lib/render_api/endpoint.rb, line 12 def initialize(api_key) @api_key = api_key end
Public Instance Methods
get(path, params: nil)
click to toggle source
# File lib/render_api/endpoint.rb, line 16 def get(path, params: nil) request(:get, path, params: params) end
post(path, body: nil)
click to toggle source
# File lib/render_api/endpoint.rb, line 20 def post(path, body: nil) request(:post, path, body: body) end
Private Instance Methods
http()
click to toggle source
# File lib/render_api/endpoint.rb, line 28 def http HTTP .auth("Bearer #{api_key}") .headers("Accept" => "application/json") end
request(verb, path, body: nil, params: nil)
click to toggle source
# File lib/render_api/endpoint.rb, line 34 def request(verb, path, body: nil, params: nil) Response.new http.request(verb, url_for(path), body: body, params: params) end
url_for(path)
click to toggle source
# File lib/render_api/endpoint.rb, line 38 def url_for(path) "#{HOST}#{VERSION}#{path}" end