usps-imis-api 0.12.5 → 0.12.7
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: 30d6aa19fa31eec9b8764be29c68d392c0ea09a2a3591c1cd831f54929d4f0f2
|
|
4
|
+
data.tar.gz: 9c29140bb367ad070c8c0c2fe656760f4163ed37a6925eb51d772debe73acd38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f576a6640f0a423903fa1fa9a1bb80a723449ab1dba44ea0169e09eb350aba4bbd9249674624986a6bdeeeba6638d5cc60e77296f12b77f86b2360b67f72321b
|
|
7
|
+
data.tar.gz: d101dda70d3b2ce34f7764456f90d92e109e97e4174d66ee73f41074d0baf72a0ad537b43065af6fad08b5895744baaaae9735ed8da40c8e52d0a379608e5ac6
|
|
@@ -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|
|
|
@@ -95,6 +95,7 @@ csv:
|
|
|
95
95
|
# General config
|
|
96
96
|
config:
|
|
97
97
|
- "Path to the JSON/YAML config file to use, or one of the following preset options: \
|
|
98
|
+
`<%= 'local_dot'.yellow %>`, \
|
|
98
99
|
`<%= 'local'.yellow %>`, \
|
|
99
100
|
`<%= 'local_dot_config'.yellow %>`, \
|
|
100
101
|
`<%= 'local_config'.yellow %>`, \
|
|
@@ -110,7 +111,7 @@ include_ids:
|
|
|
110
111
|
- "Include any <%= 'iMIS ID'.yellow %> and <%= 'Ordinal'.yellow %> properties in returned data"
|
|
111
112
|
- short: N
|
|
112
113
|
|
|
113
|
-
#
|
|
114
|
+
# Interactions for supporting other language wrappers
|
|
114
115
|
auth_token:
|
|
115
116
|
- Return an auth token for other language wrappers
|
|
116
117
|
- 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