usps-imis-api 0.11.12 → 0.11.14

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: 3b7dbdde63c0e5541e240df706bd51d2f4db983473a29e3b5db1d4779015893b
4
- data.tar.gz: aa80e0a5094e561d3e8a2b64c56c9e18ea4cf93c24a6e3c8729c108d3a639ccf
3
+ metadata.gz: 44450f01517549462f9d3aa96be347bd194af2ae1b5783f6b850490e00996c1b
4
+ data.tar.gz: 4f0e3a76e46b7b18c1f2fb6456d49630df2bf61a123f672ac892926db3504abb
5
5
  SHA512:
6
- metadata.gz: cda6f17fedd33eaed4f347bf0213b4f87ba1d784cd333208a244c84ac6223610363f402bc40348eb2bc4ea770de83d3f63edfa37bd3bcb5d3c4d7454cc064780
7
- data.tar.gz: 2124949a5db9853087e076681f76b3e7df609610573026679f2bc89f9403f88cf762ae9be68f2a7f3852d255a9bfcceb3eed02bf0a5b518d5f6b9daaeeec0a84
6
+ metadata.gz: 7e3c7adbd2000547146095a15a375e330a9a14ec4fd63fdac085d08b36fc3932bd99f3c3c165de8321ad8b55dc7022496e5ab6c672333296fc88d180997e0acc
7
+ data.tar.gz: 4157ad2c639306c47026fe1a14846515a07a2933cd6f039e5d44887aef7b3e5167d2c0bd5c6bc7f5510e7d25167bbb04a986b42ea5088aa09fbcc114404c5382
data/lib/usps/imis/api.rb CHANGED
@@ -46,6 +46,8 @@ module Usps
46
46
  #
47
47
  # @param id [Integer, String] iMIS ID to select for future requests
48
48
  #
49
+ # @return [Integer] iMIS ID
50
+ #
49
51
  def imis_id=(id)
50
52
  raise Errors::LockedIdError if lock_imis_id
51
53
 
@@ -56,7 +58,7 @@ module Usps
56
58
  #
57
59
  # @param certificate [String] Certificate number to lookup the corresponding iMIS ID for
58
60
  #
59
- # @return [String] Corresponding iMIS ID
61
+ # @return [Integer] Corresponding iMIS ID
60
62
  #
61
63
  def imis_id_for(certificate)
62
64
  raise Errors::LockedIdError if lock_imis_id
@@ -85,6 +87,8 @@ module Usps
85
87
  # update(mm: 15)
86
88
  # end
87
89
  #
90
+ # @return [Usps::Imis::Api]
91
+ #
88
92
  def with(id, &)
89
93
  old_id = imis_id
90
94
  self.imis_id = id
@@ -117,6 +121,8 @@ module Usps
117
121
  # @param business_object_name [String] Name of the business object
118
122
  # @param ordinal [Integer] Ordinal to build override ID param of the URL (e.g. used for Panels)
119
123
  #
124
+ # @return [Usps::Imis::BusinessObject]
125
+ #
120
126
  def on(business_object_name, ordinal: nil, &)
121
127
  object = BusinessObject.new(self, business_object_name, ordinal:)
122
128
  return object unless block_given?
@@ -132,24 +138,34 @@ module Usps
132
138
 
133
139
  # Convenience alias for reading mapped fields
134
140
  #
141
+ # @return Value of the specified field
142
+ #
135
143
  def fetch(field_key) = mapper.fetch(field_key)
136
144
  alias [] fetch
137
145
 
138
146
  # Convenience alias for reading multiple mapped fields
139
147
  #
148
+ # @return [Array] Values of the specified fields
149
+ #
140
150
  def fetch_all(*fields) = mapper.fetch_all(*fields)
141
151
 
142
152
  # Convenience alias for updating mapped fields
143
153
  #
154
+ # @return [Array] Array containing the updated object
155
+ #
144
156
  def put_field(field_key, value) = update(field_key => value)
145
157
  alias []= put_field
146
158
 
147
159
  # Convenience alias for updating mapped fields
148
160
  #
161
+ # @return [Usps::Imis::Data] Updated object
162
+ #
149
163
  def update(data) = mapper.update(data)
150
164
 
151
165
  # List of available Business Object names
152
166
  #
167
+ # @return [Hash<Symbol, Array<String>>] Grouped available Business Objects
168
+ #
153
169
  def business_objects
154
170
  abc, other = query('BOEntityDefinition').map(&:entity).partition { it.include?('ABC') }
155
171
 
@@ -71,7 +71,7 @@ module Usps
71
71
  in mapper:, data: then mapper.update(data)
72
72
 
73
73
  in on:, delete: true then on.delete
74
- in on:, post: true, data: then on.post(data)
74
+ in on:, create: true, data: then on.post(data)
75
75
  in on:, data:, field: then on.put_field(field, data)
76
76
  in on:, data: then on.put_fields(data)
77
77
  in on:, fields: then on.get_fields(*fields)
@@ -79,7 +79,7 @@ module Usps
79
79
  in on: then on.get
80
80
 
81
81
  in panel:, delete: true, ordinal: then panel.delete(ordinal)
82
- in panel:, post: true, data: then panel.post(data)
82
+ in panel:, create: true, data: then panel.post(data)
83
83
  in panel:, ordinal:, data:, field: then panel.put_field(ordinal, field, data)
84
84
  in panel:, ordinal:, data: then panel.put_fields(ordinal, data)
85
85
  in panel:, ordinal:, fields: then panel.get_fields(ordinal, *fields)
@@ -88,6 +88,8 @@ module Usps
88
88
 
89
89
  in query:, data: then api.query(query, data)
