Module: HyperledgerCli
- Defined in:
- lib/hyperledger_cli.rb,
lib/hyperledger_cli/key.rb,
lib/hyperledger_cli/version.rb,
lib/hyperledger_cli/error_printer.rb
Defined Under Namespace
Modules: ErrorPrinter
Classes: Key
Constant Summary
collapse
- VERSION =
"0.1.0"
Instance Method Summary
collapse
Instance Method Details
#get(url) ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/hyperledger_cli.rb', line 31
def get(url)
begin
response = RestClient.get(url, accept: 'application/vnd.uber-amundsen+json')
pp JSON.parse(response)["uber"]["data"]
rescue => e
print_error(e)
end
end
|
#post(url, data, key = nil) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/hyperledger_cli.rb', line 10
def post(url, data, key = nil)
json_data = data.to_json
= {
content_type: :json,
accept: 'application/vnd.uber-amundsen+json'
}
if key
sig = key.sign(json_data)
.merge!({
authorization: "Hyper Key=#{key.public_key}, Signature=#{sig}"
})
end
begin
response = RestClient.post(url, json_data, )
pp JSON.parse(response)["uber"]["data"]
rescue => e
print_error(e)
end
end
|