class Conjure::DigitalOcean::Account
Public Class Methods
new(options)
click to toggle source
# File lib/conjure/digital_ocean/account.rb, line 7 def initialize(options) @token = options[:token] end
Public Instance Methods
get(path)
click to toggle source
# File lib/conjure/digital_ocean/account.rb, line 11 def get(path) request path, :method => :get end
post(path, data = {})
click to toggle source
# File lib/conjure/digital_ocean/account.rb, line 15 def post(path, data = {}) request path, :method => :post, :data => JSON.unparse(data) end
Private Instance Methods
endpoint()
click to toggle source
# File lib/conjure/digital_ocean/account.rb, line 34 def endpoint "https://api.digitalocean.com/v2/" end
headers()
click to toggle source
# File lib/conjure/digital_ocean/account.rb, line 27 def headers { "Authorization" => "Bearer #{@token}", "Content-Type" => "application/json", } end
request(path, options)
click to toggle source
# File lib/conjure/digital_ocean/account.rb, line 21 def request(path, options) url = endpoint + path options = options.merge :headers => headers JSON.parse HttpRequest.new(url, options).data end