common

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertInterfaceToByteAndMap

func ConvertInterfaceToByteAndMap(Body interface{}) ([]byte, map[string]interface{}, error)

func CreateMultiPartFormPayload

func CreateMultiPartFormPayload(file *os.File, reqBodyMap map[string]interface{}) (*bytes.Reader, string, error)

func EncodeToBase64

func EncodeToBase64(val string) string

EncodeToBase64 gives base64 encoded string

func GetRequestedDateTime

func GetRequestedDateTime() string

GetRequestedDateTime reuse and returns the date time created

func HttpRequest

func HttpRequest(method string, apiUrl string, queryParams map[string]string, data interface{}, headers map[string]string) ([]byte, error)

func MapToURLEncodedString

func MapToURLEncodedString(valMap map[string]string) (encodedData string)

MapToURLEncodedString converts map to url encoded string

func MapToUrlString

func MapToUrlString(valMap map[string]string) string

Types

type FDKError

type FDKError struct {
	// Message is user-friendly message that can be displayed on front-end for end-users
	Message string `json:"message"`

	// Status is HTTP status code that is set in API response
	Status int `json:"status"`

	// A Code should be unique and used only once throughout the project
	// so that it can lead to the exact line of failed function when searched in the entire project.
	Code string `json:"code"`

	// Exception is technical expection title. This should be mostly 2-3 words title of the
	// error/er to be understood by developers.
	Exception string `json:"exception"`

	// Info is link/URL to the logging system(Sentry/Kibana) to get more insight and trace error
	Info string `json:"info"`

	// RequestID is the unique ID of a particular request for tracing the errors in the logging system(Sentry/Kibana)
	RequestID string `json:"request_id,omitempty"`

	//StackTrace gives the report of the active stack frames at a certain point in time during the execution of a program used for debugging purposes
	StackTrace string `json:"stack_trace,omitempty"`

	//Meta can be used for your custom keys, which would be helpful for detailed error and for debugging
	Meta objx.Map `json:"meta,omitempty"`
}

FDKError is custom error type to pass more information along with the native error.

func NewFDKError

func NewFDKError(message string) *FDKError

NewFDKError constructs and returns new FDKError object

func (*FDKError) Error

func (f *FDKError) Error() string

Error returns technical error message with error code and er title

func (*FDKError) SetRequestID

func (f *FDKError) SetRequestID(requestID string) *FDKError

SetRequestID sets the RequestID in the error object

func (*FDKError) SetStatus

func (f *FDKError) SetStatus(httpStatus int) *FDKError

SetStatus sets the HTTP Status in the error object

func (*FDKError) String

func (f *FDKError) String() string

type Paginator

type Paginator struct {
	PageNo      float64
	HasNextPage bool
	NextID      string
	Next        func() (interface{}, error)
}

Paginator holds paginator object

func NewPaginator

func NewPaginator(pageType string) *Paginator

NewPaginator returns paginator instance

func (*Paginator) HasNext

func (p *Paginator) HasNext() bool

HasNext return has_next value

func (*Paginator) SetPaginator

func (p *Paginator) SetPaginator(hasNext bool, pageNo int, nextID string)

SetPaginator sets paginator instance with either next_id or page_no

type SignatureModel

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

func NewSignatureModel

func NewSignatureModel(domain string, method string, url string, queryString string, headers map[string]string, body interface{}, excludeHeaders []string) *SignatureModel

func (*SignatureModel) AddSignatureToHeaders

func (model *SignatureModel) AddSignatureToHeaders(signQuery bool) (map[string]string, error)

Jump to

Keyboard shortcuts

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