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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6a54133261ba20f49174cc2a975fccdbfec6b7d7d5d802288e454197cbfb48c
4
- data.tar.gz: 9537533c2c6e1f211662f4f92f861bde82b26132a447421216cb21fbad87ae62
3
+ metadata.gz: 7763aa9e092db7309780e3217dc381191e49141d8120a3dfd38791ff4af47e9c
4
+ data.tar.gz: 3e8288142e201c52adf9ca05b3607f0f37c8a6ffad4a2df6c8c271395e226fff
5
5
  SHA512:
6
- metadata.gz: 5ae23ce6d5418c2311044814906d73280fb414f2a48401d0620584dfa5b1242b149bf41723ef49a2c43a8543b24622dbdd017e8b4aa3113f7ef9c9837f71a09d
7
- data.tar.gz: dbe91900ae7fc4871752775547e6e8cfe4d68841e494872c02c362fc648840ae5809f2472715525cc608f46704961b52d46528e13a0c5738917ab5996f1f9316
6
+ metadata.gz: f683839ae7f97389a8ff392d386587f6c47df0ab1b68da3c733dfd35516be74bdb20d51da1770b15b83bc08eee9bc234c09410bb845f8729f842996d9d3641e7
7
+ data.tar.gz: fcefcc27355f4df841b4624506dafc25d2abd0399ef14779bb72b3c39d25ed27a922f4cd1a4d415533659104c6c4f27585b9f35a0a5266a537e8fa11d5e1ef44
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
- # hubrise_ruby_lib
1
+ # hubrise_client
2
2
 
3
- To publish the latest version to RubyGems.org:
3
+ To upload the latest version to RubyGems.org:
4
4
 
5
- - Increase version in `lib/hubrise_client/version.rb` and commit
5
+ 1. Increase version in `lib/hubrise_client/version.rb` and commit
6
6
 
7
- - `gem push`
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
+ ```
@@ -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
- headers: headers)
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
- uri = add_params_to_uri(uri, data)
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"
@@ -1,3 +1,3 @@
1
1
  module HubriseClient
2
- VERSION = "2.0.1".freeze
2
+ VERSION = "2.0.2".freeze
3
3
  end
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.1
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: 2019-09-29 00:00:00.000000000 Z
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.5
105
+ rubygems_version: 3.0.3
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: HubRise Ruby client