usps-imis-api 0.12.9 → 0.12.11

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: a42c46a141077cd81f0bf4ecd680a25ad10df88bd28d183d24280f2d7f0b5348
4
- data.tar.gz: f54f32c44e31d39dd5cef4703b72d3e9f95847b971194a91211bc314b767e932
3
+ metadata.gz: 6ec2297be1e5f52e2fc6e790a8a8cf2aba7ff67a430f5bef76337f42fc298289
4
+ data.tar.gz: 4e919e980577e95daa39fbf84d5bb0326e5fbb22d51188a7eaa7cf19434197b3
5
5
  SHA512:
6
- metadata.gz: 99af41b8445740f5e7489533314aa932ea57e51fae07ab37739c9dbcbc91a419aabf73fac67034debff920163a50770ffe60dab1ed7a1ae584a104a03fb1c8bc
7
- data.tar.gz: 12ca8d1d0e81ec8fa0c0644074e51789c079b242a56b2463f01705f56fde05891771b23c0f668a01af64a7b322ac5f2db74344fe63e492c9fa2bf5f7327ee8a5
6
+ metadata.gz: 01b5bfe414810fd40b892b37d83bfd8c5bc70380c8e3b4c824bb0bc211cfc1a6152452f531403b6ae108fdb72fca8529604d571aa26aa832778590f3f0b6febe
7
+ data.tar.gz: bb1e46ce5c63bfbcbd0b078e9f842b9acff81a0c256d5d3209e55ca0dbc0b6240dd774379f0264987f5b0dfb3741bf743b4085945ba277435247dd55e6578546
@@ -44,7 +44,12 @@ module Usps
44
44
  #
45
45
  # @return [Usps::Imis::Query] Query wrapper
46
46
  #
47
- def query = api.query(business_object_name)
47
+ def query(**) = api.query(business_object_name, **)
48
+
49
+ # Get all records from the business object for the current member
50
+ #
51
+ def get_all(**) = query(**, id: api.imis_id).to_a
52
+ alias list get_all
48
53
 
49
54
  # Support passthrough for Api#with
50
55
  #
@@ -69,6 +69,8 @@ module Usps
69
69
  CSV.generate(headers:, write_headers: !headers.nil?) do |csv|
70
70
  headers ? value.each { csv << it } : csv << value
71
71
  end
72
+ rescue StandardError
73
+ raise Errors::CommandLineError, 'Unable to format response as CSV'
72
74
  end
73
75
  end
74
76
  end
@@ -59,7 +59,7 @@ module Usps
59
59
 
60
60
  set_member
61
61
 
62
- result = simplify(perform!)
62
+ result = logger.time { simplify(perform!) }
63
63
 
64
64
  output { result }
65
65
 
@@ -47,6 +47,9 @@ create:
47
47
  delete:
48
48
  - "Send a <%= 'DELETE'.cyan %> request"
49
49
  - short: D
50
+ all:
51
+ - "Send a <%= 'GET'.cyan %> request for all records for a member"
52
+ - short: A
50
53
 
51
54
  # Data
52
55
  ordinal:
@@ -54,6 +54,7 @@ module Usps
54
54
  case options
55
55
  in delete: true then on.delete
56
56
  in create: true, data: then on.post(data)
57
+ in all: true then on.list
57
58
  in data:, field: then on.put_field(field, data)
58
59
  in data: then on.put_fields(data)
59
60
  in fields: then on.get_fields(*fields)
@@ -66,6 +67,7 @@ module Usps
66
67
  case options
67
68
  in delete: true, ordinal: then panel.delete(ordinal)
68
69
  in create: true, data: then panel.post(data)
70
+ in all: true then panel.list
69
71
  in ordinal:, data:, field: then panel.put_field(ordinal, field, data)
70
72
  in ordinal:, data: then panel.put_fields(ordinal, data)
71
73
  in ordinal:, fields: then panel.get_fields(ordinal, *fields)
@@ -15,6 +15,14 @@ module Usps
15
15
  rescue StandardError
16
16
  multiline(data)
17
17
  end
18
+
19
+ def time
20
+ start_time = Time.now
21
+
22
+ yield.tap do
23
+ tagged('Time').debug(ActiveSupport::Duration.build(Time.now - start_time).inspect)
24
+ end
25
+ end
18
26
  end
19
27
  end
20
28
  end
@@ -21,6 +21,17 @@ module Usps
21
21
  @logger = Imis.logger('Panel')
22
22
  end
23
23
 
24
+ # Run a query on the entire business object
25
+ #
26
+ # @return [Usps::Imis::Query] Query wrapper
27
+ #
28
+ def query(**) = api.query(business_object_name, **)
29
+
30
+ # Get all records from the Panel for the current member
31
+ #
32
+ def get_all(**) = query(**, id: api.imis_id).to_a
33
+ alias list get_all
34
+
24
35
  # Get a specific object from the Panel
25
36
  #
26
37
  # If +fields+ is provided, will return only those field values
@@ -88,7 +88,7 @@ module Usps
88
88
 
89
89
  # Fetch a filtered query page, and update the current offset
90
90
  #
91
- def page = fetch_next['Items']['$values'].map { iqa? ? it.except('$type') : Imis::Data[it] }
91
+ def page = fetch_next['Items']['$values'].map { iqa? ? it.except('$type') : wrap(it) }
92
92
 
93
93
  # Fetch the next raw query page, and update the current offset
94
94
  #
@@ -148,6 +148,8 @@ module Usps
148
148
  "#{Imis::BusinessObject::API_PATH}/#{query_name}?#{path_params.to_query}"
149
149
  end
150
150
  end
151
+
152
+ def wrap(data) = query_name == 'Party' ? Imis::PartyData[data] : Imis::Data[data]
151
153
  end
152
154
  end
153
155
  end
@@ -36,12 +36,12 @@ module Usps
36
36
  logger.debug "#{request.class.name.demodulize.upcase} #{uri}"
37
37
  logger.json sanitized_request_body(request)
38
38
 
39
- start_time = Time.now
40
- client.request(request).tap do |result|
41
- check_result_success!(result)
39
+ logger.time do
40
+ client.request(request).tap do |result|
41
+ check_result_success!(result)
42
42
 
43
- logger.info 'Request succeeded'
44
- logger.tagged('Time').debug ActiveSupport::Duration.build(Time.now - start_time).inspect
43
+ logger.info 'Request succeeded'
44
+ end
45
45
  end
46
46
  end
47
47
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.12.9'
5
+ VERSION = '0.12.11'
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.12.9
4
+ version: 0.12.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander