tito 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd8ca9fe94ea995499e3b1c204ff40313809eb59
4
- data.tar.gz: bd442ad3ba07d49dfaa95996e3c5fe571498fd0d
3
+ metadata.gz: 483e40092182ff4404978eb36a57948fccce7e29
4
+ data.tar.gz: 7bb411122530628861021608ae127009638738c6
5
5
  SHA512:
6
- metadata.gz: 0ab0f72cc9fc66873d6ab09c8f8c800006a2b109995bbab5f71a41175009c9e5d072fb968ea519dbec33536a26166eb1333f9f93db0ed41d88dd586a63069d6a
7
- data.tar.gz: 50963475ff5ce2c15585dfe3c3062cdc2f1d159186faf23c8d1085ead52b9ebce1f4142c321c644cdc89b5cce5f642f30e3a70f5b496359e12749656486acee3
6
+ metadata.gz: 12a28e82d98da8d4e112e9d079ae027f0c6a0d94a82dd44b40acf82b2e4350d202070a8e749e80ed807685f2f41a77ea77462a8be30ffbea01a5d9bfb1e7f3fd
7
+ data.tar.gz: 42fdb2a5b4a5a868fbb0645164969a6c6f711219fc7508ab2908e530a304d572cd685e099b4a7059e9434a1b6078b8eda54c019d5886992a7ea9befce077e627
@@ -1,5 +1,9 @@
1
1
  module Tito
2
2
  class Base < JsonApiClient::Resource
3
3
  self.site = ENV['TITO_SITE'] || "https://api.tito.io/v2"
4
+
5
+ def self.with_api_key(api_key)
6
+ with_params(api_key: api_key)
7
+ end
4
8
  end
5
9
  end
@@ -1,7 +1,10 @@
1
1
  module Tito
2
2
  class OAuth2Middleware < FaradayMiddleware::OAuth2
3
3
  def call(env)
4
- token = if @token.is_a?(Proc)
4
+ params = query_params(env[:url])
5
+
6
+ token = params.delete(:api_key) || params.delete('api_key')
7
+ token ||= if @token.is_a?(Proc)
5
8
  @token.call(env)
6
9
  else
7
10
  @token
@@ -9,8 +12,6 @@ module Tito
9
12
 
10
13
  token ||= Tito.api_key
11
14
 
12
- params = query_params(env[:url])
13
-
14
15
  if token.respond_to?(:empty?) && !token.empty?
15
16
  env[:url].query = build_query params
16
17
  env[:request_headers][AUTH_HEADER] ||= %(Bearer #{token})
@@ -1,3 +1,3 @@
1
1
  module Tito
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tito
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Campbell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-28 00:00:00.000000000 Z
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_api_client