mykubota

package module
v0.0.0-...-9cc3346 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: MIT Imports: 11 Imported by: 0

README

mykubota

This is a go SDK build around the API used by the MyKubota iOS and Android application.

Functionality

  • login/ logout
  • equipment search by pin/ serial
  • list own equipment
  • show equipment details
  • define geofences
  • update equipment attributes
  • add equipment
  • delete equipment
  • listing maintenance schedules
  • listing maintenance history
  • adding maintenance history

Documentation

Overview

Package mykubota implements an API SDK matching the MyKubota app

Index

Constants

This section is empty.

Variables

View Source
var (
	AppEndpoint     = "https://app.mykubota.com"
	AppClientID     = "1e74fe67-9753-4f65-b6e4-dd65a8132ea2"
	AppClientSecret = "TCDx0qg5kFQhIdCxW0t1iFlESodtWfaR49vy4JdbYjc"
)

taken from MyKubota app on iOS

Functions

This section is empty.

Types

type AddEquipmentRequest

type AddEquipmentRequest struct {
	Model       *Model
	PinOrSerial string
}

type Category

type Category struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	ParentID *int   `json:"parentId"`
}

type CategoryNode

type CategoryNode struct {
	ID       int
	Name     string
	ParentID *int

	SubCategories []*CategoryNode
	Models        []Model
}

type Client

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

Client allows location specific access to public content from the MyKubota app

func New

func New(locale string) *Client

New creates a new MyKubota client for public content in the region specified by the locale locale must be of format `{ISO 639-1}-{ISO 3166}`, ie en-US or en-CA

func (*Client) Authenticate

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

Authenticate performs a password authentication with the MyKubota oauth API

func (*Client) GetModelTree

func (c *Client) GetModelTree(ctx context.Context) ([]*CategoryNode, error)

GetModelTree returns a category tree containing all machines/ attachments currently offered by Kubota

func (*Client) ListCategories

func (s *Client) ListCategories(ctx context.Context) ([]Category, error)

Listcategories returns all product categories offered by Kubota

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context) ([]Model, error)

ListModels returns all machines/ attachments offered by Kubota

func (*Client) MaintenanceSchedule

func (c *Client) MaintenanceSchedule(model string) ([]Maintenance, error)

func (*Client) SearchMachine

func (c *Client) SearchMachine(ctx context.Context, request SearchMachineRequest) (*Model, error)

SearchMachine performs a location aware search in Kubotas registry for a matching model/ serial combination

func (*Client) SessionFromToken

func (c *Client) SessionFromToken(ctx context.Context, t *oauth2.Token) (*Session, error)

SessionFromToken restores a session from an existing token

type Equipment

type Equipment struct {
	ID                      string  `json:"id"`
	Model                   string  `json:"model"`
	CategoryID              int     `json:"categoryId"`
	Category                string  `json:"category"`
	SubCategory             string  `json:"subcategory"`
	IdentifierType          string  `json:"identifierType"`
	Type                    string  `json:"type"`
	PinOrSerial             string  `json:"pinOrSerial"`
	Pin                     string  `json:"pin"`
	Serial                  string  `json:"serial"`
	Nickname                string  `json:"nickName"`
	UserEnteredEngineHours  float64 `json:"userEnteredEngineHours"`
	HasTelematics           bool    `json:"hasTelematics"`
	HasFaultCodes           bool    `json:"hasFaultCodes"`
	HasMaintenanceSchedules bool    `json:"hasMaintenanceSchedules"`

	// TODO - no use for these today, but they exist
	// "modelHeroUrl"
	// "modelFullUrl"
	// "modelIconUrl"
	// "warrantyUrl"
	// "guideUrl"
	ManualEntries ManualEntries `json:"manualEntries"`
	VideoEntries  VideoEntries  `json:"videoEntries"`

	Telematics EquipmentTelematics `json:"telematics"`
}

type EquipmentLocation

type EquipmentLocation struct {
	Latitude             float64 `json:"latitude"`
	Longitude            float64 `json:"longitude"`
	AltitudeMeters       float64 `json:"altitudeMeters"`
	PositionHeadingAngle float64 `json:"positionHeadingAngle"`
}

EquipmentLocation contains location information for telematics enabled equipment

type EquipmentRestartInhibitStatus

type EquipmentRestartInhibitStatus struct {
	CanModify       bool   `json:"canModify"`
	CommandStatus   string `json:"commandStatus"`
	EquipmentStatus string `json:"equipmentStatus"`
}

EquipmentRestartInhibitStatus contains restart inhibit information for telematics enabled equipment

type EquipmentTelematics

type EquipmentTelematics struct {
	LocationTime             time.Time                     `json:"locationTime"`
	CumulativeOperatingHours float64                       `json:"cumulativeOperatingHours"`
	Location                 EquipmentLocation             `json:"location"`
	EngineRunning            bool                          `json:"engineRunning"`
	FuelTempCelsius          int                           `json:"fuelTempCelsius"`
	FuelRemainingPercent     int                           `json:"fuelRemainingPercent"`
	DEFTempCelsius           int                           `json:"defTempCelsius"`
	DEFQualityPercent        float64                       `json:"defQualityPercent"`
	DEFRemainingPercent      float64                       `json:"defRemainingPercent"`
	DEFPressureKPascal       float64                       `json:"defPressureKPascal"`
	EngineRPM                int                           `json:"engineRPM"`
	CoolantTempCelsius       int                           `json:"coolantTempCelsius"`
	HydraulicTempCelsius     int                           `json:"hydraulicTempCelsius"`
	ExtPowerVolts            float64                       `json:"extPowerVolts"`
	AirInletTempCelsius      float64                       `json:"airInletTempCelsius"`
	AmbientAirTempCelsius    float64                       `json:"ambientAirTempCelsius"`
	RunNumber                int                           `json:"runNumber"`
	MotionState              string                        `json:"motionState"`
	FaultCodes               []interface{}                 `json:"faultCodes"`
	RestartInhibitStatus     EquipmentRestartInhibitStatus `json:"restartInhibitStatus"`
	InsideGeofences          []interface{}                 `json:"insideGeofences"`
}

EquipmentTelematics contains basic telematics data for telematics enabled equipment

type Maintenance

type Maintenance struct {
	ID                  string `json:"id"`
	CheckPoint          string `json:"checkPoint"`
	Measures            string `json:"measures"`
	FirstCheckValue     int    `json:"firstCheckValue"`
	DisplayIntervalType string `json:"displayIntervalType"`
	IntervalTyp         string `json:"intervalType"`
	IntervalValue       int    `json:"intervalValue"`
	SortOrder           int    `json:"sortOrder"`
}

Maintenance contains required maintenance including intervals for a specific model

type MaintenanceHistory

type MaintenanceHistory struct {
	ID                   string    `json:"id"`
	IntervalType         string    `json:"intervalType"`
	IntervalValue        int       `json:"intervalValue"`
	CompletedEngineHours float32   `json:"completedEngineHours"`
	Notes                string    `json:"notes"`
	UpdatedDate          time.Time `json:"updatedDate"`
	// map of MaintenanceSchedule id to performed <Y/N>
	MaintenanceCheckList map[string]bool `json:"maintenanceCheckList"`
}

type ManualEntries

type ManualEntries []ManualEntry

type ManualEntry

type ManualEntry struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

type Model

type Model struct {
	CategoryID            int      `json:"categoryId"`
	Type                  string   `json:"type"`
	CompatibleAttachments []string `json:"compatibleAttachments"`
	// categoryFullUrl, categoryHeroUrl, categoryIconUrl, guideUrl string
	HasFaultCodes           bool          `json:"hasFaultCodes"`
	HasMaintenanceSchedules bool          `json:"hasMaintenanceSchedules"`
	ManualEntries           []ManualEntry `json:"manualEntries"`
	VideoEntries            []VideoEntry  `json:"videoEntries"`
	Model                   string        `json:"model"`
}

type SearchMachineRequest

type SearchMachineRequest struct {
	PartialModel string
	Serial       string
}

type Session

type Session struct {
	Token *oauth2.Token
	// contains filtered or unexported fields
}

Session allows location specific access to authenticated content

func (*Session) AddEquipment

func (s *Session) AddEquipment(ctx context.Context, request AddEquipmentRequest) error

AddEquipment adds equipment associations for the current user

func (*Session) DeleteEquipment

func (s *Session) DeleteEquipment(ctx context.Context, id string) error

DeleteEquipment removes equipment associations for the current user

func (*Session) GetEquipment

func (s *Session) GetEquipment(ctx context.Context, id string) (*Equipment, error)

GetEquipment fetches a particular equipment by its ID

func (*Session) ListEquipment

func (s *Session) ListEquipment(ctx context.Context) ([]Equipment, error)

ListEquipment retrieves all equipment registered with the MyKubota app

func (*Session) MaintenanceHistory

func (s *Session) MaintenanceHistory(equipmentID string) ([]MaintenanceHistory, error)

func (*Session) RecordMaintenance

func (s *Session) RecordMaintenance(equipmentID string, entry MaintenanceHistory) error

func (*Session) Settings

func (s *Session) Settings(ctx context.Context) (*Settings, error)

Settings loads user settings made in the MyKubota app

func (*Session) UpdateEquipment

func (s *Session) UpdateEquipment(ctx context.Context, req UpdateEquipmentRequest) (*Equipment, error)

func (*Session) User

func (s *Session) User(ctx context.Context) (*User, error)

User fetches the authenticated user for the current session

type Settings

type Settings struct {
	MeasurementUnit string `json:"measurementUnit"`
}

type UpdateEquipmentRequest

type UpdateEquipmentRequest struct {
	EquipmentID string  `json:"id"`
	EngineHours float64 `json:"engineHours"`
	NickName    string  `json:"nickName"`
}

type User

type User struct {
	Email         string `json:"email"`
	PhoneNumber   string `json:"phone_number"`
	EmailVerified bool   `json:"email_verified"`
	MfaEnabled    bool   `json:"mfa_enabled"`
}

User contains basic informations about your MyKubota registration

type VideoEntries

type VideoEntries []VideoEntry

type VideoEntry

type VideoEntry struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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