Module: EnfApi

Defined in:
lib/enfapi.rb,
lib/enfapi/dns.rb,
lib/enfapi/user.rb,
lib/enfapi/firewall.rb

Overview

Copyright 2020 Xaptum,Inc

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Classes: API, Captive, Dns, ERROR, Firewall, Iam, NetworkManager, UserManager

Class Method Summary collapse

Class Method Details

.from_json(string) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/enfapi.rb', line 33

def self.from_json(string)
  begin
    JSON.parse(string, { symbolize_names: true })
  rescue
    raise EnfApi::ERROR, "Unable to parse api response json!"
  end
end

.to_json(hash) ⇒ Object



29
30
31
# File 'lib/enfapi.rb', line 29

def self.to_json(hash)
  JSON.generate(hash)
end

.url_encode(str) ⇒ Object



41
42
43
# File 'lib/enfapi.rb', line 41

def self.url_encode(str)
  CGI.escape(str).gsub("+", "%20")
end