platform-api 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d92f219cfa928a250924c521ec4ab95fbc14c81f
4
- data.tar.gz: f59e2fe52912929d67292bbc1d981a6156b8387f
3
+ metadata.gz: 55cb2a8539f3f2c2125ca1d37f11c004b5c6acd7
4
+ data.tar.gz: c24292d90bb59ed473f42349e0bea60ab10cb0d0
5
5
  SHA512:
6
- metadata.gz: 4097c473d0bdd1863e6b9d9b6058a5d5b351f112444a5252f2d3b2e4cea988372c2c452a3b2b9db1db8f4cda94c9771b7b439dfbe0f69ce53b312127373d0299
7
- data.tar.gz: aeb2695535f24e9068f7c67c05f8b5d0036ac93d96377377580a34e40808c4b02f57d197b9ec99fcacd40b39df88c409ad737bdd1a5a9e869b1e7fd944b16e60
6
+ metadata.gz: c5f4f716094a9e9622e2e5e286633961dc029629852df9b207aa950d3eae73594e61654d7af0192d0516db2f9d74a94ee64e9b8712a4fd67c483d48d57e8378a
7
+ data.tar.gz: 9db71e470f1c78921d7609f132d448885d2a3cb1d7228a56161207ce376fd41c30f07804f42030fc802326db2709b2da826a6e6ab5b36d80365fc175d7272eb5
data/README.md CHANGED
@@ -60,15 +60,29 @@ raises `Excon::Error` exceptions when errors occur. You can catch specific
60
60
  ### A real world example
61
61
 
62
62
  Let's go through an example of creating an app and using the API to work with
63
- it. The first thing you need is a client that's setup with your API token.
64
- You can find your API token by clicking the *Show API Key* on your
65
- [account page](https://dashboard.heroku.com/account).
63
+ it. The first thing you need is a client setup with an OAuth token. You can
64
+ create an OAuth token using the `heroku-oauth` toolbelt plugin:
65
+
66
+ ```bash
67
+ $ heroku plugins:install git@github.com:heroku/heroku-oauth.git
68
+ $ heroku authorizations:create -d "Platform API example token"
69
+ Created OAuth authorization.
70
+ ID: 2f01aac0-e9d3-4773-af4e-3e510aa006ca
71
+ Description: Platform API example token
72
+ Scope: global
73
+ Token: e7dd6ad7-3c6a-411e-a2be-c9fe52ac7ed2
74
+ ```
75
+
76
+ Use the `Token` value when instantiating a client:
66
77
 
67
78
  ```ruby
68
79
  require 'platform-api'
69
- heroku = PlatformAPI.connect('token')
80
+ heroku = PlatformAPI.connect_oauth('e7dd6ad7-3c6a-411e-a2be-c9fe52ac7ed2')
70
81
  ```
71
82
 
83
+ The [OAuth article]()https://devcenter.heroku.com/articles/oauth has more information about OAuth tokens, including how to
84
+ create tokens with specific scopes.
85
+
72
86
  Now let's create an app:
73
87
 
74
88
  ```ruby
@@ -1,6 +1,20 @@
1
1
  module PlatformAPI
2
- # Get a client configured with the specified token.
3
- def self.connect( token)
2
+ # Get a client configured with the specified OAuth token.
3
+ def self.connect_oauth(oauth_token)
4
+ url = "https://api.heroku.com"
5
+ default_headers = {'Accept' => 'application/vnd.heroku+json; version=3'}
6
+ cache = Moneta.new(:File, dir: "#{Dir.home}/.heroku/platform-api")
7
+ options = {default_headers: default_headers, cache: cache}
8
+ schema_json = File.read("#{File.dirname(__FILE__)}/schema.json")
9
+ schema = Heroics::Schema.new(MultiJson.decode(schema_json))
10
+ Heroics.oauth_client_from_schema(oauth_token, schema, url, options)
11
+ end
12
+
13
+ # Get a client configured with the specified API token.
14
+ #
15
+ # Always prefer `connect_oauth` unless there's a very good reason you must
16
+ # use a non-OAuth API token.
17
+ def self.connect(token)
4
18
  url = "https://:#{token}@api.heroku.com"
5
19
  default_headers = {'Accept' => 'application/vnd.heroku+json; version=3'}
6
20
  cache = Moneta.new(:File, dir: "#{Dir.home}/.heroku/platform-api")
@@ -1,3 +1,3 @@
1
1
  module PlatformAPI
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
data/platform-api.gemspec CHANGED
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency 'bundler', '~> 1.3'
23
23
  spec.add_development_dependency 'rake'
24
24
 
25
- spec.add_dependency 'heroics', '~> 0.0.4'
25
+ spec.add_dependency 'heroics', '~> 0.0.5'
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platform-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - jkakar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-18 00:00:00.000000000 Z
11
+ date: 2014-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 0.0.4
47
+ version: 0.0.5
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 0.0.4
54
+ version: 0.0.5
55
55
  description: Ruby HTTP client for the Heroku API.
56
56
  email:
57
57
  - jkakar@kakar.ca