zaikio-procurement 2.0.2 → 2.1.0
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
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f514551c75276723f89ef84fe2888072c00dcb6f44d0237d54cc11821517507c
|
|
4
|
+
data.tar.gz: 3c3db09e362d8573b187a2e1821adacc0cb720415e09575dd4c27ffad22553c7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4982b2fcf2cdf1ef0bb2c3d13d82636935eb455419f5252b8e49183f8bb57aef751af61ee6bb49d836b917c1763ec41829beb751d1303c9afcc946cb8f3593a4
|
|
7
|
+
data.tar.gz: 62eb46093fde1d29b43ebb3573882df0df1ab914968f44c693d113525c32ba114d43313e3e2f5739db19605841faa1a6db8c11a8e79d274be613e16ccab6146e
|
|
@@ -2,38 +2,15 @@ require "logger"
|
|
|
2
2
|
|
|
3
3
|
module Zaikio
|
|
4
4
|
module Procurement
|
|
5
|
-
class Configuration
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
attr_accessor :host
|
|
15
|
-
attr_reader :environment
|
|
16
|
-
attr_writer :logger
|
|
17
|
-
|
|
18
|
-
def initialize
|
|
19
|
-
@environment = :sandbox
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def logger
|
|
23
|
-
@logger ||= Logger.new($stdout)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def environment=(env)
|
|
27
|
-
@environment = env.to_sym
|
|
28
|
-
@host = host_for(environment)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
private
|
|
32
|
-
|
|
33
|
-
def host_for(environment)
|
|
34
|
-
HOSTS.fetch(environment) do
|
|
35
|
-
raise StandardError.new, "Invalid Zaikio::Procurement environment '#{environment}'"
|
|
36
|
-
end
|
|
5
|
+
class Configuration < Zaikio::Client::Helpers::Configuration
|
|
6
|
+
def self.hosts
|
|
7
|
+
{
|
|
8
|
+
development: "https://procurement.zaikio.test/api/v2/",
|
|
9
|
+
test: "https://procurement.zaikio.test/api/v2/",
|
|
10
|
+
staging: "https://procurement.staging.zaikio.com/api/v2/",
|
|
11
|
+
sandbox: "https://procurement.sandbox.zaikio.com/api/v2/",
|
|
12
|
+
production: "https://procurement.zaikio.com/api/v2/"
|
|
13
|
+
}.freeze
|
|
37
14
|
end
|
|
38
15
|
end
|
|
39
16
|
end
|
data/lib/zaikio/procurement.rb
CHANGED
|
@@ -2,7 +2,6 @@ require "faraday"
|
|
|
2
2
|
require "spyke"
|
|
3
3
|
require "zaikio-client-helpers"
|
|
4
4
|
require "zaikio/procurement/configuration"
|
|
5
|
-
require "zaikio/procurement/authorization_middleware"
|
|
6
5
|
|
|
7
6
|
# Models
|
|
8
7
|
require "zaikio/procurement/base"
|
|
@@ -40,24 +39,12 @@ module Zaikio
|
|
|
40
39
|
Base.connection = create_connection
|
|
41
40
|
end
|
|
42
41
|
|
|
43
|
-
def with_token(token)
|
|
44
|
-
|
|
45
|
-
AuthorizationMiddleware.token = token
|
|
46
|
-
yield
|
|
47
|
-
ensure
|
|
48
|
-
AuthorizationMiddleware.token = original_token
|
|
42
|
+
def with_token(token, &block)
|
|
43
|
+
Zaikio::Client.with_token(token, &block)
|
|
49
44
|
end
|
|
50
45
|
|
|
51
46
|
def create_connection
|
|
52
|
-
self.connection =
|
|
53
|
-
ssl: { verify: configuration.environment != :test }) do |c|
|
|
54
|
-
c.request :json
|
|
55
|
-
c.response :logger, configuration&.logger, headers: false
|
|
56
|
-
c.use Zaikio::Client::Helpers::Pagination::FaradayMiddleware
|
|
57
|
-
c.use Zaikio::Client::Helpers::JSONParser
|
|
58
|
-
c.use AuthorizationMiddleware
|
|
59
|
-
c.adapter Faraday.default_adapter
|
|
60
|
-
end
|
|
47
|
+
self.connection = Zaikio::Client.create_connection(configuration)
|
|
61
48
|
end
|
|
62
49
|
end
|
|
63
50
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zaikio-procurement
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Zaikio GmbH
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2022-08-
|
|
12
|
+
date: 2022-08-15 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: concurrent-ruby
|
|
@@ -25,20 +25,6 @@ dependencies:
|
|
|
25
25
|
- - ">="
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
27
|
version: '0'
|
|
28
|
-
- !ruby/object:Gem::Dependency
|
|
29
|
-
name: jwt
|
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
|
31
|
-
requirements:
|
|
32
|
-
- - ">="
|
|
33
|
-
- !ruby/object:Gem::Version
|
|
34
|
-
version: '0'
|
|
35
|
-
type: :runtime
|
|
36
|
-
prerelease: false
|
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
-
requirements:
|
|
39
|
-
- - ">="
|
|
40
|
-
- !ruby/object:Gem::Version
|
|
41
|
-
version: '0'
|
|
42
28
|
- !ruby/object:Gem::Dependency
|
|
43
29
|
name: multi_json
|
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -87,14 +73,14 @@ dependencies:
|
|
|
87
73
|
requirements:
|
|
88
74
|
- - "~>"
|
|
89
75
|
- !ruby/object:Gem::Version
|
|
90
|
-
version: '0.
|
|
76
|
+
version: '0.3'
|
|
91
77
|
type: :runtime
|
|
92
78
|
prerelease: false
|
|
93
79
|
version_requirements: !ruby/object:Gem::Requirement
|
|
94
80
|
requirements:
|
|
95
81
|
- - "~>"
|
|
96
82
|
- !ruby/object:Gem::Version
|
|
97
|
-
version: '0.
|
|
83
|
+
version: '0.3'
|
|
98
84
|
description: Ruby API Client for Zaikio's Procurement Platform
|
|
99
85
|
email:
|
|
100
86
|
- sw@zaikio.com
|
|
@@ -108,7 +94,6 @@ files:
|
|
|
108
94
|
- lib/zaikio/procurement.rb
|
|
109
95
|
- lib/zaikio/procurement/address.rb
|
|
110
96
|
- lib/zaikio/procurement/article.rb
|
|
111
|
-
- lib/zaikio/procurement/authorization_middleware.rb
|
|
112
97
|
- lib/zaikio/procurement/availability.rb
|
|
113
98
|
- lib/zaikio/procurement/base.rb
|
|
114
99
|
- lib/zaikio/procurement/configuration.rb
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require "faraday"
|
|
2
|
-
require "jwt"
|
|
3
|
-
require "concurrent"
|
|
4
|
-
|
|
5
|
-
module Zaikio
|
|
6
|
-
module Procurement
|
|
7
|
-
class AuthorizationMiddleware < Faraday::Middleware
|
|
8
|
-
def self.token
|
|
9
|
-
@token ||= Concurrent::ThreadLocalVar.new { nil }
|
|
10
|
-
@token.value
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.token=(value)
|
|
14
|
-
@token ||= Concurrent::ThreadLocalVar.new { nil }
|
|
15
|
-
@token.value = value
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def self.reset_token
|
|
19
|
-
self.token = nil
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def call(request_env)
|
|
23
|
-
request_env[:request_headers]["Authorization"] = "Bearer #{self.class.token}" if self.class.token
|
|
24
|
-
|
|
25
|
-
@app.call(request_env).on_complete do |response_env|
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|