norseal-api 0.1.4 → 0.1.5
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 +4 -4
- data/Gemfile +2 -0
- data/bin/console +2 -5
- data/lib/norseal/api.rb +26 -4
- data/lib/norseal/api/resources/attribute.rb +13 -0
- data/lib/norseal/api/resources/collection.rb +0 -1
- data/lib/norseal/api/resources/manufacturer.rb +1 -2
- data/lib/norseal/api/resources/product.rb +1 -4
- data/lib/norseal/api/resources/question.rb +1 -2
- data/lib/norseal/api/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6d2283e948c830885f7df452967acd4e4dcdb58
|
4
|
+
data.tar.gz: 0b05ffbffb8a7fbbeabd7bc1107191f3e6bca766
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b91daf7f5656c6a22d6f5a87bfaefda5252b82da9decd3a62167b2d74dd27827b5b729b11d10aee360addc27d75ee5e3e8ac991a6065ca8a09f0e5ab4e45340
|
7
|
+
data.tar.gz: f234022869afa962b0831385c510b54ef9565b0b5677156acda39b77ca4399f688804da6deea62a5d77ab23f21c7a67018f9db23f277f695609eb3bca75f539c
|
data/Gemfile
CHANGED
data/bin/console
CHANGED
data/lib/norseal/api.rb
CHANGED
@@ -7,25 +7,47 @@ module Norseal
|
|
7
7
|
module Api
|
8
8
|
class ClientNotConfigured < Exception; end
|
9
9
|
|
10
|
+
class MyTokenAuth < Faraday::Middleware
|
11
|
+
def initialize(app, options = {})
|
12
|
+
@app = app
|
13
|
+
@options = options
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
env[:request_headers]["authorization"] = "Token token=#{@options[:token]}" if @options.include?(:token)
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
10
22
|
def self.configure(host, api_key, &block)
|
11
23
|
@api = Her::API.new
|
12
24
|
|
13
25
|
@api.setup :url => "http://#{host}/" do |c|
|
14
|
-
c.use
|
26
|
+
c.use Norseal::Api::MyTokenAuth, token: api_key
|
27
|
+
# c.use FaradayMiddleware::EncodeJson
|
15
28
|
c.use Her::Middleware::AcceptJSON
|
16
|
-
c.use Her::Middleware::FirstLevelParseJSON
|
29
|
+
# c.use Her::Middleware::FirstLevelParseJSON
|
30
|
+
|
31
|
+
# Response
|
32
|
+
c.use Her::Middleware::DefaultParseJSON
|
33
|
+
|
34
|
+
# Adapter
|
35
|
+
c.use Faraday::Adapter::NetHttp
|
36
|
+
|
37
|
+
c.use Faraday::Request::UrlEncoded
|
17
38
|
|
18
|
-
c.authorization :token, api_key
|
39
|
+
# c.authorization :token, Token: api_key
|
19
40
|
|
20
41
|
yield c if block_given?
|
21
42
|
|
22
|
-
c.adapter Faraday.default_adapter unless c.builder.handlers.include?(Faraday::Adapter::Test)
|
43
|
+
# c.adapter Faraday.default_adapter# unless c.builder.handlers.include?(Faraday::Adapter::Test)
|
23
44
|
end
|
24
45
|
|
25
46
|
require "norseal/api/resources/collection"
|
26
47
|
require "norseal/api/resources/product"
|
27
48
|
require "norseal/api/resources/question"
|
28
49
|
require "norseal/api/resources/manufacturer"
|
50
|
+
require "norseal/api/resources/attribute"
|
29
51
|
end
|
30
52
|
|
31
53
|
def self.api
|
data/lib/norseal/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: norseal-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Barton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: her
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- bin/setup
|
100
100
|
- lib/norseal/api.rb
|
101
101
|
- lib/norseal/api/model.rb
|
102
|
+
- lib/norseal/api/resources/attribute.rb
|
102
103
|
- lib/norseal/api/resources/collection.rb
|
103
104
|
- lib/norseal/api/resources/manufacturer.rb
|
104
105
|
- lib/norseal/api/resources/product.rb
|
@@ -125,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
126
|
version: '0'
|
126
127
|
requirements: []
|
127
128
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.4.
|
129
|
+
rubygems_version: 2.4.8
|
129
130
|
signing_key:
|
130
131
|
specification_version: 4
|
131
132
|
summary: Consume the Norseal API.
|