casvisorsdk

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: Apache-2.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRecord

func AddRecord(record *Record) (bool, error)

func DeleteRecord

func DeleteRecord(record *Record) (bool, error)

func InitConfig

func InitConfig(endpoint string, clientId string, clientSecret string, organizationName string, applicationName string)

func SetHttpClient

func SetHttpClient(httpClient HttpClient)

SetHttpClient sets custom http Client.

func UpdateRecord

func UpdateRecord(record *Record) (bool, error)

Types

type Client

type Client struct {
	Config
}

func GetClient added in v1.0.3

func GetClient() *Client

func NewClient

func NewClient(endpoint string, clientId string, clientSecret string, organizationName string, applicationName string) *Client

func NewClientWithConf

func NewClientWithConf(config *Config) *Client

func (*Client) AddRecord

func (c *Client) AddRecord(record *Record) (bool, error)

func (*Client) DeleteRecord

func (c *Client) DeleteRecord(record *Record) (bool, error)

func (*Client) DoGetBytes

func (c *Client) DoGetBytes(url string) ([]byte, error)

DoGetBytes is a general function to get response data in bytes from param url through HTTP Get method.

func (*Client) DoGetBytesRaw

func (c *Client) DoGetBytesRaw(url string) ([]byte, error)

DoGetBytesRaw is a general function to get response from param url through HTTP Get method.

func (*Client) DoGetResponse

func (c *Client) DoGetResponse(url string) (*Response, error)

DoGetResponse is a general function to get response from param url through HTTP Get method.

func (*Client) DoPost

func (c *Client) DoPost(action string, queryMap map[string]string, postBytes []byte, isForm, isFile bool) (*Response, error)

func (*Client) DoPostBytesRaw

func (c *Client) DoPostBytesRaw(url string, contentType string, body io.Reader) ([]byte, error)

DoPostBytesRaw is a general function to post a request from url, body through HTTP Post method.

func (*Client) GetPaginationRecords

func (c *Client) GetPaginationRecords(p int, pageSize int, queryMap map[string]string) ([]*Record, int, error)

func (*Client) GetRecord

func (c *Client) GetRecord(name string) (*Record, error)

func (*Client) GetRecords

func (c *Client) GetRecords() ([]*Record, error)

func (*Client) GetUrl

func (c *Client) GetUrl(action string, queryMap map[string]string) string

func (*Client) UpdateRecord

func (c *Client) UpdateRecord(record *Record) (bool, error)

type Config added in v1.0.3

type Config struct {
	Endpoint         string
	ClientId         string
	ClientSecret     string
	OrganizationName string
	ApplicationName  string
}

type HttpClient

type HttpClient interface {
	Do(*http.Request) (*http.Response, error)
}

HttpClient interface has the method required to use a type as custom http client. The net/*http.Client type satisfies this interface.

type Record

type Record struct {
	Id int `xorm:"int notnull pk autoincr" json:"id"`

	Owner       string `xorm:"varchar(100) index" json:"owner"`
	Name        string `xorm:"varchar(100) index" json:"name"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`

	Organization string `xorm:"varchar(100)" json:"organization"`
	ClientIp     string `xorm:"varchar(100)" json:"clientIp"`
	User         string `xorm:"varchar(100)" json:"user"`
	Method       string `xorm:"varchar(100)" json:"method"`
	RequestUri   string `xorm:"varchar(1000)" json:"requestUri"`
	Action       string `xorm:"varchar(1000)" json:"action"`
	Language     string `xorm:"varchar(100)" json:"language"`

	Object   string `xorm:"mediumtext" json:"object"`
	Response string `xorm:"mediumtext" json:"response"`

	IsTriggered bool `json:"isTriggered"`
}

func GetPaginationRecords

func GetPaginationRecords(p int, pageSize int, queryMap map[string]string) ([]*Record, int, error)

func GetRecord

func GetRecord(name string) (*Record, error)

func GetRecords

func GetRecords() ([]*Record, error)

type Response

type Response struct {
	Status string      `json:"status"`
	Msg    string      `json:"msg"`
	Data   interface{} `json:"data"`
	Data2  interface{} `json:"data2"`
}

Jump to

Keyboard shortcuts

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