uc3-dmp-external-api 0.0.7 → 0.0.9
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 +4 -4
- data/lib/uc3-dmp-external-api/client.rb +5 -8
- data/lib/uc3-dmp-external-api/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e178888492267ac893548e8da18b84cedd8176aeb53cdba538d062a70c20ad86
|
4
|
+
data.tar.gz: 4ad54d6b09e2b4387166b0cf8cfd4e4ea30f494f06c8359441bde9eca1bff8c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb09f23c248470c64789cef799aec2825f0c710421321710daaa61d864b7868749eb1781bdba2d28cd2377cbb535e6dfcbae561844c3f830647aaee94afe38a5
|
7
|
+
data.tar.gz: 9e9ec1d090510c09b9dbb2086a0875a3ad294b1c9b297d00ec73a19e1f05a9be808add4e79206ac69c3a49154d64accc02197b3370badecf1fc25de75f3baeb4
|
@@ -18,11 +18,11 @@ module Uc3DmpExternalApi
|
|
18
18
|
class << self
|
19
19
|
# Call the specified URL using the specified HTTP method, body and headers
|
20
20
|
# rubocop:disable Metrics/AbcSize
|
21
|
-
def call(url:, method: :get, body: '', additional_headers: {},
|
21
|
+
def call(url:, method: :get, body: '', additional_headers: {}, logger: nil)
|
22
22
|
uri = URI(url)
|
23
23
|
# Skip the body if we are doing a get
|
24
24
|
body = nil if method.to_sym == :get
|
25
|
-
opts = _options(body: body, additional_headers: additional_headers,
|
25
|
+
opts = _options(body: body, additional_headers: additional_headers, logger: logger)
|
26
26
|
resp = HTTParty.send(method.to_sym, uri, opts)
|
27
27
|
|
28
28
|
if resp.code != 200
|
@@ -44,10 +44,7 @@ module Uc3DmpExternalApi
|
|
44
44
|
# # Handle the response body based on the Content-Type
|
45
45
|
def _process_response(resp:)
|
46
46
|
return nil if resp.body.nil? || resp.body.empty?
|
47
|
-
|
48
|
-
mime = resp.headers['content-type']
|
49
|
-
mime = 'application/json' if mime.nil? && (rep.body.start_with?('[') || resp.body.start_with?('{'))
|
50
|
-
return resp.body.to_s unless mime == 'application/json'
|
47
|
+
return resp.body.to_s unless resp.headers.fetch('content-type', '').include?('application/json')
|
51
48
|
|
52
49
|
JSON.parse(resp.body)
|
53
50
|
end
|
@@ -65,7 +62,7 @@ module Uc3DmpExternalApi
|
|
65
62
|
end
|
66
63
|
|
67
64
|
# Prepare the HTTParty gem options
|
68
|
-
def _options(body:, additional_headers: {},
|
65
|
+
def _options(body:, additional_headers: {}, logger: nil)
|
69
66
|
hdrs = _headers(additional_headers: additional_headers)
|
70
67
|
opts = {
|
71
68
|
headers: hdrs,
|
@@ -75,7 +72,7 @@ module Uc3DmpExternalApi
|
|
75
72
|
# If the body is not already JSON and we intend to send JSON, convert it
|
76
73
|
opts[:body] = body.is_a?(Hash) && hdrs['Content-Type'] == 'application/json' ? body.to_json : body
|
77
74
|
# If debug is enabled then tap into the HTTParty gem's debug option
|
78
|
-
opts[:debug_output] = $stdout if debug
|
75
|
+
opts[:debug_output] = $stdout if logger&.level == 'debug'
|
79
76
|
opts
|
80
77
|
end
|
81
78
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uc3-dmp-external-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Riley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: active_record_simple_execute
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.9.1
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.9.1
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: aws-sdk-sns
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|