wolf_core 0.1.44 → 0.1.45
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90c1f8f955a6f904bd51d2ee8c728979342cdce86d656f1410486489192cd419
|
4
|
+
data.tar.gz: 7b9ba63cef9b265c8942925a088e53406e75dd95cbebc6cada8c023ba7535c41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71132fc6ff3d9695a7c6729d71a851fdd39383bd5c04f3605cc58f348bb5ae192343b29b81fc62ab0d76262eff43e2ad24467b8e36c6ee0889ecbc68abc5e0fd
|
7
|
+
data.tar.gz: 73b0d496431e45270609aef6ad44a860e79b04520b943a5e6cab3640e2b125ff97888e3a9c08ec274eb92a996d229b516f188befe251cc3fde313ab29d78d407
|
@@ -24,27 +24,6 @@ module WolfCore
|
|
24
24
|
)
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
28
|
-
def import_order_description(order_id:, listing:)
|
29
|
-
domain_url = ENV['GENERATE_JOB_DESCRIPTION_URL']
|
30
|
-
path = 'barton/import/order_description'
|
31
|
-
headers = {
|
32
|
-
'Authorization' => ENV['GENERATE_JOB_DESCRIPTION_TOKEN'],
|
33
|
-
'tenant' => ENV['GENERATE_JOB_DESCRIPTION_TENANT'],
|
34
|
-
}
|
35
|
-
body = { order_id: order_id, listing: listing }
|
36
|
-
|
37
|
-
if domain_url.present?
|
38
|
-
async_http_post(url: "#{domain_url}/#{path}", headers: headers, body: body)
|
39
|
-
else
|
40
|
-
function_name = PATH_TO_FUNCTION_NAME_MAPPING[path]
|
41
|
-
body['headers'] = headers
|
42
|
-
invoke_lambda(
|
43
|
-
function_name: function_name,
|
44
|
-
payload: body,
|
45
|
-
)
|
46
|
-
end
|
47
|
-
end
|
48
27
|
end
|
49
28
|
end
|
50
29
|
end
|
@@ -2,18 +2,30 @@ module WolfCore
|
|
2
2
|
module HttpOperations
|
3
3
|
include WolfCore::ExceptionOperations
|
4
4
|
include WolfCore::AsyncUtils
|
5
|
+
include WolfCore::LoggingUtils
|
5
6
|
|
6
7
|
def async_http_get(**args)
|
7
|
-
|
8
|
-
|
9
|
-
pp args
|
8
|
+
log_object 'starting async_http_get'
|
9
|
+
log_object args, title: 'async_http_get args are'
|
10
10
|
run_async do
|
11
11
|
response = http_get(**args)
|
12
|
-
|
13
|
-
pp parse_http_response(response).to_h
|
12
|
+
log_object parse_http_response(response), title: 'async_http_get response is'
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
16
|
+
def safe_http_get(url:, headers: {}, query: nil, error_message: nil, title: nil)
|
17
|
+
response = http_get(url: url, headers: headers, query: query)
|
18
|
+
response = parse_http_response(response)
|
19
|
+
|
20
|
+
title ||= 'safe_http_get response is'
|
21
|
+
log_object response, title: title
|
22
|
+
|
23
|
+
error_message ||= 'Error on safe_http_get'
|
24
|
+
validate_http_response(response: response, message: error_message)
|
25
|
+
|
26
|
+
response
|
27
|
+
end
|
28
|
+
|
17
29
|
def http_get(url:, headers: {}, query: nil)
|
18
30
|
WolfCore::HttpDataSource.http_get(url: url, headers: headers, query: query)
|
19
31
|
end
|
@@ -21,29 +33,54 @@ module WolfCore
|
|
21
33
|
def async_http_post(**args)
|
22
34
|
puts "starting async_http_post"
|
23
35
|
puts "async_http_post args are"
|
24
|
-
|
36
|
+
log_object args
|
25
37
|
run_async do
|
26
38
|
response = http_post(**args)
|
27
39
|
puts "async_http_post response is"
|
28
|
-
|
40
|
+
log_object parse_http_response(response).to_h
|
29
41
|
end
|
30
42
|
end
|
31
43
|
|
44
|
+
def safe_http_post(url:, headers: {}, body: nil, query: nil, error_message: nil, title: nil)
|
45
|
+
response = http_post(url: url, headers: headers, body: body, query: query)
|
46
|
+
response = parse_http_response(response)
|
47
|
+
|
48
|
+
title ||= 'safe_http_post response is'
|
49
|
+
log_object response, title: title
|
50
|
+
|
51
|
+
error_message ||= 'Error on safe_http_post'
|
52
|
+
validate_http_response(response: response, message: error_message)
|
53
|
+
|
54
|
+
response
|
55
|
+
end
|
56
|
+
|
32
57
|
def http_post(url:, headers: {}, body: nil, query: nil)
|
33
58
|
WolfCore::HttpDataSource.http_post(url: url, headers: headers, query: query, body: body)
|
34
59
|
end
|
35
60
|
|
36
61
|
def async_http_put(**args)
|
37
|
-
|
38
|
-
|
39
|
-
pp args
|
62
|
+
log_object 'starting async_http_put'
|
63
|
+
log_object args, title: 'async_http_put args are'
|
40
64
|
run_async do
|
41
65
|
response = http_put(**args)
|
42
66
|
puts "async_http_put response is"
|
43
|
-
|
67
|
+
log_object parse_http_response(response).to_h
|
44
68
|
end
|
45
69
|
end
|
46
70
|
|
71
|
+
def safe_http_put(url:, headers: {}, body: nil, query: nil, error_message: nil, title: nil)
|
72
|
+
response = http_put(url: url, headers: headers, body: body, query: query)
|
73
|
+
response = parse_http_response(response)
|
74
|
+
|
75
|
+
title ||= 'safe_http_put response is'
|
76
|
+
log_object response, title: title
|
77
|
+
|
78
|
+
error_message ||= 'Error on safe_http_put'
|
79
|
+
validate_http_response(response: response, message: error_message)
|
80
|
+
|
81
|
+
response
|
82
|
+
end
|
83
|
+
|
47
84
|
def http_put(url:, headers: {}, body: nil, query: nil)
|
48
85
|
WolfCore::HttpDataSource.http_put(url: url, headers: headers, query: query, body: body)
|
49
86
|
end
|
data/lib/wolf_core/version.rb
CHANGED