bitballoon 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -3
- data/lib/bitballoon/client.rb +8 -0
- data/lib/bitballoon/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -22,18 +22,29 @@ You'll need an application client id and a client secret before you can access t
|
|
22
22
|
|
23
23
|
Once you have your credentials you can instantiate a BitBalloon client.
|
24
24
|
|
25
|
-
|
25
|
+
```ruby
|
26
|
+
bitballoon = BitBalloon::Client.new(:client_id => "YOUR_API_KEY", :client_secret => "YOUR_API_SECRET")
|
27
|
+
```
|
26
28
|
|
27
29
|
Before you can make any requests to the API, you'll need to authenticate with OAuth2. The BitBalloon client supports two OAuth2 flows.
|
28
30
|
|
29
31
|
If you're authenticating on behalf of a user, you'll need to get a valid access token for that user. Use the BitBalloon client to request an authentication URL:
|
30
32
|
|
31
|
-
|
33
|
+
```ruby
|
34
|
+
url = bitballoon.authorize_url(:redirect_urai => "http://www.example.com/callback")
|
35
|
+
```
|
32
36
|
|
33
37
|
The user then visits that URL and will be prompted to authorize your application to access his BitBalloon sites. If she grants permission, she'll be redirected back to the `redirect_uri` provided in the `authorize_url` call. This URL must match the redirect url configured for your BitBalloon application. Once the user comes back to your app, you'll be able to access a `code` query parameter that gives you an authorization code. Use this to finish the OAuth2 flow:
|
34
38
|
|
35
|
-
|
39
|
+
```ruby
|
40
|
+
bitballoon.authorize!(token, :redirect_uri => "http://www.example.com/callback")
|
41
|
+
```
|
36
42
|
|
43
|
+
If you're not authenticating on behalf of a user you can authorize directly with the API credentials. Just call:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
bitballoon.authorize_from_credentials!
|
47
|
+
```
|
37
48
|
|
38
49
|
Sites
|
39
50
|
=====
|
data/lib/bitballoon/client.rb
CHANGED
@@ -36,6 +36,14 @@ module BitBalloon
|
|
36
36
|
Sites.new(self)
|
37
37
|
end
|
38
38
|
|
39
|
+
def forms
|
40
|
+
Forms.new(self)
|
41
|
+
end
|
42
|
+
|
43
|
+
def submissions
|
44
|
+
Submissions.new(self)
|
45
|
+
end
|
46
|
+
|
39
47
|
def request(verb, path, opts={}, &block)
|
40
48
|
raise "Authorize with BitBalloon before making requests" unless oauth_token
|
41
49
|
oauth_token.request(verb, ::File.join("/api", API_VERSION, path), opts, &block)
|
data/lib/bitballoon/version.rb
CHANGED