class BB8::Voltos::API

Constants

DOMAIN
ENDPOINT
VERSION

Public Instance Methods

create_bundle(name) click to toggle source
# File lib/bb8/voltos/api.rb, line 18
def create_bundle(name)
  JSON.parse connection.post("#{VERSION}/bundles", {
    :name       => name,
    :token_name => 'BB8'
  }).body
end
get(path) click to toggle source
# File lib/bb8/voltos/api.rb, line 6
def get(path)
  JSON.parse connection.get("#{VERSION}/#{path}").body
end
post(path, params) click to toggle source
# File lib/bb8/voltos/api.rb, line 14
def post(path, params)
  JSON.parse connection.post("#{VERSION}/#{path}", params).body
end
put(path, params) click to toggle source
# File lib/bb8/voltos/api.rb, line 10
def put(path, params)
  JSON.parse connection.put("#{VERSION}/#{path}", params).body
end

Private Instance Methods

configuration() click to toggle source
# File lib/bb8/voltos/api.rb, line 27
def configuration
  @configuration ||= JSON.parse(
    File.read(File.expand_path('~/.voltos/config.json'))
  )
end
connection() click to toggle source
# File lib/bb8/voltos/api.rb, line 33
def connection
  @connection ||= Faraday.new(:url => DOMAIN) do |faraday|
    faraday.request :url_encoded
    faraday.adapter Faraday.default_adapter

    faraday.headers['User-Agent']    = "BB8/#{BB8::VERSION}"
    faraday.headers['Authorization'] = "Token token=#{token}"
  end
end
token() click to toggle source
# File lib/bb8/voltos/api.rb, line 43
def token
  configuration['auths']["#{ENDPOINT}"]['auth']
end