23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/apiotics_factory/publish.rb', line 23
def fetch_info
config_dir = File.dirname(__FILE__).chomp("/lib/apiotics_factory") + "/var"
if File.exist?(config_dir + "/config.json")
config = JSON.parse(File.read(config_dir + "/config.json"))
ApioticsFactory.configuration.public_key = config["public_key"]
ApioticsFactory.configuration.private_key = config["private_key"]
ApioticsFactory.configuration.portal = config["portal"]
else
say("Please enter your vendor public key from the Apiotics Portal.")
ApioticsFactory.configuration.public_key = ask("Vendor Public Key: ")
say("Please enter your vendor private key from the Apiotics Portal.")
ApioticsFactory.configuration.private_key = ask("Vendor Private Key: ")
say("Please confirm the Apiotics Portal web address.")
ApioticsFactory.configuration.portal = ask("Portal: ", default: "https://portal.apiotics.com/")
unless ApioticsFactory.configuration.portal[-1] == "/"
ApioticsFactory.configuration.portal = ApioticsFactory.configuration.portal + "/"
end
config = {
"public_key" => ApioticsFactory.configuration.public_key,
"private_key" => ApioticsFactory.configuration.private_key,
"portal" => ApioticsFactory.configuration.portal
}
unless Dir.exist?(config_dir)
Dir.mkdir(config_dir)
end
File.write(config_dir + "/config.json", config.to_json)
end
data = ApioticsFactory::Portal.driver_version(id)
data = JSON.parse(data)
@driver_name = data["name"]
@status = true
unless data.keys.include?("errors")
@version = data["version"]
else
@status = false
say("#{data['errors']['detail']}")
end
end
|