usps-imis-api 0.12.10 → 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: 885f7ace4c5c5f77d9e986c1b09e12d9e1d811596800b6181220b24fe3fecbe8
4
- data.tar.gz: 397ad89928f4efdbfea3299123378685c4fcbe78c87edf852f2fd60873acd4a5
3
+ metadata.gz: 6ec2297be1e5f52e2fc6e790a8a8cf2aba7ff67a430f5bef76337f42fc298289
4
+ data.tar.gz: 4e919e980577e95daa39fbf84d5bb0326e5fbb22d51188a7eaa7cf19434197b3
5
5
  SHA512:
6
- metadata.gz: '07083a6c15f1177f94c2039f1a3b80c893bfd671a6d8f9cbcfeabad33d16a8d1da3d162132acf0864ed2d21768ac0ca773e72a65b0e6a02bbb08fe9a262342f5'
7
- data.tar.gz: e5933277a7c6923b729c26fa68a65a63cf91eb997b6bc18221c57db027cb4d310f96fe2dc3d554f2d0f1ec79803154eddc4bdcb2ab268a4c52de66f9908ee596
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
@@ -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)
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.12.10'
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.10
4
+ version: 0.12.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander