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.7'
Class Method Summary collapse
-
.connect(token) ⇒ Object
Get a client configured with the specified API token.
-
.connect_oauth(oauth_token) ⇒ Object
Get a client configured with the specified OAuth token.
Class Method Details
.connect(token) ⇒ Object
Get a client configured with the specified API token.
Always prefer ‘connect_oauth` unless there’s a very good reason you must use a non-OAuth API token.
17 18 19 20 21 22 23 24 25 |
# File 'lib/platform-api/client.rb', line 17 def self.connect(token) url = "https://:#{token}@api.heroku.com" default_headers = {'Accept' => 'application/vnd.heroku+json; version=3'} cache = Moneta.new(:File, dir: "#{Dir.home}/.heroku/platform-api") = {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, ) end |
.connect_oauth(oauth_token) ⇒ Object
Get a client configured with the specified OAuth token.
3 4 5 6 7 8 9 10 11 |
# File 'lib/platform-api/client.rb', line 3 def self.connect_oauth(oauth_token) url = "https://api.heroku.com" default_headers = {'Accept' => 'application/vnd.heroku+json; version=3'} cache = Moneta.new(:File, dir: "#{Dir.home}/.heroku/platform-api") = {default_headers: default_headers, cache: cache} schema_json = File.read("#{File.dirname(__FILE__)}/schema.json") schema = Heroics::Schema.new(MultiJson.decode(schema_json)) Heroics.oauth_client_from_schema(oauth_token, schema, url, ) end |