Module: PlatformAPI

Defined in:
lib/platform-api.rb,
lib/platform-api/client.rb,
lib/platform-api/version.rb

Overview

Ruby HTTP client for the Heroku API.

Constant Summary collapse

VERSION =
'0.0.2'

Class Method Summary collapse

Class Method Details

.connect(username, token) ⇒ Object

Get a client configured with the specified username and token.



3
4
5
6
7
8
9
10
11
# File 'lib/platform-api/client.rb', line 3

def self.connect(username, token)
  url = "https://#{username}:#{token}@api.heroku.com"
  default_headers = {'Accept' => 'application/vnd.heroku+json; version=3'}
  cache = Moneta.new(:File, dir: "#{Dir.home}/.heroku/platform-api")
  options = {default_headers: default_headers, cache: cache}
  schema_json = File.read("#{File.dirname(__FILE__)}/schema.json")
  schema = Heroics::Schema.new(MultiJson.decode(schema_json))
  Heroics.client_from_schema(schema, url, options)
end