class Callsigns::Callook
Public Class Methods
lookup(callsign, client)
click to toggle source
# File lib/callsigns/callook.rb, line 2 def self.lookup(callsign, client) callook_uri = "https://callook.info/" + callsign.downcase + "/json" response = HTTParty.get(callook_uri).parsed_response if response["status"] == "INVALID" client.puts "Invalid callsign. Please make sure you entered a valid USA-Based callsign" elsif response["status"] == "VALID" client.puts "Callsign " + callsign.upcase + " is found!\n\n" if response["previous"]["callsign"] == callsign.upcase client.puts "ATTENTION: The callsign " + callsign.upcase + " is out-of-date. Operator changed callsign to: " + response["current"]["callsign"] end client.puts response["current"]["callsign"] client.puts "=========" client.puts "Type: " + response["type"].capitalize client.puts "Name: " + response["name"].upcase if response["type"] == "CLUB" client.puts "Trustee: " + response["trustee"]["name"].upcase + " [" + response["trustee"]["callsign"] + "]" elsif response["type"] == "PERSON" client.puts "Class: " + response["current"]["operClass"] end client.puts "Address: " + response["address"]["line1"] client.puts " " + response["address"]["line2"] client.puts " " + response["address"]["attn"] if response["address"]["attn"] != "" client.puts "Previous callsign: " + response["previous"]["callsign"] radioid_dmr_uri = "https://database.radioid.net/api/dmr/user/?callsign=" + callsign.downcase response = HTTParty.get(radioid_dmr_uri).parsed_response client.puts "DMR IDs: " + response["count"].to_s + " IDs found" if response["count"].to_i > 0 response["results"].each do |r| client.puts " " + r["id"].to_s end end radioid_nxdn_uri = "https://database.radioid.net/api/nxdn/user/?callsign=" + callsign.downcase response = HTTParty.get(radioid_nxdn_uri).parsed_response client.puts "NXDN IDs: " + response["count"].to_s + " IDs found" if response["count"].to_i > 0 response["results"].each do |r| client.puts " " + r["id"].to_s end end end end