service

package
v0.0.0-...-c934e4d Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OauthURI                 = "apigw/token"
	CustomersServiceEndpoint = "customers/v1/customer"
)

Functions

This section is empty.

Types

type Correlation

type Correlation struct {
}

Correlation struct

func NewCorrelation

func NewCorrelation() *Correlation

NewCorrelation creates a new instance

func (*Correlation) UUIDv4

func (c *Correlation) UUIDv4() string

UUIDv4 create a UUID version 4

type Customer

type Customer struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	Address string `json:"address"`
}

func (*Customer) ConvertToJSON

func (c *Customer) ConvertToJSON() (string, error)

ConvertToJSON convert object to json

func (*Customer) LoadFromJSON

func (c *Customer) LoadFromJSON(data []byte) error

LoadFromJSON update object from json

type FileSystem

type FileSystem struct {
}

FileSystem struct

func NewFileSystem

func NewFileSystem() *FileSystem

NewFileSystem creates a new instance

func (*FileSystem) ClearDir

func (fs *FileSystem) ClearDir(dir string) error

ClearDir removes all files and sub dirs

func (*FileSystem) DeleteDir

func (fs *FileSystem) DeleteDir(dir string) error

DeleteDir deletes a dir

func (*FileSystem) DeleteFile

func (fs *FileSystem) DeleteFile(path string) error

DeleteFile deletes a file

func (*FileSystem) DirExists

func (fs *FileSystem) DirExists(path string) bool

DirExists reports whether the dir exists

func (*FileSystem) EnsureDir

func (fs *FileSystem) EnsureDir(dirName string, mode int) error

EnsureDir ensures that directory exists

func (*FileSystem) EnsureTrailingSlash

func (fs *FileSystem) EnsureTrailingSlash(dir string) string

EnsureTrailingSlash ensure there is a trailing slash

func (*FileSystem) FileExists

func (fs *FileSystem) FileExists(path string) bool

FileExists reports whether the named file exists

func (*FileSystem) GetHostname

func (fs *FileSystem) GetHostname() (string, error)

GetHostname gets the hostname

func (*FileSystem) PathExists

func (fs *FileSystem) PathExists(path string) bool

PathExists reports whether the path exists

func (*FileSystem) ReadFile

func (fs *FileSystem) ReadFile(path string) (string, error)

ReadFile get the file content

func (*FileSystem) RemoveStartingSlash

func (fs *FileSystem) RemoveStartingSlash(dir string) string

RemoveStartingSlash removes any starting slash

func (*FileSystem) RemoveTrailingSlash

func (fs *FileSystem) RemoveTrailingSlash(dir string) string

RemoveTrailingSlash removes any trailing slash

func (*FileSystem) StoreFile

func (fs *FileSystem) StoreFile(path, content string) error

StoreFile stores a file content

type Helmet

type Helmet struct {
	Timeout time.Duration
	APIGW   string
}

Helmet struct

func NewHelmetClient

func NewHelmetClient(apigwURL string, timeout int) *Helmet

NewHelmetClient creates an instance of http client

func (*Helmet) FetchAccessToken

func (h *Helmet) FetchAccessToken(ctx context.Context) (*Token, error)

FetchAccessToken ..

func (*Helmet) GetCustomerById

func (h *Helmet) GetCustomerById(id int, accessToken string) (Customer, error)

GetCustomerById ..

type Token

type Token struct {
	sync.RWMutex

	AccessToken string    `json:"access_token"`
	TokenType   string    `json:"token_type"`
	ExpireAt    time.Time `json:"expire_at"`
}

func (*Token) ConvertToJSON

func (t *Token) ConvertToJSON() (string, error)

ConvertToJSON convert object to json

func (*Token) IsExpired

func (t *Token) IsExpired() bool

IsExpired ..

func (*Token) LoadFromJSON

func (t *Token) LoadFromJSON(data []byte) error

LoadFromJSON update object from json

func (*Token) Update

func (t *Token) Update(accessToken, tokenType string, expireAt time.Time)

Update ..

Jump to

Keyboard shortcuts

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