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.
Defined Under Namespace
Classes: Account, AccountFeature, Addon, AddonService, App, AppFeature, AppTransfer, Build, BuildResult, Client, Collaborator, ConfigVar, Domain, Dyno, Formation, Key, LogDrain, LogSession, OauthAuthorization, OauthClient, OauthGrant, OauthToken, Organization, OrganizationApp, OrganizationAppCollaborator, OrganizationMember, Plan, RateLimit, Region, Release, SSLEndpoint, Slug, Stack
Constant Summary collapse
- VERSION =
'0.0.9'
Class Method Summary collapse
-
.connect(username, password, headers = nil) ⇒ Client
Get a Client configured to use HTTP Basic authentication.
-
.connect_oauth(oauth_token, headers = nil) ⇒ Client
Get a Client configured to use OAuth authentication.
-
.connect_token(token, headers = nil) ⇒ Client
Get a Client configured to use Token authentication.
Class Method Details
.connect(username, password, headers = nil) ⇒ Client
Get a Client configured to use HTTP Basic authentication.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/platform-api/client.rb', line 20 def self.connect(username, password, headers=nil) url = URI.parse("https://api.heroku.com") url.user = username url.password = password default_headers = {"Accept"=>"application/vnd.heroku+json; version=3"} unless headers.nil? default_headers.merge!(headers) end cache = Moneta.new(:File, dir: "#{Dir.home}/.heroics/platform-api") = { default_headers: default_headers, cache: cache } client = Heroics.client_from_schema(SCHEMA, url.to_s, ) Client.new(client) end |
.connect_oauth(oauth_token, headers = nil) ⇒ Client
Get a Client configured to use OAuth authentication.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/platform-api/client.rb', line 44 def self.connect_oauth(oauth_token, headers=nil) url = "https://api.heroku.com" default_headers = {"Accept"=>"application/vnd.heroku+json; version=3"} unless headers.nil? default_headers.merge!(headers) end cache = Moneta.new(:File, dir: "#{Dir.home}/.heroics/platform-api") = { default_headers: default_headers, cache: cache } client = Heroics.oauth_client_from_schema(oauth_token, SCHEMA, url, ) Client.new(client) end |
.connect_token(token, headers = nil) ⇒ Client
Get a Client configured to use Token authentication.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/platform-api/client.rb', line 66 def self.connect_token(token, headers=nil) url = "https://api.heroku.com" default_headers = {"Accept"=>"application/vnd.heroku+json; version=3"} unless headers.nil? default_headers.merge!(headers) end cache = Moneta.new(:File, dir: "#{Dir.home}/.heroics/platform-api") = { default_headers: default_headers, cache: cache } client = Heroics.token_client_from_schema(token, SCHEMA, url, ) Client.new(client) end |