spotware

package module
v0.0.0-...-27770e8 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: MIT Imports: 1 Imported by: 0

README

Spotware-SDK

Work In Progress

Just the right piece for your puzzle.

Go Report Card Go Version GitHub license

go get -u github.com/leandergangso/spotware-sdk

Overview

This is a small library for Spotware OpenAPI.

Getting Started

Let's take a look at a minimal setup:

package main

import (
    "fmt"
    "log"
    "time"

    "github.com/leandergangso/spotware-sdk"
)

func main() {
    sdk, err := spotware.NewClient(spotware.Settings{
        // credentials from your spotware application
        ClientID: "YOUR CLIENT ID",
        Secret: "YOUR SECRET",
    })
    if err != nil {
        log.Fatal(err)
    }
    defer sdk.Stop() // option for safe exit (finish all messages in que before exit)

    sdk.Receive(sdk.Events.OnMessage, func(msg *spotware.ProtoMessage) { // ADD CORRECT PARAMETER FOR FUNCTION !!!
        fmt.Println(msg.)
    })

    protoMsg := &spotware.Proto.ProtoOAAccountAuthReq{
        CtidTraderAccountId: 123456,
        AccessToken: "TOKEN HERE",
    }
    err = sdk.Send(protoMsg)
    if err != nil {
        log.Println("can't send given proto message:", err)
    }

    sdk.Start()
}

Setup

First, we have to make sure the protobuf messages are up to date.

Make sure make and protoc is installed.

# check and update
make proto

# on error, add next line to *.proto files
option go_package = ".;message";

# again run
make proto

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint string

type SDK

type SDK struct {
}

Sdk represents a separate spotware SDK instance

func NewSDK

func NewSDK(s *Settings) (*SDK, error)

NewSDK will return a new client that you can use to connect to Spotware

Note: only create 1 client pr.application

type Settings

type Settings struct {
	// Client ID for your application
	ClientID string

	// Secret for your application
	Secret string
}

Jump to

Keyboard shortcuts

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