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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 856bf739e0e0b82c34436be2f0bf897d442a8080513f12f387204f0a5a5e095d
|
|
4
|
+
data.tar.gz: 655004a782af3a21ae1224678c34dcd9936f71b943af1d657579a7bf4991bbf4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
49
|
+
puts format_output(value)
|
|
50
50
|
end
|
|
51
51
|
# :nocov:
|
|
52
52
|
|
|
53
|
-
def
|
|
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
|
-
#
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
data/lib/usps/imis/version.rb
CHANGED