GO/GOLANG SDK is a connector library for the insanely fast HEXONET Backend API.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
apiclient chore(release): 2.0.1 [skip ci] Nov 12, 2018
column refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018
record refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018
response refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018
responseparser refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018
responsetemplate refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018
responsetemplatemanager refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018
scripts refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018
socketconfig refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018
.gitignore refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018
.travis.yml refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018
CONTRIBUTING.md Update CONTRIBUTING.md Jul 4, 2018
HISTORY.md chore(release): 2.0.1 [skip ci] Nov 12, 2018
HISTORY.md.OLD refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018
LICENSE Initial commit Jun 18, 2018
README.md docs(readme): review usage examples Nov 12, 2018
apiclient.go fix(pkg): readd missing root-folder go file Nov 12, 2018
package-lock.json chore(release): 2.0.0 [skip ci] Nov 12, 2018
package.json refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018
updateVersion.sh refactor(pkg): migration to generic cross-sdk structure; add CI/CD Nov 12, 2018

README.md

go-sdk

GoDoc Go Report Card cover.run Slack Widget

This module is a connector library for the insanely fast HEXONET Backend API. For further informations visit our homepage and do not hesitate to contact us.

Resources

How to use this module in your project

We have also a demo app available showing how to integrate and use our SDK. See here.

Requirements

NOTE: Make sure you add the go binary path to your PATH environment variable. Add the below lines for a standard installation into your profile configuration file (~/.profile).

export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

Then reload the profile configuration by source ~/.profile.

Using govendor

Use govendor for the dependency installation by govendor fetch -tree github.com/hexonet/go-sdk@<tag id> where tag id corresponds to a release version tag. You can update this dependency later on by govendor sync github.com/hexonet/go-sdk@<new tag id>. The dependencies will be installed in your project's subfolder "vendor". Import the module in your project as shown in the examples below.

For more details on govendor, please read the CheatSheet and also the developer guide.

Usage Examples

Please have an eye on our HEXONET Backend API documentation. Here you can find information on available Commands and their response data.

Session based API Communication

package main

import (
    "fmt"
    
    CL "github.com/hexonet/go-sdk/apiclient"
)

func main() {
    cl := CL.NewAPIClient()
    cl.SetCredentials("test.user", "test.passw0rd")//username, password
    // or cl.SetRoleCredentials("test.user", "testrole", "test.passw0rd")
    // for role user credentials
    cl.UseOTESystem()

    // use this to provide your outgoing ip address for api communication
    // to be used in case you have ip filter settings active
    cl.SetRemoteIPAddress("1.2.3.4");

    // cl.EnableDebugMode() // to activate debug outputs of the API communication
    r := cl.Login()
    // or r := cl.Login("12345678") // provide here your 2FA otp code
    if r.IsSuccess() {
        fmt.Println("Login succeeded.")
        cmd := map[string]string{
            "COMMAND": "StatusAccount",
        }
        r = cl.Request(cmd)
        if r.IsSuccess() {
            fmt.Println("Command succeeded.")
            r = cl.Logout()
            if r.IsSuccess() {
                fmt.Println("Logout succeeded.")
            } else {
                fmt.Println("Logout failed.")
            }
        } else {
            fmt.Println("Command failed.")
        }
    } else {
        fmt.Println("Login failed.")
    }
}

Sessionless API Communication

package main

import (
    "fmt"
    
    CL "github.com/hexonet/go-sdk/apiclient"
)

func main() {
    cl := CL.NewAPIClient()
    cl.SetCredentials("test.user", "test.passw0rd")
    cl.SetRemoteIPAddress("1.2.3.4")
    //cl.SetOTP("12345678") to provide your 2FA otp code
    cl.UseOTESystem()
    cmd := map[string]string{
        "COMMAND": "StatusAccount",
    }
    r := cl.Request(cmd)
    if r.IsSuccess() {
        fmt.Println("Command succeeded.")
    } else {
        fmt.Println("Command failed.")
    }
}

Contributing

Please read our development guide for details on our code of conduct, and the process for submitting pull requests to us.

Authors

  • Kai Schwarz - lead development - PapaKai

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.