usps-imis-api 0.9.0 → 0.9.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: e94dcde6abaf560148b72523c9defe96cd30f6980631f11b79cf8b35f52a1dcc
4
- data.tar.gz: a94d8ce631656ff48bf6c3b905e3e06bf130a5a658dfad737afec2be21ac1957
3
+ metadata.gz: 1e410751cbd3ff6de46be231c0003cd5b23ffdfa891233f70025e493fa8e8057
4
+ data.tar.gz: 993830af54fb76c8361b589b797b6c8fe600d485704087bf8020a17c20c5ca8e
5
5
  SHA512:
6
- metadata.gz: 1c155ff3c3e0801c4cb1d738c736e7da9833b651ba56cafb5983439d8e7708f15a266f688d40672917270745b198cac6a38e86b735932c447a631b1c5922b17d
7
- data.tar.gz: e99827b9bb433d673c6d76558c209f23a12aba1dbe22a674d4972f8ff97b0122374cb4ef2955c0b903ebcf5f7d20721c15b800b79cba17c304113436ea8c66a9
6
+ metadata.gz: 481e7d0d83547f00cb77dbdec9ecb7b1d678d467fb8aacf0e35883bcdfa6700a9e926e6f1f73fb783bcdaed96fbda3a765ce854cf5d12f64e1c9aa3162ae3bed
7
+ data.tar.gz: 1712c9f3e1ad4cf2ab7b6567861c6c1537b69fae0601829eafabacc80a22ae300681edb67d3ef6ab02e5c07e2ac0a999eab1e51142a21a101f262511a9115cf2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps-imis-api (0.9.0)
4
+ usps-imis-api (0.9.2)
5
5
  activesupport (~> 8.0)
6
6
 
7
7
  GEM
@@ -159,7 +159,9 @@ module Usps
159
159
  def raw_object
160
160
  request = Net::HTTP::Get.new(uri)
161
161
  result = submit(uri, authorize(request))
162
- Data.from_json(result.body)
162
+ result = Data.from_json(result.body)
163
+ JSON.pretty_generate(result).split("\n").each { Imis.logger.debug " -> #{it}" }
164
+ result
163
165
  end
164
166
 
165
167
  # Upload an object to the API
@@ -167,7 +169,9 @@ module Usps
167
169
  def put_object(request, body)
168
170
  request.body = JSON.dump(body)
169
171
  result = submit(uri, authorize(request))
170
- Data.from_json(result.body)
172
+ result = Data.from_json(result.body)
173
+ JSON.pretty_generate(result).split("\n").each { Imis.logger.debug " -> #{it}" }
174
+ result
171
175
  end
172
176
  end
173
177
  end
@@ -41,6 +41,10 @@ module Usps
41
41
  # Ruby 3.5 instance variable filter
42
42
  #
43
43
  def instance_variables_to_inspect = %i[@environment @imis_id_query_name @username @logger_level]
44
+
45
+ # Parameters to filter out of logging
46
+ #
47
+ def filtered_parameters = %i[password]
44
48
  end
45
49
  end
46
50
  end
@@ -28,7 +28,7 @@ module Usps
28
28
 
29
29
  def submit(uri, request)
30
30
  Imis.logger.info 'Submitting request to iMIS'
31
- Imis.logger.debug " -> #{uri}"
31
+ Imis.logger.debug " -> #{request.class.name.demodulize.upcase} #{uri}"
32
32
  sanitized_request_body(request).split("\n").each { Imis.logger.debug " -> #{it}" }
33
33
  client(uri).request(request).tap do |result|
34
34
  raise Errors::ResponseError.from(result) unless result.is_a?(Net::HTTPSuccess)
@@ -38,9 +38,17 @@ module Usps
38
38
  end
39
39
 
40
40
  def sanitized_request_body(request)
41
- return 'grant_type=password&username=[filtered]&password=[filtered]' if request.body&.include?('password=')
41
+ return '*** empty request body ***' if request.body.nil?
42
42
 
43
- request.body.nil? ? '*** empty request body ***' : JSON.pretty_generate(JSON.parse(request.body))
43
+ body = request.body.dup
44
+
45
+ Imis.config.filtered_parameters.each do |parameter|
46
+ body =
47
+ body.gsub(Imis.config.public_send(parameter), '[FILTERED]')
48
+ .gsub(CGI.escape(Imis.config.public_send(parameter)), '[FILTERED]')
49
+ end
50
+
51
+ body
44
52
  end
45
53
  end
46
54
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.9.0'
5
+ VERSION = '0.9.2'
6
6
  end
7
7
  end
data/lib/usps/imis.rb CHANGED
@@ -32,6 +32,7 @@ module Usps
32
32
  def configuration
33
33
  @configuration ||= Config.new
34
34
  end
35
+ alias config configuration
35
36
 
36
37
  # Used to define a block of configuration settings
37
38
  #
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.9.0
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander