utils

package
v0.0.0-...-0d01294 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildUrlWithQueryString

func BuildUrlWithQueryString(url string, params interface{}) string

func GetValidate

func GetValidate() *validator.Validate

func Upload

Types

type File

type File struct {
	Reader   io.Reader
	FileName string
	FileKey  string
}

type FileData

type FileData interface {
	GetFileData() File
	GetFormValues() url.Values
}

type HttpConfig

type HttpConfig struct {
	BaseUrl string
	AppId   string
}

func InitHttpConfig

func InitHttpConfig(baseUrl string, appId string) *HttpConfig

type HttpErrorResponse

type HttpErrorResponse struct {
	Success bool               `json:"success,omitempty"`
	Message string             `json:"message,omitempty"`
	Errors  *map[string]string `json:"errors,omitempty"`
}

func Delete

func Delete[T any](config HttpConfig, path string, resultType T) (*T, *HttpErrorResponse)

func Download

func Download(config HttpConfig, path string) ([]byte, *HttpErrorResponse)

func Get

func Get[T any](config HttpConfig, path string, resultType T) (*T, *HttpErrorResponse)

func HttpRequest

func HttpRequest[T any](request *http.Request, url string, successResponse T) (*T, *HttpErrorResponse)

func Patch

func Patch[T any](config HttpConfig, path string, payload interface{}, resultType T) (*T, *HttpErrorResponse)

func Post

func Post[T any](config HttpConfig, path string, payload interface{}, resultType T) (*T, *HttpErrorResponse)

func Put

func Put[T any](config HttpConfig, path string, payload interface{}, resultType T) (*T, *HttpErrorResponse)

type HttpSuccessBasicResponse

type HttpSuccessBasicResponse struct {
	Success bool `json:"success"`
}

type OptionalDateParams

type OptionalDateParams struct {
	From QueryDateParams `validate:"omitempty" url:"from,omitempty"`
	To   QueryDateParams `validate:"omitempty" url:"to,omitempty"`
}

type OptionalDatePayload

type OptionalDatePayload struct {
	From PayloadDateParams `validate:"omitempty" json:"from,omitempty"`
	To   PayloadDateParams `validate:"omitempty" json:"to,omitempty"`
}

type Pagination

type Pagination struct {
	CurrentPage int `json:"current_page"`
	PerPage     int `json:"per_page"`
	Total       int `json:"total"`
	TotalPages  int `json:"total_pages"`
}

type PaginationParams

type PaginationParams struct {
	Page    int `url:"page,omitempty"`
	PerPage int `url:"per_page,omitempty"`
}

type PaginationPayload

type PaginationPayload struct {
	Page    int `json:"page,omitempty"`
	PerPage int `json:"per_page,omitempty"`
}

type PaginationResponse

type PaginationResponse[T any] struct {
	Items      []T        `json:"items"`
	Pagination Pagination `json:"pagination"`
}

type PayloadDateParams

type PayloadDateParams time.Time

func (PayloadDateParams) MarshalJSON

func (dp PayloadDateParams) MarshalJSON() ([]byte, error)

func (*PayloadDateParams) UnmarshalJSON

func (dp *PayloadDateParams) UnmarshalJSON(data []byte) error

type QueryDateParams

type QueryDateParams time.Time

func (QueryDateParams) EncodeValues

func (qdp QueryDateParams) EncodeValues(key string, v *url.Values) error

func (QueryDateParams) String

func (qdp QueryDateParams) String() string

type RequiredDateParams

type RequiredDateParams struct {
	From QueryDateParams `validate:"required" url:"from,omitempty"`
	To   QueryDateParams `validate:"required" url:"to,omitempty"`
}

type RequiredDatePayload

type RequiredDatePayload struct {
	From PayloadDateParams `validate:"required" json:"from,omitempty"`
	To   PayloadDateParams `validate:"required" json:"to,omitempty"`
}

type SyncHangupResponse

type SyncHangupResponse struct {
	Success bool    `json:"success"`
	Code    int     `json:"code"`
	Message *string `json:"message"`
}

Jump to

Keyboard shortcuts

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