firstdue

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 12 Imported by: 0

README

firstdue

Go Report Card GoDoc

Go client for the First Due REST API.

Documentation

Index

Constants

View Source
const BaseURL = "https://sizeup.firstduesizeup.com/fd-api"

BaseURL is the default base URL for the FirstDue API.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client for the FirstDue API.

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient returns a new client for the FirstDue API.

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context, username string, password string) error

func (*Client) BaseURL

func (c *Client) BaseURL() string

func (*Client) Debug

func (c *Client) Debug() bool

func (*Client) DeleteNfirsNotificationsID

func (c *Client) DeleteNfirsNotificationsID(ctx context.Context, id uint64) error

func (*Client) DeleteNfirsNotificationsIDApparatusesID

func (c *Client) DeleteNfirsNotificationsIDApparatusesID(ctx context.Context, id uint64, apparatusID uint64) error

func (*Client) DeleteNfirsNotificationsNumberID

func (c *Client) DeleteNfirsNotificationsNumberID(ctx context.Context, id string) error

func (*Client) DeleteNfirsNotificationsNumberIDApparatusesCodeID

func (c *Client) DeleteNfirsNotificationsNumberIDApparatusesCodeID(ctx context.Context, id string, apparatusID string) error

func (*Client) GetApparatuses added in v0.1.2

func (c *Client) GetApparatuses(ctx context.Context, input GetApparatusesRequest) (output GetApparatusesResponse, err error)

func (*Client) GetDispatches

func (c *Client) GetDispatches(ctx context.Context, input GetDispatchesRequest) (output GetDispatchesResponse, err error)

func (*Client) GetLogsSettings

func (c *Client) GetLogsSettings(ctx context.Context, input GetLogsSettingsRequest) (output GetLogsSettingsResponse, err error)

func (*Client) GetNfirsNotificationsDispatchNumberID added in v0.1.1

func (c *Client) GetNfirsNotificationsDispatchNumberID(ctx context.Context, dispatchNumber string, input GetNfirsNotificationsDispatchNumberIDRequest) (output GetNfirsNotificationsDispatchNumberIDResponse, err error)

func (*Client) GetNfirsNotificationsID

func (c *Client) GetNfirsNotificationsID(ctx context.Context, id uint64) (output GetNfirsNotificationsIDResponse, err error)

func (*Client) GetStations added in v0.1.2

func (c *Client) GetStations(ctx context.Context, input GetStationsRequest) (output GetStationsResponse, err error)

func (*Client) HTTPClient

func (c *Client) HTTPClient() *http.Client

func (*Client) PostLogs

func (c *Client) PostLogs(ctx context.Context, input PostLogsRequest) error

func (*Client) PostLogsBatch

func (c *Client) PostLogsBatch(ctx context.Context, input PostLogsBatchRequest) error

func (*Client) PostNfirsNotifications

func (c *Client) PostNfirsNotifications(ctx context.Context, input PostNfirsNotificationsRequest) (output PostNfirsNotificationsResponse, err error)

func (*Client) PostNfirsNotificationsNumberIDApparatuses

func (c *Client) PostNfirsNotificationsNumberIDApparatuses(ctx context.Context, id string, input PostNfirsNotificationsNumberIDApparatusesRequest) error

func (*Client) PutNfirsNotificationsID

func (c *Client) PutNfirsNotificationsID(ctx context.Context, id uint64, input PutNfirsNotificationsIDRequest) error

func (*Client) PutNfirsNotificationsIDApparatusesID

func (c *Client) PutNfirsNotificationsIDApparatusesID(ctx context.Context, id uint64, apparatusID uint64, input PutNfirsNotificationsIDApparatusesIDRequest) error

func (*Client) PutNfirsNotificationsNumberID

func (c *Client) PutNfirsNotificationsNumberID(ctx context.Context, id string, input PutNfirsNotificationsNumberIDRequest) error

func (*Client) PutNfirsNotificationsNumberIDApparatusesCodeID

func (c *Client) PutNfirsNotificationsNumberIDApparatusesCodeID(ctx context.Context, id string, apparatusID string, input PutNfirsNotificationsNumberIDApparatusesCodeIDRequest) error

func (*Client) Raw

func (c *Client) Raw(ctx context.Context, method string, path string, input any, output any) error

Raw performs a raw HTTP request to the FirstDue API. It handles authentication, request creation, and response parsing.

Input and output are expected to be JSON-serializable structures. If omitted, they will not be sent or parsed.

func (*Client) Token

func (c *Client) Token() string

type ClientConfig added in v0.1.1

type ClientConfig struct {
	BaseURL    string       // The base URL for API requests; if empty, the default will be used.
	Token      string       // The API "Bearer" token for authentication.
	Debug      bool         // If true, debug information will be printed to the log.
	HTTPClient *http.Client // The HTTP client to use.
}

