blackstack-core 1.2.2 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blackstack-core.rb +1 -0
- data/lib/functions.rb +16 -21
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8344c762d3fc997d89a57ddcd77676814c455723f26bfe8d22e95c099cdc288
|
4
|
+
data.tar.gz: 63a99bb07b29dc75226b246495c3f101ca052786c0c3aa22cc4d1b2c15690ece
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97e7775f584296c46873f921177452f9e27d94237d370e83df9f951f5436ac6a066917ce627b4ad8f106e532b090413dd126f801d37c914ae5d7394c8a61a8b3
|
7
|
+
data.tar.gz: 4f353651ad7da375523ea5c5758f9e30b1d7ca2f98bb282672cb39a3169fb5e56ce370ec8fc464572d69a9e2a027c49da3aec2c208948de4e1a98ba5f47e0b82
|
data/lib/blackstack-core.rb
CHANGED
data/lib/functions.rb
CHANGED
@@ -560,7 +560,7 @@ module BlackStack
|
|
560
560
|
res = http.request req
|
561
561
|
case res
|
562
562
|
when Net::HTTPSuccess then res
|
563
|
-
when Net::HTTPRedirection then BlackStack::Netting::call_get(URI(res['location']), params, false) if support_redirections
|
563
|
+
when Net::HTTPRedirection then BlackStack::Netting::call_get(URI(res['location']), params, ssl_verify_mode, false) if support_redirections
|
564
564
|
else
|
565
565
|
res.error!
|
566
566
|
end
|
@@ -573,13 +573,13 @@ module BlackStack
|
|
573
573
|
# For more information about support for complex data structures, reference to: https://github.com/leandrosardi/mysaas/issues/59
|
574
574
|
#
|
575
575
|
# url: valid internet address
|
576
|
-
#
|
576
|
+
# body: hash of body to attach in the call
|
577
577
|
# ssl_verify_mode: you can disabele SSL verification here.
|
578
578
|
# max_channels: this method use lockfiles to prevent an excesive number of API calls from each datacenter. There is not allowed more simultaneous calls than max_channels.
|
579
579
|
#
|
580
580
|
# TODO: parameter support_redirections has been deprecated.
|
581
581
|
#
|
582
|
-
def self.call_post(url,
|
582
|
+
def self.call_post(url, body = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, support_redirections=true)
|
583
583
|
# issue: https://github.com/leandrosardi/mysaas/issues/59
|
584
584
|
#
|
585
585
|
# when ruby pushes hash of hashes (or hash of arrays), all values are converted into strings.
|
@@ -587,31 +587,26 @@ module BlackStack
|
|
587
587
|
#
|
588
588
|
# the solution is to convert each element of the hash into a string using `.to_json` method.
|
589
589
|
#
|
590
|
-
#
|
590
|
+
# references:
|
591
|
+
# - https://stackoverflow.com/questions/1667630/how-do-i-convert-a-string-object-into-a-hash-object
|
592
|
+
# - https://stackoverflow.com/questions/67572866/how-to-build-complex-json-to-post-to-a-web-service-with-rails-5-2-and-faraday-ge
|
591
593
|
#
|
592
594
|
# iterate the keys of the hash
|
593
595
|
#
|
594
|
-
params
|
596
|
+
params = {} # not needed for post calls to access points
|
597
|
+
path = URI::parse(url).path
|
598
|
+
domain = url.gsub(/#{Regexp.escape(path)}/, '')
|
595
599
|
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
req =
|
600
|
-
req['
|
601
|
-
|
602
|
-
res = http.request req
|
603
|
-
case res
|
604
|
-
when Net::HTTPSuccess then res
|
605
|
-
#when Net::HTTPRedirection then BlackStack::Netting::call_post(URI(res['location']), params, BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, false) if support_redirections
|
606
|
-
else
|
607
|
-
res.error!
|
608
|
-
end
|
609
|
-
end
|
610
|
-
# return
|
600
|
+
conn = Faraday.new(domain, :ssl=>{:verify=>ssl_verify_mode!=OpenSSL::SSL::VERIFY_NONE})
|
601
|
+
ret = conn.post(path, params) do |req|
|
602
|
+
req.body = body.to_json
|
603
|
+
req.headers['Content-Type'] = 'application/json'
|
604
|
+
req.headers['Accept'] = 'application/json'
|
605
|
+
end
|
611
606
|
ret
|
612
607
|
end
|
613
608
|
|
614
|
-
#
|
609
|
+
# TODO: deprecated
|
615
610
|
def self.api_call(url, params={}, method=BlackStack::Netting::CALL_METHOD_POST, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, max_retries=5)
|
616
611
|
nTries = 0
|
617
612
|
bSuccess = false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackstack-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: content_spinning
|
@@ -70,6 +70,26 @@ dependencies:
|
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: 0.14.1
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: faraday
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 2.3.0
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.3.0
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.3.0
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 2.3.0
|
73
93
|
description: 'THIS GEM IS STILL IN DEVELOPMENT STAGE. Find documentation here: https://github.com/leandrosardi/blackstack-core.'
|
74
94
|
email: leandro.sardi@expandedventure.com
|
75
95
|
executables: []
|