Class: RecordsKeeperRubyLib::Permissions

Inherits:
Object
  • Object
show all
Defined in:
lib/RecordsKeeperRubyLib/permissions.rb

Class Method Summary collapse

Class Method Details

.grantPermission(address, permissions) ⇒ Object

Function to grant permissions on RecordsKeeper Blockchain



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/RecordsKeeperRubyLib/permissions.rb', line 38

def self.grantPermission address, permissions
  auth = {:username => @user, :password => @password}
  options = {
    :headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
    :basic_auth => auth,
    :body => [ {"method":"grant","params":[address, permissions],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
  }
  response = HTTParty.get(@url, options)
  out = response.parsed_response
  result = out[0]['result']
  if result.nil?
    res = out[0]['error']['message']
  else
    res = out[0]['result']
  end
  return res;									#returns permissions tx id
end

.revokePermission(address, permissions) ⇒ Object

Function to revoke permissions on RecordsKeeper Blockchain



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/RecordsKeeperRubyLib/permissions.rb', line 57

def self.revokePermission address, permissions
  auth = {:username => @user, :password => @password}
  options = {
    :headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"},
    :basic_auth => auth,
    :body => [ {"method":"revoke","params":[address, permissions],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json
  }
  response = HTTParty.get(@url, options)
  out = response.parsed_response
  result = out[0]['result']
  if result.nil?
    res = out[0]['error']['message']
  else
    res = out[0]['result']
  end
  return res;									#returns revoke permissions tx id
end