naranya_ecm-sdk 0.0.22 → 0.0.23
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/naranya_ecm-sdk.rb +8 -0
- data/lib/naranya_ecm-sdk/version.rb +1 -1
- data/lib/naranya_ecm/rest/client.rb +9 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d79823461b0001b4f7559d10806b5d80c9010fcf
|
4
|
+
data.tar.gz: b8302cc1f957e309f4d7d45e33c1507c4565204d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52cd6c2eb08f9bf803d6a87473fce85c2efd5e39f95f3592f5c371eb88fc32a6f23bf863d0f587301723f442827c371ae4612a87e5c59a482e4dd89c52a8ab0a
|
7
|
+
data.tar.gz: 8da103e715e0b4484bfd75b1ecaf954269c0406d2c139692bd4511ab3c2506fd75ad8db620d5281af3f63c06cd23de80c4c909141e3ec143d1e7863bd228ecc1
|
data/lib/naranya_ecm-sdk.rb
CHANGED
@@ -86,6 +86,11 @@ module NaranyaEcm
|
|
86
86
|
@cache ||= ActiveSupport::Cache.lookup_store *options[:cache]
|
87
87
|
end
|
88
88
|
|
89
|
+
def logger
|
90
|
+
auto_conf unless config.present?
|
91
|
+
@logger ||= Logger.new($stdout)
|
92
|
+
end
|
93
|
+
|
89
94
|
def load_config_from_yml(yml_path, env="production")
|
90
95
|
raise "YAML file doesn't extst" unless File.exist?(yml_path)
|
91
96
|
yml_config = DEFAULT_CONFIG.merge(YAML::load(ERB.new(File.read(yml_path)).result)[env])
|
@@ -103,6 +108,9 @@ module NaranyaEcm
|
|
103
108
|
|
104
109
|
# Use the Rails cache:
|
105
110
|
@cache = Rails.cache
|
111
|
+
|
112
|
+
# Use the Rails logger:
|
113
|
+
@logger = Rails.logger
|
106
114
|
elsif File.exists?('./naranya_ecm.yml')
|
107
115
|
load_config_from_yml('./naranya_ecm.yml')
|
108
116
|
end
|
@@ -22,7 +22,11 @@ module NaranyaEcm::Rest
|
|
22
22
|
|
23
23
|
options[:headers] = {} unless options.has_key? :headers
|
24
24
|
options[:headers]['Authorization'] = authorization_header
|
25
|
-
|
25
|
+
|
26
|
+
options[:logger] = NaranyaEcm.logger
|
27
|
+
options[:log_level] = :debug
|
28
|
+
options[:log_format] = :curl
|
29
|
+
|
26
30
|
response = HTTParty.send method, url, options
|
27
31
|
|
28
32
|
# Retry if response code is 422 and a client token is present:
|
@@ -46,7 +50,10 @@ module NaranyaEcm::Rest
|
|
46
50
|
@authorization_header ||= NaranyaEcm.cache.fetch(TOKEN_CACHE_KEY) do
|
47
51
|
token_response = HTTParty.post "#{NaranyaEcm.options[:site]}/oauth/token",
|
48
52
|
basic_auth: { username: NaranyaEcm.options[:api_key], password: NaranyaEcm.options[:api_secret] },
|
49
|
-
body: { grant_type: "client_credentials" }
|
53
|
+
body: { grant_type: "client_credentials" },
|
54
|
+
logger: NaranyaEcm.logger,
|
55
|
+
log_level: :debug,
|
56
|
+
log_format: :curl
|
50
57
|
|
51
58
|
::NaranyaEcm::Rest::RestError.raise_by_code(token_response.code) unless token_response.success?
|
52
59
|
|