type ClientOption

type ClientOption func(*ClientConfig)

ClientOption is a function that configures a Client.

func WithBaseURL added in v0.1.1

func WithBaseURL(baseURL string) ClientOption

WithBaseURL sets the base URL for API requests.

func WithDebug added in v0.1.1

func WithDebug(debug bool) ClientOption

WithDebug sets the debug flag.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient sets the HTTP client to use for requests.

func WithToken added in v0.1.1

func WithToken(token string) ClientOption

WithToken sets the API "Bearer" token for authentication.

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Errors  []struct {
		Field   string `json:"field"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"errors,omitempty"`
}

type GetApparatusesRequest added in v0.1.2

type GetApparatusesRequest struct {
}

type GetApparatusesResponse added in v0.1.2

type GetApparatusesResponse struct {
	List  []GetApparatusesResponseApparatus `json:"list"`
	Total int                               `json:"total"`
}

type GetApparatusesResponseApparatus added in v0.1.2

type GetApparatusesResponseApparatus struct {
	UUID     string  `json:"uuid"`
	Name     string  `json:"name"`
	UnitCode *string `json:"unit_code"` // The unit code that maps back to the dispatch information.
	UseCode  string  `json:"use_code"`
	UseName  string  `json:"use_name"`
}

type GetDispatchesRequest

type GetDispatchesRequest struct {
	Page  int       `url:"page,omitempty"`
	Since Timestamp `url:"since,omitempty"`
}

type GetDispatchesResponse

type GetDispatchesResponse []struct {
	ID               int       `json:"id"`
	Type             string    `json:"type"`
	Message          string    `json:"message"`
	Address          string    `json:"address"`
	Address2         string    `json:"address2"`
	City             string    `json:"city"`
	StateCode        string    `json:"state_code"`
	Latitude         float64   `json:"latitude"`
	Longitude        float64   `json:"longitude"`
	UnitCodes        []string  `json:"unit_codes"`
	IncidentTypeCode string    `json:"incident_type_code"`
	StatusCode       string    `json:"status_code"`
	XrefID           string    `json:"xref_id"`
	CreatedAt        Timestamp `json:"created_at"`
}

type GetLogsSettingsRequest

type GetLogsSettingsRequest struct{}

type GetLogsSettingsResponse

type GetLogsSettingsResponse struct {
	IsFdapiConnectorLogEnabled bool `json:"is_fdapi_connector_log_enabled"`
}

type GetNfirsNotificationsDispatchNumberIDRequest added in v0.1.1

type GetNfirsNotificationsDispatchNumberIDRequest struct{}

type GetNfirsNotificationsDispatchNumberIDResponse added in v0.1.1

type GetNfirsNotificationsDispatchNumberIDResponse NfirsNotification

type GetNfirsNotificationsIDResponse

type GetNfirsNotificationsIDResponse NfirsNotification

type GetStationsRequest added in v0.1.2

type GetStationsRequest struct {
}

type GetStationsResponse added in v0.1.2

type GetStationsResponse struct {
	List  []GetStationsResponseStation `json:"list"`
	Total int                          `json:"total"`
}

type GetStationsResponseStation added in v0.1.2

type GetStationsResponseStation struct {
	UUID string `json:"uuid"`
	Name string `json:"name"`
}

type NfirsNotification

type NfirsNotification struct {
	ID                       uint64          `json:"id,omitempty"`
	DispatchNumber           string          `json:"dispatch_number"`
	IncidentNumber           string          `json:"incident_number"`
	DispatchType             string          `json:"dispatch_type"`
	DispatchIncidentTypeCode string          `json:"dispatch_incident_type_code"`
	AlarmAt                  Timestamp       `json:"alarm_at"`
	DispatchNotifiedAt       Timestamp       `json:"dispatch_notified_at"`
	Alarms                   int             `json:"alarms"`
	CADPriority              *string         `json:"cad_priority"`
	PlaceName                *string         `json:"place_name"`
	BusinessName             *string         `json:"business_name"`
	LocationInfo             *string         `json:"location_info"`
	Venue                    *string         `json:"venue"`
	Address                  string          `json:"address"`
	Unit                     *string         `json:"unit"`
	CrossStreets             string          `json:"cross_streets"`
	City                     string          `json:"city"`
	StateCode                string          `json:"state_code"`
	ZipCode                  *string         `json:"zip_code"`
	Latitude                 *StringFloat64  `json:"latitude"`
	Longitude                *StringFloat64  `json:"longitude"`
	Narratives               *string         `json:"narratives"`
	ShiftName                *string         `json:"shift_name"`
	NotificationType         *string         `json:"notification_type"`
	AidTypeCode              *int            `json:"aid_type_code"`
	AidFDIDNumber            json.RawMessage `json:"aid_fdid_number"`  // There seems to be a bug in the API.  The in format is not the out format.
	AidFDIDNumbers           json.RawMessage `json:"aid_fdid_numbers"` // There seems to be a bug in the API.  The in format is not the out format.
	ControlledAt             *Timestamp      `json:"controlled_at"`
	OfficerInCharge          *string         `json:"officer_in_charge"`
	CallCompletedAt          Timestamp       `json:"call_completed_at"`
	Zone                     *string         `json:"zone"`
	HouseNum                 *string         `json:"house_num"`
	PrefixDirection          *string         `json:"prefix_direction"`
	StreetName               *string         `json:"street_name"`
	StreetType               *string         `json:"street_type"`
	SuffixDirection          *string         `json:"suffix_direction"`
	EMSIncidentNumber        *string         `json:"ems_incident_number"`
	EMSResponseNumber        *string         `json:"ems_response_number"`
	Station                  *string         `json:"station"`
	EMDCardNumber            *string         `json:"emd_card_number"`
	PSAPAnsweredAt           *Timestamp      `json:"psap_answered_at"`
}

type NfirsNotificationApparatus

type NfirsNotificationApparatus struct {
	UnitCode               string    `json:"unit_code"`
	IsAid                  bool      `json:"is_aid"`
	DispatchAt             Timestamp `json:"dispatch_at"`
	ArriveAt               Timestamp `json:"arrive_at"`
	DispatchAcknowledgedAt Timestamp `json:"dispatch_acknowledged_at"`
	EnrouteAt              Timestamp `json:"enroute_at"`
	ClearAt                Timestamp `json:"clear_at"`
	BackInServiceAt        Timestamp `json:"back_in_service_at"`
	CanceledAt             Timestamp `json:"canceled_at"`
	CanceledStageCode      string    `json:"canceled_stage_code"`
}

type PostAuthTokenRequest

type PostAuthTokenRequest struct {
	GrantType string `json:"grant_type"`
	Email     string `json:"email"`
	Password  string `json:"password"`
}

type PostAuthTokenResponse

type PostAuthTokenResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"`
	Scope       string `json:"scope"`
}

type PostLogsBatchRequest

type PostLogsBatchRequest []struct {
	Message   string `json:"message"`
	LevelCode string `json:"level_code"`
	Category  string `json:"category"`
}

type PostLogsRequest

type PostLogsRequest struct {
	Message   string `json:"message"`
	LevelCode string `json:"level_code"`
	Category  string `json:"category"`
}

type PostNfirsNotificationsIDApparatusesRequest

type PostNfirsNotificationsIDApparatusesRequest NfirsNotificationApparatus

type PostNfirsNotificationsIDApparatusesResponse

type PostNfirsNotificationsIDApparatusesResponse struct {
	ID StringUint64 `json:"id"`
}

type PostNfirsNotificationsNumberIDApparatusesRequest

type PostNfirsNotificationsNumberIDApparatusesRequest NfirsNotificationApparatus

type PostNfirsNotificationsRequest

type PostNfirsNotificationsRequest NfirsNotification

type PostNfirsNotificationsResponse

type PostNfirsNotificationsResponse struct {
	ID StringUint64 `json:"id"`
}

type PutNfirsNotificationsIDApparatusesIDRequest

type PutNfirsNotificationsIDApparatusesIDRequest NfirsNotificationApparatus

type PutNfirsNotificationsIDRequest

type PutNfirsNotificationsIDRequest NfirsNotification

type PutNfirsNotificationsNumberIDApparatusesCodeIDRequest

type PutNfirsNotificationsNumberIDApparatusesCodeIDRequest NfirsNotificationApparatus

type PutNfirsNotificationsNumberIDRequest

type PutNfirsNotificationsNumberIDRequest NfirsNotification

type StringFloat64

type StringFloat64 float64

func (StringFloat64) MarshalJSON

func (f StringFloat64) MarshalJSON() ([]byte, error)

func (*StringFloat64) UnmarshalJSON

func (f *StringFloat64) UnmarshalJSON(data []byte) error

type StringUint64

type StringUint64 uint64

func (StringUint64) MarshalJSON

func (n StringUint64) MarshalJSON() ([]byte, error)

func (*StringUint64) UnmarshalJSON

func (n *StringUint64) UnmarshalJSON(data []byte) error

type Timestamp

type Timestamp time.Time

func (Timestamp) EncodeValues

func (t Timestamp) EncodeValues(key string, v *url.Values) error

func (Timestamp) IsZero

func (t Timestamp) IsZero() bool

IsZero returns true if the timestamp is the zero value.

This is used for "omitempty" support in query parameters.

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) error

Directories

Path Synopsis
cmd
firstdue command

Jump to

Keyboard shortcuts

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