usps-imis-api 0.11.6 → 0.11.7
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 +4 -4
- data/lib/usps/imis/command_line/interface.rb +16 -6
- data/lib/usps/imis/command_line/options_parser.rb +25 -7
- data/lib/usps/imis/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ae10bc832e8ffa7cb4bc3bb14f5ea0b2d2daef3866cde32cdaea89bfcfe60376
|
|
4
|
+
data.tar.gz: 137943c3dce52c4c56bc32e2b2dcb6329e1bd568bb95c653084b299d701ed39e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9bfc02dddae6d07ee6fedfcc0a89101415d4af68cab2b90380f199957976dd4d128c2913373b38066a4da76d41fbc0a21bca6dab672032e3e6cd03ade2114547
|
|
7
|
+
data.tar.gz: f31225ef3c5f2b24a69220d165c42697f052427b27967525678846c8ddd0280a4177ef4f4b388e70a45c033a7e1dda7f6d16ead1d6c9ce786b552c96c6aefdbd
|
|
@@ -65,9 +65,9 @@ module Usps
|
|
|
65
65
|
# rubocop:disable Metrics
|
|
66
66
|
def perform!
|
|
67
67
|
case convert(options)
|
|
68
|
-
in mapper
|
|
69
|
-
in mapper
|
|
70
|
-
in mapper
|
|
68
|
+
in mapper:, field:, data: then mapper.put_field(field.to_sym, data)
|
|
69
|
+
in mapper:, field: then mapper.fetch(field.to_sym)
|
|
70
|
+
in mapper:, data: then mapper.update(data)
|
|
71
71
|
|
|
72
72
|
in on:, delete: true then on.delete
|
|
73
73
|
in on:, post: true, data: then on.post(data)
|
|
@@ -96,21 +96,31 @@ module Usps
|
|
|
96
96
|
def convert(options)
|
|
97
97
|
options.dup.tap do |converted|
|
|
98
98
|
case converted
|
|
99
|
-
in map: then converted.merge!(mapper:
|
|
99
|
+
in map: then converted.merge!(mapper: api.mapper, field: map)
|
|
100
|
+
in mapper: true then converted[:mapper] = api.mapper
|
|
100
101
|
in on: then converted[:on] = api.on(on)
|
|
101
102
|
in panel: then converted[:panel] = api.panels.public_send(panel)
|
|
102
103
|
else
|
|
103
104
|
# Nothing to convert
|
|
104
105
|
end
|
|
106
|
+
|
|
107
|
+
# Remove mapper flag when false
|
|
108
|
+
converted.delete(:mapper) unless converted[:mapper]
|
|
105
109
|
end
|
|
106
110
|
end
|
|
107
111
|
|
|
108
112
|
def simplify(data)
|
|
109
113
|
return data.to_a if data.is_a?(Query)
|
|
110
114
|
return data if options[:raw]
|
|
111
|
-
return data unless data.is_a?(Hash) # Includes Usps::Imis::Data
|
|
112
115
|
|
|
113
|
-
|
|
116
|
+
# Hash includes Usps::Imis::Data
|
|
117
|
+
if data.is_a?(Hash)
|
|
118
|
+
data.properties(include_ids: options[:include_ids])
|
|
119
|
+
elsif data.is_a?(Array) && data.all? { it.is_a?(Hash) }
|
|
120
|
+
data.map { it.properties(include_ids: options[:include_ids]) }
|
|
121
|
+
else
|
|
122
|
+
data
|
|
123
|
+
end
|
|
114
124
|
end
|
|
115
125
|
|
|
116
126
|
# :nocov:
|
|
@@ -13,25 +13,42 @@ module Usps
|
|
|
13
13
|
panel: ['Panel name', { type: :string }],
|
|
14
14
|
ordinal: ['Ordinal ID within a Panel', { type: :integer }],
|
|
15
15
|
query: ['IQA Query or Business Object name to query', { type: :string, short: :Q }],
|
|
16
|
+
mapper: ['Interact with mapped fields', { short: :M }],
|
|
17
|
+
map: ["Shorthand for accessing a single mapped field\n Equivalent to #{'-Mf'.green}", { type: :string }],
|
|
16
18
|
post: ["Send a #{'POST'.cyan} request", { short: :P }],
|
|
17
19
|
delete: ["Send a #{'DELETE'.cyan} request", { short: :D }],
|
|
18
20
|
field: ['Specific field to return or update', { type: :string }],
|
|
19
21
|
fields: ['Specific field(s) to return', { type: :strings, short: :F }],
|
|
20
|
-
|
|
21
|
-
mapper: ['Interact with mapped fields', { short: :M }],
|
|
22
|
-
data: ['JSON string input', { type: :string }],
|
|
22
|
+
data: ["JSON string input\n When present, sets the default HTTP verb to #{'PUT'.cyan}", { type: :string }],
|
|
23
23
|
config: ['Path to the JSON config file to use', { type: :string, short: :C }],
|
|
24
24
|
raw: ['Return raw JSON output, rather than simplified data', { short: :R }],
|
|
25
|
-
include_ids: [
|
|
26
|
-
quiet: [
|
|
27
|
-
log: [
|
|
25
|
+
include_ids: ["Include #{'iMIS ID'.yellow} and #{'Ordinal'.yellow} properties in returned data, if present"],
|
|
26
|
+
quiet: ["Suppress logging to #{'STDERR'.red}"],
|
|
27
|
+
log: ["Redirect logging to #{'STDOUT'.red}"],
|
|
28
28
|
log_level: ['Set the logging level', { type: :string, default: 'info', short: :L }]
|
|
29
29
|
}.freeze
|
|
30
30
|
|
|
31
31
|
CONFLICTING_OPTION_GROUPS = [
|
|
32
32
|
%i[certificate id],
|
|
33
33
|
%i[on panel query map],
|
|
34
|
-
%i[field fields map query]
|
|
34
|
+
%i[field fields map query],
|
|
35
|
+
%i[raw include_ids],
|
|
36
|
+
%i[quiet log_level],
|
|
37
|
+
%i[quiet log],
|
|
38
|
+
|
|
39
|
+
%i[post delete],
|
|
40
|
+
|
|
41
|
+
%i[post mapper],
|
|
42
|
+
%i[post query],
|
|
43
|
+
%i[post map],
|
|
44
|
+
|
|
45
|
+
%i[delete mapper],
|
|
46
|
+
%i[delete query],
|
|
47
|
+
%i[delete map]
|
|
48
|
+
].freeze
|
|
49
|
+
|
|
50
|
+
DEPENDENT_OPTION_PAIRS = [
|
|
51
|
+
%i[ordinal panel]
|
|
35
52
|
].freeze
|
|
36
53
|
|
|
37
54
|
attr_reader :arguments, :options
|
|
@@ -103,6 +120,7 @@ module Usps
|
|
|
103
120
|
|
|
104
121
|
OPTIONS.each { |option, data| opt(option, *data) }
|
|
105
122
|
CONFLICTING_OPTION_GROUPS.each { |group| conflicts(*group) }
|
|
123
|
+
DEPENDENT_OPTION_PAIRS.each { |pair| depends(*pair) }
|
|
106
124
|
|
|
107
125
|
educate_on_error
|
|
108
126
|
end
|
data/lib/usps/imis/version.rb
CHANGED