usps-imis-api 0.11.7 → 0.11.8

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: ae10bc832e8ffa7cb4bc3bb14f5ea0b2d2daef3866cde32cdaea89bfcfe60376
4
- data.tar.gz: 137943c3dce52c4c56bc32e2b2dcb6329e1bd568bb95c653084b299d701ed39e
3
+ metadata.gz: 5cb250d5dd836f5ca8b2382bcc45e788d57307dc47800337d59ff2976b4c52dd
4
+ data.tar.gz: 65c492cb9bec04a98be6aa8c5821cda5f3bf28304b91fb9202c13c95ab21ae67
5
5
  SHA512:
6
- metadata.gz: 9bfc02dddae6d07ee6fedfcc0a89101415d4af68cab2b90380f199957976dd4d128c2913373b38066a4da76d41fbc0a21bca6dab672032e3e6cd03ade2114547
7
- data.tar.gz: f31225ef3c5f2b24a69220d165c42697f052427b27967525678846c8ddd0280a4177ef4f4b388e70a45c033a7e1dda7f6d16ead1d6c9ce786b552c96c6aefdbd
6
+ metadata.gz: 764a6555ba593dc6e7b6b159aa741d9866f9981278fc1d4b7820d3a83efaa0ff5ddfff8eb93c7f2d09868853251db89163471582ed4a8f0086809c824823703d
7
+ data.tar.gz: 949e90aa4c506455184fd162cc75fb6b8a45c8c98b4e3561e3656d2445ca32b5174c6bd14164d51108fb5c69d7275a30a8cb06eda04ee480290eacb77524a6bd
@@ -131,11 +131,13 @@ module Usps
131
131
  end
132
132
  # :nocov:
133
133
 
134
+ # Supports YAML or JSON config data
135
+ #
134
136
  def configure!
135
- json_config = JSON.parse(File.read(options[:config]))
137
+ config_data = YAML.safe_load_file(options[:config])
136
138
 
137
139
  Usps::Imis.configure do |config|
138
- json_config.each do |key, value|
140
+ config_data.each do |key, value|
139
141
  config.public_send("#{key}=", value)
140
142
  end
141
143
  end
@@ -20,7 +20,7 @@ module Usps
20
20
  field: ['Specific field to return or update', { type: :string }],
21
21
  fields: ['Specific field(s) to return', { type: :strings, short: :F }],
22
22
  data: ["JSON string input\n When present, sets the default HTTP verb to #{'PUT'.cyan}", { type: :string }],
23
- config: ['Path to the JSON config file to use', { type: :string, short: :C }],
23
+ config: ['Path to the JSON/YAML config file to use', { type: :string, short: :C }],
24
24
  raw: ['Return raw JSON output, rather than simplified data', { short: :R }],
25
25
  include_ids: ["Include #{'iMIS ID'.yellow} and #{'Ordinal'.yellow} properties in returned data, if present"],
26
26
  quiet: ["Suppress logging to #{'STDERR'.red}"],
@@ -73,25 +73,9 @@ module Usps
73
73
 
74
74
  #{'Configuration'.underline}
75
75
 
76
- API configuration can be specified in two ways:
76
+ For an explanation of how to provide API configuration, please refer to the wiki:
77
77
 
78
-
79
- With #{'--config'.green}/#{'-C'.green} given the path to a JSON file, e.g.:
80
-
81
- {
82
- "imis_id_query_name": "#{'$/IQA_QUERY_NAME'.yellow}",
83
- "environment": "#{'development'.yellow}",
84
- "username": "#{'USERNAME'.yellow}",
85
- "password": "#{'PASSWORD'.yellow}"
86
- }
87
-
88
-
89
- By setting the following environment variables:
90
-
91
- #{'IMIS_ID_QUERY_NAME'.yellow}
92
- #{'IMIS_ENVIRONMENT'.yellow}
93
- #{'IMIS_USERNAME'.yellow}
94
- #{'IMIS_PASSWORD'.yellow}
78
+ https://github.com/unitedstatespowersquadrons/imis-api-ruby/wiki/Usage#command-line-interface
95
79
 
96
80
 
97
81
  #{'Options'.underline}
@@ -52,7 +52,6 @@ module Usps
52
52
  @api = api
53
53
  @query_name = query_name
54
54
  @query_params = query_params
55
- @query_params.merge!(QueryName: query_name) if iqa?
56
55
  @page_size = page_size
57
56
  @offset = offset
58
57
  @count = 0
@@ -137,10 +136,16 @@ module Usps
137
136
  def iqa? = query_name.match?(/^\$/)
138
137
  def query_type = iqa? ? :IQA : :'Business Object'
139
138
  def path_params = query_params.merge({ Offset: offset, Limit: page_size }.compact)
140
- def endpoint = iqa? ? IQA_PATH : "#{Imis::BusinessObject::API_PATH}/#{query_name}"
141
- def path = "#{endpoint}?#{path_params.to_query}"
142
139
  def uri = URI(File.join(Imis.configuration.hostname, path))
143
140
 
141
+ def path
142
+ if iqa?
143
+ "#{IQA_PATH}?#{path_params.merge(QueryName: query_name).to_query}"
144
+ else
145
+ "#{Imis::BusinessObject::API_PATH}/#{query_name}?#{path_params.to_query}"
146
+ end
147
+ end
148
+
144
149
  def logger = Imis.logger("#{query_type} Query")
145
150
  end
146
151
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.11.7'
5
+ VERSION = '0.11.8'
6
6
  end
7
7
  end
data/lib/usps/imis.rb CHANGED
@@ -4,6 +4,7 @@
4
4
  # Core dependencies
5
5
  require 'net/https'
6
6
  require 'json'
7
+ require 'yaml'
7
8
  require 'time'
8
9
  require 'cgi'
9
10
 
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.11.7
4
+ version: 0.11.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander