teamsnap_rb 0.0.6 → 0.0.7

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: ee6713987eed0b0f7f4a226d42b231fd4cd3b62e
4
- data.tar.gz: e82f3f683e6fedf48bd19c806a1225a0055e7b4e
3
+ metadata.gz: 386562e820e675cef97c66d5b22804bfd20ae626
4
+ data.tar.gz: fdea3d3e62bcccff199ece97232569142abef828
5
5
  SHA512:
6
- metadata.gz: 3610ade4641f2decf863efd96d8b4024c70d9da0eb02bfe583f31d2a3204159118bf912e3ba8b77a2a33378caa27012df8262913e8b1880557899acdadf6d8b3
7
- data.tar.gz: b1b4c282fdf34f89f6f7c06b44da03e4a943dd19579903d80cccd0d6c6a20bd19f6590bf11157ccf2e753d38cc6e9e3fb0d3904592acdecaf16687220a571d9a
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
@@ -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!({
@@ -1,3 +1,3 @@
1
1
  module TeamsnapRb
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
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.6
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: 2014-11-12 00:00:00.000000000 Z
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler