teamsnap_rb 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/teamsnap_rb/config.rb +2 -1
- data/lib/teamsnap_rb/request_builder.rb +2 -0
- data/lib/teamsnap_rb/version.rb +1 -1
- data/spec/config_spec.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 386562e820e675cef97c66d5b22804bfd20ae626
|
4
|
+
data.tar.gz: fdea3d3e62bcccff199ece97232569142abef828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a9444f3b2e4afe4f920701f3114842fa36f233511f9a4e0b00dbdc217b51879190e0b8a99a211f3fae1b8ee9d0232bd0ac102f5060b9b2758fb1745a4b499f1
|
7
|
+
data.tar.gz: 2e485eae3d4d3ca5fb87b81984b1a2b0dd963ba603a95e23a3710c2c3babe44c2cd1eb4aa9c15b389c01f591a1f77367ccf63b505bf234e7e9a08960f556a655
|
data/README.md
CHANGED
@@ -61,6 +61,23 @@ $ irb
|
|
61
61
|
=> # team object
|
62
62
|
```
|
63
63
|
|
64
|
+
You can also access the API via OAuth2, which is handled outside of this gem.
|
65
|
+
Simply pass the authorization token to access:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
$ irb
|
69
|
+
> require 'teamsnap_rb'
|
70
|
+
=> true
|
71
|
+
> client_config = TeamsnapRb::Config.new(
|
72
|
+
> authorization: "authorization key here",
|
73
|
+
> )
|
74
|
+
> client = TeamsnapRb::Client.new("http://apiv3.teamsnap.com/", config: client_config)
|
75
|
+
=> # client object
|
76
|
+
> client.me.first.teams.inject({}){|a, t| a[t.name] = t.href; a }
|
77
|
+
=> {"Authorized User Team"=>"https://apiv3.teamsnap.com/teams/82308"}
|
78
|
+
```
|
79
|
+
|
80
|
+
|
64
81
|
In order to work on teamsnap_rb most effectively and efficiently, it'll he helpful
|
65
82
|
to have a TeamSnap account and teams so you can work with that data. You can
|
66
83
|
create a TeamSnap account [here](https://go.teamsnap.com) and you can then
|
data/lib/teamsnap_rb/config.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
module TeamsnapRb
|
2
2
|
class Config
|
3
|
-
attr_accessor :access_token, :client_id, :client_secret, :request_middleware, :response_middleware
|
3
|
+
attr_accessor :access_token, :client_id, :client_secret, :request_middleware, :response_middleware, :authorization
|
4
4
|
|
5
5
|
def initialize(options = {})
|
6
|
+
self.authorization = options.fetch(:authorization, nil)
|
6
7
|
self.access_token = options.fetch(:access_token, nil)
|
7
8
|
self.client_secret = options.fetch(:client_secret, nil)
|
8
9
|
self.client_id = options.fetch(:client_id, nil)
|
@@ -35,6 +35,8 @@ module TeamsnapRb
|
|
35
35
|
def call(env)
|
36
36
|
if config.access_token
|
37
37
|
env.request_headers["X-Teamsnap-Access-Token"] = config.access_token
|
38
|
+
elsif config.authorization
|
39
|
+
env.request_headers["Authorization"] = "Bearer #{config.authorization}"
|
38
40
|
elsif config.client_id && config.client_secret
|
39
41
|
query_params = Hash[URI.decode_www_form(env.url.query || "")]
|
40
42
|
query_params.merge!({
|
data/lib/teamsnap_rb/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -5,6 +5,7 @@ describe TeamsnapRb::Config do
|
|
5
5
|
|
6
6
|
describe "#new" do
|
7
7
|
it "uses sensible defaults when no options are passed in" do
|
8
|
+
expect(config.authorization).to be_nil
|
8
9
|
expect(config.access_token).to be_nil
|
9
10
|
expect(config.client_secret).to be_nil
|
10
11
|
expect(config.client_id).to be_nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teamsnap_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Party Chicken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|