qrz

package module
v0.2.38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 23 Imported by: 1

README

PkgGoDev Go Report Card

Go API client for QRZ.com

A GoLang client library for QRZ.com's XML subscription data service. The service provides real-time access to information from the QRZ.COM servers and databases. The API is documented here.

This client library was generated based on the OpenAPI specification in the api/openapi.yaml file. However, the API itself is not well-described by OpenAPI, so the generated library is supplemented with wrapper.go.

A simple application to demonstrate how to integrate the library is located in cmd/qrz-lookup/main.go.

A QRZ.com XML subscription is required to take full advantage of the API. A description of subscription plans and rates is available on the QRZ.com website.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {
	DefaultApi *DefaultApiService
	// contains filtered or unexported fields
}

APIClient manages communication with the QRZ XML Logbook Data Specification API v1.34 In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

ChangeBasePath changes base path to allow switching to mocks

func (*APIClient) GetConfig

func (c *APIClient) GetConfig() *Configuration

Allow modification of underlying config for alternate implementations and testing Caution: modifying the configuration while live can cause data races and potentially unwanted behavior

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the OpenAPI operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

APIResponse stores the API response returned by the server.

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

NewAPIResponse returns a new APIResonse object.

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

NewAPIResponseWithError returns a new APIResponse object with the provided error message.

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Callsign