90
90
  in query: then api.query(query)
91
+
92
+ in business_objects: true then api.business_objects
91
93
  end
92
94
  rescue NoMatchingPatternError => e
93
95
  raise Errors::CommandLineError, "Unable to match pattern from options: #{e.message}"
@@ -115,7 +117,7 @@ module Usps
115
117
  return data if options[:raw]
116
118
 
117
119
  # Hash includes Usps::Imis::Data
118
- if data.is_a?(Hash)
120
+ if data.is_a?(Hash) && !options[:business_objects]
119
121
  data.properties(include_ids: options[:include_ids])
120
122
  elsif data.is_a?(Array) && data.all? { it.is_a?(Hash) }
121
123
  data.map { it.properties(include_ids: options[:include_ids]) }
@@ -7,22 +7,32 @@ module Usps
7
7
  #
8
8
  class OptionsParser
9
9
  OPTIONS = {
10
+ # IDs
10
11
  certificate: ['Member certificate number', { type: :string }],
11
12
  id: ['Member iMIS ID', { type: :integer }],
13
+
14
+ # Primary interactions
12
15
  on: ['Business Object name', { type: :string }],
13
16
  panel: ['Panel name', { type: :string }],
14
- ordinal: ['Ordinal ID within a Panel', { type: :integer }],
15
17
  query: ['IQA Query or Business Object name to query', { type: :string, short: :Q }],
16
18
  mapper: ['Interact with mapped fields', { short: :M }],
17
- map: ["Shorthand for accessing a single mapped field\n Equivalent to #{'-Mf'.green}", { type: :string }],
18
- post: ["Send a #{'POST'.cyan} request", { short: :P }],
19
+ map: ["Shorthand for #{'-Mf'.green} to access a single mapped field", { type: :string }],
20
+ business_objects: ['List available Business Objects'],
21
+
22
+ # Alternate verbs
23
+ create: ["Send a #{'POST'.cyan} request", { short: :P }],
19
24
  delete: ["Send a #{'DELETE'.cyan} request", { short: :D }],
25
+
26
+ # Data
27
+ ordinal: ['Ordinal ID within a Panel', { type: :integer }],
20
28
  field: ['Specific field to return or update', { type: :string }],
21
29
  fields: ['Specific field(s) to return', { type: :strings, short: :F }],
22
- data: ["JSON string input\n When present, sets the default HTTP verb to #{'PUT'.cyan}", { type: :string }],
30
+ data: ['JSON string input', { type: :string }],
31
+
32
+ # General config
23
33
  config: ['Path to the JSON/YAML config file to use', { type: :string, short: :C }],
24
34
  raw: ['Return raw JSON output, rather than simplified data', { short: :R }],
25
- include_ids: ["Include #{'iMIS ID'.yellow} and #{'Ordinal'.yellow} properties in returned data, if present"],
35
+ include_ids: ["Include any #{'iMIS ID'.yellow} and #{'Ordinal'.yellow} properties in returned data"],
26
36
  quiet: ["Suppress logging to #{'STDERR'.red}"],
27
37
  log: ["Redirect logging to #{'STDOUT'.red}"],
28
38
  log_level: ['Set the logging level', { type: :string, default: 'info', short: :L }]
@@ -30,25 +40,32 @@ module Usps
30
40
 
31
41
  CONFLICTING_OPTION_GROUPS = [
32
42
  %i[certificate id],
33
- %i[on panel query map],
43
+ %i[on panel query mapper map business_objects],
34
44
  %i[field fields map query],
35
45
  %i[raw include_ids],
36
46
  %i[quiet log_level],
37
47
  %i[quiet log],
38
48
 
39
- %i[post delete],
49
+ %i[create delete],
40
50
 
41
- %i[post mapper],
42
- %i[post query],
43
- %i[post map],
51
+ %i[create mapper],
52
+ %i[create query],
53
+ %i[create map],
54
+ %i[create field],
55
+ %i[create fields],
44
56
 
45
57
  %i[delete mapper],
46
58
  %i[delete query],
47
- %i[delete map]
59
+ %i[delete map],
60
+ %i[delete field],
61
+ %i[delete fields],
62
+ %i[delete data],
63
+ %i[delete raw]
48
64
  ].freeze
49
65
 
50
66
  DEPENDENT_OPTION_PAIRS = [
51
- %i[ordinal panel]
67
+ %i[ordinal panel],
68
+ %i[create data]
52
69
  ].freeze
53
70
 
54
71
  attr_reader :arguments, :options
@@ -67,20 +84,10 @@ module Usps
67
84
  #{'imis.rb'.bold} #{'[options]'.gray}
68
85
 
69
86
 
70
- #{'HTTP Verbs'.underline}
71
-
72
- The default HTTP verb is #{'GET'.cyan}.
73
-
74
- If #{'--data'.green}/#{'-d'.green} is provided, the default HTTP verb is #{'PUT'.cyan}.
75
-
76
- #{'--data'.green}/#{'-d'.green} is used to provide field(s) data for #{'PUT'.cyan}
77
- requests and mapper updates, object data for #{'POST'.cyan},
78
- and to provide any query params.
79
-
80
-
81
- #{'Configuration'.underline}
87
+ #{'Further Help'.underline}
82
88
 
83
- For an explanation of how to provide API configuration, please refer to the wiki:
89
+ For an explanation of how to provide API configuration, more details on the options,
90
+ and usage examples, please refer to the wiki:
84
91
 
85
92
  https://github.com/unitedstatespowersquadrons/imis-api-ruby/wiki/Command-Line
86
93
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.11.12'
5
+ VERSION = '0.11.14'
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.12
4
+ version: 0.11.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander