hubrise_client 2.0.1 → 2.0.2
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/README.md +8 -4
- data/lib/hubrise_client/base.rb +5 -2
- data/lib/hubrise_client/request.rb +7 -2
- data/lib/hubrise_client/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7763aa9e092db7309780e3217dc381191e49141d8120a3dfd38791ff4af47e9c
|
4
|
+
data.tar.gz: 3e8288142e201c52adf9ca05b3607f0f37c8a6ffad4a2df6c8c271395e226fff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f683839ae7f97389a8ff392d386587f6c47df0ab1b68da3c733dfd35516be74bdb20d51da1770b15b83bc08eee9bc234c09410bb845f8729f842996d9d3641e7
|
7
|
+
data.tar.gz: fcefcc27355f4df841b4624506dafc25d2abd0399ef14779bb72b3c39d25ed27a922f4cd1a4d415533659104c6c4f27585b9f35a0a5266a537e8fa11d5e1ef44
|
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# hubrise_client
|
2
2
|
|
3
|
-
To
|
3
|
+
To upload the latest version to RubyGems.org:
|
4
4
|
|
5
|
-
|
5
|
+
1. Increase version in `lib/hubrise_client/version.rb` and commit
|
6
6
|
|
7
|
-
|
7
|
+
2. Build & publish (assuming the new version is `2.0.1`):
|
8
8
|
|
9
|
+
```bash
|
10
|
+
gem build hubrise_client
|
11
|
+
gem push hubrise_client-2.0.1.gem
|
12
|
+
```
|
data/lib/hubrise_client/base.rb
CHANGED
@@ -13,7 +13,8 @@ module HubriseClient
|
|
13
13
|
:location_id,
|
14
14
|
:catalog_id,
|
15
15
|
:customer_list_id,
|
16
|
-
:logger
|
16
|
+
:logger,
|
17
|
+
:request_callback
|
17
18
|
|
18
19
|
def initialize(app_id, app_secret, params = {}) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
19
20
|
@app_id = app_id
|
@@ -23,6 +24,7 @@ module HubriseClient
|
|
23
24
|
@oauth_host = params[:oauth_host] || DEFAULT_OAUTH_HOST
|
24
25
|
@oauth_port = params[:oauth_port] || DEFAULT_OAUTH_PORT
|
25
26
|
@use_https = !!params.fetch(:use_https, USE_HTTPS)
|
27
|
+
@request_callback = params[:request_callback]
|
26
28
|
|
27
29
|
initialize_scope_params(params)
|
28
30
|
|
@@ -77,7 +79,8 @@ module HubriseClient
|
|
77
79
|
raise(HubriseAccessTokenMissing) if @access_token.nil?
|
78
80
|
|
79
81
|
api_request("#{@api_host}:#{@api_port}/#{version}", @access_token).perform(method, path, data, json: json,
|
80
|
-
|
82
|
+
headers: headers,
|
83
|
+
&@request_callback)
|
81
84
|
end
|
82
85
|
|
83
86
|
def api_request(hostname, access_token = nil)
|
@@ -15,7 +15,7 @@ module HubriseClient
|
|
15
15
|
@logger = logger
|
16
16
|
end
|
17
17
|
|
18
|
-
def perform(method, path, data, json: true, headers: {})
|
18
|
+
def perform(method, path, data, json: true, headers: {}, callback: nil)
|
19
19
|
uri = URI.parse(@protocol + "://" + @hostname + path)
|
20
20
|
http_request = build_request(uri, method, data, json: json, headers: headers)
|
21
21
|
http_response = perform_request(uri, http_request)
|
@@ -30,6 +30,8 @@ module HubriseClient
|
|
30
30
|
end
|
31
31
|
rescue Errno::ECONNREFUSED
|
32
32
|
raise HubriseError, "API is not reachable"
|
33
|
+
ensure
|
34
|
+
yield(http_request, http_response) if http_request && block_given?
|
33
35
|
end
|
34
36
|
|
35
37
|
protected
|
@@ -38,7 +40,10 @@ module HubriseClient
|
|
38
40
|
headers["X-Access-Token"] = @access_token if @access_token
|
39
41
|
|
40
42
|
if method == :get
|
41
|
-
|
43
|
+
if data && data.count > 0
|
44
|
+
uri = add_params_to_uri(uri, data)
|
45
|
+
end
|
46
|
+
|
42
47
|
data = nil
|
43
48
|
elsif json
|
44
49
|
headers["Content-Type"] ||= "application/json"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubrise_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antoine Monnier
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
|
-
rubygems_version: 3.0.
|
105
|
+
rubygems_version: 3.0.3
|
106
106
|
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: HubRise Ruby client
|