usps-imis-api 0.13.7 → 0.13.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: 0c08ef9fb00018afc5a5ff89f2504c1c3eb50966834323549a0d5b889bf62fc8
4
- data.tar.gz: cb0eb88ff00dcff37318ae4db9d5eba37c82a1138aab77c257dd9c81455adb70
3
+ metadata.gz: fca31f9bb4d8d748374f47185b5110c95b6f80088dc682cb44613e3629199319
4
+ data.tar.gz: 742c11021ae6b6446bc29e3b5b29fc99bf151683e5607e2ca2fcb12d5b19f569
5
5
  SHA512:
6
- metadata.gz: e828834ae003610f3c3e217763bc26602626cb840b69cd4590b1ebe07659cd960cc1988da5ac0551fcac9fcfc71e89ab1ffaf004831d69344b9ad8503b787e83
7
- data.tar.gz: fc6eccef25f63c11fd8e997d99c6527da8a56a0cfdcd16034744d457c214a86a973262de5215d1979f8cee5581c7f130992c3b9e7abeea85687d2ad8ab200177
6
+ metadata.gz: 7b5bc685dec91340b99d60d5cf199d41b7dbf5750a5469b25dc46f445c0bb180b1d77bc7cd5e244ee68f88e93f9332083eea11fa19516dbd8d84e572177a35b5
7
+ data.tar.gz: 3fc9d20a2d78f4cc0ced1c3552db53e08106bb8ab74cd1384897f7faee5b7091a7b411b0ba5b6c91c06a3dcc01d1b94f5f315d746d89b81f9757f98129fda2df
data/lib/usps/imis/api.rb CHANGED
@@ -59,16 +59,18 @@ module Usps
59
59
  # A new instance of +Api+
60
60
  #
61
61
  # @param imis_id [Integer, String] iMIS ID to select immediately on initialization
62
+ # @param record_id [Integer, String] iMIS ID to select immediately on initialization
63
+ # @param certificate [String] Certificate to convert to iMIS ID immediately on initialization
62
64
  #
63
65
  def initialize(imis_id: nil, record_id: nil, certificate: nil)
64
66
  raise ArgumentError, 'Cannot provide both imis_id and certificate' if imis_id && certificate
65
67
 
68
+ @logger = Imis.logger('Api')
69
+ Imis.config.validate!
70
+
66
71
  self.imis_id = imis_id if imis_id
67
72
  self.record_id = record_id if record_id
68
73
  imis_id_for(certificate) if certificate
69
-
70
- @logger = Imis.logger('Api')
71
- Imis.config.validate!
72
74
  end
73
75
 
74
76
  # Manually set the current ID, if you already have it for a given member
@@ -15,9 +15,11 @@ module Usps
15
15
 
16
16
  private
17
17
 
18
+ # rubocop:disable Metrics/MethodLength
18
19
  def simplify(data)
19
- return data.to_a if data.is_a?(Query)
20
- return data.is_a?(BaseData) ? data.raw : data if force_raw_output?
20
+ data = data.to_a if data.is_a?(Query)
21
+
22
+ return simplify_raw(data) if force_raw_output?
21
23
 
22
24
  if data.is_a?(PartyData)
23
25
  logger.debug 'Returning simplified PartyData#properties'
@@ -25,6 +27,9 @@ module Usps
25
27
  elsif data.is_a?(Data)
26
28
  logger.debug 'Returning simplified Data#properties'
27
29
  data.properties(include_ids: options[:include_ids])
30
+ elsif data.is_a?(Array) && data.all?(PartyData)
31
+ logger.debug 'Returning simplified Array<PartyData#properties>'
32
+ data.map(&:properties)
28
33
  elsif data.is_a?(Array) && data.all?(Data)
29
34
  logger.debug 'Returning simplified Array<Data#properties>'
30
35
  data.map { it.properties(include_ids: options[:include_ids]) }
@@ -32,6 +37,14 @@ module Usps
32
37
  data
33
38
  end
34
39
  end
40
+ # rubocop:enable Metrics/MethodLength
41
+
42
+ def simplify_raw(data)
43
+ return data.raw if data.is_a?(BaseData)
44
+ return data.map(&:raw) if data.is_a?(Array) && data.all?(BaseData)
45
+
46
+ data
47
+ end
35
48
 
36
49
  def force_raw_output? = options[:raw] || RAW_HASH_RESPONSE_OPTIONS.any? { options[it] }
37
50
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.13.7'
5
+ VERSION = '0.13.9'
6
6
  end
7
7
  end
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.13.7
4
+ version: 0.13.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander