smartcatclient

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 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 unknown error
	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"`
}

Account information about your current account.

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"`
}

AccountMTEngine information about the machine translation engine

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

AccountMTEngines list of available machine translation engines

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"`
}

AdditionalHeader additional headers for transmission with a callback

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"`
}

Callback callback settings

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
}

Client client connecting to the server

func NewClient

func NewClient(c Config) *Client

NewClient init client

func NewCustomClient

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

NewCustomClient init client

func (*Client) Debug

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

Debug enable logging of responses

func (*Client) DelCallback added in v0.0.2

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

DelCallback Resetting the configuration of notifications reception

func (*Client) DelProject added in v0.0.3

func (v *Client) DelProject(id string) (err error)

DelProject Delete the project

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) GetProject added in v0.0.3

func (v *Client) GetProject(id string) (out Project, err error)

GetProject Receive the project model

func (*Client) ListProject added in v0.0.3

func (v *Client) ListProject() (out ProjectsList, err error)

ListProject List all projects

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

func (*Client) SetProject added in v0.0.3

func (v *Client) SetProject(id string, in PatchProject) (out Project, err error)

SetProject Change the project model

type Config

type Config struct {
	AccountID string
	AuthKey   string
	URL       string
}

Config client settings for connecting to the server

func (Config) AuthToken

func (c Config) AuthToken() string

AuthToken generating an authorization token

type Cost added in v0.0.3

type Cost struct {
	Value           float64 `json:"value"`
	Currency        string  `json:"currency"`
	AccuracyDegree  string  `json:"accuracyDegree"`
	DetailsFileName string  `json:"detailsFileName"`
	PaymentStatus   string  `json:"paymentStatus"`
}

Cost model

func (Cost) MarshalEasyJSON added in v0.0.3

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (Cost) MarshalJSON added in v0.0.3

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

MarshalJSON supports json.Marshaler interface

func (*Cost) UnmarshalEasyJSON added in v0.0.3

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Cost) UnmarshalJSON added in v0.0.3

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

UnmarshalJSON supports json.Unmarshaler interface

type Document added in v0.0.3

type Document struct {
	ID                     string                  `json:"id"`
	Name                   string                  `json:"name"`
	CreationDate           string                  `json:"creationDate"`
	Deadline               string                  `json:"deadline"`
	SourceLanguage         string                  `json:"sourceLanguage"`
	DisassemblingStatus    string                  `json:"documentDisassemblingStatus"`
	TargetLanguage         string                  `json:"targetLanguage"`
	Status                 string                  `json:"status"`
	WordsCount             uint64                  `json:"wordsCount"`
	StatusModificationDate string                  `json:"statusModificationDate"`
	PretranslateCompleted  bool                    `json:"pretranslateCompleted"`
	WorkflowStages         []DocumentWorkflowStage `json:"workflowStages"`
	ExternalID             string                  `json:"externalId"`
	MetaInfo               string                  `json:"metaInfo"`
	PlaceholdersAreEnabled bool                    `json:"placeholdersAreEnabled"`
}

Document model

func (Document) MarshalEasyJSON added in v0.0.3

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (Document) MarshalJSON added in v0.0.3

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

MarshalJSON supports json.Marshaler interface

func (*Document) UnmarshalEasyJSON added in v0.0.3

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Document) UnmarshalJSON added in v0.0.3

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

UnmarshalJSON supports json.Unmarshaler interface

type DocumentWorkflowStage added in v0.0.3

type DocumentWorkflowStage struct {
	Progress             uint        `json:"progress"`
	WordsTranslated      uint64      `json:"wordsTranslated"`
	UnassignedWordsCount uint64      `json:"unassignedWordsCount"`
	Status               string      `json:"status"`
	Executives           []Executive `json:"executives"`
}

DocumentWorkflowStage model

func (DocumentWorkflowStage) MarshalEasyJSON added in v0.0.3

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (DocumentWorkflowStage) MarshalJSON added in v0.0.3

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

MarshalJSON supports json.Marshaler interface

func (*DocumentWorkflowStage) UnmarshalEasyJSON added in v0.0.3

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*DocumentWorkflowStage) UnmarshalJSON added in v0.0.3

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

UnmarshalJSON supports json.Unmarshaler interface

type ErrorResponse

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

ErrorResponse model error response from the server

func (ErrorResponse) Error

func (v ErrorResponse) Error() string

Error error interface

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 Executive added in v0.0.3

type Executive struct {
	ID                 string `json:"id"`
	AssignedWordsCount uint64 `json:"assignedWordsCount"`
	Progress           uint   `json:"progress"`
	SupplierType       string `json:"supplierType"`
}

Executive model

func (Executive) MarshalEasyJSON added in v0.0.3

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (Executive) MarshalJSON added in v0.0.3

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

MarshalJSON supports json.Marshaler interface

func (*Executive) UnmarshalEasyJSON added in v0.0.3

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Executive) UnmarshalJSON added in v0.0.3

func (v *Executive) 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"`
}

LastError information about callback errors

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

LastErrors error list

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

type PatchProject added in v0.0.3

type PatchProject struct {
	Name             string   `json:"name"`
	Description      string   `json:"description"`
	Deadline         string   `json:"deadline"`
	ClientID         string   `json:"clientId"`
	DomainID         uint64   `json:"domainId"`
	VendorAccountIDs []string `json:"vendorAccountIds"`
	ExternalTag      string   `json:"externalTag"`
	Specializations  []string `json:"specializations"`
	WorkflowStages   []string `json:"workflowStages"`
}

PatchProject model

func (PatchProject) MarshalEasyJSON added in v0.0.3

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (PatchProject) MarshalJSON added in v0.0.3

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

MarshalJSON supports json.Marshaler interface

func (*PatchProject) UnmarshalEasyJSON added in v0.0.3

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*PatchProject) UnmarshalJSON added in v0.0.3

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

UnmarshalJSON supports json.Unmarshaler interface

type Project added in v0.0.3

type Project struct {
	ID                     string          `json:"id"`
	AccountID              string          `json:"accountId"`
	Name                   string          `json:"name"`
	Description            string          `json:"description"`
	Deadline               string          `json:"deadline"`
	CreationDate           string          `json:"creationDate"`
	CreatedByUserID        string          `json:"createdByUserId"`
	CreatedByUserEmail     string          `json:"createdByUserEmail"`
	ModificationDate       string          `json:"modificationDate"`
	SourceLanguageID       uint64          `json:"sourceLanguageId"`
	SourceLanguage         string          `json:"sourceLanguage"`
	TargetLanguages        []string        `json:"targetLanguages"`
	Status                 string          `json:"status"`
	StatusModificationDate string          `json:"statusModificationDate"`
	DomainID               uint64          `json:"domainId"`
	ClientID               uint64          `json:"clientId"`
	Vendors                []Vendor        `json:"vendors"`
	WorkflowStages         []WorkflowStage `json:"workflowStages"`
	Documents              []Document      `json:"documents"`
	ExternalTag            string          `json:"externalTag"`
	Specializations        []string        `json:"specializations"`
	Managers               []string        `json:"managers"`
	Number                 []string        `json:"number"`
}

Project model

func (Project) MarshalEasyJSON added in v0.0.3

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (Project) MarshalJSON added in v0.0.3

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

MarshalJSON supports json.Marshaler interface

func (*Project) UnmarshalEasyJSON added in v0.0.3

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Project) UnmarshalJSON added in v0.0.3

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

UnmarshalJSON supports json.Unmarshaler interface

type ProjectsList added in v0.0.3

type ProjectsList []Project

ProjectsList model

func (ProjectsList) MarshalEasyJSON added in v0.0.3

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (ProjectsList) MarshalJSON added in v0.0.3

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

MarshalJSON supports json.Marshaler interface

func (*ProjectsList) UnmarshalEasyJSON added in v0.0.3

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ProjectsList) UnmarshalJSON added in v0.0.3

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

UnmarshalJSON supports json.Unmarshaler interface

type Vendor added in v0.0.3

type Vendor struct {
	VendorAccountID    string `json:"vendorAccountId"`
	RemovedFromProject bool   `json:"removedFromProject"`
	Cost               Cost   `json:"cost"`
	CostDetailsFileID  string `json:"costDetailsFileId"`
}

Vendor model

func (Vendor) MarshalEasyJSON added in v0.0.3

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (Vendor) MarshalJSON added in v0.0.3

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

MarshalJSON supports json.Marshaler interface

func (*Vendor) UnmarshalEasyJSON added in v0.0.3

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Vendor) UnmarshalJSON added in v0.0.3

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

UnmarshalJSON supports json.Unmarshaler interface

type WorkflowStage added in v0.0.3

type WorkflowStage struct {
	Progress  uint   `json:"progress"`
	StageType string `json:"stageType"`
}

WorkflowStage model

func (WorkflowStage) MarshalEasyJSON added in v0.0.3

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (WorkflowStage) MarshalJSON added in v0.0.3

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

MarshalJSON supports json.Marshaler interface

func (*WorkflowStage) UnmarshalEasyJSON added in v0.0.3

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*WorkflowStage) UnmarshalJSON added in v0.0.3

func (v *WorkflowStage) 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