smartcatclient

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: BSD-3-Clause Imports: 13 Imported by: 0

README

go-smartcat-client

Unofficial golang client for smartcat.com

Coverage Status Release Go Report Card Build Status

Example

package main

import (
	"fmt"
	"os"

	cli "github.com/markus621/go-smartcat-client"
)

func main() {

	conf := cli.Config{
		AccountID: os.Getenv(`SMARTCAT_ACCOUNT_ID`),
		AuthKey:   os.Getenv(`SMARTCAT_AUTH_KEY`),
		URL:       cli.HostURL,
	}

	client := cli.NewClient(conf)
	client.Debug(true, os.Stdout)

	_, _ = client.GetAccount()
    _, _ = client.GetAccountMTEngines()
    _, _ = client.SetCallback(cli.Callback{
        URL: "https://demo.example/callback",
        AdditionalHeaders: []cli.AdditionalHeader{
            {Name: "x-header", Value: "demo"},
        },
    })
    _, _ = client.GetCallback()
    _ = client.DelCallback()
    _, _ = client.GetCallbackLastErrors(10)
}

Documentation

Index

Constants

View Source
const (
	//HostURL  if you are using the European server.
	HostURL = `https://smartcat.ai`
	//USHostURL  if you are using the American server.
	USHostURL = `https://us.smartcat.ai`
	//EAHostURL  if you are using the Asian server.
	EAHostURL = `https://ea.smartcat.ai`
)

Variables

View Source
var (
	ErrUnknown = errors.New("unknown error")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	IsPersonal bool   `json:"isPersonal"`
	Type       string `json:"type"`
}

func (Account) MarshalEasyJSON

func (v Account) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Account) MarshalJSON

func (v Account) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Account) UnmarshalEasyJSON

func (v *Account) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Account) UnmarshalJSON

func (v *Account) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type AccountMTEngine

type AccountMTEngine struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

func (AccountMTEngine) MarshalEasyJSON

func (v AccountMTEngine) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (AccountMTEngine) MarshalJSON

func (v AccountMTEngine) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*AccountMTEngine) UnmarshalEasyJSON

func (v *AccountMTEngine) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*AccountMTEngine) UnmarshalJSON

func (v *AccountMTEngine) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type AccountMTEngines

type AccountMTEngines []AccountMTEngine

func (AccountMTEngines) MarshalEasyJSON

func (v AccountMTEngines) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (AccountMTEngines) MarshalJSON

func (v AccountMTEngines) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*AccountMTEngines) UnmarshalEasyJSON

func (v *AccountMTEngines) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*AccountMTEngines) UnmarshalJSON

func (v *AccountMTEngines) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type AdditionalHeader added in v0.0.2

type AdditionalHeader struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

func (AdditionalHeader) MarshalEasyJSON added in v0.0.2

func (v AdditionalHeader) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (AdditionalHeader) MarshalJSON added in v0.0.2

func (v AdditionalHeader) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*AdditionalHeader) UnmarshalEasyJSON added in v0.0.2

func (v *AdditionalHeader) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*AdditionalHeader) UnmarshalJSON added in v0.0.2

func (v *AdditionalHeader) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Callback added in v0.0.2

type Callback struct {
	URL               string             `json:"url"`
	AdditionalHeaders []AdditionalHeader `json:"additionalHeaders"`
}

func (Callback) MarshalEasyJSON added in v0.0.2

func (v Callback) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Callback) MarshalJSON added in v0.0.2

func (v Callback) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Callback) UnmarshalEasyJSON added in v0.0.2

func (v *Callback) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Callback) UnmarshalJSON added in v0.0.2

func (v *Callback) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Client

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

func NewClient

func NewClient(c Config) *Client

NewClient init client

func NewCustomClient

func NewCustomClient(c Config, cli *http.Client) *Client

NewClient init client

func (*Client) Debug

func (v *Client) Debug(is bool, w io.Writer)

func (*Client) DelCallback added in v0.0.2

func (v *Client) DelCallback() (err error)

DelCallback Resetting the configuration of notifications reception

func (*Client) GetAccount added in v0.0.2

func (v *Client) GetAccount() (out Account, err error)

GetAccount Receiving the account details

func (*Client) GetAccountMTEngines added in v0.0.2

func (v *Client) GetAccountMTEngines() (out AccountMTEngines, err error)

GetAccountMTEngines Receiving MT engines available for the account

func (*Client) GetCallback added in v0.0.2

func (v *Client) GetCallback() (out Callback, err error)

GetCallback Reading configurations of notifications reception of the account

func (*Client) GetCallbackLastErrors added in v0.0.2

func (v *Client) GetCallbackLastErrors(limit int) (out LastErrors, err error)

GetCallbackLastErrors Reading the recent sending errors

func (*Client) SetCallback added in v0.0.2

func (v *Client) SetCallback(in Callback) (out Callback, err error)

SetCallback Setting configurations of notifications reception of the account

type Config

type Config struct {
	AccountID string
	AuthKey   string
	URL       string
}

func (Config) AuthToken

func (c Config) AuthToken() string

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"Message"`
}

ErrorResponse ...

func (ErrorResponse) Error

func (v ErrorResponse) Error() string

func (ErrorResponse) MarshalEasyJSON

func (v ErrorResponse) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ErrorResponse) MarshalJSON

func (v ErrorResponse) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ErrorResponse) UnmarshalEasyJSON

func (v *ErrorResponse) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ErrorResponse) UnmarshalJSON

func (v *ErrorResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type LastError added in v0.0.2

type LastError struct {
	Created   string   `json:"created"`
	URL       string   `json:"url"`
	Reason    string   `json:"reason"`
	Code      int      `json:"code"`
	Content   string   `json:"content"`
	SourceIds []string `json:"sourceIds"`
}

func (LastError) MarshalEasyJSON added in v0.0.2

func (v LastError) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (LastError) MarshalJSON added in v0.0.2

func (v LastError) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*LastError) UnmarshalEasyJSON added in v0.0.2

func (v *LastError) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*LastError) UnmarshalJSON added in v0.0.2

func (v *LastError) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type LastErrors added in v0.0.2

type LastErrors []LastError

func (LastErrors) MarshalEasyJSON added in v0.0.2

func (v LastErrors) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (LastErrors) MarshalJSON added in v0.0.2

func (v LastErrors) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*LastErrors) UnmarshalEasyJSON added in v0.0.2

func (v *LastErrors) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*LastErrors) UnmarshalJSON added in v0.0.2

func (v *LastErrors) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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