lotw

package module
v0.3.49 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 Logbook of the World

A GoLang client library for the Logbook of the World query API. LoTW provides a web service that accepts RESTful queries that report QSOs satisfying specified criteria:

  • accepted by LoTW after a specified date
  • confirmed by LoTW after a specified date
  • with a specified callsign
  • with an operator in a specified DXCC entity
  • in a specified mode
  • on a specified band
  • at a specified date and timeusing a specified station callsign

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/lotw-qsl/main.go.

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.

func Query added in v0.0.2

func Query(user string, pw string, opts *QueryOpts) (string, error)

Query LotW and return an ADIF string with the results.

func QueryContext added in v0.3.0

func QueryContext(ctx context.Context, user string, pw string, opts *QueryOpts) (string, error)

QueryContext performs a context aware LotW query and returns an ADIF string with the results.

Types

type APIClient

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

APIClient manages communication with the Logbook of the World Query API API v1.0 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 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) Query

func (a *DefaultApiService) Query(ctx _context.Context, login string, password string, qsoQuery int32, localVarOptionals *QueryOpts) (string, *_nethttp.Response, error)

Query Querying LoTW for Acceptance and Confirmation of Submitted QSOs

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param login Note that while the user's primary call sign is usually the username, this is not always the case and should not be assumed.
  • @param password The user's plaintext LotW password.
  • @param qsoQuery If absent, ADIF file will contain no QSO records
  • @param optional nil or *QueryOpts - Optional Parameters:
  • @param "QsoQsl" (optional.Interface of YesOrNo) - If \"yes\", only QSL records are returned
  • @param "QsoQslsince" (optional.String) - Returns QSL records received (matched or updated) on or after the specified date. Will also accept date/time in \"YYYY-MM-DD HH:MM:SS\" format. Ignored unless qso_qsl=\"yes\".
  • @param "QsoQsorxsince" (optional.String) - Returns QSO records received (uploaded) on or after the specified date. Will also accept date/time in \"YYYY-MM-DD HH:MM:SS\" format. Ignored unless qso_qsl=\"no\".
  • @param "QsoOwncall" (optional.String) - Returns only records whose \"own\" call sign matches.
  • @param "QsoCallsign" (optional.String) - Returns only records whose \"worked\" call sign matches.
  • @param "QsoMode" (optional.String) - Returns only records whose mode matches. Mode must be one of the allowed modes.
  • @param "QsoBand" (optional.String) - Returns only records whose band matches. Mode must be one of the allowed bands.
  • @param "QsoDxcc" (optional.Int32) - Returns only records whose DXCC entity matches. (This implies qso_qsl=\"yes\" since the DXCC entity of un-QSL'd stations isn't known to LoTW.) Value must be the ARRL DXCC entity number.
  • @param "QsoStartdate" (optional.String) - Returns only records with a QSO date on or after the specified value.
  • @param "QsoStarttime" (optional.String) - Returns only records with a QSO time at or after the specified value on the starting date. This value is ignored if qso_startdate is not provided.
  • @param "QsoEnddate" (optional.String) - Returns only records with a QSO date on or before the specified value.
  • @param "QsoEndtime" (optional.String) - Returns only records with a QSO time at or before the specified value on the ending date. This value is ignored if qso_enddate is not provided.
  • @param "QsoMydetail" (optional.Interface of YesOrNo) - If \"yes\", returns fields that contain the Logging station's location data, if any.
  • @param "QsoQsldetail" (optional.Interface of YesOrNo) - If \"yes\", returns fields that contain the QSLing station's location data, if any.
  • @param "QsoWithown" (optional.Interface of YesOrNo) - If \"yes\", each record contains the STATION_CALLSIGN and APP_LoTW_OWNCALL fields to identify the \"own\" call sign used for the QSO.

@return string

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 QueryOpts

type QueryOpts struct {
	QsoQsl        optional.Interface
	QsoQslsince   optional.String
	QsoQsorxsince optional.String
	QsoOwncall    optional.String
	QsoCallsign   optional.String
	QsoMode       optional.String
	QsoBand       optional.String
	QsoDxcc       optional.Int32
	QsoStartdate  optional.String
	QsoStarttime  optional.String
	QsoEnddate    optional.String
	QsoEndtime    optional.String
	QsoMydetail   optional.Interface
	QsoQsldetail  optional.Interface
	QsoWithown    optional.Interface
}

QueryOpts Optional parameters for the method 'Query'

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 YesOrNo

type YesOrNo string

YesOrNo the model 'YesOrNo'

const (
	YES YesOrNo = "yes"
	NO  YesOrNo = "no"
)

List of YesOrNo

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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