type Callsign struct {
	// callsign
	Call string `json:"call,omitempty" xml:"call"`
	// Cross reference: the query callsign that returned this record
	Xref string `json:"xref,omitempty" xml:"xref"`
	// Other callsigns that resolve to this record
	Aliases string `json:"aliases,omitempty" xml:"aliases"`
	// DXCC entity ID (country code) for the callsign
	Dxcc string `json:"dxcc,omitempty" xml:"dxcc"`
	// first name
	Fname string `json:"fname,omitempty" xml:"fname"`
	// last name
	Name string `json:"name,omitempty" xml:"name"`
	// address line 1 (i.e. house # and street)
	Addr1 string `json:"addr1,omitempty" xml:"addr1"`
	// address line 2 (i.e, city name)
	Addr2 string `json:"addr2,omitempty" xml:"addr2"`
	// state (USA Only)
	State string `json:"state,omitempty" xml:"state"`
	// Zip/postal code
	Zip string `json:"zip,omitempty" xml:"zip"`
	// country name for the QSL mailing address
	Country string `json:"country,omitempty" xml:"country"`
	// dxcc entity code for the mailing address country
	Ccode string `json:"ccode,omitempty" xml:"ccode"`
	// lattitude of address (signed decimal) S < 0 > N
	Lat float64 `json:"lat,omitempty" xml:"lat"`
	// longitude of address (signed decimal) W < 0 > E
	Lon float64 `json:"lon,omitempty" xml:"lon"`
	// Maidenhead grid locator
	Grid string `json:"grid,omitempty" xml:"grid"`
	// county name (USA)
	County string `json:"county,omitempty" xml:"county"`
	// FIPS county identifier (USA)
	Fips string `json:"fips,omitempty" xml:"fips"`
	// DXCC country name of the callsign
	Land string `json:"land,omitempty" xml:"land"`
	// license effective date (USA)
	Efdate string `json:"efdate,omitempty" xml:"efdate"`
	// license expiration date (USA)
	Expdate string `json:"expdate,omitempty" xml:"expdate"`
	// previous callsign
	PCall string `json:"p_call,omitempty" xml:"p_call"`
	// license class
	Class string `json:"class,omitempty" xml:"class"`
	// license type codes (USA)
	Codes string `json:"codes,omitempty" xml:"codes"`
	// QSL manager info
	Qslmgr string `json:"qslmgr,omitempty" xml:"qslmgr"`
	// email address
	Email string `json:"email,omitempty" xml:"email"`
	// web page address
	Url string `json:"url,omitempty" xml:"url"`
	// QRZ web page views
	UViews float32 `json:"u_views,omitempty" xml:"u_views"`
	// approximate length of the bio HTML in bytes
	Bio string `json:"bio,omitempty" xml:"bio"`
	// date of the last bio update
	Biodate string `json:"biodate,omitempty" xml:"biodate"`
	// full URL of the callsign's primary image
	Image string `json:"image,omitempty" xml:"image"`
	// height:width:size in bytes, of the image file
	Imageinfo string `json:"imageinfo,omitempty" xml:"imageinfo"`
	// QRZ db serial number
	Serial string `json:"serial,omitempty" xml:"serial"`
	// QRZ callsign last modified date
	Moddate string `json:"moddate,omitempty" xml:"moddate"`
	// Metro Service Area (USPS)
	MSA string `json:"MSA,omitempty" xml:"MSA"`
	// Telephone Area Code (USA)
	AreaCode string `json:"AreaCode,omitempty" xml:"AreaCode"`
	// Time Zone (USA)
	TimeZone string `json:"TimeZone,omitempty" xml:"TimeZone"`
	// GMT Time Offset
	GMTOffset string `json:"GMTOffset,omitempty" xml:"GMTOffset"`
	// Daylight Saving Time Observed
	DST string `json:"DST,omitempty" xml:"DST"`
	// Will accept e-qsl (0/1 or blank if unknown)
	Eqsl string `json:"eqsl,omitempty" xml:"eqsl"`
	// Will return paper QSL (0/1 or blank if unknown)
	Mqsl string `json:"mqsl,omitempty" xml:"mqsl"`
	// CQ Zone identifier
	Cqzone string `json:"cqzone,omitempty" xml:"cqzone"`
	// ITU Zone identifier
	Ituzone string `json:"ituzone,omitempty" xml:"ituzone"`
	// operator's year of birth
	Born float32 `json:"born,omitempty" xml:"born"`
	// User who manages this callsign on QRZ
	User string `json:"user,omitempty" xml:"user"`
	// Will accept LOTW (0/1 or blank if unknown)
	Lotw string `json:"lotw,omitempty" xml:"lotw"`
	// IOTA Designator (blank if unknown)
	Iota string `json:"iota,omitempty" xml:"iota"`
	// Describes source of lat/long data
	Geoloc string `json:"geoloc,omitempty" xml:"geoloc"`
	// Attention address line, this line should be prepended to the address
	Attn string `json:"attn,omitempty" xml:"attn"`
	// A different or shortened name used on the air
	Nickname string `json:"nickname,omitempty" xml:"nickname"`
	// Combined full name and nickname in the format used by QRZ. This fortmat is subject to change.
	NameFmt string `json:"name_fmt,omitempty" xml:"name_fmt"`
}

Callsign struct for Callsign

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	Debug         bool              `json:"debug,omitempty"`
	Servers       []ServerConfiguration
	HTTPClient    *http.Client
}

Configuration stores the configuration of the API client

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration returns a new Configuration object

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

AddDefaultHeader adds a new HTTP header to the default header in the request

func (*Configuration) ServerUrl

func (c *Configuration) ServerUrl(index int, variables map[string]string) (string, error)

ServerUrl returns URL based on server settings

type DefaultApiService

type DefaultApiService service

DefaultApiService DefaultApi service

func (*DefaultApiService) RootGet

func (a *DefaultApiService) RootGet(ctx _context.Context, localVarOptionals *RootGetOpts) (QrzDatabase, *_nethttp.Response, error)

RootGet The do-everything endpoint

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param optional nil or *RootGetOpts - Optional Parameters:
  • @param "Username" (optional.String) -
  • @param "Password" (optional.String) -
  • @param "Agent" (optional.String) -
  • @param "S" (optional.String) - session token
  • @param "Callsign" (optional.String) - perform a callsign info lookup
  • @param "Dxcc" (optional.Interface of OneOfnumberstring) - perform a DXCC info lookup

