estc

package
v0.0.0-...-96c97c1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuccessStatusCode = 0
	ErrorStatusCode   = 1
)

constants

Variables

View Source
var DefaultHandlerMap = map[string]http.Handler{
	"/v1/estimate-time": http.HandlerFunc(estimateHandler),
	"/v1/users":         http.HandlerFunc(updateUserHandler),
}

DefaultHandlerMap default url and handler map

Functions

func TestNewMux

func TestNewMux(hm map[string]http.Handler) *http.ServeMux

TestNewMux creates mux for test/dev server

func TestNewServer

func TestNewServer(hm map[string]http.Handler, port string) *http.Server

TestNewServer creates dev server

Types

type Client

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

Client api client

func NewClient

func NewClient(cfg *Config, c *http.Client, logger *log.Logger) *Client

NewClient creates api client

func (*Client) EstimateTimeToComplete

func (c *Client) EstimateTimeToComplete(ctx context.Context, req *Task) (*ETCResponse, error)

EstimateTimeToComplete estimate time to complete

func (*Client) UpdateUser

func (c *Client) UpdateUser(ctx context.Context, req *UpdateUserRequest) (*UpdateUserResponse, error)

UpdateUser update ETC user info

type Config

type Config struct {
	BaseEndpoint string `toml:"base_endpoint"`
	APIKey       string `toml:"api_key"`
	APISecret    string `toml:"api_secret"`
	Debug        bool   `toml:"debug"`
}

Config api client config

func TestNewConfig

func TestNewConfig(url string) *Config

TestNewConfig test new config

type ETCResponse

type ETCResponse struct {
	StatusCode      int `json:"statusCode"`
	Message         int `json:"message,omitempty"`
	Time            int `json:"time,omitempty"`
	ConfidenceLevel int `json:"confidenceLevel,omitempty"`
}

ETCResponse estimated time to complete

type Task

type Task struct {
	Name       string `json:"name"`
	Difficulty int    `json:"difficulty"`
}

Task request

type UpdateUserRequest

type UpdateUserRequest struct {
	ID       string `json:"id"`
	UserName string `json:"userName"`
	Email    string `json:"email"`
}

UpdateUserRequest update ETC user request

type UpdateUserResponse

type UpdateUserResponse struct {
	ID         string `json:"id"`
	UserName   string `json:"userName"`
	Email      string `json:"email"`
	StatusCode int    `json:"statusCode"`
}

UpdateUserResponse update ETC user response

Jump to

Keyboard shortcuts

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