Git Product home page Git Product logo

qcmobile's Introduction

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)
}

qcmobile's People

Contributors

brandenc40 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.