@return QrzDatabase

type Dxcc

type Dxcc struct {
	// DXCC entity number for this record
	Dxcc string `json:"dxcc,omitempty" xml:"dxcc"`
	// 2-letter country code (ISO-3166)
	Cc string `json:"cc,omitempty" xml:"cc"`
	// 3-letter country code (ISO-3166)
	Ccc string `json:"ccc,omitempty" xml:"ccc"`
	// long name
	Name string `json:"name,omitempty" xml:"name"`
	// 2-letter continent designator
	Continent string `json:"continent,omitempty" xml:"continent"`
	// ITU Zone
	Ituzone string `json:"ituzone,omitempty" xml:"ituzone"`
	// CQ Zone
	Cqzone string `json:"cqzone,omitempty" xml:"cqzone"`
	// timezone offset +/- UTC in hours. Odd timezones, such as 0545 mean \"5 hours, 45 minutes\". The plus (+) sign is implied.
	Timezone int32 `json:"timezone,omitempty" xml:"timezone"`
	// Latitude (approx.)
	Lat float64 `json:"lat,omitempty" xml:"lat"`
	// Longitude (approx.)
	Lon float64 `json:"lon,omitempty" xml:"lon"`
	// Special notes and/or exceptions
	Notes string `json:"notes,omitempty" xml:"notes"`
}

Dxcc struct for Dxcc

type GenericOpenAPIError

type GenericOpenAPIError struct {
	// contains filtered or unexported fields
}

GenericOpenAPIError Provides access to the body, error and model on returned errors.

func (GenericOpenAPIError) Body

func (e GenericOpenAPIError) Body() []byte

Body returns the raw bytes of the response

func (GenericOpenAPIError) Error

func (e GenericOpenAPIError) Error() string

Error returns non-empty string if there was an error.

func (GenericOpenAPIError) Model

func (e GenericOpenAPIError) Model() interface{}

Model returns the unpacked model of the error

type QrzDatabase

type QrzDatabase struct {
	Session  Session  `json:"Session,omitempty" xml:"Session"`
	Callsign Callsign `json:"Callsign,omitempty" xml:"Callsign"`
	DXCC     Dxcc     `json:"DXCC,omitempty" xml:"DXCC"`
}

QrzDatabase struct for QrzDatabase

func Lookup

func Lookup(ctx context.Context, user *string, pw *string, call *string) (*QrzDatabase, error)

type RootGetOpts

type RootGetOpts struct {
	Username optional.String
	Password optional.String
	Agent    optional.String
	S        optional.String
	Callsign optional.String
	Dxcc     optional.Interface
}

RootGetOpts Optional parameters for the method 'RootGet'

type ServerConfiguration

type ServerConfiguration struct {
	Url         string
	Description string
	Variables   map[string]ServerVariable
}

ServerConfiguration stores the information about a server

type ServerVariable

type ServerVariable struct {
	Description  string
	DefaultValue string
	EnumValues   []string
}

ServerVariable stores the information about a server variable

type Session

type Session struct {
	// a valid user session key. A user session is established whenever a session key is returned. Any response from the server that does not contain the Key element indicates that no valid session exists and that a re-login is required to continue.
	Key string `json:"Key,omitempty" xml:"Key"`
	// Number of lookups performed by this user in the current 24 hour period
	Count float32 `json:"Count,omitempty" xml:"Count"`
	// time and date that the users subscription will expire - or - \"non-subscriber\"
	SubExp string `json:"SubExp,omitempty" xml:"SubExp"`
	// Time stamp for this message
	GMTime string `json:"GMTime,omitempty" xml:"GMTime"`
	// An informational message for the user
	Message string `json:"Message,omitempty" xml:"Message"`
	// XML system error message
	Error string `json:"Error,omitempty" xml:"Error"`
}

Session struct for Session

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL