wialon

package module
v0.0.0-...-becdb8d Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2020 License: MIT Imports: 6 Imported by: 0

README

WialonSDK for Go

License PkgGoDev Go Report Card

Installation

To install the library, you should use the following command:

go get gitlab.com/goldenm-software/open-source-libraries/wialonsdk-for-go

Documentation

The documentation is provided by GoDoc

Example usage into file

import (
  "fmt"

  "gitlab.com/goldenm-software/open-source-libraries/wialonsdk-for-go"
)

func main() {
  var sdk wialon.Sdk

  scheme := ""
  host := ""
  port := 0
  isDevelopment := true

  sdk.New(scheme, host, port, isDevelopment)
  
  token := "myTokenHere"
	sdkResponse, err := sdk.Login(token)
	if err != nil {
		panic(err)
	}

	var args map[string]interface{}
	args = make(map[string]interface{})
	var spec map[string]interface{}
  spec = make(map[string]interface{})

	spec["itemsType"] = <string>
	spec["propName"] = <string>
	spec["propValueMask"] = <string>
	spec["sortType"] = <string>
	spec["propType"] = <string>

	args["spec"] = spec
	args["force"] = <int>
	args["flags"] = <int>
	args["from"] = <int>
	args["to"] = <int>

	sdkResponse, err := sdk.Request("core/search_items", args)
	if err != nil {
		panic(err)
	}

	fmt.Println(string(sdkResponse.Result))

	hasUnlogged, err = sdk.Logout()
	if err != nil {
		panic(err)
  }
  
  if hasUnlogged {
    fmt.Println("Logged out!")
  } else {
    fmt.Println("Something went wrong, " + err.Error())
  }
}

Main methods

This library supports all types of queries to the Wialon API.

Methods available

For more information, please go to Wialon Remote API documentation

Work with us!

Feel free to send us an email to sales@goldenmcorp.com

License

MIT

Contributing

Merge requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sdk

type Sdk struct {
	HasAuthenticated bool // Controlled using login and logout methods.
	// contains filtered or unexported fields
}

Sdk struct definition for all operations in this library. Will store the connecitivty attributes as: host, port and scheme. If you want to change this attributes, you need re-initialize the interface. Also, will store the sessionID, this attribute will be rewritted or getted using GetSessionID or SetSessionID

func (*Sdk) GetSessionID

func (s *Sdk) GetSessionID() string

GetSessionID is a getter function used to retrieve the sessionID used in all SDK requests.

func (*Sdk) Login

func (s *Sdk) Login(token string) (SdkResult, error)

Login method, you should use this if you want to login quickly, you can find more information about this function in the SDK documentation as "token/login" method. Disclaimer: method "core/login" was deprecated at 2015.

func (*Sdk) Logout

func (s *Sdk) Logout() (bool, error)

Logout method, you should use this if you want to logout quickly, you can find more information about this function in the SDK documentation as "core/logout" method

func (*Sdk) New

func (s *Sdk) New(scheme, host string, port int, isDevelopment bool) error

New constructor initialize the instance, please send port as 0, host and scheme as empty string ("") if you will use Wialon Hosting

func (*Sdk) Request

func (s *Sdk) Request(method string, args interface{}) (SdkResult, error)

Request function to call any function in Wialon SDK, method is defined as "svc" in the official documentation, args is "params" argument in the documentation

func (*Sdk) SetSessionID

func (s *Sdk) SetSessionID(newSessionID string) error

SetSessionID is a setter function used to set a new sessionID, generally you should use this function when you already has a session

type SdkResult

type SdkResult struct {
	Method    string      // Method used/called
	Arguments interface{} // Arguments used
	Status    int         // HTTP Status code
	Result    []byte      // JSON result, json.Unmarshal required
}

SdkResult is the default response of all operations in this library.

Jump to

Keyboard shortcuts

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