usps-imis-api 0.12.5 → 0.12.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: f3339b55eb073ceb6d09da8f6855a6b35181d9ba341968c19a029dc916e5f6da
4
- data.tar.gz: 3366076637725838e3f4b404d2db28f349632681bb2211fb7cf1d3493965073f
3
+ metadata.gz: 856bf739e0e0b82c34436be2f0bf897d442a8080513f12f387204f0a5a5e095d
4
+ data.tar.gz: 655004a782af3a21ae1224678c34dcd9936f71b943af1d657579a7bf4991bbf4
5
5
  SHA512:
6
- metadata.gz: e5d137638ffabd6b8ecdf5a72ec2d3769ef511d0963f431d7fc9d34d5659d7a460e3c7e60acbc87532b04ca519e7ed2f5bfd38c30f50fc70ddcd97302a44066a
7
- data.tar.gz: b9e980910b7507a39dec6ad2ca992ebbcf57227f119775bdfa972d58045a60d0b569137e3952c81aff16ed311ac2e49306b528800c4dca22e3c26f4a4fe2bc24
6
+ metadata.gz: ba31e19e7a0fd96800c83f7727b000acbcea80066c8edcabcf03f4cf020066e65573127f20a07f6fe155b807b25b531c8179d11a0e1adc6082a3566186c57724
7
+ data.tar.gz: 5b9e6900ff14f31d1eab9d00ba559861790ae89b6f09b2a29df3a81de149bbd62f681df57a3b09e03725bfcf4e607a6c5a0d63102178f757eabd9be0fe33006f
@@ -46,11 +46,11 @@ module Usps
46
46
 
47
47
  value = yield
48
48
 
49
- puts format(value)
49
+ puts format_output(value)
50
50
  end
51
51
  # :nocov:
52
52
 
53
- def format(value)
53
+ def format_output(value)
54
54
  if value.is_a?(Array) && @options[:jsonl] then jsonl(value)
55
55
  elsif value.is_a?(Array) && @options[:csv] then csv(value)
56
56
  else json(value)
@@ -62,6 +62,8 @@ module Usps
62
62
  def jsonl(value) = value.map { JSON.dump(it) }
63
63
 
64
64
  def csv(value)
65
+ return '' if value.empty?
66
+
65
67
  headers = value.first.keys if value.first.is_a?(Hash) || value.first.is_a?(BaseData)
66
68
 
67
69
  CSV.generate(headers:, write_headers: !headers.nil?) do |csv|
@@ -110,7 +110,7 @@ include_ids:
110
110
  - "Include any <%= 'iMIS ID'.yellow %> and <%= 'Ordinal'.yellow %> properties in returned data"
111
111
  - short: N
112
112
 
113
- # Iteractions for supporting other language wrappers
113
+ # Interactions for supporting other language wrappers
114
114
  auth_token:
115
115
  - Return an auth token for other language wrappers
116
116
  - short: T
@@ -138,8 +138,7 @@ module Usps
138
138
  # Support shorthand for setting `certificate` param on queries
139
139
  return unless @options[:query] && @options[:certificate]
140
140
 
141
- @options[:data] ||= {}
142
- @options[:data]['certificate'] = @options.delete(:certificate)
141
+ @options[:data] = { 'certificate' => @options.delete(:certificate) }
143
142
  end
144
143
 
145
144
  def validate_query_options!
@@ -75,16 +75,11 @@ module Usps
75
75
  end
76
76
 
77
77
  def perform_query(query, **options)
78
- case options
79
- in page: _, page_size:, offset:, data: then api.query(query, page_size:, offset:, **data).page
80
- in page: _, page_size:, offset: then api.query(query, page_size:, offset:).page
81
- in page: _, page_size:, data: then api.query(query, page_size:, **data).page
82
- in page: _, page_size: then api.query(query, page_size:).page
83
- in page_size:, offset:, data: then api.query(query, page_size:, offset:, **data)
84
- in page_size:, data: then api.query(query, page_size:, **data)
85
- in data: then api.query(query, **data)
86
- else api.query(query)
87
- end
78
+ kwargs = options.slice(:page_size, :offset)
79
+ kwargs.merge!(options[:data]) if options[:data]
80
+
81
+ result = api.query(query, **kwargs)
82
+ options.key?(:page) ? result.page : result
88
83
  end
89
84
  end
90
85
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.12.5'
5
+ VERSION = '0.12.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.12.5
4
+ version: 0.12.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander