qcmobile

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: Apache-2.0 Imports: 9 Imported by: 1

README

FMCSA QC Mobile API Client

Go Reference Go Report Card

Unofficial API client

https://mobile.fmcsa.dot.gov/QCDevsite/home

go get github.com/brandenc40/qcmobile

Client Interface

// Client - QC Mobile API Client interface
type Client interface {
    SearchCarriersByName(ctx context.Context, name string, start, size int) ([]*CarrierDetails, error)
    GetCompleteCarrierDetails(ctx context.Context, dotNumber string) (*CompleteCarrierDetails, error)
    GetCarriersByDocket(ctx context.Context, docketNumber string) ([]*CarrierDetails, error)
    GetCarrier(ctx context.Context, dotNumber string) (*CarrierDetails, error)
    GetCargoCarried(ctx context.Context, dotNumber string) ([]*CargoClass, error)
    GetOperationClassification(ctx context.Context, dotNumber string) ([]*OperationClass, error)
    GetDocketNumbers(ctx context.Context, dotNumber string) ([]*Docket, error)
    GetAuthority(ctx context.Context, dotNumber string) ([]*AuthorityDetails, error)
    GetOOS(ctx context.Context, dotNumber string) ([]*OOSDetails, error)
    GetBasics(ctx context.Context, dotNumber string) ([]*BasicsDetails, error)
}

Example Usage

package main

import (
	"context"
	"fmt"
	"net/http"
	"time"

	"github.com/brandenc40/qcmobile"
)

func main() {
	// build client
	cfg := qcmobile.Config{
		Key:        "YOUR_KEY",
		HTTPClient: &http.Client{}, // OPTIONAL - will default to &http.Client{} if nil
	}
	client := qcmobile.NewClient(cfg)
	
	// build context to handle function timeout
	ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
	defer cancel()
	
	// get carrier from QC Mobile and print
	carrier, err := client.GetCarrier(ctx, "53467")
	if err != nil {
		// handle error
	}
	fmt.Println(carrier.Carrier)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSystemMaintenance is returned when the api is failing due to system maintenance
	ErrSystemMaintenance = errors.New("FMCSA Portal Unavailable due to Scheduled System Maintenance")
)

Functions

This section is empty.

Types

type AuthorityDetails

type AuthorityDetails struct {
	CarrierAuthority CarrierAuthority `json:"carrierAuthority"`
}

AuthorityDetails -

type Basic

type Basic struct {
	BasicsPercentile                                      string     `json:"basicsPercentile"`
	BasicsRunDate                                         Timestamp  `json:"basicsRunDate"`
	BasicsType                                            BasicsType `json:"basicsType"`
	BasicsViolationThreshold                              string     `json:"basicsViolationThreshold"`
	ExceededFMCSAInterventionThreshold                    string     `json:"exceededFMCSAInterventionThreshold"`
	ID                                                    BasicsID   `json:"id"`
	MeasureValue                                          string     `json:"measureValue"`
	OnRoadPerformanceThresholdViolationIndicator          string     `json:"onRoadPerformanceThresholdViolationIndicator"`
	SeriousViolationFromInvestigationPast12MonthIndicator string     `json:"seriousViolationFromInvestigationPast12MonthIndicator"`
	TotalInspectionWithViolation                          int        `json:"totalInspectionWithViolation"`
	TotalViolation                                        int        `json:"totalViolation"`
}

Basic -

type BasicsDetails

type BasicsDetails struct {
	Basic     Basic  `json:"basic"`
	DOTNumber string `json:"dotNumber"`
}

BasicsDetails -

type BasicsID

type BasicsID struct {
	BasicsID  int `json:"basicsId"`
	DotNumber int `json:"dotNumber"`
}

BasicsID -

type BasicsType

type BasicsType struct {
	BasicsCode      string `json:"basicsCode"`
	BasicsCodeMCMIS string `json:"basicsCodeMcmis"`
	BasicsID        int    `json:"basicsId"`
	BasicsLongDesc  string `json:"basicsLongDesc"`
	BasicsShortDesc string `json:"basicsShortDesc"`
}

BasicsType -

type CargoClass

type CargoClass struct {
	CargoClassDesc string  `json:"cargoClassDesc"`
	ID             CargoID `json:"id"`
}

CargoClass -

type CargoID

type CargoID struct {
	CargoClassID int `json:"cargoClassId"`
	DOTNumber    int `json:"dotNumber"`
}

CargoID -

type Carrier

type Carrier struct {
	AllowedToOperate             string           `json:"allowedToOperate"`
	BIPDInsuranceOnFile          string           `json:"bipdInsuranceOnFile"`
	BIPDInsuranceRequired        string           `json:"bipdInsuranceRequired"`
	BIPDRequiredAmount           string           `json:"bipdRequiredAmount"`
	BondInsuranceOnFile          string           `json:"bondInsuranceOnFile"`
	BondInsuranceRequired        string           `json:"bondInsuranceRequired"`
	BrokerAuthorityStatus        string           `json:"brokerAuthorityStatus"`
	CargoInsuranceOnFile         string           `json:"cargoInsuranceOnFile"`
	CargoInsuranceRequired       string           `json:"cargoInsuranceRequired"`
	CarrierOperation             CarrierOperation `json:"carrierOperation"`
	CensusTypeID                 CensusTypeID     `json:"censusTypeId"`
	CommonAuthorityStatus        string           `json:"commonAuthorityStatus"`
	ContractAuthorityStatus      string           `json:"contractAuthorityStatus"`
	CrashTotal                   int              `json:"crashTotal"`
	DBAName                      string           `json:"dbaName"`
	DOTNumber                    int              `json:"dotNumber"`
	DriverInspections            int              `json:"driverInsp"`
	DriverOOSInspections         int              `json:"driverOosInsp"`
	DriverOOSRate                float64          `json:"driverOosRate"`
	DriverOOSRateNationalAverage string           `json:"driverOosRateNationalAverage"`
	EIN                          int              `json:"ein"`
	FatalCrash                   int              `json:"fatalCrash"`
	HazmatInspections            int              `json:"hazmatInsp"`
	HazmatOOSInspections         int              `json:"hazmatOosInsp"`
	HazmatOOSRate                float64          `json:"hazmatOosRate"`
	HazmatOOSRateNationalAverage string           `json:"hazmatOosRateNationalAverage"`
	InjCrash                     int              `json:"injCrash"`
	IsPassengerCarrier           string           `json:"isPassengerCarrier"`
	// ISSScore is an interface{} type since I'm unable to determine what datatype this should be
	ISSScore                      interface{} `json:"issScore"`
	LegalName                     string      `json:"legalName"`
	MCS150Outdated                string      `json:"mcs150Outdated"`
	OOSDate                       Date        `json:"oosDate"`
	OOSRateNationalAverageYear    string      `json:"oosRateNationalAverageYear"`
	PhyCity                       string      `json:"phyCity"`
	PhyCountry                    string      `json:"phyCountry"`
	PhyState                      string      `json:"phyState"`
	PhyStreet                     string      `json:"phyStreet"`
	PhyZipcode                    string      `json:"phyZipcode"`
	ReviewDate                    Date        `json:"reviewDate"`
	ReviewType                    string      `json:"reviewType"`
	SafetyRating                  string      `json:"safetyRating"`
	SafetyRatingDate              Date        `json:"safetyRatingDate"`
	SafetyReviewDate              Date        `json:"safetyReviewDate"`
	SafetyReviewType              string      `json:"safetyReviewType"`
	SnapshotDate                  Date        `json:"snapshotDate"`
	StatusCode                    string      `json:"statusCode"`
	TotalDrivers                  int         `json:"totalDrivers"`
	TotalPowerUnits               int         `json:"totalPowerUnits"`
	TowAwayCrash                  int         `json:"towawayCrash"`
	VehicleInspections            int         `json:"vehicleInsp"`
	VehicleOOSInspections         int         `json:"vehicleOosInsp"`
	VehicleOOSRate                float64     `json:"vehicleOosRate"`
	VehicleOOSRateNationalAverage string      `json:"vehicleOosRateNationalAverage"`
}

Carrier -

type CarrierAuthority

type CarrierAuthority struct {
	ApplicantID                 int    `json:"applicantID"`
	Authority                   string `json:"authority"`
	AuthorizedForBroker         string `json:"authorizedForBroker"`
	AuthorizedForHouseholdGoods string `json:"authorizedForHouseholdGoods"`
	AuthorizedForPassenger      string `json:"authorizedForPassenger"`
	AuthorizedForProperty       string `json:"authorizedForProperty"`
	BrokerAuthorityStatus       string `json:"brokerAuthorityStatus"`
	CommonAuthorityStatus       string `json:"commonAuthorityStatus"`
	ContractAuthorityStatus     string `json:"contractAuthorityStatus"`
	DocketNumber                int    `json:"docketNumber"`
	DOTNumber                   int    `json:"dotNumber"`
	Prefix                      string `json:"prefix"`
}

CarrierAuthority -

type CarrierDetails

type CarrierDetails struct {
	Carrier *Carrier `json:"carrier"`
}

CarrierDetails -

type CarrierOperation

type CarrierOperation struct {
	CarrierOperationCode string `json:"carrierOperationCode"`
	CarrierOperationDesc string `json:"carrierOperationDesc"`
}

CarrierOperation -

type CensusTypeID

type CensusTypeID struct {
	CensusType     string `json:"censusType"`
	CensusTypeDesc string `json:"censusTypeDesc"`
	CensusTypeID   int    `json:"censusTypeId"`
}

CensusTypeID -

type Client

type Client interface {
	SearchCarriersByName(ctx context.Context, name string, start, size int) ([]*CarrierDetails, error)
	GetCompleteCarrierDetails(ctx context.Context, dotNumber string) (*CompleteCarrierDetails, error)
	GetCarriersByDocket(ctx context.Context, docketNumber string) ([]*CarrierDetails, error)
	GetCarrier(ctx context.Context, dotNumber string) (*CarrierDetails, error)
	GetCargoCarried(ctx context.Context, dotNumber string) ([]*CargoClass, error)
	GetOperationClassification(ctx context.Context, dotNumber string) ([]*OperationClass, error)
	GetDocketNumbers(ctx context.Context, dotNumber string) ([]*Docket, error)
	GetAuthority(ctx context.Context, dotNumber string) ([]*AuthorityDetails, error)
	GetOOS(ctx context.Context, dotNumber string) ([]*OOSDetails, error)
	GetBasics(ctx context.Context, dotNumber string) ([]*BasicsDetails, error)
}

Client - QC Mobile API Client interface

func NewClient

func NewClient(cfg Config) Client

NewClient -

type CompleteCarrierDetails

type CompleteCarrierDetails struct {
	Carrier                  *Carrier
	CargosCarried            []*CargoClass
	OperationClassifications []*OperationClass
	Dockets                  []*Docket
	AuthorityDetails         []*AuthorityDetails
	BasicsDetails            []*BasicsDetails
	OOSDetails               []*OOSDetails
}

CompleteCarrierDetails -

type Config

type Config struct {
	// Key - (required) Your QCMobile API WebKey
	Key string

	// HTTPClient - (optional) Defaults to &http.Client{}
	HTTPClient *http.Client
}

Config -

type Date

type Date string

Date -

func (Date) Parse

func (d Date) Parse() (time.Time, error)

Parse -

func (Date) String

func (d Date) String() string

String -

type Docket

type Docket struct {
	DocketNumber   int    `json:"docketNumber"`
	DocketNumberID int    `json:"docketNumberId"`
	DOTNumber      int    `json:"dotNumber"`
	Prefix         string `json:"prefix"`
}

Docket -

type OOS added in v1.1.0

type OOS struct {
	DOTNumber            int    `json:"dotNumber"`
	ID                   int    `json:"id"`
	OOSDate              Date   `json:"oosDate"`
	OOSReason            string `json:"oosReason"`
	OOSReasonDescription string `json:"oosReasonDescription"`
}

OOS - Out of Service

type OOSDetails

type OOSDetails struct {
	OOS OOS `json:"oos"`
}

OOSDetails - Out of Service details

type OperationClass

type OperationClass struct {
	OperationClassDesc string      `json:"operationClassDesc"`
	ID                 OperationID `json:"id"`
}

OperationClass -

type OperationID

type OperationID struct {
	DOTNumber        int `json:"dotNumber"`
	OperationClassID int `json:"operationClassId"`
}

OperationID -

type Timestamp

type Timestamp string

Timestamp -

func (Timestamp) Parse

func (t Timestamp) Parse() (time.Time, error)

Parse -

func (Timestamp) String

func (t Timestamp) String() string

String -

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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