memori-client 0.0.6 → 0.0.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 +4 -4
- data/lib/memori_client/engine/resource.rb +28 -20
- data/lib/memori_client/http_client.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b54ce0efa13b135e18861657e0a27e3511b732c4743e45cc62ab3269fe2a0efd
|
4
|
+
data.tar.gz: 49c44003c4e80665d2d3f836d93fa1a2a404ba2bb9fab173be78e898108b518a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19c6421a24b233a1b7f2918b9b310f96611c12b1d9cb3a67a83341c9eafd3dc598fdb962ac83d237298233e38272fd3e4d5dcb96988491ea6cc7d08e115e0961
|
7
|
+
data.tar.gz: cba5db29ca9227df52d7047ac51d7011d440a4dfdbd39377cfaf74baf405d0d0caabb07ca2ec4bcb42e923abc266b701b3c37de630fbc5b24f9c8e1462f3d67a
|
@@ -1,24 +1,32 @@
|
|
1
1
|
class MemoriClient::Engine::Resource
|
2
2
|
def self.exec_http_request(method, path, args)
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
3
|
+
stop = false
|
4
|
+
processed_tokens = []
|
5
|
+
path.split('/').each do |token|
|
6
|
+
break if stop == true
|
7
|
+
if token =~ /^{.*}$/
|
8
|
+
param_name = token.match(/^{(.*)}$/).captures.first
|
9
|
+
if args[param_name.to_sym].blank?
|
10
|
+
stop = true
|
11
|
+
else
|
12
|
+
processed_tokens << args[param_name.to_sym]
|
13
|
+
end
|
14
|
+
else
|
15
|
+
processed_tokens << token
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
url = processed_tokens.join('/')
|
20
|
+
url = [MemoriClient.configuration.engine_api_root, url].join('')
|
21
|
+
http = MemoriClient::HttpClient.new
|
22
|
+
|
23
|
+
case method
|
24
|
+
when 'get'
|
25
|
+
status, body = http.get(url)
|
26
|
+
else
|
27
|
+
status, body = http.send(method, url, payload: args[:payload])
|
28
|
+
end
|
29
|
+
|
30
|
+
[status, body]
|
23
31
|
end
|
24
32
|
end
|
@@ -46,6 +46,16 @@ class MemoriClient::HttpClient
|
|
46
46
|
handle_response(response, request)
|
47
47
|
end
|
48
48
|
|
49
|
+
def post_file(url, file:)
|
50
|
+
url = URI(url)
|
51
|
+
https = Net::HTTP.new(url.host, url.port)
|
52
|
+
https.use_ssl = url.scheme == 'https'
|
53
|
+
request = Net::HTTP::Post.new(url)
|
54
|
+
request.set_form([['upload', file]], 'multipart/form-data')
|
55
|
+
response = https.request(request)
|
56
|
+
handle_response(response, request)
|
57
|
+
end
|
58
|
+
|
49
59
|
def delete(url, headers: {}, payload: {})
|
50
60
|
url = URI(url)
|
51
61
|
https = Net::HTTP.new(url.host, url.port)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memori-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Lampis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Memori Client to interact with Memori backend and engine API
|
14
14
|
email: me@stefanolampis.com
|