usps-imis-api 0.12.8 → 0.12.9

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: 3132a1932f2a84508fb362e35355f3230bc96be49945da54614b4d3c8af26b82
4
- data.tar.gz: 2f026366c1d86c036e188aef7bff291a15954be13ebd5251d1a6433e61874751
3
+ metadata.gz: a42c46a141077cd81f0bf4ecd680a25ad10df88bd28d183d24280f2d7f0b5348
4
+ data.tar.gz: f54f32c44e31d39dd5cef4703b72d3e9f95847b971194a91211bc314b767e932
5
5
  SHA512:
6
- metadata.gz: 74248d90918c20176b21d53fb249d40518e17fdb12eb9bbf80556ae060c19d4116eaae6702346ab87a99979e532066ad02173fa21525d152b869dff7d6eaab72
7
- data.tar.gz: '0960f0a7b26f1bcbd8a321b3c6f852104fc3e64569655c03394153474d5f31caa9e9293775470f69eed0e328c7b18c7f0bbb47c40e80873fbaa1834473e568e4'
6
+ metadata.gz: 99af41b8445740f5e7489533314aa932ea57e51fae07ab37739c9dbcbc91a419aabf73fac67034debff920163a50770ffe60dab1ed7a1ae584a104a03fb1c8bc
7
+ data.tar.gz: 12ca8d1d0e81ec8fa0c0644074e51789c079b242a56b2463f01705f56fde05891771b23c0f668a01af64a7b322ac5f2db74344fe63e492c9fa2bf5f7327ee8a5
data/lib/usps/imis/api.rb CHANGED
@@ -208,14 +208,14 @@ module Usps
208
208
  #
209
209
  # @return Value of the specified field
210
210
  #
211
- def fetch(field_key) = mapper.fetch(field_key)
211
+ delegate :fetch, to: :mapper
212
212
  alias [] fetch
213
213
 
214
214
  # Convenience alias for reading multiple mapped fields
215
215
  #
216
216
  # @return [Array] Values of the specified fields
217
217
  #
218
- def fetch_all(*fields) = mapper.fetch_all(*fields)
218
+ delegate :fetch_all, to: :mapper
219
219
 
220
220
  # Convenience alias for updating mapped fields
221
221
  #
@@ -228,7 +228,7 @@ module Usps
228
228
  #
229
229
  # @return [Usps::Imis::Data] Updated object
230
230
  #
231
- def update(data) = mapper.update(data)
231
+ delegate :update, to: :mapper
232
232
 
233
233
  # List of available Business Object names
234
234
  #
@@ -28,7 +28,7 @@ module Usps
28
28
 
29
29
  alias to_h raw
30
30
 
31
- def to_json(*) = raw.to_json(*)
31
+ delegate :to_json, to: :raw
32
32
 
33
33
  # Access the iMIS ID property
34
34
  #
@@ -9,9 +9,7 @@ module Usps
9
9
 
10
10
  def logger = raise(Errors::ApiError, "#{self.class.name} must implement #logger")
11
11
 
12
- def token = api.token
13
- def token_expiration = api.token_expiration
14
- def authenticate = api.authenticate
12
+ delegate :token, :token_expiration, :authenticate, to: :api
15
13
 
16
14
  def http_get = Net::HTTP::Get.new(uri)
17
15
  def http_put = Net::HTTP::Put.new(uri)
@@ -38,14 +36,20 @@ module Usps
38
36
  logger.debug "#{request.class.name.demodulize.upcase} #{uri}"
39
37
  logger.json sanitized_request_body(request)
40
38
 
39
+ start_time = Time.now
41
40
  client.request(request).tap do |result|
42
- raise Errors::ResponseError.from(result) unless result.is_a?(Net::HTTPSuccess)
41
+ check_result_success!(result)
43
42
 
44
43
  logger.info 'Request succeeded'
44
+ logger.tagged('Time').debug ActiveSupport::Duration.build(Time.now - start_time).inspect
45
45
  end
46
46
  end
47
47
  end
48
48
 
49
+ def check_result_success!(result)
50
+ raise Errors::ResponseError.from(result) unless result.is_a?(Net::HTTPSuccess)
51
+ end
52
+
49
53
  def sanitized_request_body(request)
50
54
  return '*** empty request body ***' if request.body.nil?
51
55
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.12.8'
5
+ VERSION = '0.12.9'
6
6
  end
7
7
  end
data/lib/usps/imis.rb CHANGED
@@ -10,7 +10,9 @@ require 'cgi'
10
10
  require 'active_support/core_ext/string/inflections'
11
11
  require 'active_support/core_ext/object/to_query'
12
12
  require 'active_support/core_ext/enumerable'
13
+ require 'active_support/core_ext/module/delegation'
13
14
  require 'active_support/string_inquirer'
15
+ require 'active_support/duration'
14
16
  require 'logger'
15
17
  require 'active_support/isolated_execution_state' # Fix constant loading issue with TaggedLogging
16
18
  require 'active_support/tagged_logging'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps-imis-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.8
4
+ version: 0.12.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander