util

package
v2.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultScopes = []string{
		"integration_read",
		"integration_write",
	}
	DefaultCredentials = []string{
		"/api/integration-modules/{code}",
		"/api/integration-modules/{code}/edit",
	}
)

Functions

func DefaultCurrencies

func DefaultCurrencies() map[string]string

DefaultCurrencies will return default currencies list for all bots.

func FormatCurrencyValue

func FormatCurrencyValue(value float32) string

func GetCurrencySymbol

func GetCurrencySymbol(code string) string

GetCurrencySymbol returns currency symbol by it's ISO 4127 code. It returns provided currency code in uppercase if currency symbol cannot be found.

func GetEntitySHA1

func GetEntitySHA1(v interface{}) (hash string, err error)

GetEntitySHA1 will serialize any value to JSON and return SHA1 hash of this JSON.

func GetMGItemData

func GetMGItemData(client *v1.MgClient, url string, caption string) (v1.Item, int, error)

GetMGItemData will upload file to MG by URL and return information about attachable item.

func ReplaceMarkdownSymbols

func ReplaceMarkdownSymbols(s string) string

ReplaceMarkdownSymbols will remove markdown symbols from text.

Types

type Utils

type Utils struct {
	Logger logger.Logger

	AWS          config.AWS
	TokenCounter uint32
	IsDebug      bool
	// contains filtered or unexported fields
}

Utils service object.

func NewUtils

func NewUtils(awsConfig config.AWS, logger logger.Logger, debug bool) *Utils

NewUtils will create new Utils instance.

func (*Utils) GenerateToken

func (u *Utils) GenerateToken() string

GenerateToken will generate long pseudo-random string.

func (*Utils) GetAPIClient

func (u *Utils) GetAPIClient(
	url, key string, scopes []string, credentials ...[]string) (*retailcrm.Client, int, error)

GetAPIClient will initialize RetailCRM api client from url and key. Scopes will be used to determine if client is valid. If there are no scopes - credentials will be used instead.

func (*Utils) RemoveTrailingSlash

func (u *Utils) RemoveTrailingSlash(crmURL string) string

RemoveTrailingSlash will remove slash at the end of any string.

func (*Utils) ResetUtils

func (u *Utils) ResetUtils(awsConfig config.AWS, debug bool, tokenCounter uint32)

ResetUtils resets the utils inner state.

func (*Utils) UploadUserAvatar

func (u *Utils) UploadUserAvatar(url string) (picURLs3 string, err error)

UploadUserAvatar will upload avatar for user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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