abstract_client

package
v0.0.0-...-826d235 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractClient

type AbstractClient interface {
	GetIPAddress() (string, error)
	Login(username, password string) error
	SetAPIKey(key string)
	SetToken(key string)
	GetToken() string
	GetURL() string
	IsAuthenticated() bool

	Get(path string) (*resty.Response, error)
	Post(path string, body []byte) (*resty.Response, error)
	Put(path string, body []byte) (*resty.Response, error)
	Patch(path string, body []byte) (*resty.Response, error)
	Delete(path string) (*resty.Response, error)

	DialWebsocket(endpoint string) (*websocket.Conn, *http.Response, error)
	WriteToWebsocket(message []byte) error
	ReadFromWebsocket() (int, []byte, error)
	CloseWebsocketConnection() error
}

type AbstractConfig

type AbstractConfig struct {
	APIKey         string
	Token          string
	URL            string
	TimeoutSeconds int
}

type AbstractServiceClient

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

AbstractServiceClient is a struct that contains the url of the Pixo Service and a restyClient to make requests

func NewClient

func NewClient(config AbstractConfig) *AbstractServiceClient

NewClient is a function that returns a AbstractServiceClient

func (*AbstractServiceClient) Client

func (a *AbstractServiceClient) Client() *resty.Client

Client returns the resty client

func (*AbstractServiceClient) CloseWebsocketConnection

func (a *AbstractServiceClient) CloseWebsocketConnection() error

func (*AbstractServiceClient) Delete

func (a *AbstractServiceClient) Delete(path string) (*resty.Response, error)

Delete makes a DELETE request to the API

func (*AbstractServiceClient) DialWebsocket

func (a *AbstractServiceClient) DialWebsocket(endpoint string) (*websocket.Conn, *http.Response, error)

func (*AbstractServiceClient) FormatRequest

func (a *AbstractServiceClient) FormatRequest() *resty.Request

FormatRequest formats the request headers needed for authentication

func (*AbstractServiceClient) Get

func (a *AbstractServiceClient) Get(path string) (*resty.Response, error)

Get makes a GET request to the API

func (*AbstractServiceClient) GetAPIKey

func (a *AbstractServiceClient) GetAPIKey() string

GetAPIKey returns the token of the restClient

func (*AbstractServiceClient) GetIPAddress

func (a *AbstractServiceClient) GetIPAddress() (string, error)

func (*AbstractServiceClient) GetToken

func (a *AbstractServiceClient) GetToken() string

GetToken returns the token of the restClient

func (*AbstractServiceClient) GetURL

func (a *AbstractServiceClient) GetURL() string

GetURL returns the url of the restClient

func (*AbstractServiceClient) GetURLWithPath

func (a *AbstractServiceClient) GetURLWithPath(path string) string

GetURLWithPath returns the url of the restClient with a path appended

func (*AbstractServiceClient) IsAuthenticated

func (a *AbstractServiceClient) IsAuthenticated() bool

IsAuthenticated returns true if the client is authenticated

func (*AbstractServiceClient) Patch

func (a *AbstractServiceClient) Patch(path string, body []byte) (*resty.Response, error)

Patch makes a PATCH request to the API

func (*AbstractServiceClient) Post

func (a *AbstractServiceClient) Post(path string, body []byte) (*resty.Response, error)

Post makes a POST request to the API

func (*AbstractServiceClient) Put

func (a *AbstractServiceClient) Put(path string, body []byte) (*resty.Response, error)

Put makes a PUT request to the API

func (*AbstractServiceClient) ReadFromWebsocket

func (a *AbstractServiceClient) ReadFromWebsocket() (int, []byte, error)

func (*AbstractServiceClient) SetAPIKey

func (a *AbstractServiceClient) SetAPIKey(key string)

SetAPIKey sets the token of the restClient

func (*AbstractServiceClient) SetHeader

func (a *AbstractServiceClient) SetHeader(key string, value string)

func (*AbstractServiceClient) SetToken

func (a *AbstractServiceClient) SetToken(token string)

SetToken sets the token of the restClient

func (*AbstractServiceClient) WriteToWebsocket

func (a *AbstractServiceClient) WriteToWebsocket(message []byte) error

type MockAbstractClient

type MockAbstractClient struct {
	NumCalledGetIPAddress int
	GetIPAddressError     error

	NumCalledGetURL          int
	NumCalledLogin           int
	NumCalledSetAPIKey       int
	NumCalledSetToken        int
	NumCalledGetToken        int
	NumCalledIsAuthenticated int
	NumCalledActiveUserID    int

	NumCalledGet int
	GetError     error

	NumCalledPost int
	PostError     error

	NumCalledPut int
	PutError     error

	NumCalledPatch int
	PatchError     error

	NumCalledDelete int
	DeleteError     error

	NumCalledDialWebsocket     int
	NumCalledWriteToWebsocket  int
	NumCalledReadFromWebsocket int
	NumCalledCloseWebsocket    int

	Response []byte
}

func (*MockAbstractClient) ActiveUserID

func (m *MockAbstractClient) ActiveUserID() int

func (*MockAbstractClient) CloseWebsocketConnection

func (m *MockAbstractClient) CloseWebsocketConnection() error

func (*MockAbstractClient) Delete

func (m *MockAbstractClient) Delete(path string) (*resty.Response, error)

func (*MockAbstractClient) DialWebsocket

func (m *MockAbstractClient) DialWebsocket(endpoint string) (*websocket.Conn, *http.Response, error)

func (*MockAbstractClient) Get

func (m *MockAbstractClient) Get(path string) (*resty.Response, error)

func (*MockAbstractClient) GetIPAddress

func (m *MockAbstractClient) GetIPAddress() (string, error)

func (*MockAbstractClient) GetToken

func (m *MockAbstractClient) GetToken() string

func (*MockAbstractClient) GetURL

func (m *MockAbstractClient) GetURL() string

func (*MockAbstractClient) IsAuthenticated

func (m *MockAbstractClient) IsAuthenticated() bool

func (*MockAbstractClient) Login

func (m *MockAbstractClient) Login(username, password string) error

func (*MockAbstractClient) Patch

func (m *MockAbstractClient) Patch(path string, body []byte) (*resty.Response, error)

func (*MockAbstractClient) Post

func (m *MockAbstractClient) Post(path string, body []byte) (*resty.Response, error)

func (*MockAbstractClient) Put

func (m *MockAbstractClient) Put(path string, body []byte) (*resty.Response, error)

func (*MockAbstractClient) ReadFromWebsocket

func (m *MockAbstractClient) ReadFromWebsocket() (int, []byte, error)

func (*MockAbstractClient) SetAPIKey

func (m *MockAbstractClient) SetAPIKey(key string)

func (*MockAbstractClient) SetToken

func (m *MockAbstractClient) SetToken(key string)

func (*MockAbstractClient) WriteToWebsocket

func (m *MockAbstractClient) WriteToWebsocket(message []byte) error

type Response

type Response struct {
	Message string `json:"message"`
	Error   string `json:"error"`
}

Jump to

Keyboard shortcuts

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