usps-imis-api 0.11.4 → 0.11.6

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: e8eb337744ecc5e0a04d0bcb6d7b0dc6f0a71652dcb419d2ad401fac4d2ebd62
4
- data.tar.gz: 94cd6355d822afb03d72d17c038b4be0a4afd163ffe0c686654be3617fec355a
3
+ metadata.gz: 67535b48ce969a401d19d573ba5b1557fac0dfa971dddacf9345a0c1c365486f
4
+ data.tar.gz: 6c39e4c4f3276f8bd26a317c2c96ebf0be2561998d5b3cfecc3ebdefd27d6328
5
5
  SHA512:
6
- metadata.gz: 6d9c4765758a516a7119dd43dc7d2681b09eef01d00ade3967cb0495c88b1b7b09579df78e8cb35e7bf035bcb487ed03c3aeff8cf3915f890451a560cb75d003
7
- data.tar.gz: fb012df3006fddd40566eca42371452c98908e88dd869c2733fe90ee858b1cffe44f087639787433534a9e1dc9a37cb8bd5c773e78441d5a6ea6d4ff9019c41b
6
+ metadata.gz: 4c9fa38439583904701cfbd42aaad35e9b1affae85fb15eaf94237641380462df353aaa25b93ec901e633ef37b8ee88af5e55928cb560a2ec273484fcb79b731
7
+ data.tar.gz: f321eaf91b434b4bfa15279cab97fbf9d2c7f0d9d54094f6987de69742ea1927d0f5f93bd6206a458316cb99dc02222c7e030780b4a09dfede70d174b34b865d
@@ -64,26 +64,26 @@ module Usps
64
64
 
65
65
  # rubocop:disable Metrics
66
66
  def perform!
67
- case options
67
+ case convert(options)
68
+ in mapper: true, field:, data: then api.mapper[field.to_sym] = data
69
+ in mapper: true, field: then api.mapper[field.to_sym]
68
70
  in mapper: true, data: then api.mapper.update(data)
69
- in map:, data: then api.mapper[map.to_sym] = data
70
- in map: then api.mapper[map.to_sym]
71
-
72
- in on:, delete: true then api.on(on).delete
73
- in on:, data:, post: true then api.on(on).post(data)
74
- in on:, data:, field: then api.on(on).put_field(field, data)
75
- in on:, data: then api.on(on).put_fields(data)
76
- in on:, fields: then api.on(on).get_fields(*fields)
77
- in on:, field: then api.on(on).get_field(field)
78
- in on: then api.on(on).get
79
-
80
- in panel:, ordinal:, delete: true then api.panels.public_send(panel).delete(ordinal)
81
- in panel:, data:, post: true then api.panels.public_send(panel).post(data)
82
- in panel:, ordinal:, data:, field: then api.panels.public_send(panel).put_field(ordinal, field, data)
83
- in panel:, ordinal:, data: then api.panels.public_send(panel).put_fields(ordinal, data)
84
- in panel:, ordinal:, fields: then api.panels.public_send(panel).get_fields(ordinal, *fields)
85
- in panel:, ordinal:, field: then api.panels.public_send(panel).get_field(ordinal, field)
86
- in panel:, ordinal: then api.panels.public_send(panel).get(ordinal)
71
+
72
+ in on:, delete: true then on.delete
73
+ in on:, post: true, data: then on.post(data)
74
+ in on:, data:, field: then on.put_field(field, data)
75
+ in on:, data: then on.put_fields(data)
76
+ in on:, fields: then on.get_fields(*fields)
77
+ in on:, field: then on.get_field(field)
78
+ in on: then on.get
79
+
80
+ in panel:, delete: true, ordinal: then panel.delete(ordinal)
81
+ in panel:, post: true, data: then panel.post(data)
82
+ in panel:, ordinal:, data:, field: then panel.put_field(ordinal, field, data)
83
+ in panel:, ordinal:, data: then panel.put_fields(ordinal, data)
84
+ in panel:, ordinal:, fields: then panel.get_fields(ordinal, *fields)
85
+ in panel:, ordinal:, field: then panel.get_field(ordinal, field)
86
+ in panel:, ordinal: then panel.get(ordinal)
87
87
 
88
88
  in query:, data: then api.query(query, data)
89
89
  in query: then api.query(query)
@@ -93,6 +93,18 @@ module Usps
93
93
  end
94
94
  # rubocop:enable Metrics
95
95
 
96
+ def convert(options)
97
+ options.dup.tap do |converted|
98
+ case converted
99
+ in map: then converted.merge!(mapper: true, field: map)
100
+ in on: then converted[:on] = api.on(on)
101
+ in panel: then converted[:panel] = api.panels.public_send(panel)
102
+ else
103
+ # Nothing to convert
104
+ end
105
+ end
106
+ end
107
+
96
108
  def simplify(data)
97
109
  return data.to_a if data.is_a?(Query)
98
110
  return data if options[:raw]
@@ -136,13 +148,9 @@ module Usps
136
148
  end
137
149
 
138
150
  def validate_options!
139
- if options[:log_level] == 'info' && options.except(:log_level, :quiet).values.none?
140
- raise Errors::CommandLineError, 'No options provided'
141
- end
142
-
143
- return if options[:query].nil? || options[:query].start_with?('$/')
151
+ return unless options[:log_level] == 'info' && options.except(:log_level, :quiet).values.none?
144
152
 
145
- raise Errors::CommandLineError, 'Invalid IQA Query name'
153
+ raise Errors::CommandLineError, 'No options provided'
146
154
  end
147
155
  end
148
156
  end
@@ -12,13 +12,13 @@ module Usps
12
12
  on: ['Business Object name', { type: :string }],
13
13
  panel: ['Panel name', { type: :string }],
14
14
  ordinal: ['Ordinal ID within a Panel', { type: :integer }],
15
- query: ['IQA Query name', { type: :string, short: :Q }],
15
+ query: ['IQA Query or Business Object name to query', { type: :string, short: :Q }],
16
16
  post: ["Send a #{'POST'.cyan} request", { short: :P }],
17
17
  delete: ["Send a #{'DELETE'.cyan} request", { short: :D }],
18
18
  field: ['Specific field to return or update', { type: :string }],
19
19
  fields: ['Specific field(s) to return', { type: :strings, short: :F }],
20
- map: ['Mapped field name to return or update', { type: :string }],
21
- mapper: ['Multiple mapped fields to update together', { short: :M }],
20
+ map: ['Shorthand for accessing a single mapped field', { type: :string }],
21
+ mapper: ['Interact with mapped fields', { short: :M }],
22
22
  data: ['JSON string input', { 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 }],
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.11.4'
5
+ VERSION = '0.11.6'
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.11.4
4
+ version: 0.11.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander