usps-imis-api 0.12.8 → 0.12.10

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: 885f7ace4c5c5f77d9e986c1b09e12d9e1d811596800b6181220b24fe3fecbe8
4
+ data.tar.gz: 397ad89928f4efdbfea3299123378685c4fcbe78c87edf852f2fd60873acd4a5
5
5
  SHA512:
6
- metadata.gz: 74248d90918c20176b21d53fb249d40518e17fdb12eb9bbf80556ae060c19d4116eaae6702346ab87a99979e532066ad02173fa21525d152b869dff7d6eaab72
7
- data.tar.gz: '0960f0a7b26f1bcbd8a321b3c6f852104fc3e64569655c03394153474d5f31caa9e9293775470f69eed0e328c7b18c7f0bbb47c40e80873fbaa1834473e568e4'
6
+ metadata.gz: '07083a6c15f1177f94c2039f1a3b80c893bfd671a6d8f9cbcfeabad33d16a8d1da3d162132acf0864ed2d21768ac0ca773e72a65b0e6a02bbb08fe9a262342f5'
7
+ data.tar.gz: e5933277a7c6923b729c26fa68a65a63cf91eb997b6bc18221c57db027cb4d310f96fe2dc3d554f2d0f1ec79803154eddc4bdcb2ab268a4c52de66f9908ee596
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
  #
@@ -59,7 +59,7 @@ module Usps
59
59
 
60
60
  set_member
61
61
 
62
- result = simplify(perform!)
62
+ result = logger.time { simplify(perform!) }
63
63
 
64
64
  output { result }
65
65
 
@@ -15,6 +15,14 @@ module Usps
15
15
  rescue StandardError
16
16
  multiline(data)
17
17
  end
18
+
19
+ def time
20
+ start_time = Time.now
21
+
22
+ yield.tap do
23
+ tagged('Time').debug(ActiveSupport::Duration.build(Time.now - start_time).inspect)
24
+ end
25
+ end
18
26
  end
19
27
  end
20
28
  end
@@ -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
 
41
- client.request(request).tap do |result|
42
- raise Errors::ResponseError.from(result) unless result.is_a?(Net::HTTPSuccess)
39
+ logger.time do
40
+ client.request(request).tap do |result|
41
+ check_result_success!(result)
43
42
 
44
- logger.info 'Request succeeded'
43
+ logger.info 'Request succeeded'
44
+ end
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.10'
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.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander