Class: DX::Lookup::QRZ

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/dx/lookup/qrz.rb,
lib/dx/lookup/qrz/entity.rb,
lib/dx/lookup/qrz/callsign.rb

Defined Under Namespace

Classes: APIError, Callsign, Entity

Constant Summary collapse

API_VERSION =
'1.33'
AGENT =
"dx-lookup-#{DX::Lookup::VERSION}"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password, options = {}) ⇒ QRZ

Returns a new instance of QRZ.



18
19
20
# File 'lib/dx/lookup/qrz.rb', line 18

def initialize(username, password, options={})
  @username, @password = username, password
end

Instance Attribute Details

#session_keyObject (readonly)

Returns the value of attribute session_key.



16
17
18
# File 'lib/dx/lookup/qrz.rb', line 16

def session_key
  @session_key
end

Instance Method Details

#create_session!Object



44
45
46
47
48
49
50
51
# File 'lib/dx/lookup/qrz.rb', line 44

def create_session!
  uri = construct_uri(:username => @username, :password => @password, :agent => AGENT)
  response = self.class.get(uri)
  response = response.parsed_response
  check_for_error(response)

  @session_key = response['QRZDatabase']['Session']['Key']
end

#get_all_entitiesObject



36
37
38
# File 'lib/dx/lookup/qrz.rb', line 36

def get_all_entities
  get_entities('all')
end

#get_callsign(callsign) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/dx/lookup/qrz.rb', line 22

def get_callsign(callsign)
  
  uri = construct_uri(:callsign => callsign)
  response = self.class.get(uri).parsed_response
  check_for_error(response)

  callsign_response = response['QRZDatabase']['Callsign']
  Callsign.from_response(callsign_response)
end

#get_callsign_entity(callsign) ⇒ Object



40
41
42
# File 'lib/dx/lookup/qrz.rb', line 40

def get_callsign_entity(callsign)
  get_entities(callsign).first
end

#get_dxcc_entity(dxcc) ⇒ Object



32
33
34
# File 'lib/dx/lookup/qrz.rb', line 32

def get_dxcc_entity(dxcc)
  get_entities(dxcc.to_s).first
end